babylon.module.d.ts 5.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  686. static readonly GEQUAL: number;
  687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = nearest */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Class used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. * @deprecated Please use FromArray instead.
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. * @deprecated Please use FromArrayToRef instead.
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar not used as infinity is used as far clip
  4496. * @param result defines the target matrix
  4497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4498. */
  4499. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4500. /**
  4501. * Creates a right-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a right-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a right-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a right-handed perspective projection into a given matrix
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Stores a perspective projection for WebVR info a given matrix
  4531. * @param fov defines the field of view
  4532. * @param znear defines the near clip plane
  4533. * @param zfar defines the far clip plane
  4534. * @param result defines the target matrix
  4535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4536. */
  4537. static PerspectiveFovWebVRToRef(fov: {
  4538. upDegrees: number;
  4539. downDegrees: number;
  4540. leftDegrees: number;
  4541. rightDegrees: number;
  4542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4543. /**
  4544. * Computes a complete transformation matrix
  4545. * @param viewport defines the viewport to use
  4546. * @param world defines the world matrix
  4547. * @param view defines the view matrix
  4548. * @param projection defines the projection matrix
  4549. * @param zmin defines the near clip plane
  4550. * @param zmax defines the far clip plane
  4551. * @returns the transformation matrix
  4552. */
  4553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4554. /**
  4555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4556. * @param matrix defines the matrix to use
  4557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4558. */
  4559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4560. /**
  4561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4562. * @param matrix defines the matrix to use
  4563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4564. */
  4565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4566. /**
  4567. * Compute the transpose of a given matrix
  4568. * @param matrix defines the matrix to transpose
  4569. * @returns the new matrix
  4570. */
  4571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4572. /**
  4573. * Compute the transpose of a matrix and store it in a target matrix
  4574. * @param matrix defines the matrix to transpose
  4575. * @param result defines the target matrix
  4576. */
  4577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4578. /**
  4579. * Computes a reflection matrix from a plane
  4580. * @param plane defines the reflection plane
  4581. * @returns a new matrix
  4582. */
  4583. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4584. /**
  4585. * Computes a reflection matrix from a plane
  4586. * @param plane defines the reflection plane
  4587. * @param result defines the target matrix
  4588. */
  4589. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4590. /**
  4591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4592. * @param xaxis defines the value of the 1st axis
  4593. * @param yaxis defines the value of the 2nd axis
  4594. * @param zaxis defines the value of the 3rd axis
  4595. * @param result defines the target matrix
  4596. */
  4597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4598. /**
  4599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4600. * @param quat defines the quaternion to use
  4601. * @param result defines the target matrix
  4602. */
  4603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4604. }
  4605. /**
  4606. * @hidden
  4607. */
  4608. export class TmpVectors {
  4609. static Vector2: Vector2[];
  4610. static Vector3: Vector3[];
  4611. static Vector4: Vector4[];
  4612. static Quaternion: Quaternion[];
  4613. static Matrix: Matrix[];
  4614. }
  4615. }
  4616. declare module "babylonjs/Maths/math.path" {
  4617. import { DeepImmutable, Nullable } from "babylonjs/types";
  4618. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4619. /**
  4620. * Defines potential orientation for back face culling
  4621. */
  4622. export enum Orientation {
  4623. /**
  4624. * Clockwise
  4625. */
  4626. CW = 0,
  4627. /** Counter clockwise */
  4628. CCW = 1
  4629. }
  4630. /** Class used to represent a Bezier curve */
  4631. export class BezierCurve {
  4632. /**
  4633. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4634. * @param t defines the time
  4635. * @param x1 defines the left coordinate on X axis
  4636. * @param y1 defines the left coordinate on Y axis
  4637. * @param x2 defines the right coordinate on X axis
  4638. * @param y2 defines the right coordinate on Y axis
  4639. * @returns the interpolated value
  4640. */
  4641. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4642. }
  4643. /**
  4644. * Defines angle representation
  4645. */
  4646. export class Angle {
  4647. private _radians;
  4648. /**
  4649. * Creates an Angle object of "radians" radians (float).
  4650. * @param radians the angle in radians
  4651. */
  4652. constructor(radians: number);
  4653. /**
  4654. * Get value in degrees
  4655. * @returns the Angle value in degrees (float)
  4656. */
  4657. degrees(): number;
  4658. /**
  4659. * Get value in radians
  4660. * @returns the Angle value in radians (float)
  4661. */
  4662. radians(): number;
  4663. /**
  4664. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4665. * @param a defines first vector
  4666. * @param b defines second vector
  4667. * @returns a new Angle
  4668. */
  4669. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4670. /**
  4671. * Gets a new Angle object from the given float in radians
  4672. * @param radians defines the angle value in radians
  4673. * @returns a new Angle
  4674. */
  4675. static FromRadians(radians: number): Angle;
  4676. /**
  4677. * Gets a new Angle object from the given float in degrees
  4678. * @param degrees defines the angle value in degrees
  4679. * @returns a new Angle
  4680. */
  4681. static FromDegrees(degrees: number): Angle;
  4682. }
  4683. /**
  4684. * This represents an arc in a 2d space.
  4685. */
  4686. export class Arc2 {
  4687. /** Defines the start point of the arc */
  4688. startPoint: Vector2;
  4689. /** Defines the mid point of the arc */
  4690. midPoint: Vector2;
  4691. /** Defines the end point of the arc */
  4692. endPoint: Vector2;
  4693. /**
  4694. * Defines the center point of the arc.
  4695. */
  4696. centerPoint: Vector2;
  4697. /**
  4698. * Defines the radius of the arc.
  4699. */
  4700. radius: number;
  4701. /**
  4702. * Defines the angle of the arc (from mid point to end point).
  4703. */
  4704. angle: Angle;
  4705. /**
  4706. * Defines the start angle of the arc (from start point to middle point).
  4707. */
  4708. startAngle: Angle;
  4709. /**
  4710. * Defines the orientation of the arc (clock wise/counter clock wise).
  4711. */
  4712. orientation: Orientation;
  4713. /**
  4714. * Creates an Arc object from the three given points : start, middle and end.
  4715. * @param startPoint Defines the start point of the arc
  4716. * @param midPoint Defines the midlle point of the arc
  4717. * @param endPoint Defines the end point of the arc
  4718. */
  4719. constructor(
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2,
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2,
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2);
  4726. }
  4727. /**
  4728. * Represents a 2D path made up of multiple 2D points
  4729. */
  4730. export class Path2 {
  4731. private _points;
  4732. private _length;
  4733. /**
  4734. * If the path start and end point are the same
  4735. */
  4736. closed: boolean;
  4737. /**
  4738. * Creates a Path2 object from the starting 2D coordinates x and y.
  4739. * @param x the starting points x value
  4740. * @param y the starting points y value
  4741. */
  4742. constructor(x: number, y: number);
  4743. /**
  4744. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4745. * @param x the added points x value
  4746. * @param y the added points y value
  4747. * @returns the updated Path2.
  4748. */
  4749. addLineTo(x: number, y: number): Path2;
  4750. /**
  4751. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4752. * @param midX middle point x value
  4753. * @param midY middle point y value
  4754. * @param endX end point x value
  4755. * @param endY end point y value
  4756. * @param numberOfSegments (default: 36)
  4757. * @returns the updated Path2.
  4758. */
  4759. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4760. /**
  4761. * Closes the Path2.
  4762. * @returns the Path2.
  4763. */
  4764. close(): Path2;
  4765. /**
  4766. * Gets the sum of the distance between each sequential point in the path
  4767. * @returns the Path2 total length (float).
  4768. */
  4769. length(): number;
  4770. /**
  4771. * Gets the points which construct the path
  4772. * @returns the Path2 internal array of points.
  4773. */
  4774. getPoints(): Vector2[];
  4775. /**
  4776. * Retreives the point at the distance aways from the starting point
  4777. * @param normalizedLengthPosition the length along the path to retreive the point from
  4778. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4779. */
  4780. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4781. /**
  4782. * Creates a new path starting from an x and y position
  4783. * @param x starting x value
  4784. * @param y starting y value
  4785. * @returns a new Path2 starting at the coordinates (x, y).
  4786. */
  4787. static StartingAt(x: number, y: number): Path2;
  4788. }
  4789. /**
  4790. * Represents a 3D path made up of multiple 3D points
  4791. */
  4792. export class Path3D {
  4793. /**
  4794. * an array of Vector3, the curve axis of the Path3D
  4795. */
  4796. path: Vector3[];
  4797. private _curve;
  4798. private _distances;
  4799. private _tangents;
  4800. private _normals;
  4801. private _binormals;
  4802. private _raw;
  4803. private _alignTangentsWithPath;
  4804. private readonly _pointAtData;
  4805. /**
  4806. * new Path3D(path, normal, raw)
  4807. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4808. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4809. * @param path an array of Vector3, the curve axis of the Path3D
  4810. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4811. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4812. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4813. */
  4814. constructor(
  4815. /**
  4816. * an array of Vector3, the curve axis of the Path3D
  4817. */
  4818. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4819. /**
  4820. * Returns the Path3D array of successive Vector3 designing its curve.
  4821. * @returns the Path3D array of successive Vector3 designing its curve.
  4822. */
  4823. getCurve(): Vector3[];
  4824. /**
  4825. * Returns the Path3D array of successive Vector3 designing its curve.
  4826. * @returns the Path3D array of successive Vector3 designing its curve.
  4827. */
  4828. getPoints(): Vector3[];
  4829. /**
  4830. * @returns the computed length (float) of the path.
  4831. */
  4832. length(): number;
  4833. /**
  4834. * Returns an array populated with tangent vectors on each Path3D curve point.
  4835. * @returns an array populated with tangent vectors on each Path3D curve point.
  4836. */
  4837. getTangents(): Vector3[];
  4838. /**
  4839. * Returns an array populated with normal vectors on each Path3D curve point.
  4840. * @returns an array populated with normal vectors on each Path3D curve point.
  4841. */
  4842. getNormals(): Vector3[];
  4843. /**
  4844. * Returns an array populated with binormal vectors on each Path3D curve point.
  4845. * @returns an array populated with binormal vectors on each Path3D curve point.
  4846. */
  4847. getBinormals(): Vector3[];
  4848. /**
  4849. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4851. */
  4852. getDistances(): number[];
  4853. /**
  4854. * Returns an interpolated point along this path
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @returns a new Vector3 as the point
  4857. */
  4858. getPointAt(position: number): Vector3;
  4859. /**
  4860. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4861. * @param position the position of the point along this path, from 0.0 to 1.0
  4862. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4863. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4864. */
  4865. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4866. /**
  4867. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4868. * @param position the position of the point along this path, from 0.0 to 1.0
  4869. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4870. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4871. */
  4872. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4873. /**
  4874. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4877. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4878. */
  4879. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4880. /**
  4881. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4884. */
  4885. getDistanceAt(position: number): number;
  4886. /**
  4887. * Returns the array index of the previous point of an interpolated point along this path
  4888. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4889. * @returns the array index
  4890. */
  4891. getPreviousPointIndexAt(position: number): number;
  4892. /**
  4893. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4894. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4895. * @returns the sub position
  4896. */
  4897. getSubPositionAt(position: number): number;
  4898. /**
  4899. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4900. * @param target the vector of which to get the closest position to
  4901. * @returns the position of the closest virtual point on this path to the target vector
  4902. */
  4903. getClosestPositionTo(target: Vector3): number;
  4904. /**
  4905. * Returns a sub path (slice) of this path
  4906. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4907. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4908. * @returns a sub path (slice) of this path
  4909. */
  4910. slice(start?: number, end?: number): Path3D;
  4911. /**
  4912. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4913. * @param path path which all values are copied into the curves points
  4914. * @param firstNormal which should be projected onto the curve
  4915. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4916. * @returns the same object updated.
  4917. */
  4918. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4919. private _compute;
  4920. private _getFirstNonNullVector;
  4921. private _getLastNonNullVector;
  4922. private _normalVector;
  4923. /**
  4924. * Updates the point at data for an interpolated point along this curve
  4925. * @param position the position of the point along this curve, from 0.0 to 1.0
  4926. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4927. * @returns the (updated) point at data
  4928. */
  4929. private _updatePointAtData;
  4930. /**
  4931. * Updates the point at data from the specified parameters
  4932. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4933. * @param point the interpolated point
  4934. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4935. */
  4936. private _setPointAtData;
  4937. /**
  4938. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4939. */
  4940. private _updateInterpolationMatrix;
  4941. }
  4942. /**
  4943. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4944. * A Curve3 is designed from a series of successive Vector3.
  4945. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4946. */
  4947. export class Curve3 {
  4948. private _points;
  4949. private _length;
  4950. /**
  4951. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4952. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4953. * @param v1 (Vector3) the control point
  4954. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4961. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4962. * @param v1 (Vector3) the first control point
  4963. * @param v2 (Vector3) the second control point
  4964. * @param v3 (Vector3) the end point of the Cubic Bezier
  4965. * @param nbPoints (integer) the wanted number of points in the curve
  4966. * @returns the created Curve3
  4967. */
  4968. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4969. /**
  4970. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4971. * @param p1 (Vector3) the origin point of the Hermite Spline
  4972. * @param t1 (Vector3) the tangent vector at the origin point
  4973. * @param p2 (Vector3) the end point of the Hermite Spline
  4974. * @param t2 (Vector3) the tangent vector at the end point
  4975. * @param nbPoints (integer) the wanted number of points in the curve
  4976. * @returns the created Curve3
  4977. */
  4978. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4979. /**
  4980. * Returns a Curve3 object along a CatmullRom Spline curve :
  4981. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4982. * @param nbPoints (integer) the wanted number of points between each curve control points
  4983. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4984. * @returns the created Curve3
  4985. */
  4986. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4987. /**
  4988. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4989. * A Curve3 is designed from a series of successive Vector3.
  4990. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4991. * @param points points which make up the curve
  4992. */
  4993. constructor(points: Vector3[]);
  4994. /**
  4995. * @returns the Curve3 stored array of successive Vector3
  4996. */
  4997. getPoints(): Vector3[];
  4998. /**
  4999. * @returns the computed length (float) of the curve.
  5000. */
  5001. length(): number;
  5002. /**
  5003. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5004. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5005. * curveA and curveB keep unchanged.
  5006. * @param curve the curve to continue from this curve
  5007. * @returns the newly constructed curve
  5008. */
  5009. continue(curve: DeepImmutable<Curve3>): Curve3;
  5010. private _computeLength;
  5011. }
  5012. }
  5013. declare module "babylonjs/Animations/easing" {
  5014. /**
  5015. * This represents the main contract an easing function should follow.
  5016. * Easing functions are used throughout the animation system.
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export interface IEasingFunction {
  5020. /**
  5021. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5022. * of the easing function.
  5023. * The link below provides some of the most common examples of easing functions.
  5024. * @see https://easings.net/
  5025. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5026. * @returns the corresponding value on the curve defined by the easing function
  5027. */
  5028. ease(gradient: number): number;
  5029. }
  5030. /**
  5031. * Base class used for every default easing function.
  5032. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5033. */
  5034. export class EasingFunction implements IEasingFunction {
  5035. /**
  5036. * Interpolation follows the mathematical formula associated with the easing function.
  5037. */
  5038. static readonly EASINGMODE_EASEIN: number;
  5039. /**
  5040. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5041. */
  5042. static readonly EASINGMODE_EASEOUT: number;
  5043. /**
  5044. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5045. */
  5046. static readonly EASINGMODE_EASEINOUT: number;
  5047. private _easingMode;
  5048. /**
  5049. * Sets the easing mode of the current function.
  5050. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5051. */
  5052. setEasingMode(easingMode: number): void;
  5053. /**
  5054. * Gets the current easing mode.
  5055. * @returns the easing mode
  5056. */
  5057. getEasingMode(): number;
  5058. /**
  5059. * @hidden
  5060. */
  5061. easeInCore(gradient: number): number;
  5062. /**
  5063. * Given an input gradient between 0 and 1, this returns the corresponding value
  5064. * of the easing function.
  5065. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5066. * @returns the corresponding value on the curve defined by the easing function
  5067. */
  5068. ease(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a circle shape (see link below).
  5072. * @see https://easings.net/#easeInCirc
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class CircleEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a ease back shape (see link below).
  5081. * @see https://easings.net/#easeInBack
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class BackEase extends EasingFunction implements IEasingFunction {
  5085. /** Defines the amplitude of the function */
  5086. amplitude: number;
  5087. /**
  5088. * Instantiates a back ease easing
  5089. * @see https://easings.net/#easeInBack
  5090. * @param amplitude Defines the amplitude of the function
  5091. */
  5092. constructor(
  5093. /** Defines the amplitude of the function */
  5094. amplitude?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. /**
  5099. * Easing function with a bouncing shape (see link below).
  5100. * @see https://easings.net/#easeInBounce
  5101. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5102. */
  5103. export class BounceEase extends EasingFunction implements IEasingFunction {
  5104. /** Defines the number of bounces */
  5105. bounces: number;
  5106. /** Defines the amplitude of the bounce */
  5107. bounciness: number;
  5108. /**
  5109. * Instantiates a bounce easing
  5110. * @see https://easings.net/#easeInBounce
  5111. * @param bounces Defines the number of bounces
  5112. * @param bounciness Defines the amplitude of the bounce
  5113. */
  5114. constructor(
  5115. /** Defines the number of bounces */
  5116. bounces?: number,
  5117. /** Defines the amplitude of the bounce */
  5118. bounciness?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. /**
  5123. * Easing function with a power of 3 shape (see link below).
  5124. * @see https://easings.net/#easeInCubic
  5125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5126. */
  5127. export class CubicEase extends EasingFunction implements IEasingFunction {
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with an elastic shape (see link below).
  5133. * @see https://easings.net/#easeInElastic
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of oscillations*/
  5138. oscillations: number;
  5139. /** Defines the amplitude of the oscillations*/
  5140. springiness: number;
  5141. /**
  5142. * Instantiates an elastic easing function
  5143. * @see https://easings.net/#easeInElastic
  5144. * @param oscillations Defines the number of oscillations
  5145. * @param springiness Defines the amplitude of the oscillations
  5146. */
  5147. constructor(
  5148. /** Defines the number of oscillations*/
  5149. oscillations?: number,
  5150. /** Defines the amplitude of the oscillations*/
  5151. springiness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with an exponential shape (see link below).
  5157. * @see https://easings.net/#easeInExpo
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5161. /** Defines the exponent of the function */
  5162. exponent: number;
  5163. /**
  5164. * Instantiates an exponential easing function
  5165. * @see https://easings.net/#easeInExpo
  5166. * @param exponent Defines the exponent of the function
  5167. */
  5168. constructor(
  5169. /** Defines the exponent of the function */
  5170. exponent?: number);
  5171. /** @hidden */
  5172. easeInCore(gradient: number): number;
  5173. }
  5174. /**
  5175. * Easing function with a power shape (see link below).
  5176. * @see https://easings.net/#easeInQuad
  5177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5178. */
  5179. export class PowerEase extends EasingFunction implements IEasingFunction {
  5180. /** Defines the power of the function */
  5181. power: number;
  5182. /**
  5183. * Instantiates an power base easing function
  5184. * @see https://easings.net/#easeInQuad
  5185. * @param power Defines the power of the function
  5186. */
  5187. constructor(
  5188. /** Defines the power of the function */
  5189. power?: number);
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with a power of 2 shape (see link below).
  5195. * @see https://easings.net/#easeInQuad
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5199. /** @hidden */
  5200. easeInCore(gradient: number): number;
  5201. }
  5202. /**
  5203. * Easing function with a power of 4 shape (see link below).
  5204. * @see https://easings.net/#easeInQuart
  5205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. /**
  5212. * Easing function with a power of 5 shape (see link below).
  5213. * @see https://easings.net/#easeInQuint
  5214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5215. */
  5216. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a sin shape (see link below).
  5222. * @see https://easings.net/#easeInSine
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class SineEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a bezier shape (see link below).
  5231. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5235. /** Defines the x component of the start tangent in the bezier curve */
  5236. x1: number;
  5237. /** Defines the y component of the start tangent in the bezier curve */
  5238. y1: number;
  5239. /** Defines the x component of the end tangent in the bezier curve */
  5240. x2: number;
  5241. /** Defines the y component of the end tangent in the bezier curve */
  5242. y2: number;
  5243. /**
  5244. * Instantiates a bezier function
  5245. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5246. * @param x1 Defines the x component of the start tangent in the bezier curve
  5247. * @param y1 Defines the y component of the start tangent in the bezier curve
  5248. * @param x2 Defines the x component of the end tangent in the bezier curve
  5249. * @param y2 Defines the y component of the end tangent in the bezier curve
  5250. */
  5251. constructor(
  5252. /** Defines the x component of the start tangent in the bezier curve */
  5253. x1?: number,
  5254. /** Defines the y component of the start tangent in the bezier curve */
  5255. y1?: number,
  5256. /** Defines the x component of the end tangent in the bezier curve */
  5257. x2?: number,
  5258. /** Defines the y component of the end tangent in the bezier curve */
  5259. y2?: number);
  5260. /** @hidden */
  5261. easeInCore(gradient: number): number;
  5262. }
  5263. }
  5264. declare module "babylonjs/Maths/math.color" {
  5265. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5266. /**
  5267. * Class used to hold a RBG color
  5268. */
  5269. export class Color3 {
  5270. /**
  5271. * Defines the red component (between 0 and 1, default is 0)
  5272. */
  5273. r: number;
  5274. /**
  5275. * Defines the green component (between 0 and 1, default is 0)
  5276. */
  5277. g: number;
  5278. /**
  5279. * Defines the blue component (between 0 and 1, default is 0)
  5280. */
  5281. b: number;
  5282. /**
  5283. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5284. * @param r defines the red component (between 0 and 1, default is 0)
  5285. * @param g defines the green component (between 0 and 1, default is 0)
  5286. * @param b defines the blue component (between 0 and 1, default is 0)
  5287. */
  5288. constructor(
  5289. /**
  5290. * Defines the red component (between 0 and 1, default is 0)
  5291. */
  5292. r?: number,
  5293. /**
  5294. * Defines the green component (between 0 and 1, default is 0)
  5295. */
  5296. g?: number,
  5297. /**
  5298. * Defines the blue component (between 0 and 1, default is 0)
  5299. */
  5300. b?: number);
  5301. /**
  5302. * Creates a string with the Color3 current values
  5303. * @returns the string representation of the Color3 object
  5304. */
  5305. toString(): string;
  5306. /**
  5307. * Returns the string "Color3"
  5308. * @returns "Color3"
  5309. */
  5310. getClassName(): string;
  5311. /**
  5312. * Compute the Color3 hash code
  5313. * @returns an unique number that can be used to hash Color3 objects
  5314. */
  5315. getHashCode(): number;
  5316. /**
  5317. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5318. * @param array defines the array where to store the r,g,b components
  5319. * @param index defines an optional index in the target array to define where to start storing values
  5320. * @returns the current Color3 object
  5321. */
  5322. toArray(array: FloatArray, index?: number): Color3;
  5323. /**
  5324. * Returns a new Color4 object from the current Color3 and the given alpha
  5325. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5326. * @returns a new Color4 object
  5327. */
  5328. toColor4(alpha?: number): Color4;
  5329. /**
  5330. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5331. * @returns the new array
  5332. */
  5333. asArray(): number[];
  5334. /**
  5335. * Returns the luminance value
  5336. * @returns a float value
  5337. */
  5338. toLuminance(): number;
  5339. /**
  5340. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5341. * @param otherColor defines the second operand
  5342. * @returns the new Color3 object
  5343. */
  5344. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5345. /**
  5346. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5347. * @param otherColor defines the second operand
  5348. * @param result defines the Color3 object where to store the result
  5349. * @returns the current Color3
  5350. */
  5351. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5352. /**
  5353. * Determines equality between Color3 objects
  5354. * @param otherColor defines the second operand
  5355. * @returns true if the rgb values are equal to the given ones
  5356. */
  5357. equals(otherColor: DeepImmutable<Color3>): boolean;
  5358. /**
  5359. * Determines equality between the current Color3 object and a set of r,b,g values
  5360. * @param r defines the red component to check
  5361. * @param g defines the green component to check
  5362. * @param b defines the blue component to check
  5363. * @returns true if the rgb values are equal to the given ones
  5364. */
  5365. equalsFloats(r: number, g: number, b: number): boolean;
  5366. /**
  5367. * Multiplies in place each rgb value by scale
  5368. * @param scale defines the scaling factor
  5369. * @returns the updated Color3
  5370. */
  5371. scale(scale: number): Color3;
  5372. /**
  5373. * Multiplies the rgb values by scale and stores the result into "result"
  5374. * @param scale defines the scaling factor
  5375. * @param result defines the Color3 object where to store the result
  5376. * @returns the unmodified current Color3
  5377. */
  5378. scaleToRef(scale: number, result: Color3): Color3;
  5379. /**
  5380. * Scale the current Color3 values by a factor and add the result to a given Color3
  5381. * @param scale defines the scale factor
  5382. * @param result defines color to store the result into
  5383. * @returns the unmodified current Color3
  5384. */
  5385. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5386. /**
  5387. * Clamps the rgb values by the min and max values and stores the result into "result"
  5388. * @param min defines minimum clamping value (default is 0)
  5389. * @param max defines maximum clamping value (default is 1)
  5390. * @param result defines color to store the result into
  5391. * @returns the original Color3
  5392. */
  5393. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5394. /**
  5395. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5396. * @param otherColor defines the second operand
  5397. * @returns the new Color3
  5398. */
  5399. add(otherColor: DeepImmutable<Color3>): Color3;
  5400. /**
  5401. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5402. * @param otherColor defines the second operand
  5403. * @param result defines Color3 object to store the result into
  5404. * @returns the unmodified current Color3
  5405. */
  5406. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5407. /**
  5408. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5409. * @param otherColor defines the second operand
  5410. * @returns the new Color3
  5411. */
  5412. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5413. /**
  5414. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5415. * @param otherColor defines the second operand
  5416. * @param result defines Color3 object to store the result into
  5417. * @returns the unmodified current Color3
  5418. */
  5419. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5420. /**
  5421. * Copy the current object
  5422. * @returns a new Color3 copied the current one
  5423. */
  5424. clone(): Color3;
  5425. /**
  5426. * Copies the rgb values from the source in the current Color3
  5427. * @param source defines the source Color3 object
  5428. * @returns the updated Color3 object
  5429. */
  5430. copyFrom(source: DeepImmutable<Color3>): Color3;
  5431. /**
  5432. * Updates the Color3 rgb values from the given floats
  5433. * @param r defines the red component to read from
  5434. * @param g defines the green component to read from
  5435. * @param b defines the blue component to read from
  5436. * @returns the current Color3 object
  5437. */
  5438. copyFromFloats(r: number, g: number, b: number): Color3;
  5439. /**
  5440. * Updates the Color3 rgb values from the given floats
  5441. * @param r defines the red component to read from
  5442. * @param g defines the green component to read from
  5443. * @param b defines the blue component to read from
  5444. * @returns the current Color3 object
  5445. */
  5446. set(r: number, g: number, b: number): Color3;
  5447. /**
  5448. * Compute the Color3 hexadecimal code as a string
  5449. * @returns a string containing the hexadecimal representation of the Color3 object
  5450. */
  5451. toHexString(): string;
  5452. /**
  5453. * Computes a new Color3 converted from the current one to linear space
  5454. * @returns a new Color3 object
  5455. */
  5456. toLinearSpace(): Color3;
  5457. /**
  5458. * Converts current color in rgb space to HSV values
  5459. * @returns a new color3 representing the HSV values
  5460. */
  5461. toHSV(): Color3;
  5462. /**
  5463. * Converts current color in rgb space to HSV values
  5464. * @param result defines the Color3 where to store the HSV values
  5465. */
  5466. toHSVToRef(result: Color3): void;
  5467. /**
  5468. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5469. * @param convertedColor defines the Color3 object where to store the linear space version
  5470. * @returns the unmodified Color3
  5471. */
  5472. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5473. /**
  5474. * Computes a new Color3 converted from the current one to gamma space
  5475. * @returns a new Color3 object
  5476. */
  5477. toGammaSpace(): Color3;
  5478. /**
  5479. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5480. * @param convertedColor defines the Color3 object where to store the gamma space version
  5481. * @returns the unmodified Color3
  5482. */
  5483. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5484. private static _BlackReadOnly;
  5485. /**
  5486. * Convert Hue, saturation and value to a Color3 (RGB)
  5487. * @param hue defines the hue
  5488. * @param saturation defines the saturation
  5489. * @param value defines the value
  5490. * @param result defines the Color3 where to store the RGB values
  5491. */
  5492. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5493. /**
  5494. * Creates a new Color3 from the string containing valid hexadecimal values
  5495. * @param hex defines a string containing valid hexadecimal values
  5496. * @returns a new Color3 object
  5497. */
  5498. static FromHexString(hex: string): Color3;
  5499. /**
  5500. * Creates a new Color3 from the starting index of the given array
  5501. * @param array defines the source array
  5502. * @param offset defines an offset in the source array
  5503. * @returns a new Color3 object
  5504. */
  5505. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5506. /**
  5507. * Creates a new Color3 from integer values (< 256)
  5508. * @param r defines the red component to read from (value between 0 and 255)
  5509. * @param g defines the green component to read from (value between 0 and 255)
  5510. * @param b defines the blue component to read from (value between 0 and 255)
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromInts(r: number, g: number, b: number): Color3;
  5514. /**
  5515. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5516. * @param start defines the start Color3 value
  5517. * @param end defines the end Color3 value
  5518. * @param amount defines the gradient value between start and end
  5519. * @returns a new Color3 object
  5520. */
  5521. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5522. /**
  5523. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5524. * @param left defines the start value
  5525. * @param right defines the end value
  5526. * @param amount defines the gradient factor
  5527. * @param result defines the Color3 object where to store the result
  5528. */
  5529. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5530. /**
  5531. * Returns a Color3 value containing a red color
  5532. * @returns a new Color3 object
  5533. */
  5534. static Red(): Color3;
  5535. /**
  5536. * Returns a Color3 value containing a green color
  5537. * @returns a new Color3 object
  5538. */
  5539. static Green(): Color3;
  5540. /**
  5541. * Returns a Color3 value containing a blue color
  5542. * @returns a new Color3 object
  5543. */
  5544. static Blue(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a black color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Black(): Color3;
  5550. /**
  5551. * Gets a Color3 value containing a black color that must not be updated
  5552. */
  5553. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5554. /**
  5555. * Returns a Color3 value containing a white color
  5556. * @returns a new Color3 object
  5557. */
  5558. static White(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a purple color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Purple(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a magenta color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Magenta(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a yellow color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Yellow(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a gray color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Gray(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a teal color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Teal(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a random color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Random(): Color3;
  5589. }
  5590. /**
  5591. * Class used to hold a RBGA color
  5592. */
  5593. export class Color4 {
  5594. /**
  5595. * Defines the red component (between 0 and 1, default is 0)
  5596. */
  5597. r: number;
  5598. /**
  5599. * Defines the green component (between 0 and 1, default is 0)
  5600. */
  5601. g: number;
  5602. /**
  5603. * Defines the blue component (between 0 and 1, default is 0)
  5604. */
  5605. b: number;
  5606. /**
  5607. * Defines the alpha component (between 0 and 1, default is 1)
  5608. */
  5609. a: number;
  5610. /**
  5611. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5612. * @param r defines the red component (between 0 and 1, default is 0)
  5613. * @param g defines the green component (between 0 and 1, default is 0)
  5614. * @param b defines the blue component (between 0 and 1, default is 0)
  5615. * @param a defines the alpha component (between 0 and 1, default is 1)
  5616. */
  5617. constructor(
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r?: number,
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g?: number,
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b?: number,
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a?: number);
  5634. /**
  5635. * Adds in place the given Color4 values to the current Color4 object
  5636. * @param right defines the second operand
  5637. * @returns the current updated Color4 object
  5638. */
  5639. addInPlace(right: DeepImmutable<Color4>): Color4;
  5640. /**
  5641. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5642. * @returns the new array
  5643. */
  5644. asArray(): number[];
  5645. /**
  5646. * Stores from the starting index in the given array the Color4 successive values
  5647. * @param array defines the array where to store the r,g,b components
  5648. * @param index defines an optional index in the target array to define where to start storing values
  5649. * @returns the current Color4 object
  5650. */
  5651. toArray(array: number[], index?: number): Color4;
  5652. /**
  5653. * Determines equality between Color4 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgba values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color4>): boolean;
  5658. /**
  5659. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5660. * @param right defines the second operand
  5661. * @returns a new Color4 object
  5662. */
  5663. add(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5666. * @param right defines the second operand
  5667. * @returns a new Color4 object
  5668. */
  5669. subtract(right: DeepImmutable<Color4>): Color4;
  5670. /**
  5671. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5672. * @param right defines the second operand
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the current Color4 object
  5675. */
  5676. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5677. /**
  5678. * Creates a new Color4 with the current Color4 values multiplied by scale
  5679. * @param scale defines the scaling factor to apply
  5680. * @returns a new Color4 object
  5681. */
  5682. scale(scale: number): Color4;
  5683. /**
  5684. * Multiplies the current Color4 values by scale and stores the result in "result"
  5685. * @param scale defines the scaling factor to apply
  5686. * @param result defines the Color4 object where to store the result
  5687. * @returns the current unmodified Color4
  5688. */
  5689. scaleToRef(scale: number, result: Color4): Color4;
  5690. /**
  5691. * Scale the current Color4 values by a factor and add the result to a given Color4
  5692. * @param scale defines the scale factor
  5693. * @param result defines the Color4 object where to store the result
  5694. * @returns the unmodified current Color4
  5695. */
  5696. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5697. /**
  5698. * Clamps the rgb values by the min and max values and stores the result into "result"
  5699. * @param min defines minimum clamping value (default is 0)
  5700. * @param max defines maximum clamping value (default is 1)
  5701. * @param result defines color to store the result into.
  5702. * @returns the cuurent Color4
  5703. */
  5704. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5705. /**
  5706. * Multipy an Color4 value by another and return a new Color4 object
  5707. * @param color defines the Color4 value to multiply by
  5708. * @returns a new Color4 object
  5709. */
  5710. multiply(color: Color4): Color4;
  5711. /**
  5712. * Multipy a Color4 value by another and push the result in a reference value
  5713. * @param color defines the Color4 value to multiply by
  5714. * @param result defines the Color4 to fill the result in
  5715. * @returns the result Color4
  5716. */
  5717. multiplyToRef(color: Color4, result: Color4): Color4;
  5718. /**
  5719. * Creates a string with the Color4 current values
  5720. * @returns the string representation of the Color4 object
  5721. */
  5722. toString(): string;
  5723. /**
  5724. * Returns the string "Color4"
  5725. * @returns "Color4"
  5726. */
  5727. getClassName(): string;
  5728. /**
  5729. * Compute the Color4 hash code
  5730. * @returns an unique number that can be used to hash Color4 objects
  5731. */
  5732. getHashCode(): number;
  5733. /**
  5734. * Creates a new Color4 copied from the current one
  5735. * @returns a new Color4 object
  5736. */
  5737. clone(): Color4;
  5738. /**
  5739. * Copies the given Color4 values into the current one
  5740. * @param source defines the source Color4 object
  5741. * @returns the current updated Color4 object
  5742. */
  5743. copyFrom(source: Color4): Color4;
  5744. /**
  5745. * Copies the given float values into the current one
  5746. * @param r defines the red component to read from
  5747. * @param g defines the green component to read from
  5748. * @param b defines the blue component to read from
  5749. * @param a defines the alpha component to read from
  5750. * @returns the current updated Color4 object
  5751. */
  5752. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5753. /**
  5754. * Copies the given float values into the current one
  5755. * @param r defines the red component to read from
  5756. * @param g defines the green component to read from
  5757. * @param b defines the blue component to read from
  5758. * @param a defines the alpha component to read from
  5759. * @returns the current updated Color4 object
  5760. */
  5761. set(r: number, g: number, b: number, a: number): Color4;
  5762. /**
  5763. * Compute the Color4 hexadecimal code as a string
  5764. * @returns a string containing the hexadecimal representation of the Color4 object
  5765. */
  5766. toHexString(): string;
  5767. /**
  5768. * Computes a new Color4 converted from the current one to linear space
  5769. * @returns a new Color4 object
  5770. */
  5771. toLinearSpace(): Color4;
  5772. /**
  5773. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5774. * @param convertedColor defines the Color4 object where to store the linear space version
  5775. * @returns the unmodified Color4
  5776. */
  5777. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5778. /**
  5779. * Computes a new Color4 converted from the current one to gamma space
  5780. * @returns a new Color4 object
  5781. */
  5782. toGammaSpace(): Color4;
  5783. /**
  5784. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5785. * @param convertedColor defines the Color4 object where to store the gamma space version
  5786. * @returns the unmodified Color4
  5787. */
  5788. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5789. /**
  5790. * Creates a new Color4 from the string containing valid hexadecimal values
  5791. * @param hex defines a string containing valid hexadecimal values
  5792. * @returns a new Color4 object
  5793. */
  5794. static FromHexString(hex: string): Color4;
  5795. /**
  5796. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5797. * @param left defines the start value
  5798. * @param right defines the end value
  5799. * @param amount defines the gradient factor
  5800. * @returns a new Color4 object
  5801. */
  5802. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5803. /**
  5804. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5805. * @param left defines the start value
  5806. * @param right defines the end value
  5807. * @param amount defines the gradient factor
  5808. * @param result defines the Color4 object where to store data
  5809. */
  5810. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5811. /**
  5812. * Creates a new Color4 from a Color3 and an alpha value
  5813. * @param color3 defines the source Color3 to read from
  5814. * @param alpha defines the alpha component (1.0 by default)
  5815. * @returns a new Color4 object
  5816. */
  5817. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5818. /**
  5819. * Creates a new Color4 from the starting index element of the given array
  5820. * @param array defines the source array to read from
  5821. * @param offset defines the offset in the source array
  5822. * @returns a new Color4 object
  5823. */
  5824. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5825. /**
  5826. * Creates a new Color3 from integer values (< 256)
  5827. * @param r defines the red component to read from (value between 0 and 255)
  5828. * @param g defines the green component to read from (value between 0 and 255)
  5829. * @param b defines the blue component to read from (value between 0 and 255)
  5830. * @param a defines the alpha component to read from (value between 0 and 255)
  5831. * @returns a new Color3 object
  5832. */
  5833. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5834. /**
  5835. * Check the content of a given array and convert it to an array containing RGBA data
  5836. * If the original array was already containing count * 4 values then it is returned directly
  5837. * @param colors defines the array to check
  5838. * @param count defines the number of RGBA data to expect
  5839. * @returns an array containing count * 4 values (RGBA)
  5840. */
  5841. static CheckColors4(colors: number[], count: number): number[];
  5842. }
  5843. /**
  5844. * @hidden
  5845. */
  5846. export class TmpColors {
  5847. static Color3: Color3[];
  5848. static Color4: Color4[];
  5849. }
  5850. }
  5851. declare module "babylonjs/Animations/animationKey" {
  5852. /**
  5853. * Defines an interface which represents an animation key frame
  5854. */
  5855. export interface IAnimationKey {
  5856. /**
  5857. * Frame of the key frame
  5858. */
  5859. frame: number;
  5860. /**
  5861. * Value at the specifies key frame
  5862. */
  5863. value: any;
  5864. /**
  5865. * The input tangent for the cubic hermite spline
  5866. */
  5867. inTangent?: any;
  5868. /**
  5869. * The output tangent for the cubic hermite spline
  5870. */
  5871. outTangent?: any;
  5872. /**
  5873. * The animation interpolation type
  5874. */
  5875. interpolation?: AnimationKeyInterpolation;
  5876. }
  5877. /**
  5878. * Enum for the animation key frame interpolation type
  5879. */
  5880. export enum AnimationKeyInterpolation {
  5881. /**
  5882. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5883. */
  5884. STEP = 1
  5885. }
  5886. }
  5887. declare module "babylonjs/Animations/animationRange" {
  5888. /**
  5889. * Represents the range of an animation
  5890. */
  5891. export class AnimationRange {
  5892. /**The name of the animation range**/
  5893. name: string;
  5894. /**The starting frame of the animation */
  5895. from: number;
  5896. /**The ending frame of the animation*/
  5897. to: number;
  5898. /**
  5899. * Initializes the range of an animation
  5900. * @param name The name of the animation range
  5901. * @param from The starting frame of the animation
  5902. * @param to The ending frame of the animation
  5903. */
  5904. constructor(
  5905. /**The name of the animation range**/
  5906. name: string,
  5907. /**The starting frame of the animation */
  5908. from: number,
  5909. /**The ending frame of the animation*/
  5910. to: number);
  5911. /**
  5912. * Makes a copy of the animation range
  5913. * @returns A copy of the animation range
  5914. */
  5915. clone(): AnimationRange;
  5916. }
  5917. }
  5918. declare module "babylonjs/Animations/animationEvent" {
  5919. /**
  5920. * Composed of a frame, and an action function
  5921. */
  5922. export class AnimationEvent {
  5923. /** The frame for which the event is triggered **/
  5924. frame: number;
  5925. /** The event to perform when triggered **/
  5926. action: (currentFrame: number) => void;
  5927. /** Specifies if the event should be triggered only once**/
  5928. onlyOnce?: boolean | undefined;
  5929. /**
  5930. * Specifies if the animation event is done
  5931. */
  5932. isDone: boolean;
  5933. /**
  5934. * Initializes the animation event
  5935. * @param frame The frame for which the event is triggered
  5936. * @param action The event to perform when triggered
  5937. * @param onlyOnce Specifies if the event should be triggered only once
  5938. */
  5939. constructor(
  5940. /** The frame for which the event is triggered **/
  5941. frame: number,
  5942. /** The event to perform when triggered **/
  5943. action: (currentFrame: number) => void,
  5944. /** Specifies if the event should be triggered only once**/
  5945. onlyOnce?: boolean | undefined);
  5946. /** @hidden */
  5947. _clone(): AnimationEvent;
  5948. }
  5949. }
  5950. declare module "babylonjs/Behaviors/behavior" {
  5951. import { Nullable } from "babylonjs/types";
  5952. /**
  5953. * Interface used to define a behavior
  5954. */
  5955. export interface Behavior<T> {
  5956. /** gets or sets behavior's name */
  5957. name: string;
  5958. /**
  5959. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5960. */
  5961. init(): void;
  5962. /**
  5963. * Called when the behavior is attached to a target
  5964. * @param target defines the target where the behavior is attached to
  5965. */
  5966. attach(target: T): void;
  5967. /**
  5968. * Called when the behavior is detached from its target
  5969. */
  5970. detach(): void;
  5971. }
  5972. /**
  5973. * Interface implemented by classes supporting behaviors
  5974. */
  5975. export interface IBehaviorAware<T> {
  5976. /**
  5977. * Attach a behavior
  5978. * @param behavior defines the behavior to attach
  5979. * @returns the current host
  5980. */
  5981. addBehavior(behavior: Behavior<T>): T;
  5982. /**
  5983. * Remove a behavior from the current object
  5984. * @param behavior defines the behavior to detach
  5985. * @returns the current host
  5986. */
  5987. removeBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Gets a behavior using its name to search
  5990. * @param name defines the name to search
  5991. * @returns the behavior or null if not found
  5992. */
  5993. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5994. }
  5995. }
  5996. declare module "babylonjs/Misc/smartArray" {
  5997. /**
  5998. * Defines an array and its length.
  5999. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6000. */
  6001. export interface ISmartArrayLike<T> {
  6002. /**
  6003. * The data of the array.
  6004. */
  6005. data: Array<T>;
  6006. /**
  6007. * The active length of the array.
  6008. */
  6009. length: number;
  6010. }
  6011. /**
  6012. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6013. */
  6014. export class SmartArray<T> implements ISmartArrayLike<T> {
  6015. /**
  6016. * The full set of data from the array.
  6017. */
  6018. data: Array<T>;
  6019. /**
  6020. * The active length of the array.
  6021. */
  6022. length: number;
  6023. protected _id: number;
  6024. /**
  6025. * Instantiates a Smart Array.
  6026. * @param capacity defines the default capacity of the array.
  6027. */
  6028. constructor(capacity: number);
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * @param value defines the object to push in the array.
  6032. */
  6033. push(value: T): void;
  6034. /**
  6035. * Iterates over the active data and apply the lambda to them.
  6036. * @param func defines the action to apply on each value.
  6037. */
  6038. forEach(func: (content: T) => void): void;
  6039. /**
  6040. * Sorts the full sets of data.
  6041. * @param compareFn defines the comparison function to apply.
  6042. */
  6043. sort(compareFn: (a: T, b: T) => number): void;
  6044. /**
  6045. * Resets the active data to an empty array.
  6046. */
  6047. reset(): void;
  6048. /**
  6049. * Releases all the data from the array as well as the array.
  6050. */
  6051. dispose(): void;
  6052. /**
  6053. * Concats the active data with a given array.
  6054. * @param array defines the data to concatenate with.
  6055. */
  6056. concat(array: any): void;
  6057. /**
  6058. * Returns the position of a value in the active data.
  6059. * @param value defines the value to find the index for
  6060. * @returns the index if found in the active data otherwise -1
  6061. */
  6062. indexOf(value: T): number;
  6063. /**
  6064. * Returns whether an element is part of the active data.
  6065. * @param value defines the value to look for
  6066. * @returns true if found in the active data otherwise false
  6067. */
  6068. contains(value: T): boolean;
  6069. private static _GlobalId;
  6070. }
  6071. /**
  6072. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6073. * The data in this array can only be present once
  6074. */
  6075. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6076. private _duplicateId;
  6077. /**
  6078. * Pushes a value at the end of the active data.
  6079. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6080. * @param value defines the object to push in the array.
  6081. */
  6082. push(value: T): void;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * If the data is already present, it won t be added again
  6086. * @param value defines the object to push in the array.
  6087. * @returns true if added false if it was already present
  6088. */
  6089. pushNoDuplicate(value: T): boolean;
  6090. /**
  6091. * Resets the active data to an empty array.
  6092. */
  6093. reset(): void;
  6094. /**
  6095. * Concats the active data with a given array.
  6096. * This ensures no dupplicate will be present in the result.
  6097. * @param array defines the data to concatenate with.
  6098. */
  6099. concatWithNoDuplicate(array: any): void;
  6100. }
  6101. }
  6102. declare module "babylonjs/Cameras/cameraInputsManager" {
  6103. import { Nullable } from "babylonjs/types";
  6104. import { Camera } from "babylonjs/Cameras/camera";
  6105. /**
  6106. * @ignore
  6107. * This is a list of all the different input types that are available in the application.
  6108. * Fo instance: ArcRotateCameraGamepadInput...
  6109. */
  6110. export var CameraInputTypes: {};
  6111. /**
  6112. * This is the contract to implement in order to create a new input class.
  6113. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6114. */
  6115. export interface ICameraInput<TCamera extends Camera> {
  6116. /**
  6117. * Defines the camera the input is attached to.
  6118. */
  6119. camera: Nullable<TCamera>;
  6120. /**
  6121. * Gets the class name of the current intput.
  6122. * @returns the class name
  6123. */
  6124. getClassName(): string;
  6125. /**
  6126. * Get the friendly name associated with the input class.
  6127. * @returns the input friendly name
  6128. */
  6129. getSimpleName(): string;
  6130. /**
  6131. * Attach the input controls to a specific dom element to get the input from.
  6132. * @param element Defines the element the controls should be listened from
  6133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6134. */
  6135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6136. /**
  6137. * Detach the current controls from the specified dom element.
  6138. * @param element Defines the element to stop listening the inputs from
  6139. */
  6140. detachControl(element: Nullable<HTMLElement>): void;
  6141. /**
  6142. * Update the current camera state depending on the inputs that have been used this frame.
  6143. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6144. */
  6145. checkInputs?: () => void;
  6146. }
  6147. /**
  6148. * Represents a map of input types to input instance or input index to input instance.
  6149. */
  6150. export interface CameraInputsMap<TCamera extends Camera> {
  6151. /**
  6152. * Accessor to the input by input type.
  6153. */
  6154. [name: string]: ICameraInput<TCamera>;
  6155. /**
  6156. * Accessor to the input by input index.
  6157. */
  6158. [idx: number]: ICameraInput<TCamera>;
  6159. }
  6160. /**
  6161. * This represents the input manager used within a camera.
  6162. * It helps dealing with all the different kind of input attached to a camera.
  6163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6164. */
  6165. export class CameraInputsManager<TCamera extends Camera> {
  6166. /**
  6167. * Defines the list of inputs attahed to the camera.
  6168. */
  6169. attached: CameraInputsMap<TCamera>;
  6170. /**
  6171. * Defines the dom element the camera is collecting inputs from.
  6172. * This is null if the controls have not been attached.
  6173. */
  6174. attachedElement: Nullable<HTMLElement>;
  6175. /**
  6176. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6177. */
  6178. noPreventDefault: boolean;
  6179. /**
  6180. * Defined the camera the input manager belongs to.
  6181. */
  6182. camera: TCamera;
  6183. /**
  6184. * Update the current camera state depending on the inputs that have been used this frame.
  6185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6186. */
  6187. checkInputs: () => void;
  6188. /**
  6189. * Instantiate a new Camera Input Manager.
  6190. * @param camera Defines the camera the input manager blongs to
  6191. */
  6192. constructor(camera: TCamera);
  6193. /**
  6194. * Add an input method to a camera
  6195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6196. * @param input camera input method
  6197. */
  6198. add(input: ICameraInput<TCamera>): void;
  6199. /**
  6200. * Remove a specific input method from a camera
  6201. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6202. * @param inputToRemove camera input method
  6203. */
  6204. remove(inputToRemove: ICameraInput<TCamera>): void;
  6205. /**
  6206. * Remove a specific input type from a camera
  6207. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6208. * @param inputType the type of the input to remove
  6209. */
  6210. removeByType(inputType: string): void;
  6211. private _addCheckInputs;
  6212. /**
  6213. * Attach the input controls to the currently attached dom element to listen the events from.
  6214. * @param input Defines the input to attach
  6215. */
  6216. attachInput(input: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6219. * @param element Defines the dom element to collect the events from
  6220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6221. */
  6222. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6223. /**
  6224. * Detach the current manager inputs controls from a specific dom element.
  6225. * @param element Defines the dom element to collect the events from
  6226. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6227. */
  6228. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6229. /**
  6230. * Rebuild the dynamic inputCheck function from the current list of
  6231. * defined inputs in the manager.
  6232. */
  6233. rebuildInputCheck(): void;
  6234. /**
  6235. * Remove all attached input methods from a camera
  6236. */
  6237. clear(): void;
  6238. /**
  6239. * Serialize the current input manager attached to a camera.
  6240. * This ensures than once parsed,
  6241. * the input associated to the camera will be identical to the current ones
  6242. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6243. */
  6244. serialize(serializedCamera: any): void;
  6245. /**
  6246. * Parses an input manager serialized JSON to restore the previous list of inputs
  6247. * and states associated to a camera.
  6248. * @param parsedCamera Defines the JSON to parse
  6249. */
  6250. parse(parsedCamera: any): void;
  6251. }
  6252. }
  6253. declare module "babylonjs/Meshes/buffer" {
  6254. import { Nullable, DataArray } from "babylonjs/types";
  6255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6256. /**
  6257. * Class used to store data that will be store in GPU memory
  6258. */
  6259. export class Buffer {
  6260. private _engine;
  6261. private _buffer;
  6262. /** @hidden */
  6263. _data: Nullable<DataArray>;
  6264. private _updatable;
  6265. private _instanced;
  6266. private _divisor;
  6267. /**
  6268. * Gets the byte stride.
  6269. */
  6270. readonly byteStride: number;
  6271. /**
  6272. * Constructor
  6273. * @param engine the engine
  6274. * @param data the data to use for this buffer
  6275. * @param updatable whether the data is updatable
  6276. * @param stride the stride (optional)
  6277. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6278. * @param instanced whether the buffer is instanced (optional)
  6279. * @param useBytes set to true if the stride in in bytes (optional)
  6280. * @param divisor sets an optional divisor for instances (1 by default)
  6281. */
  6282. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6283. /**
  6284. * Create a new VertexBuffer based on the current buffer
  6285. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6286. * @param offset defines offset in the buffer (0 by default)
  6287. * @param size defines the size in floats of attributes (position is 3 for instance)
  6288. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6289. * @param instanced defines if the vertex buffer contains indexed data
  6290. * @param useBytes defines if the offset and stride are in bytes *
  6291. * @param divisor sets an optional divisor for instances (1 by default)
  6292. * @returns the new vertex buffer
  6293. */
  6294. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6295. /**
  6296. * Gets a boolean indicating if the Buffer is updatable?
  6297. * @returns true if the buffer is updatable
  6298. */
  6299. isUpdatable(): boolean;
  6300. /**
  6301. * Gets current buffer's data
  6302. * @returns a DataArray or null
  6303. */
  6304. getData(): Nullable<DataArray>;
  6305. /**
  6306. * Gets underlying native buffer
  6307. * @returns underlying native buffer
  6308. */
  6309. getBuffer(): Nullable<DataBuffer>;
  6310. /**
  6311. * Gets the stride in float32 units (i.e. byte stride / 4).
  6312. * May not be an integer if the byte stride is not divisible by 4.
  6313. * @returns the stride in float32 units
  6314. * @deprecated Please use byteStride instead.
  6315. */
  6316. getStrideSize(): number;
  6317. /**
  6318. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6319. * @param data defines the data to store
  6320. */
  6321. create(data?: Nullable<DataArray>): void;
  6322. /** @hidden */
  6323. _rebuild(): void;
  6324. /**
  6325. * Update current buffer data
  6326. * @param data defines the data to store
  6327. */
  6328. update(data: DataArray): void;
  6329. /**
  6330. * Updates the data directly.
  6331. * @param data the new data
  6332. * @param offset the new offset
  6333. * @param vertexCount the vertex count (optional)
  6334. * @param useBytes set to true if the offset is in bytes
  6335. */
  6336. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6337. /**
  6338. * Release all resources
  6339. */
  6340. dispose(): void;
  6341. }
  6342. /**
  6343. * Specialized buffer used to store vertex data
  6344. */
  6345. export class VertexBuffer {
  6346. /** @hidden */
  6347. _buffer: Buffer;
  6348. private _kind;
  6349. private _size;
  6350. private _ownsBuffer;
  6351. private _instanced;
  6352. private _instanceDivisor;
  6353. /**
  6354. * The byte type.
  6355. */
  6356. static readonly BYTE: number;
  6357. /**
  6358. * The unsigned byte type.
  6359. */
  6360. static readonly UNSIGNED_BYTE: number;
  6361. /**
  6362. * The short type.
  6363. */
  6364. static readonly SHORT: number;
  6365. /**
  6366. * The unsigned short type.
  6367. */
  6368. static readonly UNSIGNED_SHORT: number;
  6369. /**
  6370. * The integer type.
  6371. */
  6372. static readonly INT: number;
  6373. /**
  6374. * The unsigned integer type.
  6375. */
  6376. static readonly UNSIGNED_INT: number;
  6377. /**
  6378. * The float type.
  6379. */
  6380. static readonly FLOAT: number;
  6381. /**
  6382. * Gets or sets the instance divisor when in instanced mode
  6383. */
  6384. instanceDivisor: number;
  6385. /**
  6386. * Gets the byte stride.
  6387. */
  6388. readonly byteStride: number;
  6389. /**
  6390. * Gets the byte offset.
  6391. */
  6392. readonly byteOffset: number;
  6393. /**
  6394. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6395. */
  6396. readonly normalized: boolean;
  6397. /**
  6398. * Gets the data type of each component in the array.
  6399. */
  6400. readonly type: number;
  6401. /**
  6402. * Constructor
  6403. * @param engine the engine
  6404. * @param data the data to use for this vertex buffer
  6405. * @param kind the vertex buffer kind
  6406. * @param updatable whether the data is updatable
  6407. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6408. * @param stride the stride (optional)
  6409. * @param instanced whether the buffer is instanced (optional)
  6410. * @param offset the offset of the data (optional)
  6411. * @param size the number of components (optional)
  6412. * @param type the type of the component (optional)
  6413. * @param normalized whether the data contains normalized data (optional)
  6414. * @param useBytes set to true if stride and offset are in bytes (optional)
  6415. * @param divisor defines the instance divisor to use (1 by default)
  6416. */
  6417. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6418. /** @hidden */
  6419. _rebuild(): void;
  6420. /**
  6421. * Returns the kind of the VertexBuffer (string)
  6422. * @returns a string
  6423. */
  6424. getKind(): string;
  6425. /**
  6426. * Gets a boolean indicating if the VertexBuffer is updatable?
  6427. * @returns true if the buffer is updatable
  6428. */
  6429. isUpdatable(): boolean;
  6430. /**
  6431. * Gets current buffer's data
  6432. * @returns a DataArray or null
  6433. */
  6434. getData(): Nullable<DataArray>;
  6435. /**
  6436. * Gets underlying native buffer
  6437. * @returns underlying native buffer
  6438. */
  6439. getBuffer(): Nullable<DataBuffer>;
  6440. /**
  6441. * Gets the stride in float32 units (i.e. byte stride / 4).
  6442. * May not be an integer if the byte stride is not divisible by 4.
  6443. * @returns the stride in float32 units
  6444. * @deprecated Please use byteStride instead.
  6445. */
  6446. getStrideSize(): number;
  6447. /**
  6448. * Returns the offset as a multiple of the type byte length.
  6449. * @returns the offset in bytes
  6450. * @deprecated Please use byteOffset instead.
  6451. */
  6452. getOffset(): number;
  6453. /**
  6454. * Returns the number of components per vertex attribute (integer)
  6455. * @returns the size in float
  6456. */
  6457. getSize(): number;
  6458. /**
  6459. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6460. * @returns true if this buffer is instanced
  6461. */
  6462. getIsInstanced(): boolean;
  6463. /**
  6464. * Returns the instancing divisor, zero for non-instanced (integer).
  6465. * @returns a number
  6466. */
  6467. getInstanceDivisor(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: DataArray): void;
  6473. /**
  6474. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6475. * This function will create a new buffer if the current one is not updatable
  6476. * @param data defines the data to store
  6477. */
  6478. update(data: DataArray): void;
  6479. /**
  6480. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6481. * Returns the directly updated WebGLBuffer.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param useBytes set to true if the offset is in bytes
  6485. */
  6486. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6487. /**
  6488. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6489. */
  6490. dispose(): void;
  6491. /**
  6492. * Enumerates each value of this vertex buffer as numbers.
  6493. * @param count the number of values to enumerate
  6494. * @param callback the callback function called for each value
  6495. */
  6496. forEach(count: number, callback: (value: number, index: number) => void): void;
  6497. /**
  6498. * Positions
  6499. */
  6500. static readonly PositionKind: string;
  6501. /**
  6502. * Normals
  6503. */
  6504. static readonly NormalKind: string;
  6505. /**
  6506. * Tangents
  6507. */
  6508. static readonly TangentKind: string;
  6509. /**
  6510. * Texture coordinates
  6511. */
  6512. static readonly UVKind: string;
  6513. /**
  6514. * Texture coordinates 2
  6515. */
  6516. static readonly UV2Kind: string;
  6517. /**
  6518. * Texture coordinates 3
  6519. */
  6520. static readonly UV3Kind: string;
  6521. /**
  6522. * Texture coordinates 4
  6523. */
  6524. static readonly UV4Kind: string;
  6525. /**
  6526. * Texture coordinates 5
  6527. */
  6528. static readonly UV5Kind: string;
  6529. /**
  6530. * Texture coordinates 6
  6531. */
  6532. static readonly UV6Kind: string;
  6533. /**
  6534. * Colors
  6535. */
  6536. static readonly ColorKind: string;
  6537. /**
  6538. * Matrix indices (for bones)
  6539. */
  6540. static readonly MatricesIndicesKind: string;
  6541. /**
  6542. * Matrix weights (for bones)
  6543. */
  6544. static readonly MatricesWeightsKind: string;
  6545. /**
  6546. * Additional matrix indices (for bones)
  6547. */
  6548. static readonly MatricesIndicesExtraKind: string;
  6549. /**
  6550. * Additional matrix weights (for bones)
  6551. */
  6552. static readonly MatricesWeightsExtraKind: string;
  6553. /**
  6554. * Deduces the stride given a kind.
  6555. * @param kind The kind string to deduce
  6556. * @returns The deduced stride
  6557. */
  6558. static DeduceStride(kind: string): number;
  6559. /**
  6560. * Gets the byte length of the given type.
  6561. * @param type the type
  6562. * @returns the number of bytes
  6563. */
  6564. static GetTypeByteLength(type: number): number;
  6565. /**
  6566. * Enumerates each value of the given parameters as numbers.
  6567. * @param data the data to enumerate
  6568. * @param byteOffset the byte offset of the data
  6569. * @param byteStride the byte stride of the data
  6570. * @param componentCount the number of components per element
  6571. * @param componentType the type of the component
  6572. * @param count the number of values to enumerate
  6573. * @param normalized whether the data is normalized
  6574. * @param callback the callback function called for each value
  6575. */
  6576. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6577. private static _GetFloatValue;
  6578. }
  6579. }
  6580. declare module "babylonjs/Collisions/intersectionInfo" {
  6581. import { Nullable } from "babylonjs/types";
  6582. /**
  6583. * @hidden
  6584. */
  6585. export class IntersectionInfo {
  6586. bu: Nullable<number>;
  6587. bv: Nullable<number>;
  6588. distance: number;
  6589. faceId: number;
  6590. subMeshId: number;
  6591. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6592. }
  6593. }
  6594. declare module "babylonjs/Maths/math.plane" {
  6595. import { DeepImmutable } from "babylonjs/types";
  6596. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6597. /**
  6598. * Represens a plane by the equation ax + by + cz + d = 0
  6599. */
  6600. export class Plane {
  6601. private static _TmpMatrix;
  6602. /**
  6603. * Normal of the plane (a,b,c)
  6604. */
  6605. normal: Vector3;
  6606. /**
  6607. * d component of the plane
  6608. */
  6609. d: number;
  6610. /**
  6611. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6612. * @param a a component of the plane
  6613. * @param b b component of the plane
  6614. * @param c c component of the plane
  6615. * @param d d component of the plane
  6616. */
  6617. constructor(a: number, b: number, c: number, d: number);
  6618. /**
  6619. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6620. */
  6621. asArray(): number[];
  6622. /**
  6623. * @returns a new plane copied from the current Plane.
  6624. */
  6625. clone(): Plane;
  6626. /**
  6627. * @returns the string "Plane".
  6628. */
  6629. getClassName(): string;
  6630. /**
  6631. * @returns the Plane hash code.
  6632. */
  6633. getHashCode(): number;
  6634. /**
  6635. * Normalize the current Plane in place.
  6636. * @returns the updated Plane.
  6637. */
  6638. normalize(): Plane;
  6639. /**
  6640. * Applies a transformation the plane and returns the result
  6641. * @param transformation the transformation matrix to be applied to the plane
  6642. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6643. */
  6644. transform(transformation: DeepImmutable<Matrix>): Plane;
  6645. /**
  6646. * Calcualtte the dot product between the point and the plane normal
  6647. * @param point point to calculate the dot product with
  6648. * @returns the dot product (float) of the point coordinates and the plane normal.
  6649. */
  6650. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6651. /**
  6652. * Updates the current Plane from the plane defined by the three given points.
  6653. * @param point1 one of the points used to contruct the plane
  6654. * @param point2 one of the points used to contruct the plane
  6655. * @param point3 one of the points used to contruct the plane
  6656. * @returns the updated Plane.
  6657. */
  6658. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6659. /**
  6660. * Checks if the plane is facing a given direction
  6661. * @param direction the direction to check if the plane is facing
  6662. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6663. * @returns True is the vector "direction" is the same side than the plane normal.
  6664. */
  6665. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6666. /**
  6667. * Calculates the distance to a point
  6668. * @param point point to calculate distance to
  6669. * @returns the signed distance (float) from the given point to the Plane.
  6670. */
  6671. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6672. /**
  6673. * Creates a plane from an array
  6674. * @param array the array to create a plane from
  6675. * @returns a new Plane from the given array.
  6676. */
  6677. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6678. /**
  6679. * Creates a plane from three points
  6680. * @param point1 point used to create the plane
  6681. * @param point2 point used to create the plane
  6682. * @param point3 point used to create the plane
  6683. * @returns a new Plane defined by the three given points.
  6684. */
  6685. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6686. /**
  6687. * Creates a plane from an origin point and a normal
  6688. * @param origin origin of the plane to be constructed
  6689. * @param normal normal of the plane to be constructed
  6690. * @returns a new Plane the normal vector to this plane at the given origin point.
  6691. * Note : the vector "normal" is updated because normalized.
  6692. */
  6693. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Calculates the distance from a plane and a point
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @param point point to calculate distance to
  6699. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6700. */
  6701. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6702. }
  6703. }
  6704. declare module "babylonjs/Culling/boundingSphere" {
  6705. import { DeepImmutable } from "babylonjs/types";
  6706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6707. import { Plane } from "babylonjs/Maths/math.plane";
  6708. /**
  6709. * Class used to store bounding sphere information
  6710. */
  6711. export class BoundingSphere {
  6712. /**
  6713. * Gets the center of the bounding sphere in local space
  6714. */
  6715. readonly center: Vector3;
  6716. /**
  6717. * Radius of the bounding sphere in local space
  6718. */
  6719. radius: number;
  6720. /**
  6721. * Gets the center of the bounding sphere in world space
  6722. */
  6723. readonly centerWorld: Vector3;
  6724. /**
  6725. * Radius of the bounding sphere in world space
  6726. */
  6727. radiusWorld: number;
  6728. /**
  6729. * Gets the minimum vector in local space
  6730. */
  6731. readonly minimum: Vector3;
  6732. /**
  6733. * Gets the maximum vector in local space
  6734. */
  6735. readonly maximum: Vector3;
  6736. private _worldMatrix;
  6737. private static readonly TmpVector3;
  6738. /**
  6739. * Creates a new bounding sphere
  6740. * @param min defines the minimum vector (in local space)
  6741. * @param max defines the maximum vector (in local space)
  6742. * @param worldMatrix defines the new world matrix
  6743. */
  6744. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6745. /**
  6746. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6747. * @param min defines the new minimum vector (in local space)
  6748. * @param max defines the new maximum vector (in local space)
  6749. * @param worldMatrix defines the new world matrix
  6750. */
  6751. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6752. /**
  6753. * Scale the current bounding sphere by applying a scale factor
  6754. * @param factor defines the scale factor to apply
  6755. * @returns the current bounding box
  6756. */
  6757. scale(factor: number): BoundingSphere;
  6758. /**
  6759. * Gets the world matrix of the bounding box
  6760. * @returns a matrix
  6761. */
  6762. getWorldMatrix(): DeepImmutable<Matrix>;
  6763. /** @hidden */
  6764. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6765. /**
  6766. * Tests if the bounding sphere is intersecting the frustum planes
  6767. * @param frustumPlanes defines the frustum planes to test
  6768. * @returns true if there is an intersection
  6769. */
  6770. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6771. /**
  6772. * Tests if the bounding sphere center is in between the frustum planes.
  6773. * Used for optimistic fast inclusion.
  6774. * @param frustumPlanes defines the frustum planes to test
  6775. * @returns true if the sphere center is in between the frustum planes
  6776. */
  6777. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6778. /**
  6779. * Tests if a point is inside the bounding sphere
  6780. * @param point defines the point to test
  6781. * @returns true if the point is inside the bounding sphere
  6782. */
  6783. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6784. /**
  6785. * Checks if two sphere intersct
  6786. * @param sphere0 sphere 0
  6787. * @param sphere1 sphere 1
  6788. * @returns true if the speres intersect
  6789. */
  6790. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6791. }
  6792. }
  6793. declare module "babylonjs/Culling/boundingBox" {
  6794. import { DeepImmutable } from "babylonjs/types";
  6795. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6796. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6797. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6798. import { Plane } from "babylonjs/Maths/math.plane";
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/collider" {
  6944. import { Nullable, IndicesArray } from "babylonjs/types";
  6945. import { Vector3 } from "babylonjs/Maths/math.vector";
  6946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6947. import { Plane } from "babylonjs/Maths/math.plane";
  6948. /** @hidden */
  6949. export class Collider {
  6950. /** Define if a collision was found */
  6951. collisionFound: boolean;
  6952. /**
  6953. * Define last intersection point in local space
  6954. */
  6955. intersectionPoint: Vector3;
  6956. /**
  6957. * Define last collided mesh
  6958. */
  6959. collidedMesh: Nullable<AbstractMesh>;
  6960. private _collisionPoint;
  6961. private _planeIntersectionPoint;
  6962. private _tempVector;
  6963. private _tempVector2;
  6964. private _tempVector3;
  6965. private _tempVector4;
  6966. private _edge;
  6967. private _baseToVertex;
  6968. private _destinationPoint;
  6969. private _slidePlaneNormal;
  6970. private _displacementVector;
  6971. /** @hidden */
  6972. _radius: Vector3;
  6973. /** @hidden */
  6974. _retry: number;
  6975. private _velocity;
  6976. private _basePoint;
  6977. private _epsilon;
  6978. /** @hidden */
  6979. _velocityWorldLength: number;
  6980. /** @hidden */
  6981. _basePointWorld: Vector3;
  6982. private _velocityWorld;
  6983. private _normalizedVelocity;
  6984. /** @hidden */
  6985. _initialVelocity: Vector3;
  6986. /** @hidden */
  6987. _initialPosition: Vector3;
  6988. private _nearestDistance;
  6989. private _collisionMask;
  6990. collisionMask: number;
  6991. /**
  6992. * Gets the plane normal used to compute the sliding response (in local space)
  6993. */
  6994. readonly slidePlaneNormal: Vector3;
  6995. /** @hidden */
  6996. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6997. /** @hidden */
  6998. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6999. /** @hidden */
  7000. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7001. /** @hidden */
  7002. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7003. /** @hidden */
  7004. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _getResponse(pos: Vector3, vel: Vector3): void;
  7007. }
  7008. }
  7009. declare module "babylonjs/Culling/boundingInfo" {
  7010. import { DeepImmutable } from "babylonjs/types";
  7011. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7012. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7013. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7014. import { Plane } from "babylonjs/Maths/math.plane";
  7015. import { Collider } from "babylonjs/Collisions/collider";
  7016. /**
  7017. * Interface for cullable objects
  7018. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7019. */
  7020. export interface ICullable {
  7021. /**
  7022. * Checks if the object or part of the object is in the frustum
  7023. * @param frustumPlanes Camera near/planes
  7024. * @returns true if the object is in frustum otherwise false
  7025. */
  7026. isInFrustum(frustumPlanes: Plane[]): boolean;
  7027. /**
  7028. * Checks if a cullable object (mesh...) is in the camera frustum
  7029. * Unlike isInFrustum this cheks the full bounding box
  7030. * @param frustumPlanes Camera near/planes
  7031. * @returns true if the object is in frustum otherwise false
  7032. */
  7033. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7034. }
  7035. /**
  7036. * Info for a bounding data of a mesh
  7037. */
  7038. export class BoundingInfo implements ICullable {
  7039. /**
  7040. * Bounding box for the mesh
  7041. */
  7042. readonly boundingBox: BoundingBox;
  7043. /**
  7044. * Bounding sphere for the mesh
  7045. */
  7046. readonly boundingSphere: BoundingSphere;
  7047. private _isLocked;
  7048. private static readonly TmpVector3;
  7049. /**
  7050. * Constructs bounding info
  7051. * @param minimum min vector of the bounding box/sphere
  7052. * @param maximum max vector of the bounding box/sphere
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * min vector of the bounding box/sphere
  7065. */
  7066. readonly minimum: Vector3;
  7067. /**
  7068. * max vector of the bounding box/sphere
  7069. */
  7070. readonly maximum: Vector3;
  7071. /**
  7072. * If the info is locked and won't be updated to avoid perf overhead
  7073. */
  7074. isLocked: boolean;
  7075. /**
  7076. * Updates the bounding sphere and box
  7077. * @param world world matrix to be used to update
  7078. */
  7079. update(world: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7082. * @param center New center of the bounding info
  7083. * @param extend New extend of the bounding info
  7084. * @returns the current bounding info
  7085. */
  7086. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7087. /**
  7088. * Scale the current bounding info by applying a scale factor
  7089. * @param factor defines the scale factor to apply
  7090. * @returns the current bounding info
  7091. */
  7092. scale(factor: number): BoundingInfo;
  7093. /**
  7094. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7095. * @param frustumPlanes defines the frustum to test
  7096. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7097. * @returns true if the bounding info is in the frustum planes
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7100. /**
  7101. * Gets the world distance between the min and max points of the bounding box
  7102. */
  7103. readonly diagonalLength: number;
  7104. /**
  7105. * Checks if a cullable object (mesh...) is in the camera frustum
  7106. * Unlike isInFrustum this cheks the full bounding box
  7107. * @param frustumPlanes Camera near/planes
  7108. * @returns true if the object is in frustum otherwise false
  7109. */
  7110. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7111. /** @hidden */
  7112. _checkCollision(collider: Collider): boolean;
  7113. /**
  7114. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7116. * @param point the point to check intersection with
  7117. * @returns if the point intersects
  7118. */
  7119. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7120. /**
  7121. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7122. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7123. * @param boundingInfo the bounding info to check intersection with
  7124. * @param precise if the intersection should be done using OBB
  7125. * @returns if the bounding info intersects
  7126. */
  7127. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7128. }
  7129. }
  7130. declare module "babylonjs/Maths/math.functions" {
  7131. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7132. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7161. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7162. /** @hidden */
  7163. export class WebGLDataBuffer extends DataBuffer {
  7164. private _buffer;
  7165. constructor(resource: WebGLBuffer);
  7166. readonly underlyingResource: any;
  7167. }
  7168. }
  7169. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7170. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7171. import { Nullable } from "babylonjs/types";
  7172. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7173. /** @hidden */
  7174. export class WebGLPipelineContext implements IPipelineContext {
  7175. engine: ThinEngine;
  7176. program: Nullable<WebGLProgram>;
  7177. context?: WebGLRenderingContext;
  7178. vertexShader?: WebGLShader;
  7179. fragmentShader?: WebGLShader;
  7180. isParallelCompiled: boolean;
  7181. onCompiled?: () => void;
  7182. transformFeedback?: WebGLTransformFeedback | null;
  7183. readonly isAsync: boolean;
  7184. readonly isReady: boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. }
  7187. }
  7188. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7189. import { FloatArray, Nullable } from "babylonjs/types";
  7190. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7192. module "babylonjs/Engines/thinEngine" {
  7193. interface ThinEngine {
  7194. /**
  7195. * Create an uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Create a dynamic uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param elements defines the content of the uniform buffer
  7205. * @returns the webGL uniform buffer
  7206. */
  7207. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7208. /**
  7209. * Update an existing uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param uniformBuffer defines the target uniform buffer
  7212. * @param elements defines the content to update
  7213. * @param offset defines the offset in the uniform buffer where update should start
  7214. * @param count defines the size of the data to update
  7215. */
  7216. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7217. /**
  7218. * Bind an uniform buffer to the current webGL context
  7219. * @param buffer defines the buffer to bind
  7220. */
  7221. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7222. /**
  7223. * Bind a buffer to the current webGL context at a given location
  7224. * @param buffer defines the buffer to bind
  7225. * @param location defines the index where to bind the buffer
  7226. */
  7227. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7228. /**
  7229. * Bind a specific block at a given index in a specific shader program
  7230. * @param pipelineContext defines the pipeline context to use
  7231. * @param blockName defines the block name
  7232. * @param index defines the index where to bind the block
  7233. */
  7234. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7235. }
  7236. }
  7237. }
  7238. declare module "babylonjs/Materials/uniformBuffer" {
  7239. import { Nullable, FloatArray } from "babylonjs/types";
  7240. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7241. import { Engine } from "babylonjs/Engines/engine";
  7242. import { Effect } from "babylonjs/Materials/effect";
  7243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7244. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7245. import { Color3 } from "babylonjs/Maths/math.color";
  7246. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7247. /**
  7248. * Uniform buffer objects.
  7249. *
  7250. * Handles blocks of uniform on the GPU.
  7251. *
  7252. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7253. *
  7254. * For more information, please refer to :
  7255. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7256. */
  7257. export class UniformBuffer {
  7258. private _engine;
  7259. private _buffer;
  7260. private _data;
  7261. private _bufferData;
  7262. private _dynamic?;
  7263. private _uniformLocations;
  7264. private _uniformSizes;
  7265. private _uniformLocationPointer;
  7266. private _needSync;
  7267. private _noUBO;
  7268. private _currentEffect;
  7269. /** @hidden */
  7270. _alreadyBound: boolean;
  7271. private static _MAX_UNIFORM_SIZE;
  7272. private static _tempBuffer;
  7273. /**
  7274. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7279. /**
  7280. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7285. /**
  7286. * Lambda to Update a single float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat: (name: string, x: number) => void;
  7291. /**
  7292. * Lambda to Update a vec2 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a vec3 of float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7303. /**
  7304. * Lambda to Update a vec4 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateMatrix: (name: string, mat: Matrix) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateVector3: (name: string, vector: Vector3) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateVector4: (name: string, vector: Vector4) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7339. /**
  7340. * Instantiates a new Uniform buffer objects.
  7341. *
  7342. * Handles blocks of uniform on the GPU.
  7343. *
  7344. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7345. *
  7346. * For more information, please refer to :
  7347. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7348. * @param engine Define the engine the buffer is associated with
  7349. * @param data Define the data contained in the buffer
  7350. * @param dynamic Define if the buffer is updatable
  7351. */
  7352. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7353. /**
  7354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7355. * or just falling back on setUniformXXX calls.
  7356. */
  7357. readonly useUbo: boolean;
  7358. /**
  7359. * Indicates if the WebGL underlying uniform buffer is in sync
  7360. * with the javascript cache data.
  7361. */
  7362. readonly isSync: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7365. * Also, a dynamic UniformBuffer will disable cache verification and always
  7366. * update the underlying WebGL uniform buffer to the GPU.
  7367. * @returns if Dynamic, otherwise false
  7368. */
  7369. isDynamic(): boolean;
  7370. /**
  7371. * The data cache on JS side.
  7372. * @returns the underlying data as a float array
  7373. */
  7374. getData(): Float32Array;
  7375. /**
  7376. * The underlying WebGL Uniform buffer.
  7377. * @returns the webgl buffer
  7378. */
  7379. getBuffer(): Nullable<DataBuffer>;
  7380. /**
  7381. * std140 layout specifies how to align data within an UBO structure.
  7382. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7383. * for specs.
  7384. */
  7385. private _fillAlignment;
  7386. /**
  7387. * Adds an uniform in the buffer.
  7388. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7389. * for the layout to be correct !
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param size Data size, or data directly.
  7392. */
  7393. addUniform(name: string, size: number | number[]): void;
  7394. /**
  7395. * Adds a Matrix 4x4 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param mat A 4x4 matrix.
  7398. */
  7399. addMatrix(name: string, mat: Matrix): void;
  7400. /**
  7401. * Adds a vec2 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param x Define the x component value of the vec2
  7404. * @param y Define the y component value of the vec2
  7405. */
  7406. addFloat2(name: string, x: number, y: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param x Define the x component value of the vec3
  7411. * @param y Define the y component value of the vec3
  7412. * @param z Define the z component value of the vec3
  7413. */
  7414. addFloat3(name: string, x: number, y: number, z: number): void;
  7415. /**
  7416. * Adds a vec3 to the uniform buffer.
  7417. * @param name Name of the uniform, as used in the uniform block in the shader.
  7418. * @param color Define the vec3 from a Color
  7419. */
  7420. addColor3(name: string, color: Color3): void;
  7421. /**
  7422. * Adds a vec4 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param color Define the rgb components from a Color
  7425. * @param alpha Define the a component of the vec4
  7426. */
  7427. addColor4(name: string, color: Color3, alpha: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param vector Define the vec3 components from a Vector
  7432. */
  7433. addVector3(name: string, vector: Vector3): void;
  7434. /**
  7435. * Adds a Matrix 3x3 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. */
  7438. addMatrix3x3(name: string): void;
  7439. /**
  7440. * Adds a Matrix 2x2 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix2x2(name: string): void;
  7444. /**
  7445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7446. */
  7447. create(): void;
  7448. /** @hidden */
  7449. _rebuild(): void;
  7450. /**
  7451. * Updates the WebGL Uniform Buffer on the GPU.
  7452. * If the `dynamic` flag is set to true, no cache comparison is done.
  7453. * Otherwise, the buffer will be updated only if the cache differs.
  7454. */
  7455. update(): void;
  7456. /**
  7457. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7458. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7459. * @param data Define the flattened data
  7460. * @param size Define the size of the data.
  7461. */
  7462. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7463. private _valueCache;
  7464. private _cacheMatrix;
  7465. private _updateMatrix3x3ForUniform;
  7466. private _updateMatrix3x3ForEffect;
  7467. private _updateMatrix2x2ForEffect;
  7468. private _updateMatrix2x2ForUniform;
  7469. private _updateFloatForEffect;
  7470. private _updateFloatForUniform;
  7471. private _updateFloat2ForEffect;
  7472. private _updateFloat2ForUniform;
  7473. private _updateFloat3ForEffect;
  7474. private _updateFloat3ForUniform;
  7475. private _updateFloat4ForEffect;
  7476. private _updateFloat4ForUniform;
  7477. private _updateMatrixForEffect;
  7478. private _updateMatrixForUniform;
  7479. private _updateVector3ForEffect;
  7480. private _updateVector3ForUniform;
  7481. private _updateVector4ForEffect;
  7482. private _updateVector4ForUniform;
  7483. private _updateColor3ForEffect;
  7484. private _updateColor3ForUniform;
  7485. private _updateColor4ForEffect;
  7486. private _updateColor4ForUniform;
  7487. /**
  7488. * Sets a sampler uniform on the effect.
  7489. * @param name Define the name of the sampler.
  7490. * @param texture Define the texture to set in the sampler
  7491. */
  7492. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7493. /**
  7494. * Directly updates the value of the uniform in the cache AND on the GPU.
  7495. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7496. * @param data Define the flattened data
  7497. */
  7498. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7499. /**
  7500. * Binds this uniform buffer to an effect.
  7501. * @param effect Define the effect to bind the buffer to
  7502. * @param name Name of the uniform block in the shader.
  7503. */
  7504. bindToEffect(effect: Effect, name: string): void;
  7505. /**
  7506. * Disposes the uniform buffer.
  7507. */
  7508. dispose(): void;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/iInspectable" {
  7512. /**
  7513. * Enum that determines the text-wrapping mode to use.
  7514. */
  7515. export enum InspectableType {
  7516. /**
  7517. * Checkbox for booleans
  7518. */
  7519. Checkbox = 0,
  7520. /**
  7521. * Sliders for numbers
  7522. */
  7523. Slider = 1,
  7524. /**
  7525. * Vector3
  7526. */
  7527. Vector3 = 2,
  7528. /**
  7529. * Quaternions
  7530. */
  7531. Quaternion = 3,
  7532. /**
  7533. * Color3
  7534. */
  7535. Color3 = 4,
  7536. /**
  7537. * String
  7538. */
  7539. String = 5
  7540. }
  7541. /**
  7542. * Interface used to define custom inspectable properties.
  7543. * This interface is used by the inspector to display custom property grids
  7544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7545. */
  7546. export interface IInspectable {
  7547. /**
  7548. * Gets the label to display
  7549. */
  7550. label: string;
  7551. /**
  7552. * Gets the name of the property to edit
  7553. */
  7554. propertyName: string;
  7555. /**
  7556. * Gets the type of the editor to use
  7557. */
  7558. type: InspectableType;
  7559. /**
  7560. * Gets the minimum value of the property when using in "slider" mode
  7561. */
  7562. min?: number;
  7563. /**
  7564. * Gets the maximum value of the property when using in "slider" mode
  7565. */
  7566. max?: number;
  7567. /**
  7568. * Gets the setp to use when using in "slider" mode
  7569. */
  7570. step?: number;
  7571. }
  7572. }
  7573. declare module "babylonjs/Misc/timingTools" {
  7574. /**
  7575. * Class used to provide helper for timing
  7576. */
  7577. export class TimingTools {
  7578. /**
  7579. * Polyfill for setImmediate
  7580. * @param action defines the action to execute after the current execution block
  7581. */
  7582. static SetImmediate(action: () => void): void;
  7583. }
  7584. }
  7585. declare module "babylonjs/Misc/instantiationTools" {
  7586. /**
  7587. * Class used to enable instatition of objects by class name
  7588. */
  7589. export class InstantiationTools {
  7590. /**
  7591. * Use this object to register external classes like custom textures or material
  7592. * to allow the laoders to instantiate them
  7593. */
  7594. static RegisteredExternalClasses: {
  7595. [key: string]: Object;
  7596. };
  7597. /**
  7598. * Tries to instantiate a new object from a given class name
  7599. * @param className defines the class name to instantiate
  7600. * @returns the new object or null if the system was not able to do the instantiation
  7601. */
  7602. static Instantiate(className: string): any;
  7603. }
  7604. }
  7605. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7606. /**
  7607. * Define options used to create a depth texture
  7608. */
  7609. export class DepthTextureCreationOptions {
  7610. /** Specifies whether or not a stencil should be allocated in the texture */
  7611. generateStencil?: boolean;
  7612. /** Specifies whether or not bilinear filtering is enable on the texture */
  7613. bilinearFiltering?: boolean;
  7614. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7615. comparisonFunction?: number;
  7616. /** Specifies if the created texture is a cube texture */
  7617. isCube?: boolean;
  7618. }
  7619. }
  7620. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7622. import { Nullable } from "babylonjs/types";
  7623. import { Scene } from "babylonjs/scene";
  7624. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7626. module "babylonjs/Engines/thinEngine" {
  7627. interface ThinEngine {
  7628. /**
  7629. * Creates a depth stencil cube texture.
  7630. * This is only available in WebGL 2.
  7631. * @param size The size of face edge in the cube texture.
  7632. * @param options The options defining the cube texture.
  7633. * @returns The cube texture
  7634. */
  7635. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7649. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7650. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7654. /**
  7655. * Creates a cube texture
  7656. * @param rootUrl defines the url where the files to load is located
  7657. * @param scene defines the current scene
  7658. * @param files defines the list of files to load (1 per face)
  7659. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7660. * @param onLoad defines an optional callback raised when the texture is loaded
  7661. * @param onError defines an optional callback raised if there is an issue to load the texture
  7662. * @param format defines the format of the data
  7663. * @param forcedExtension defines the extension to use to pick the right loader
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7667. /**
  7668. * Creates a cube texture
  7669. * @param rootUrl defines the url where the files to load is located
  7670. * @param scene defines the current scene
  7671. * @param files defines the list of files to load (1 per face)
  7672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7673. * @param onLoad defines an optional callback raised when the texture is loaded
  7674. * @param onError defines an optional callback raised if there is an issue to load the texture
  7675. * @param format defines the format of the data
  7676. * @param forcedExtension defines the extension to use to pick the right loader
  7677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @returns the cube texture as an InternalTexture
  7681. */
  7682. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7683. /** @hidden */
  7684. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7687. /** @hidden */
  7688. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /** @hidden */
  7690. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7691. /**
  7692. * @hidden
  7693. */
  7694. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7695. }
  7696. }
  7697. }
  7698. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7699. import { Nullable } from "babylonjs/types";
  7700. import { Scene } from "babylonjs/scene";
  7701. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7703. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * The url of the texture
  7711. */
  7712. url: string;
  7713. /**
  7714. * Gets or sets the center of the bounding box associated with the cube texture.
  7715. * It must define where the camera used to render the texture was set
  7716. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7717. */
  7718. boundingBoxPosition: Vector3;
  7719. private _boundingBoxSize;
  7720. /**
  7721. * Gets or sets the size of the bounding box associated with the cube texture
  7722. * When defined, the cubemap will switch to local mode
  7723. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7724. * @example https://www.babylonjs-playground.com/#RNASML
  7725. */
  7726. /**
  7727. * Returns the bounding box size
  7728. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7729. */
  7730. boundingBoxSize: Vector3;
  7731. protected _rotationY: number;
  7732. /**
  7733. * Sets texture matrix rotation angle around Y axis in radians.
  7734. */
  7735. /**
  7736. * Gets texture matrix rotation angle around Y axis radians.
  7737. */
  7738. rotationY: number;
  7739. /**
  7740. * Are mip maps generated for this texture or not.
  7741. */
  7742. readonly noMipmap: boolean;
  7743. private _noMipmap;
  7744. private _files;
  7745. protected _forcedExtension: Nullable<string>;
  7746. private _extensions;
  7747. private _textureMatrix;
  7748. private _format;
  7749. private _createPolynomials;
  7750. /** @hidden */
  7751. _prefiltered: boolean;
  7752. /**
  7753. * Creates a cube texture from an array of image urls
  7754. * @param files defines an array of image urls
  7755. * @param scene defines the hosting scene
  7756. * @param noMipmap specifies if mip maps are not used
  7757. * @returns a cube texture
  7758. */
  7759. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7760. /**
  7761. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7762. * @param url defines the url of the prefiltered texture
  7763. * @param scene defines the scene the texture is attached to
  7764. * @param forcedExtension defines the extension of the file if different from the url
  7765. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7766. * @return the prefiltered texture
  7767. */
  7768. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7769. /**
  7770. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7771. * as prefiltered data.
  7772. * @param rootUrl defines the url of the texture or the root name of the six images
  7773. * @param scene defines the scene the texture is attached to
  7774. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7775. * @param noMipmap defines if mipmaps should be created or not
  7776. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7777. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7778. * @param onError defines a callback triggered in case of error during load
  7779. * @param format defines the internal format to use for the texture once loaded
  7780. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7781. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7782. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7783. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7784. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7785. * @return the cube texture
  7786. */
  7787. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7788. /**
  7789. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7790. */
  7791. readonly isPrefiltered: boolean;
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module "babylonjs/Materials/materialDefines" {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. readonly isDirty: boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module "babylonjs/Materials/colorCurves" {
  7935. import { Effect } from "babylonjs/Materials/effect";
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7958. */
  7959. /**
  7960. * Sets the global Hue value.
  7961. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7962. */
  7963. globalHue: number;
  7964. /**
  7965. * Gets the global Density value.
  7966. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. /**
  7970. * Sets the global Density value.
  7971. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. globalDensity: number;
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7978. */
  7979. /**
  7980. * Sets the global Saturation value.
  7981. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7982. */
  7983. globalSaturation: number;
  7984. /**
  7985. * Gets the global Exposure value.
  7986. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7987. */
  7988. /**
  7989. * Sets the global Exposure value.
  7990. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7991. */
  7992. globalExposure: number;
  7993. private _highlightsHue;
  7994. private _highlightsDensity;
  7995. private _highlightsSaturation;
  7996. private _highlightsExposure;
  7997. /**
  7998. * Gets the highlights Hue value.
  7999. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8000. */
  8001. /**
  8002. * Sets the highlights Hue value.
  8003. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8004. */
  8005. highlightsHue: number;
  8006. /**
  8007. * Gets the highlights Density value.
  8008. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8009. * Values less than zero provide a filter of opposite hue.
  8010. */
  8011. /**
  8012. * Sets the highlights Density value.
  8013. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. highlightsDensity: number;
  8017. /**
  8018. * Gets the highlights Saturation value.
  8019. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8020. */
  8021. /**
  8022. * Sets the highlights Saturation value.
  8023. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8024. */
  8025. highlightsSaturation: number;
  8026. /**
  8027. * Gets the highlights Exposure value.
  8028. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8029. */
  8030. /**
  8031. * Sets the highlights Exposure value.
  8032. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8033. */
  8034. highlightsExposure: number;
  8035. private _midtonesHue;
  8036. private _midtonesDensity;
  8037. private _midtonesSaturation;
  8038. private _midtonesExposure;
  8039. /**
  8040. * Gets the midtones Hue value.
  8041. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8042. */
  8043. /**
  8044. * Sets the midtones Hue value.
  8045. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8046. */
  8047. midtonesHue: number;
  8048. /**
  8049. * Gets the midtones Density value.
  8050. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8051. * Values less than zero provide a filter of opposite hue.
  8052. */
  8053. /**
  8054. * Sets the midtones Density value.
  8055. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. midtonesDensity: number;
  8059. /**
  8060. * Gets the midtones Saturation value.
  8061. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8062. */
  8063. /**
  8064. * Sets the midtones Saturation value.
  8065. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8066. */
  8067. midtonesSaturation: number;
  8068. /**
  8069. * Gets the midtones Exposure value.
  8070. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8071. */
  8072. /**
  8073. * Sets the midtones Exposure value.
  8074. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8075. */
  8076. midtonesExposure: number;
  8077. private _shadowsHue;
  8078. private _shadowsDensity;
  8079. private _shadowsSaturation;
  8080. private _shadowsExposure;
  8081. /**
  8082. * Gets the shadows Hue value.
  8083. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8084. */
  8085. /**
  8086. * Sets the shadows Hue value.
  8087. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8088. */
  8089. shadowsHue: number;
  8090. /**
  8091. * Gets the shadows Density value.
  8092. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8093. * Values less than zero provide a filter of opposite hue.
  8094. */
  8095. /**
  8096. * Sets the shadows Density value.
  8097. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. shadowsDensity: number;
  8101. /**
  8102. * Gets the shadows Saturation value.
  8103. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8104. */
  8105. /**
  8106. * Sets the shadows Saturation value.
  8107. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8108. */
  8109. shadowsSaturation: number;
  8110. /**
  8111. * Gets the shadows Exposure value.
  8112. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8113. */
  8114. /**
  8115. * Sets the shadows Exposure value.
  8116. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8117. */
  8118. shadowsExposure: number;
  8119. /**
  8120. * Returns the class name
  8121. * @returns The class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Binds the color curves to the shader.
  8126. * @param colorCurves The color curve to bind
  8127. * @param effect The effect to bind to
  8128. * @param positiveUniform The positive uniform shader parameter
  8129. * @param neutralUniform The neutral uniform shader parameter
  8130. * @param negativeUniform The negative uniform shader parameter
  8131. */
  8132. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8133. /**
  8134. * Prepare the list of uniforms associated with the ColorCurves effects.
  8135. * @param uniformsList The list of uniforms used in the effect
  8136. */
  8137. static PrepareUniforms(uniformsList: string[]): void;
  8138. /**
  8139. * Returns color grading data based on a hue, density, saturation and exposure value.
  8140. * @param filterHue The hue of the color filter.
  8141. * @param filterDensity The density of the color filter.
  8142. * @param saturation The saturation.
  8143. * @param exposure The exposure.
  8144. * @param result The result data container.
  8145. */
  8146. private getColorGradingDataToRef;
  8147. /**
  8148. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8149. * @param value The input slider value in range [-100,100].
  8150. * @returns Adjusted value.
  8151. */
  8152. private static applyColorGradingSliderNonlinear;
  8153. /**
  8154. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8155. * @param hue The hue (H) input.
  8156. * @param saturation The saturation (S) input.
  8157. * @param brightness The brightness (B) input.
  8158. * @result An RGBA color represented as Vector4.
  8159. */
  8160. private static fromHSBToRef;
  8161. /**
  8162. * Returns a value clamped between min and max
  8163. * @param value The value to clamp
  8164. * @param min The minimum of value
  8165. * @param max The maximum of value
  8166. * @returns The clamped value.
  8167. */
  8168. private static clamp;
  8169. /**
  8170. * Clones the current color curve instance.
  8171. * @return The cloned curves
  8172. */
  8173. clone(): ColorCurves;
  8174. /**
  8175. * Serializes the current color curve instance to a json representation.
  8176. * @return a JSON representation
  8177. */
  8178. serialize(): any;
  8179. /**
  8180. * Parses the color curve from a json representation.
  8181. * @param source the JSON source to parse
  8182. * @return The parsed curves
  8183. */
  8184. static Parse(source: any): ColorCurves;
  8185. }
  8186. }
  8187. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8188. import { Observable } from "babylonjs/Misc/observable";
  8189. import { Nullable } from "babylonjs/types";
  8190. import { Color4 } from "babylonjs/Maths/math.color";
  8191. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8192. import { Effect } from "babylonjs/Materials/effect";
  8193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8194. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8195. /**
  8196. * Interface to follow in your material defines to integrate easily the
  8197. * Image proccessing functions.
  8198. * @hidden
  8199. */
  8200. export interface IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. EXPOSURE: boolean;
  8209. COLORCURVES: boolean;
  8210. COLORGRADING: boolean;
  8211. COLORGRADING3D: boolean;
  8212. SAMPLER3DGREENDEPTH: boolean;
  8213. SAMPLER3DBGRMAP: boolean;
  8214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8215. }
  8216. /**
  8217. * @hidden
  8218. */
  8219. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8220. IMAGEPROCESSING: boolean;
  8221. VIGNETTE: boolean;
  8222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8223. VIGNETTEBLENDMODEOPAQUE: boolean;
  8224. TONEMAPPING: boolean;
  8225. TONEMAPPING_ACES: boolean;
  8226. CONTRAST: boolean;
  8227. COLORCURVES: boolean;
  8228. COLORGRADING: boolean;
  8229. COLORGRADING3D: boolean;
  8230. SAMPLER3DGREENDEPTH: boolean;
  8231. SAMPLER3DBGRMAP: boolean;
  8232. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8233. EXPOSURE: boolean;
  8234. constructor();
  8235. }
  8236. /**
  8237. * This groups together the common properties used for image processing either in direct forward pass
  8238. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8239. * or not.
  8240. */
  8241. export class ImageProcessingConfiguration {
  8242. /**
  8243. * Default tone mapping applied in BabylonJS.
  8244. */
  8245. static readonly TONEMAPPING_STANDARD: number;
  8246. /**
  8247. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8248. * to other engines rendering to increase portability.
  8249. */
  8250. static readonly TONEMAPPING_ACES: number;
  8251. /**
  8252. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8253. */
  8254. colorCurves: Nullable<ColorCurves>;
  8255. private _colorCurvesEnabled;
  8256. /**
  8257. * Gets wether the color curves effect is enabled.
  8258. */
  8259. /**
  8260. * Sets wether the color curves effect is enabled.
  8261. */
  8262. colorCurvesEnabled: boolean;
  8263. private _colorGradingTexture;
  8264. /**
  8265. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8266. */
  8267. /**
  8268. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8269. */
  8270. colorGradingTexture: Nullable<BaseTexture>;
  8271. private _colorGradingEnabled;
  8272. /**
  8273. * Gets wether the color grading effect is enabled.
  8274. */
  8275. /**
  8276. * Sets wether the color grading effect is enabled.
  8277. */
  8278. colorGradingEnabled: boolean;
  8279. private _colorGradingWithGreenDepth;
  8280. /**
  8281. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8282. */
  8283. /**
  8284. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8285. */
  8286. colorGradingWithGreenDepth: boolean;
  8287. private _colorGradingBGR;
  8288. /**
  8289. * Gets wether the color grading texture contains BGR values.
  8290. */
  8291. /**
  8292. * Sets wether the color grading texture contains BGR values.
  8293. */
  8294. colorGradingBGR: boolean;
  8295. /** @hidden */
  8296. _exposure: number;
  8297. /**
  8298. * Gets the Exposure used in the effect.
  8299. */
  8300. /**
  8301. * Sets the Exposure used in the effect.
  8302. */
  8303. exposure: number;
  8304. private _toneMappingEnabled;
  8305. /**
  8306. * Gets wether the tone mapping effect is enabled.
  8307. */
  8308. /**
  8309. * Sets wether the tone mapping effect is enabled.
  8310. */
  8311. toneMappingEnabled: boolean;
  8312. private _toneMappingType;
  8313. /**
  8314. * Gets the type of tone mapping effect.
  8315. */
  8316. /**
  8317. * Sets the type of tone mapping effect used in BabylonJS.
  8318. */
  8319. toneMappingType: number;
  8320. protected _contrast: number;
  8321. /**
  8322. * Gets the contrast used in the effect.
  8323. */
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. contrast: number;
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. /**
  8358. * Sets the vignette blend mode allowing different kind of effect.
  8359. */
  8360. vignetteBlendMode: number;
  8361. private _vignetteEnabled;
  8362. /**
  8363. * Gets wether the vignette effect is enabled.
  8364. */
  8365. /**
  8366. * Sets wether the vignette effect is enabled.
  8367. */
  8368. vignetteEnabled: boolean;
  8369. private _applyByPostProcess;
  8370. /**
  8371. * Gets wether the image processing is applied through a post process or not.
  8372. */
  8373. /**
  8374. * Sets wether the image processing is applied through a post process or not.
  8375. */
  8376. applyByPostProcess: boolean;
  8377. private _isEnabled;
  8378. /**
  8379. * Gets wether the image processing is enabled or not.
  8380. */
  8381. /**
  8382. * Sets wether the image processing is enabled or not.
  8383. */
  8384. isEnabled: boolean;
  8385. /**
  8386. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8387. */
  8388. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8389. /**
  8390. * Method called each time the image processing information changes requires to recompile the effect.
  8391. */
  8392. protected _updateParameters(): void;
  8393. /**
  8394. * Gets the current class name.
  8395. * @return "ImageProcessingConfiguration"
  8396. */
  8397. getClassName(): string;
  8398. /**
  8399. * Prepare the list of uniforms associated with the Image Processing effects.
  8400. * @param uniforms The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of samplers associated with the Image Processing effects.
  8406. * @param samplersList The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of defines associated to the shader.
  8412. * @param defines the list of defines to complete
  8413. * @param forPostProcess Define if we are currently in post process mode or not
  8414. */
  8415. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8416. /**
  8417. * Returns true if all the image processing information are ready.
  8418. * @returns True if ready, otherwise, false
  8419. */
  8420. isReady(): boolean;
  8421. /**
  8422. * Binds the image processing to the shader.
  8423. * @param effect The effect to bind to
  8424. * @param overrideAspectRatio Override the aspect ratio of the effect
  8425. */
  8426. bind(effect: Effect, overrideAspectRatio?: number): void;
  8427. /**
  8428. * Clones the current image processing instance.
  8429. * @return The cloned image processing
  8430. */
  8431. clone(): ImageProcessingConfiguration;
  8432. /**
  8433. * Serializes the current image processing instance to a json representation.
  8434. * @return a JSON representation
  8435. */
  8436. serialize(): any;
  8437. /**
  8438. * Parses the image processing from a json representation.
  8439. * @param source the JSON source to parse
  8440. * @return The parsed image processing
  8441. */
  8442. static Parse(source: any): ImageProcessingConfiguration;
  8443. private static _VIGNETTEMODE_MULTIPLY;
  8444. private static _VIGNETTEMODE_OPAQUE;
  8445. /**
  8446. * Used to apply the vignette as a mix with the pixel color.
  8447. */
  8448. static readonly VIGNETTEMODE_MULTIPLY: number;
  8449. /**
  8450. * Used to apply the vignette as a replacement of the pixel color.
  8451. */
  8452. static readonly VIGNETTEMODE_OPAQUE: number;
  8453. }
  8454. }
  8455. declare module "babylonjs/Shaders/postprocess.vertex" {
  8456. /** @hidden */
  8457. export var postprocessVertexShader: {
  8458. name: string;
  8459. shader: string;
  8460. };
  8461. }
  8462. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8464. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8465. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8466. module "babylonjs/Engines/thinEngine" {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8478. /**
  8479. * Creates a depth stencil texture.
  8480. * This is only available in WebGL 2 or with the depth texture extension available.
  8481. * @param size The size of face edge in the texture.
  8482. * @param options The options defining the texture.
  8483. * @returns The texture
  8484. */
  8485. createDepthStencilTexture(size: number | {
  8486. width: number;
  8487. height: number;
  8488. }, options: DepthTextureCreationOptions): InternalTexture;
  8489. /** @hidden */
  8490. _createDepthStencilTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. }, options: DepthTextureCreationOptions): InternalTexture;
  8494. }
  8495. }
  8496. }
  8497. declare module "babylonjs/Maths/math.axis" {
  8498. import { Vector3 } from "babylonjs/Maths/math.vector";
  8499. /** Defines supported spaces */
  8500. export enum Space {
  8501. /** Local (object) space */
  8502. LOCAL = 0,
  8503. /** World space */
  8504. WORLD = 1,
  8505. /** Bone space */
  8506. BONE = 2
  8507. }
  8508. /** Defines the 3 main axes */
  8509. export class Axis {
  8510. /** X axis */
  8511. static X: Vector3;
  8512. /** Y axis */
  8513. static Y: Vector3;
  8514. /** Z axis */
  8515. static Z: Vector3;
  8516. }
  8517. }
  8518. declare module "babylonjs/Cameras/targetCamera" {
  8519. import { Nullable } from "babylonjs/types";
  8520. import { Camera } from "babylonjs/Cameras/camera";
  8521. import { Scene } from "babylonjs/scene";
  8522. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8523. /**
  8524. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8525. * This is the base of the follow, arc rotate cameras and Free camera
  8526. * @see http://doc.babylonjs.com/features/cameras
  8527. */
  8528. export class TargetCamera extends Camera {
  8529. private static _RigCamTransformMatrix;
  8530. private static _TargetTransformMatrix;
  8531. private static _TargetFocalPoint;
  8532. /**
  8533. * Define the current direction the camera is moving to
  8534. */
  8535. cameraDirection: Vector3;
  8536. /**
  8537. * Define the current rotation the camera is rotating to
  8538. */
  8539. cameraRotation: Vector2;
  8540. /**
  8541. * When set, the up vector of the camera will be updated by the rotation of the camera
  8542. */
  8543. updateUpVectorFromRotation: boolean;
  8544. private _tmpQuaternion;
  8545. /**
  8546. * Define the current rotation of the camera
  8547. */
  8548. rotation: Vector3;
  8549. /**
  8550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8551. */
  8552. rotationQuaternion: Quaternion;
  8553. /**
  8554. * Define the current speed of the camera
  8555. */
  8556. speed: number;
  8557. /**
  8558. * Add constraint to the camera to prevent it to move freely in all directions and
  8559. * around all axis.
  8560. */
  8561. noRotationConstraint: boolean;
  8562. /**
  8563. * Define the current target of the camera as an object or a position.
  8564. */
  8565. lockedTarget: any;
  8566. /** @hidden */
  8567. _currentTarget: Vector3;
  8568. /** @hidden */
  8569. _initialFocalDistance: number;
  8570. /** @hidden */
  8571. _viewMatrix: Matrix;
  8572. /** @hidden */
  8573. _camMatrix: Matrix;
  8574. /** @hidden */
  8575. _cameraTransformMatrix: Matrix;
  8576. /** @hidden */
  8577. _cameraRotationMatrix: Matrix;
  8578. /** @hidden */
  8579. _referencePoint: Vector3;
  8580. /** @hidden */
  8581. _transformedReferencePoint: Vector3;
  8582. protected _globalCurrentTarget: Vector3;
  8583. protected _globalCurrentUpVector: Vector3;
  8584. /** @hidden */
  8585. _reset: () => void;
  8586. private _defaultUp;
  8587. /**
  8588. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8589. * This is the base of the follow, arc rotate cameras and Free camera
  8590. * @see http://doc.babylonjs.com/features/cameras
  8591. * @param name Defines the name of the camera in the scene
  8592. * @param position Defines the start position of the camera in the scene
  8593. * @param scene Defines the scene the camera belongs to
  8594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8595. */
  8596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8597. /**
  8598. * Gets the position in front of the camera at a given distance.
  8599. * @param distance The distance from the camera we want the position to be
  8600. * @returns the position
  8601. */
  8602. getFrontPosition(distance: number): Vector3;
  8603. /** @hidden */
  8604. _getLockedTargetPosition(): Nullable<Vector3>;
  8605. private _storedPosition;
  8606. private _storedRotation;
  8607. private _storedRotationQuaternion;
  8608. /**
  8609. * Store current camera state of the camera (fov, position, rotation, etc..)
  8610. * @returns the camera
  8611. */
  8612. storeState(): Camera;
  8613. /**
  8614. * Restored camera state. You must call storeState() first
  8615. * @returns whether it was successful or not
  8616. * @hidden
  8617. */
  8618. _restoreStateValues(): boolean;
  8619. /** @hidden */
  8620. _initCache(): void;
  8621. /** @hidden */
  8622. _updateCache(ignoreParentClass?: boolean): void;
  8623. /** @hidden */
  8624. _isSynchronizedViewMatrix(): boolean;
  8625. /** @hidden */
  8626. _computeLocalCameraSpeed(): number;
  8627. /**
  8628. * Defines the target the camera should look at.
  8629. * @param target Defines the new target as a Vector or a mesh
  8630. */
  8631. setTarget(target: Vector3): void;
  8632. /**
  8633. * Return the current target position of the camera. This value is expressed in local space.
  8634. * @returns the target position
  8635. */
  8636. getTarget(): Vector3;
  8637. /** @hidden */
  8638. _decideIfNeedsToMove(): boolean;
  8639. /** @hidden */
  8640. _updatePosition(): void;
  8641. /** @hidden */
  8642. _checkInputs(): void;
  8643. protected _updateCameraRotationMatrix(): void;
  8644. /**
  8645. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8646. * @returns the current camera
  8647. */
  8648. private _rotateUpVectorWithCameraRotationMatrix;
  8649. private _cachedRotationZ;
  8650. private _cachedQuaternionRotationZ;
  8651. /** @hidden */
  8652. _getViewMatrix(): Matrix;
  8653. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8654. /**
  8655. * @hidden
  8656. */
  8657. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8658. /**
  8659. * @hidden
  8660. */
  8661. _updateRigCameras(): void;
  8662. private _getRigCamPositionAndTarget;
  8663. /**
  8664. * Gets the current object class name.
  8665. * @return the class name
  8666. */
  8667. getClassName(): string;
  8668. }
  8669. }
  8670. declare module "babylonjs/Events/keyboardEvents" {
  8671. /**
  8672. * Gather the list of keyboard event types as constants.
  8673. */
  8674. export class KeyboardEventTypes {
  8675. /**
  8676. * The keydown event is fired when a key becomes active (pressed).
  8677. */
  8678. static readonly KEYDOWN: number;
  8679. /**
  8680. * The keyup event is fired when a key has been released.
  8681. */
  8682. static readonly KEYUP: number;
  8683. }
  8684. /**
  8685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8686. */
  8687. export class KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Instantiates a new keyboard info.
  8698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. /**
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8715. */
  8716. export class KeyboardInfoPre extends KeyboardInfo {
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number;
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent;
  8725. /**
  8726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8727. */
  8728. skipOnPointerObservable: boolean;
  8729. /**
  8730. * Instantiates a new keyboard pre info.
  8731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8732. * @param type Defines the type of event (KeyboardEventTypes)
  8733. * @param event Defines the related dom event
  8734. */
  8735. constructor(
  8736. /**
  8737. * Defines the type of event (KeyboardEventTypes)
  8738. */
  8739. type: number,
  8740. /**
  8741. * Defines the related dom event
  8742. */
  8743. event: KeyboardEvent);
  8744. }
  8745. }
  8746. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8747. import { Nullable } from "babylonjs/types";
  8748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8750. /**
  8751. * Manage the keyboard inputs to control the movement of a free camera.
  8752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8753. */
  8754. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8755. /**
  8756. * Defines the camera the input is attached to.
  8757. */
  8758. camera: FreeCamera;
  8759. /**
  8760. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8761. */
  8762. keysUp: number[];
  8763. /**
  8764. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8765. */
  8766. keysDown: number[];
  8767. /**
  8768. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8769. */
  8770. keysLeft: number[];
  8771. /**
  8772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8773. */
  8774. keysRight: number[];
  8775. private _keys;
  8776. private _onCanvasBlurObserver;
  8777. private _onKeyboardObserver;
  8778. private _engine;
  8779. private _scene;
  8780. /**
  8781. * Attach the input controls to a specific dom element to get the input from.
  8782. * @param element Defines the element the controls should be listened from
  8783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8784. */
  8785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8786. /**
  8787. * Detach the current controls from the specified dom element.
  8788. * @param element Defines the element to stop listening the inputs from
  8789. */
  8790. detachControl(element: Nullable<HTMLElement>): void;
  8791. /**
  8792. * Update the current camera state depending on the inputs that have been used this frame.
  8793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8794. */
  8795. checkInputs(): void;
  8796. /**
  8797. * Gets the class name of the current intput.
  8798. * @returns the class name
  8799. */
  8800. getClassName(): string;
  8801. /** @hidden */
  8802. _onLostFocus(): void;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. }
  8809. }
  8810. declare module "babylonjs/Lights/shadowLight" {
  8811. import { Camera } from "babylonjs/Cameras/camera";
  8812. import { Scene } from "babylonjs/scene";
  8813. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8815. import { Light } from "babylonjs/Lights/light";
  8816. /**
  8817. * Interface describing all the common properties and methods a shadow light needs to implement.
  8818. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8819. * as well as binding the different shadow properties to the effects.
  8820. */
  8821. export interface IShadowLight extends Light {
  8822. /**
  8823. * The light id in the scene (used in scene.findLighById for instance)
  8824. */
  8825. id: string;
  8826. /**
  8827. * The position the shdow will be casted from.
  8828. */
  8829. position: Vector3;
  8830. /**
  8831. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8832. */
  8833. direction: Vector3;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. /**
  8843. * The friendly name of the light in the scene.
  8844. */
  8845. name: string;
  8846. /**
  8847. * Defines the shadow projection clipping minimum z value.
  8848. */
  8849. shadowMinZ: number;
  8850. /**
  8851. * Defines the shadow projection clipping maximum z value.
  8852. */
  8853. shadowMaxZ: number;
  8854. /**
  8855. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8856. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8857. */
  8858. computeTransformedInformation(): boolean;
  8859. /**
  8860. * Gets the scene the light belongs to.
  8861. * @returns The scene
  8862. */
  8863. getScene(): Scene;
  8864. /**
  8865. * Callback defining a custom Projection Matrix Builder.
  8866. * This can be used to override the default projection matrix computation.
  8867. */
  8868. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8869. /**
  8870. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8871. * @param matrix The materix to updated with the projection information
  8872. * @param viewMatrix The transform matrix of the light
  8873. * @param renderList The list of mesh to render in the map
  8874. * @returns The current light
  8875. */
  8876. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8877. /**
  8878. * Gets the current depth scale used in ESM.
  8879. * @returns The scale
  8880. */
  8881. getDepthScale(): number;
  8882. /**
  8883. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8884. * @returns true if a cube texture needs to be use
  8885. */
  8886. needCube(): boolean;
  8887. /**
  8888. * Detects if the projection matrix requires to be recomputed this frame.
  8889. * @returns true if it requires to be recomputed otherwise, false.
  8890. */
  8891. needProjectionMatrixCompute(): boolean;
  8892. /**
  8893. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8894. */
  8895. forceProjectionMatrixCompute(): void;
  8896. /**
  8897. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8900. */
  8901. getShadowDirection(faceIndex?: number): Vector3;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. }
  8915. /**
  8916. * Base implementation IShadowLight
  8917. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8918. */
  8919. export abstract class ShadowLight extends Light implements IShadowLight {
  8920. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8921. protected _position: Vector3;
  8922. protected _setPosition(value: Vector3): void;
  8923. /**
  8924. * Sets the position the shadow will be casted from. Also use as the light position for both
  8925. * point and spot lights.
  8926. */
  8927. /**
  8928. * Sets the position the shadow will be casted from. Also use as the light position for both
  8929. * point and spot lights.
  8930. */
  8931. position: Vector3;
  8932. protected _direction: Vector3;
  8933. protected _setDirection(value: Vector3): void;
  8934. /**
  8935. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8936. * Also use as the light direction on spot and directional lights.
  8937. */
  8938. /**
  8939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8940. * Also use as the light direction on spot and directional lights.
  8941. */
  8942. direction: Vector3;
  8943. private _shadowMinZ;
  8944. /**
  8945. * Gets the shadow projection clipping minimum z value.
  8946. */
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. shadowMinZ: number;
  8951. private _shadowMaxZ;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module "babylonjs/Materials/effectFallbacks" {
  9052. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9053. import { Effect } from "babylonjs/Materials/effect";
  9054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9055. /**
  9056. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9057. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9058. */
  9059. export class EffectFallbacks implements IEffectFallbacks {
  9060. private _defines;
  9061. private _currentRank;
  9062. private _maxRank;
  9063. private _mesh;
  9064. /**
  9065. * Removes the fallback from the bound mesh.
  9066. */
  9067. unBindMesh(): void;
  9068. /**
  9069. * Adds a fallback on the specified property.
  9070. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9071. * @param define The name of the define in the shader
  9072. */
  9073. addFallback(rank: number, define: string): void;
  9074. /**
  9075. * Sets the mesh to use CPU skinning when needing to fallback.
  9076. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9077. * @param mesh The mesh to use the fallbacks.
  9078. */
  9079. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9080. /**
  9081. * Checks to see if more fallbacks are still availible.
  9082. */
  9083. readonly hasMoreFallbacks: boolean;
  9084. /**
  9085. * Removes the defines that should be removed when falling back.
  9086. * @param currentDefines defines the current define statements for the shader.
  9087. * @param effect defines the current effect we try to compile
  9088. * @returns The resulting defines with defines of the current rank removed.
  9089. */
  9090. reduce(currentDefines: string, effect: Effect): string;
  9091. }
  9092. }
  9093. declare module "babylonjs/Materials/materialHelper" {
  9094. import { Nullable } from "babylonjs/types";
  9095. import { Scene } from "babylonjs/scene";
  9096. import { Engine } from "babylonjs/Engines/engine";
  9097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9098. import { Light } from "babylonjs/Lights/light";
  9099. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9100. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9103. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9104. /**
  9105. * "Static Class" containing the most commonly used helper while dealing with material for
  9106. * rendering purpose.
  9107. *
  9108. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9109. *
  9110. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9111. */
  9112. export class MaterialHelper {
  9113. /**
  9114. * Bind the current view position to an effect.
  9115. * @param effect The effect to be bound
  9116. * @param scene The scene the eyes position is used from
  9117. */
  9118. static BindEyePosition(effect: Effect, scene: Scene): void;
  9119. /**
  9120. * Helps preparing the defines values about the UVs in used in the effect.
  9121. * UVs are shared as much as we can accross channels in the shaders.
  9122. * @param texture The texture we are preparing the UVs for
  9123. * @param defines The defines to update
  9124. * @param key The channel key "diffuse", "specular"... used in the shader
  9125. */
  9126. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9127. /**
  9128. * Binds a texture matrix value to its corrsponding uniform
  9129. * @param texture The texture to bind the matrix for
  9130. * @param uniformBuffer The uniform buffer receivin the data
  9131. * @param key The channel key "diffuse", "specular"... used in the shader
  9132. */
  9133. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9134. /**
  9135. * Gets the current status of the fog (should it be enabled?)
  9136. * @param mesh defines the mesh to evaluate for fog support
  9137. * @param scene defines the hosting scene
  9138. * @returns true if fog must be enabled
  9139. */
  9140. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9141. /**
  9142. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9143. * @param mesh defines the current mesh
  9144. * @param scene defines the current scene
  9145. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9146. * @param pointsCloud defines if point cloud rendering has to be turned on
  9147. * @param fogEnabled defines if fog has to be turned on
  9148. * @param alphaTest defines if alpha testing has to be turned on
  9149. * @param defines defines the current list of defines
  9150. */
  9151. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9152. /**
  9153. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9154. * @param scene defines the current scene
  9155. * @param engine defines the current engine
  9156. * @param defines specifies the list of active defines
  9157. * @param useInstances defines if instances have to be turned on
  9158. * @param useClipPlane defines if clip plane have to be turned on
  9159. */
  9160. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9161. /**
  9162. * Prepares the defines for bones
  9163. * @param mesh The mesh containing the geometry data we will draw
  9164. * @param defines The defines to update
  9165. */
  9166. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9167. /**
  9168. * Prepares the defines for morph targets
  9169. * @param mesh The mesh containing the geometry data we will draw
  9170. * @param defines The defines to update
  9171. */
  9172. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9173. /**
  9174. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9175. * @param mesh The mesh containing the geometry data we will draw
  9176. * @param defines The defines to update
  9177. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9178. * @param useBones Precise whether bones should be used or not (override mesh info)
  9179. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9180. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9181. * @returns false if defines are considered not dirty and have not been checked
  9182. */
  9183. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9184. /**
  9185. * Prepares the defines related to multiview
  9186. * @param scene The scene we are intending to draw
  9187. * @param defines The defines to update
  9188. */
  9189. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9190. /**
  9191. * Prepares the defines related to the light information passed in parameter
  9192. * @param scene The scene we are intending to draw
  9193. * @param mesh The mesh the effect is compiling for
  9194. * @param light The light the effect is compiling for
  9195. * @param lightIndex The index of the light
  9196. * @param defines The defines to update
  9197. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9198. * @param state Defines the current state regarding what is needed (normals, etc...)
  9199. */
  9200. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9201. needNormals: boolean;
  9202. needRebuild: boolean;
  9203. shadowEnabled: boolean;
  9204. specularEnabled: boolean;
  9205. lightmapMode: boolean;
  9206. }): void;
  9207. /**
  9208. * Prepares the defines related to the light information passed in parameter
  9209. * @param scene The scene we are intending to draw
  9210. * @param mesh The mesh the effect is compiling for
  9211. * @param defines The defines to update
  9212. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9213. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9214. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9215. * @returns true if normals will be required for the rest of the effect
  9216. */
  9217. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9218. /**
  9219. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9220. * @param lightIndex defines the light index
  9221. * @param uniformsList The uniform list
  9222. * @param samplersList The sampler list
  9223. * @param projectedLightTexture defines if projected texture must be used
  9224. * @param uniformBuffersList defines an optional list of uniform buffers
  9225. */
  9226. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9227. /**
  9228. * Prepares the uniforms and samplers list to be used in the effect
  9229. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9230. * @param samplersList The sampler list
  9231. * @param defines The defines helping in the list generation
  9232. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9233. */
  9234. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9235. /**
  9236. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9237. * @param defines The defines to update while falling back
  9238. * @param fallbacks The authorized effect fallbacks
  9239. * @param maxSimultaneousLights The maximum number of lights allowed
  9240. * @param rank the current rank of the Effect
  9241. * @returns The newly affected rank
  9242. */
  9243. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9244. private static _TmpMorphInfluencers;
  9245. /**
  9246. * Prepares the list of attributes required for morph targets according to the effect defines.
  9247. * @param attribs The current list of supported attribs
  9248. * @param mesh The mesh to prepare the morph targets attributes for
  9249. * @param influencers The number of influencers
  9250. */
  9251. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9252. /**
  9253. * Prepares the list of attributes required for morph targets according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param mesh The mesh to prepare the morph targets attributes for
  9256. * @param defines The current Defines of the effect
  9257. */
  9258. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9259. /**
  9260. * Prepares the list of attributes required for bones according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param mesh The mesh to prepare the bones attributes for
  9263. * @param defines The current Defines of the effect
  9264. * @param fallbacks The current efffect fallback strategy
  9265. */
  9266. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9267. /**
  9268. * Check and prepare the list of attributes required for instances according to the effect defines.
  9269. * @param attribs The current list of supported attribs
  9270. * @param defines The current MaterialDefines of the effect
  9271. */
  9272. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9273. /**
  9274. * Add the list of attributes required for instances to the attribs array.
  9275. * @param attribs The current list of supported attribs
  9276. */
  9277. static PushAttributesForInstances(attribs: string[]): void;
  9278. /**
  9279. * Binds the light information to the effect.
  9280. * @param light The light containing the generator
  9281. * @param effect The effect we are binding the data to
  9282. * @param lightIndex The light index in the effect used to render
  9283. */
  9284. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9285. /**
  9286. * Binds the lights information from the scene to the effect for the given mesh.
  9287. * @param light Light to bind
  9288. * @param lightIndex Light index
  9289. * @param scene The scene where the light belongs to
  9290. * @param effect The effect we are binding the data to
  9291. * @param useSpecular Defines if specular is supported
  9292. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9293. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9294. */
  9295. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9296. /**
  9297. * Binds the lights information from the scene to the effect for the given mesh.
  9298. * @param scene The scene the lights belongs to
  9299. * @param mesh The mesh we are binding the information to render
  9300. * @param effect The effect we are binding the data to
  9301. * @param defines The generated defines for the effect
  9302. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9303. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9304. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9305. */
  9306. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9307. private static _tempFogColor;
  9308. /**
  9309. * Binds the fog information from the scene to the effect for the given mesh.
  9310. * @param scene The scene the lights belongs to
  9311. * @param mesh The mesh we are binding the information to render
  9312. * @param effect The effect we are binding the data to
  9313. * @param linearSpace Defines if the fog effect is applied in linear space
  9314. */
  9315. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9316. /**
  9317. * Binds the bones information from the mesh to the effect.
  9318. * @param mesh The mesh we are binding the information to render
  9319. * @param effect The effect we are binding the data to
  9320. */
  9321. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9322. /**
  9323. * Binds the morph targets information from the mesh to the effect.
  9324. * @param abstractMesh The mesh we are binding the information to render
  9325. * @param effect The effect we are binding the data to
  9326. */
  9327. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9328. /**
  9329. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9330. * @param defines The generated defines used in the effect
  9331. * @param effect The effect we are binding the data to
  9332. * @param scene The scene we are willing to render with logarithmic scale for
  9333. */
  9334. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9335. /**
  9336. * Binds the clip plane information from the scene to the effect.
  9337. * @param scene The scene the clip plane information are extracted from
  9338. * @param effect The effect we are binding the data to
  9339. */
  9340. static BindClipPlane(effect: Effect, scene: Scene): void;
  9341. }
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9344. /** @hidden */
  9345. export var packingFunctions: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9351. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9352. /** @hidden */
  9353. export var shadowMapPixelShader: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9359. /** @hidden */
  9360. export var bonesDeclaration: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9366. /** @hidden */
  9367. export var morphTargetsVertexGlobalDeclaration: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9373. /** @hidden */
  9374. export var morphTargetsVertexDeclaration: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9380. /** @hidden */
  9381. export var instancesDeclaration: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9387. /** @hidden */
  9388. export var helperFunctions: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9394. /** @hidden */
  9395. export var morphTargetsVertex: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9401. /** @hidden */
  9402. export var instancesVertex: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9408. /** @hidden */
  9409. export var bonesVertex: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9415. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9418. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9421. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9422. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9423. /** @hidden */
  9424. export var shadowMapVertexShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9430. /** @hidden */
  9431. export var depthBoxBlurPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9437. import { Nullable } from "babylonjs/types";
  9438. import { Scene } from "babylonjs/scene";
  9439. import { Matrix } from "babylonjs/Maths/math.vector";
  9440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9442. import { Mesh } from "babylonjs/Meshes/mesh";
  9443. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9444. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9445. import { Effect } from "babylonjs/Materials/effect";
  9446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9447. import "babylonjs/Shaders/shadowMap.fragment";
  9448. import "babylonjs/Shaders/shadowMap.vertex";
  9449. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. /**
  9452. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9453. */
  9454. export interface ICustomShaderOptions {
  9455. /**
  9456. * Gets or sets the custom shader name to use
  9457. */
  9458. shaderName: string;
  9459. /**
  9460. * The list of attribute names used in the shader
  9461. */
  9462. attributes?: string[];
  9463. /**
  9464. * The list of unifrom names used in the shader
  9465. */
  9466. uniforms?: string[];
  9467. /**
  9468. * The list of sampler names used in the shader
  9469. */
  9470. samplers?: string[];
  9471. /**
  9472. * The list of defines used in the shader
  9473. */
  9474. defines?: string[];
  9475. }
  9476. /**
  9477. * Interface to implement to create a shadow generator compatible with BJS.
  9478. */
  9479. export interface IShadowGenerator {
  9480. /**
  9481. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9482. * @returns The render target texture if present otherwise, null
  9483. */
  9484. getShadowMap(): Nullable<RenderTargetTexture>;
  9485. /**
  9486. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9487. * @returns The render target texture if the shadow map is present otherwise, null
  9488. */
  9489. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9490. /**
  9491. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9492. * @param subMesh The submesh we want to render in the shadow map
  9493. * @param useInstances Defines wether will draw in the map using instances
  9494. * @returns true if ready otherwise, false
  9495. */
  9496. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9497. /**
  9498. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9499. * @param defines Defines of the material we want to update
  9500. * @param lightIndex Index of the light in the enabled light list of the material
  9501. */
  9502. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9503. /**
  9504. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9505. * defined in the generator but impacting the effect).
  9506. * It implies the unifroms available on the materials are the standard BJS ones.
  9507. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9508. * @param effect The effect we are binfing the information for
  9509. */
  9510. bindShadowLight(lightIndex: string, effect: Effect): void;
  9511. /**
  9512. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9513. * (eq to shadow prjection matrix * light transform matrix)
  9514. * @returns The transform matrix used to create the shadow map
  9515. */
  9516. getTransformMatrix(): Matrix;
  9517. /**
  9518. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9519. * Cube and 2D textures for instance.
  9520. */
  9521. recreateShadowMap(): void;
  9522. /**
  9523. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9524. * @param onCompiled Callback triggered at the and of the effects compilation
  9525. * @param options Sets of optional options forcing the compilation with different modes
  9526. */
  9527. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9528. useInstances: boolean;
  9529. }>): void;
  9530. /**
  9531. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9532. * @param options Sets of optional options forcing the compilation with different modes
  9533. * @returns A promise that resolves when the compilation completes
  9534. */
  9535. forceCompilationAsync(options?: Partial<{
  9536. useInstances: boolean;
  9537. }>): Promise<void>;
  9538. /**
  9539. * Serializes the shadow generator setup to a json object.
  9540. * @returns The serialized JSON object
  9541. */
  9542. serialize(): any;
  9543. /**
  9544. * Disposes the Shadow map and related Textures and effects.
  9545. */
  9546. dispose(): void;
  9547. }
  9548. /**
  9549. * Default implementation IShadowGenerator.
  9550. * This is the main object responsible of generating shadows in the framework.
  9551. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9552. */
  9553. export class ShadowGenerator implements IShadowGenerator {
  9554. /**
  9555. * Shadow generator mode None: no filtering applied.
  9556. */
  9557. static readonly FILTER_NONE: number;
  9558. /**
  9559. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9561. */
  9562. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9563. /**
  9564. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9565. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9566. */
  9567. static readonly FILTER_POISSONSAMPLING: number;
  9568. /**
  9569. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9570. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9571. */
  9572. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9573. /**
  9574. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9575. * edge artifacts on steep falloff.
  9576. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9577. */
  9578. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9579. /**
  9580. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9581. * edge artifacts on steep falloff.
  9582. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9583. */
  9584. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9585. /**
  9586. * Shadow generator mode PCF: Percentage Closer Filtering
  9587. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9588. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9589. */
  9590. static readonly FILTER_PCF: number;
  9591. /**
  9592. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9593. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9594. * Contact Hardening
  9595. */
  9596. static readonly FILTER_PCSS: number;
  9597. /**
  9598. * Reserved for PCF and PCSS
  9599. * Highest Quality.
  9600. *
  9601. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9602. *
  9603. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9604. */
  9605. static readonly QUALITY_HIGH: number;
  9606. /**
  9607. * Reserved for PCF and PCSS
  9608. * Good tradeoff for quality/perf cross devices
  9609. *
  9610. * Execute PCF on a 3*3 kernel.
  9611. *
  9612. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9613. */
  9614. static readonly QUALITY_MEDIUM: number;
  9615. /**
  9616. * Reserved for PCF and PCSS
  9617. * The lowest quality but the fastest.
  9618. *
  9619. * Execute PCF on a 1*1 kernel.
  9620. *
  9621. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9622. */
  9623. static readonly QUALITY_LOW: number;
  9624. /** Gets or sets the custom shader name to use */
  9625. customShaderOptions: ICustomShaderOptions;
  9626. /**
  9627. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9628. */
  9629. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9630. /**
  9631. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9632. */
  9633. onAfterShadowMapRenderObservable: Observable<Effect>;
  9634. /**
  9635. * Observable triggered before a mesh is rendered in the shadow map.
  9636. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9637. */
  9638. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9639. /**
  9640. * Observable triggered after a mesh is rendered in the shadow map.
  9641. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9642. */
  9643. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9644. private _bias;
  9645. /**
  9646. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9647. */
  9648. /**
  9649. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9650. */
  9651. bias: number;
  9652. private _normalBias;
  9653. /**
  9654. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9655. */
  9656. /**
  9657. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9658. */
  9659. normalBias: number;
  9660. private _blurBoxOffset;
  9661. /**
  9662. * Gets the blur box offset: offset applied during the blur pass.
  9663. * Only useful if useKernelBlur = false
  9664. */
  9665. /**
  9666. * Sets the blur box offset: offset applied during the blur pass.
  9667. * Only useful if useKernelBlur = false
  9668. */
  9669. blurBoxOffset: number;
  9670. private _blurScale;
  9671. /**
  9672. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9673. * 2 means half of the size.
  9674. */
  9675. /**
  9676. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9677. * 2 means half of the size.
  9678. */
  9679. blurScale: number;
  9680. private _blurKernel;
  9681. /**
  9682. * Gets the blur kernel: kernel size of the blur pass.
  9683. * Only useful if useKernelBlur = true
  9684. */
  9685. /**
  9686. * Sets the blur kernel: kernel size of the blur pass.
  9687. * Only useful if useKernelBlur = true
  9688. */
  9689. blurKernel: number;
  9690. private _useKernelBlur;
  9691. /**
  9692. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9693. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9694. */
  9695. /**
  9696. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9697. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9698. */
  9699. useKernelBlur: boolean;
  9700. private _depthScale;
  9701. /**
  9702. * Gets the depth scale used in ESM mode.
  9703. */
  9704. /**
  9705. * Sets the depth scale used in ESM mode.
  9706. * This can override the scale stored on the light.
  9707. */
  9708. depthScale: number;
  9709. private _filter;
  9710. /**
  9711. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9712. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9713. */
  9714. /**
  9715. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9716. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9717. */
  9718. filter: number;
  9719. /**
  9720. * Gets if the current filter is set to Poisson Sampling.
  9721. */
  9722. /**
  9723. * Sets the current filter to Poisson Sampling.
  9724. */
  9725. usePoissonSampling: boolean;
  9726. /**
  9727. * Gets if the current filter is set to ESM.
  9728. */
  9729. /**
  9730. * Sets the current filter is to ESM.
  9731. */
  9732. useExponentialShadowMap: boolean;
  9733. /**
  9734. * Gets if the current filter is set to filtered ESM.
  9735. */
  9736. /**
  9737. * Gets if the current filter is set to filtered ESM.
  9738. */
  9739. useBlurExponentialShadowMap: boolean;
  9740. /**
  9741. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9742. * exponential to prevent steep falloff artifacts).
  9743. */
  9744. /**
  9745. * Sets the current filter to "close ESM" (using the inverse of the
  9746. * exponential to prevent steep falloff artifacts).
  9747. */
  9748. useCloseExponentialShadowMap: boolean;
  9749. /**
  9750. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9751. * exponential to prevent steep falloff artifacts).
  9752. */
  9753. /**
  9754. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9755. * exponential to prevent steep falloff artifacts).
  9756. */
  9757. useBlurCloseExponentialShadowMap: boolean;
  9758. /**
  9759. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9760. */
  9761. /**
  9762. * Sets the current filter to "PCF" (percentage closer filtering).
  9763. */
  9764. usePercentageCloserFiltering: boolean;
  9765. private _filteringQuality;
  9766. /**
  9767. * Gets the PCF or PCSS Quality.
  9768. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9769. */
  9770. /**
  9771. * Sets the PCF or PCSS Quality.
  9772. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9773. */
  9774. filteringQuality: number;
  9775. /**
  9776. * Gets if the current filter is set to "PCSS" (contact hardening).
  9777. */
  9778. /**
  9779. * Sets the current filter to "PCSS" (contact hardening).
  9780. */
  9781. useContactHardeningShadow: boolean;
  9782. private _contactHardeningLightSizeUVRatio;
  9783. /**
  9784. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9785. * Using a ratio helps keeping shape stability independently of the map size.
  9786. *
  9787. * It does not account for the light projection as it was having too much
  9788. * instability during the light setup or during light position changes.
  9789. *
  9790. * Only valid if useContactHardeningShadow is true.
  9791. */
  9792. /**
  9793. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9794. * Using a ratio helps keeping shape stability independently of the map size.
  9795. *
  9796. * It does not account for the light projection as it was having too much
  9797. * instability during the light setup or during light position changes.
  9798. *
  9799. * Only valid if useContactHardeningShadow is true.
  9800. */
  9801. contactHardeningLightSizeUVRatio: number;
  9802. private _darkness;
  9803. /** Gets or sets the actual darkness of a shadow */
  9804. darkness: number;
  9805. /**
  9806. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9807. * 0 means strongest and 1 would means no shadow.
  9808. * @returns the darkness.
  9809. */
  9810. getDarkness(): number;
  9811. /**
  9812. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9813. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9814. * @returns the shadow generator allowing fluent coding.
  9815. */
  9816. setDarkness(darkness: number): ShadowGenerator;
  9817. private _transparencyShadow;
  9818. /** Gets or sets the ability to have transparent shadow */
  9819. transparencyShadow: boolean;
  9820. /**
  9821. * Sets the ability to have transparent shadow (boolean).
  9822. * @param transparent True if transparent else False
  9823. * @returns the shadow generator allowing fluent coding
  9824. */
  9825. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9826. private _shadowMap;
  9827. private _shadowMap2;
  9828. /**
  9829. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9830. * @returns The render target texture if present otherwise, null
  9831. */
  9832. getShadowMap(): Nullable<RenderTargetTexture>;
  9833. /**
  9834. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9835. * @returns The render target texture if the shadow map is present otherwise, null
  9836. */
  9837. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9838. /**
  9839. * Gets the class name of that object
  9840. * @returns "ShadowGenerator"
  9841. */
  9842. getClassName(): string;
  9843. /**
  9844. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9845. * @param mesh Mesh to add
  9846. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9847. * @returns the Shadow Generator itself
  9848. */
  9849. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9850. /**
  9851. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9852. * @param mesh Mesh to remove
  9853. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9854. * @returns the Shadow Generator itself
  9855. */
  9856. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9857. /**
  9858. * Controls the extent to which the shadows fade out at the edge of the frustum
  9859. * Used only by directionals and spots
  9860. */
  9861. frustumEdgeFalloff: number;
  9862. private _light;
  9863. /**
  9864. * Returns the associated light object.
  9865. * @returns the light generating the shadow
  9866. */
  9867. getLight(): IShadowLight;
  9868. /**
  9869. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9870. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9871. * It might on the other hand introduce peter panning.
  9872. */
  9873. forceBackFacesOnly: boolean;
  9874. private _scene;
  9875. private _lightDirection;
  9876. private _effect;
  9877. private _viewMatrix;
  9878. private _projectionMatrix;
  9879. private _transformMatrix;
  9880. private _cachedPosition;
  9881. private _cachedDirection;
  9882. private _cachedDefines;
  9883. private _currentRenderID;
  9884. private _boxBlurPostprocess;
  9885. private _kernelBlurXPostprocess;
  9886. private _kernelBlurYPostprocess;
  9887. private _blurPostProcesses;
  9888. private _mapSize;
  9889. private _currentFaceIndex;
  9890. private _currentFaceIndexCache;
  9891. private _textureType;
  9892. private _defaultTextureMatrix;
  9893. private _storedUniqueId;
  9894. /** @hidden */
  9895. static _SceneComponentInitialization: (scene: Scene) => void;
  9896. /**
  9897. * Creates a ShadowGenerator object.
  9898. * A ShadowGenerator is the required tool to use the shadows.
  9899. * Each light casting shadows needs to use its own ShadowGenerator.
  9900. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9901. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9902. * @param light The light object generating the shadows.
  9903. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9904. */
  9905. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9906. private _initializeGenerator;
  9907. private _initializeShadowMap;
  9908. private _initializeBlurRTTAndPostProcesses;
  9909. private _renderForShadowMap;
  9910. private _renderSubMeshForShadowMap;
  9911. private _applyFilterValues;
  9912. /**
  9913. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9914. * @param onCompiled Callback triggered at the and of the effects compilation
  9915. * @param options Sets of optional options forcing the compilation with different modes
  9916. */
  9917. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9918. useInstances: boolean;
  9919. }>): void;
  9920. /**
  9921. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9922. * @param options Sets of optional options forcing the compilation with different modes
  9923. * @returns A promise that resolves when the compilation completes
  9924. */
  9925. forceCompilationAsync(options?: Partial<{
  9926. useInstances: boolean;
  9927. }>): Promise<void>;
  9928. /**
  9929. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9930. * @param subMesh The submesh we want to render in the shadow map
  9931. * @param useInstances Defines wether will draw in the map using instances
  9932. * @returns true if ready otherwise, false
  9933. */
  9934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9935. /**
  9936. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9937. * @param defines Defines of the material we want to update
  9938. * @param lightIndex Index of the light in the enabled light list of the material
  9939. */
  9940. prepareDefines(defines: any, lightIndex: number): void;
  9941. /**
  9942. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9943. * defined in the generator but impacting the effect).
  9944. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9945. * @param effect The effect we are binfing the information for
  9946. */
  9947. bindShadowLight(lightIndex: string, effect: Effect): void;
  9948. /**
  9949. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9950. * (eq to shadow prjection matrix * light transform matrix)
  9951. * @returns The transform matrix used to create the shadow map
  9952. */
  9953. getTransformMatrix(): Matrix;
  9954. /**
  9955. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9956. * Cube and 2D textures for instance.
  9957. */
  9958. recreateShadowMap(): void;
  9959. private _disposeBlurPostProcesses;
  9960. private _disposeRTTandPostProcesses;
  9961. /**
  9962. * Disposes the ShadowGenerator.
  9963. * Returns nothing.
  9964. */
  9965. dispose(): void;
  9966. /**
  9967. * Serializes the shadow generator setup to a json object.
  9968. * @returns The serialized JSON object
  9969. */
  9970. serialize(): any;
  9971. /**
  9972. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9973. * @param parsedShadowGenerator The JSON object to parse
  9974. * @param scene The scene to create the shadow map for
  9975. * @returns The parsed shadow generator
  9976. */
  9977. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9978. }
  9979. }
  9980. declare module "babylonjs/Lights/light" {
  9981. import { Nullable } from "babylonjs/types";
  9982. import { Scene } from "babylonjs/scene";
  9983. import { Vector3 } from "babylonjs/Maths/math.vector";
  9984. import { Color3 } from "babylonjs/Maths/math.color";
  9985. import { Node } from "babylonjs/node";
  9986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9987. import { Effect } from "babylonjs/Materials/effect";
  9988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9989. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9990. /**
  9991. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9992. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9993. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9994. */
  9995. export abstract class Light extends Node {
  9996. /**
  9997. * Falloff Default: light is falling off following the material specification:
  9998. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9999. */
  10000. static readonly FALLOFF_DEFAULT: number;
  10001. /**
  10002. * Falloff Physical: light is falling off following the inverse squared distance law.
  10003. */
  10004. static readonly FALLOFF_PHYSICAL: number;
  10005. /**
  10006. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10007. * to enhance interoperability with other engines.
  10008. */
  10009. static readonly FALLOFF_GLTF: number;
  10010. /**
  10011. * Falloff Standard: light is falling off like in the standard material
  10012. * to enhance interoperability with other materials.
  10013. */
  10014. static readonly FALLOFF_STANDARD: number;
  10015. /**
  10016. * If every light affecting the material is in this lightmapMode,
  10017. * material.lightmapTexture adds or multiplies
  10018. * (depends on material.useLightmapAsShadowmap)
  10019. * after every other light calculations.
  10020. */
  10021. static readonly LIGHTMAP_DEFAULT: number;
  10022. /**
  10023. * material.lightmapTexture as only diffuse lighting from this light
  10024. * adds only specular lighting from this light
  10025. * adds dynamic shadows
  10026. */
  10027. static readonly LIGHTMAP_SPECULAR: number;
  10028. /**
  10029. * material.lightmapTexture as only lighting
  10030. * no light calculation from this light
  10031. * only adds dynamic shadows from this light
  10032. */
  10033. static readonly LIGHTMAP_SHADOWSONLY: number;
  10034. /**
  10035. * Each light type uses the default quantity according to its type:
  10036. * point/spot lights use luminous intensity
  10037. * directional lights use illuminance
  10038. */
  10039. static readonly INTENSITYMODE_AUTOMATIC: number;
  10040. /**
  10041. * lumen (lm)
  10042. */
  10043. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10044. /**
  10045. * candela (lm/sr)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10048. /**
  10049. * lux (lm/m^2)
  10050. */
  10051. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10052. /**
  10053. * nit (cd/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINANCE: number;
  10056. /**
  10057. * Light type const id of the point light.
  10058. */
  10059. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10060. /**
  10061. * Light type const id of the directional light.
  10062. */
  10063. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10064. /**
  10065. * Light type const id of the spot light.
  10066. */
  10067. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10068. /**
  10069. * Light type const id of the hemispheric light.
  10070. */
  10071. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10072. /**
  10073. * Diffuse gives the basic color to an object.
  10074. */
  10075. diffuse: Color3;
  10076. /**
  10077. * Specular produces a highlight color on an object.
  10078. * Note: This is note affecting PBR materials.
  10079. */
  10080. specular: Color3;
  10081. /**
  10082. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10083. * falling off base on range or angle.
  10084. * This can be set to any values in Light.FALLOFF_x.
  10085. *
  10086. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10087. * other types of materials.
  10088. */
  10089. falloffType: number;
  10090. /**
  10091. * Strength of the light.
  10092. * Note: By default it is define in the framework own unit.
  10093. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10094. */
  10095. intensity: number;
  10096. private _range;
  10097. protected _inverseSquaredRange: number;
  10098. /**
  10099. * Defines how far from the source the light is impacting in scene units.
  10100. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10101. */
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. range: number;
  10107. /**
  10108. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10109. * of light.
  10110. */
  10111. private _photometricScale;
  10112. private _intensityMode;
  10113. /**
  10114. * Gets the photometric scale used to interpret the intensity.
  10115. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10116. */
  10117. /**
  10118. * Sets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. intensityMode: number;
  10122. private _radius;
  10123. /**
  10124. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10125. */
  10126. /**
  10127. * sets the light radius used by PBR Materials to simulate soft area lights.
  10128. */
  10129. radius: number;
  10130. private _renderPriority;
  10131. /**
  10132. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10133. * exceeding the number allowed of the materials.
  10134. */
  10135. renderPriority: number;
  10136. private _shadowEnabled;
  10137. /**
  10138. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. /**
  10142. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. shadowEnabled: boolean;
  10146. private _includedOnlyMeshes;
  10147. /**
  10148. * Gets the only meshes impacted by this light.
  10149. */
  10150. /**
  10151. * Sets the only meshes impacted by this light.
  10152. */
  10153. includedOnlyMeshes: AbstractMesh[];
  10154. private _excludedMeshes;
  10155. /**
  10156. * Gets the meshes not impacted by this light.
  10157. */
  10158. /**
  10159. * Sets the meshes not impacted by this light.
  10160. */
  10161. excludedMeshes: AbstractMesh[];
  10162. private _excludeWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are not impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. excludeWithLayerMask: number;
  10172. private _includeOnlyWithLayerMask;
  10173. /**
  10174. * Gets the layer id use to find what meshes are impacted by the light.
  10175. * Inactive if 0
  10176. */
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. includeOnlyWithLayerMask: number;
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. /**
  10187. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10188. */
  10189. lightmapMode: number;
  10190. /**
  10191. * Shadow generator associted to the light.
  10192. * @hidden Internal use only.
  10193. */
  10194. _shadowGenerator: Nullable<IShadowGenerator>;
  10195. /**
  10196. * @hidden Internal use only.
  10197. */
  10198. _excludedMeshesIds: string[];
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _includedOnlyMeshesIds: string[];
  10203. /**
  10204. * The current light unifom buffer.
  10205. * @hidden Internal use only.
  10206. */
  10207. _uniformBuffer: UniformBuffer;
  10208. /** @hidden */
  10209. _renderId: number;
  10210. /**
  10211. * Creates a Light object in the scene.
  10212. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10213. * @param name The firendly name of the light
  10214. * @param scene The scene the light belongs too
  10215. */
  10216. constructor(name: string, scene: Scene);
  10217. protected abstract _buildUniformLayout(): void;
  10218. /**
  10219. * Sets the passed Effect "effect" with the Light information.
  10220. * @param effect The effect to update
  10221. * @param lightIndex The index of the light in the effect to update
  10222. * @returns The light
  10223. */
  10224. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10225. /**
  10226. * Sets the passed Effect "effect" with the Light textures.
  10227. * @param effect The effect to update
  10228. * @param lightIndex The index of the light in the effect to update
  10229. * @returns The light
  10230. */
  10231. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10232. /**
  10233. * Binds the lights information from the scene to the effect for the given mesh.
  10234. * @param lightIndex Light index
  10235. * @param scene The scene where the light belongs to
  10236. * @param effect The effect we are binding the data to
  10237. * @param useSpecular Defines if specular is supported
  10238. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10239. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10240. */
  10241. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10242. /**
  10243. * Sets the passed Effect "effect" with the Light information.
  10244. * @param effect The effect to update
  10245. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10246. * @returns The light
  10247. */
  10248. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10249. /**
  10250. * Returns the string "Light".
  10251. * @returns the class name
  10252. */
  10253. getClassName(): string;
  10254. /** @hidden */
  10255. readonly _isLight: boolean;
  10256. /**
  10257. * Converts the light information to a readable string for debug purpose.
  10258. * @param fullDetails Supports for multiple levels of logging within scene loading
  10259. * @returns the human readable light info
  10260. */
  10261. toString(fullDetails?: boolean): string;
  10262. /** @hidden */
  10263. protected _syncParentEnabledState(): void;
  10264. /**
  10265. * Set the enabled state of this node.
  10266. * @param value - the new enabled state
  10267. */
  10268. setEnabled(value: boolean): void;
  10269. /**
  10270. * Returns the Light associated shadow generator if any.
  10271. * @return the associated shadow generator.
  10272. */
  10273. getShadowGenerator(): Nullable<IShadowGenerator>;
  10274. /**
  10275. * Returns a Vector3, the absolute light position in the World.
  10276. * @returns the world space position of the light
  10277. */
  10278. getAbsolutePosition(): Vector3;
  10279. /**
  10280. * Specifies if the light will affect the passed mesh.
  10281. * @param mesh The mesh to test against the light
  10282. * @return true the mesh is affected otherwise, false.
  10283. */
  10284. canAffectMesh(mesh: AbstractMesh): boolean;
  10285. /**
  10286. * Sort function to order lights for rendering.
  10287. * @param a First Light object to compare to second.
  10288. * @param b Second Light object to compare first.
  10289. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10290. */
  10291. static CompareLightsPriority(a: Light, b: Light): number;
  10292. /**
  10293. * Releases resources associated with this node.
  10294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10296. */
  10297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10298. /**
  10299. * Returns the light type ID (integer).
  10300. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10301. */
  10302. getTypeID(): number;
  10303. /**
  10304. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10305. * @returns the scaled intensity in intensity mode unit
  10306. */
  10307. getScaledIntensity(): number;
  10308. /**
  10309. * Returns a new Light object, named "name", from the current one.
  10310. * @param name The name of the cloned light
  10311. * @returns the new created light
  10312. */
  10313. clone(name: string): Nullable<Light>;
  10314. /**
  10315. * Serializes the current light into a Serialization object.
  10316. * @returns the serialized object.
  10317. */
  10318. serialize(): any;
  10319. /**
  10320. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10321. * This new light is named "name" and added to the passed scene.
  10322. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10323. * @param name The friendly name of the light
  10324. * @param scene The scene the new light will belong to
  10325. * @returns the constructor function
  10326. */
  10327. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10328. /**
  10329. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10330. * @param parsedLight The JSON representation of the light
  10331. * @param scene The scene to create the parsed light in
  10332. * @returns the created light after parsing
  10333. */
  10334. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10335. private _hookArrayForExcluded;
  10336. private _hookArrayForIncludedOnly;
  10337. private _resyncMeshes;
  10338. /**
  10339. * Forces the meshes to update their light related information in their rendering used effects
  10340. * @hidden Internal Use Only
  10341. */
  10342. _markMeshesAsLightDirty(): void;
  10343. /**
  10344. * Recomputes the cached photometric scale if needed.
  10345. */
  10346. private _computePhotometricScale;
  10347. /**
  10348. * Returns the Photometric Scale according to the light type and intensity mode.
  10349. */
  10350. private _getPhotometricScale;
  10351. /**
  10352. * Reorder the light in the scene according to their defined priority.
  10353. * @hidden Internal Use Only
  10354. */
  10355. _reorderLightsInScene(): void;
  10356. /**
  10357. * Prepares the list of defines specific to the light type.
  10358. * @param defines the list of defines
  10359. * @param lightIndex defines the index of the light for the effect
  10360. */
  10361. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10362. }
  10363. }
  10364. declare module "babylonjs/Actions/action" {
  10365. import { Observable } from "babylonjs/Misc/observable";
  10366. import { Condition } from "babylonjs/Actions/condition";
  10367. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10368. import { ActionManager } from "babylonjs/Actions/actionManager";
  10369. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10370. /**
  10371. * Interface used to define Action
  10372. */
  10373. export interface IAction {
  10374. /**
  10375. * Trigger for the action
  10376. */
  10377. trigger: number;
  10378. /** Options of the trigger */
  10379. triggerOptions: any;
  10380. /**
  10381. * Gets the trigger parameters
  10382. * @returns the trigger parameters
  10383. */
  10384. getTriggerParameter(): any;
  10385. /**
  10386. * Internal only - executes current action event
  10387. * @hidden
  10388. */
  10389. _executeCurrent(evt?: ActionEvent): void;
  10390. /**
  10391. * Serialize placeholder for child classes
  10392. * @param parent of child
  10393. * @returns the serialized object
  10394. */
  10395. serialize(parent: any): any;
  10396. /**
  10397. * Internal only
  10398. * @hidden
  10399. */
  10400. _prepare(): void;
  10401. /**
  10402. * Internal only - manager for action
  10403. * @hidden
  10404. */
  10405. _actionManager: AbstractActionManager;
  10406. /**
  10407. * Adds action to chain of actions, may be a DoNothingAction
  10408. * @param action defines the next action to execute
  10409. * @returns The action passed in
  10410. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10411. */
  10412. then(action: IAction): IAction;
  10413. }
  10414. /**
  10415. * The action to be carried out following a trigger
  10416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10417. */
  10418. export class Action implements IAction {
  10419. /** the trigger, with or without parameters, for the action */
  10420. triggerOptions: any;
  10421. /**
  10422. * Trigger for the action
  10423. */
  10424. trigger: number;
  10425. /**
  10426. * Internal only - manager for action
  10427. * @hidden
  10428. */
  10429. _actionManager: ActionManager;
  10430. private _nextActiveAction;
  10431. private _child;
  10432. private _condition?;
  10433. private _triggerParameter;
  10434. /**
  10435. * An event triggered prior to action being executed.
  10436. */
  10437. onBeforeExecuteObservable: Observable<Action>;
  10438. /**
  10439. * Creates a new Action
  10440. * @param triggerOptions the trigger, with or without parameters, for the action
  10441. * @param condition an optional determinant of action
  10442. */
  10443. constructor(
  10444. /** the trigger, with or without parameters, for the action */
  10445. triggerOptions: any, condition?: Condition);
  10446. /**
  10447. * Internal only
  10448. * @hidden
  10449. */
  10450. _prepare(): void;
  10451. /**
  10452. * Gets the trigger parameters
  10453. * @returns the trigger parameters
  10454. */
  10455. getTriggerParameter(): any;
  10456. /**
  10457. * Internal only - executes current action event
  10458. * @hidden
  10459. */
  10460. _executeCurrent(evt?: ActionEvent): void;
  10461. /**
  10462. * Execute placeholder for child classes
  10463. * @param evt optional action event
  10464. */
  10465. execute(evt?: ActionEvent): void;
  10466. /**
  10467. * Skips to next active action
  10468. */
  10469. skipToNextActiveAction(): void;
  10470. /**
  10471. * Adds action to chain of actions, may be a DoNothingAction
  10472. * @param action defines the next action to execute
  10473. * @returns The action passed in
  10474. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10475. */
  10476. then(action: Action): Action;
  10477. /**
  10478. * Internal only
  10479. * @hidden
  10480. */
  10481. _getProperty(propertyPath: string): string;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. _getEffectiveTarget(target: any, propertyPath: string): any;
  10487. /**
  10488. * Serialize placeholder for child classes
  10489. * @param parent of child
  10490. * @returns the serialized object
  10491. */
  10492. serialize(parent: any): any;
  10493. /**
  10494. * Internal only called by serialize
  10495. * @hidden
  10496. */
  10497. protected _serialize(serializedAction: any, parent?: any): any;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. static _SerializeValueAsString: (value: any) => string;
  10503. /**
  10504. * Internal only
  10505. * @hidden
  10506. */
  10507. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10508. name: string;
  10509. targetType: string;
  10510. value: string;
  10511. };
  10512. }
  10513. }
  10514. declare module "babylonjs/Actions/condition" {
  10515. import { ActionManager } from "babylonjs/Actions/actionManager";
  10516. /**
  10517. * A Condition applied to an Action
  10518. */
  10519. export class Condition {
  10520. /**
  10521. * Internal only - manager for action
  10522. * @hidden
  10523. */
  10524. _actionManager: ActionManager;
  10525. /**
  10526. * Internal only
  10527. * @hidden
  10528. */
  10529. _evaluationId: number;
  10530. /**
  10531. * Internal only
  10532. * @hidden
  10533. */
  10534. _currentResult: boolean;
  10535. /**
  10536. * Creates a new Condition
  10537. * @param actionManager the manager of the action the condition is applied to
  10538. */
  10539. constructor(actionManager: ActionManager);
  10540. /**
  10541. * Check if the current condition is valid
  10542. * @returns a boolean
  10543. */
  10544. isValid(): boolean;
  10545. /**
  10546. * Internal only
  10547. * @hidden
  10548. */
  10549. _getProperty(propertyPath: string): string;
  10550. /**
  10551. * Internal only
  10552. * @hidden
  10553. */
  10554. _getEffectiveTarget(target: any, propertyPath: string): any;
  10555. /**
  10556. * Serialize placeholder for child classes
  10557. * @returns the serialized object
  10558. */
  10559. serialize(): any;
  10560. /**
  10561. * Internal only
  10562. * @hidden
  10563. */
  10564. protected _serialize(serializedCondition: any): any;
  10565. }
  10566. /**
  10567. * Defines specific conditional operators as extensions of Condition
  10568. */
  10569. export class ValueCondition extends Condition {
  10570. /** path to specify the property of the target the conditional operator uses */
  10571. propertyPath: string;
  10572. /** the value compared by the conditional operator against the current value of the property */
  10573. value: any;
  10574. /** the conditional operator, default ValueCondition.IsEqual */
  10575. operator: number;
  10576. /**
  10577. * Internal only
  10578. * @hidden
  10579. */
  10580. private static _IsEqual;
  10581. /**
  10582. * Internal only
  10583. * @hidden
  10584. */
  10585. private static _IsDifferent;
  10586. /**
  10587. * Internal only
  10588. * @hidden
  10589. */
  10590. private static _IsGreater;
  10591. /**
  10592. * Internal only
  10593. * @hidden
  10594. */
  10595. private static _IsLesser;
  10596. /**
  10597. * returns the number for IsEqual
  10598. */
  10599. static readonly IsEqual: number;
  10600. /**
  10601. * Returns the number for IsDifferent
  10602. */
  10603. static readonly IsDifferent: number;
  10604. /**
  10605. * Returns the number for IsGreater
  10606. */
  10607. static readonly IsGreater: number;
  10608. /**
  10609. * Returns the number for IsLesser
  10610. */
  10611. static readonly IsLesser: number;
  10612. /**
  10613. * Internal only The action manager for the condition
  10614. * @hidden
  10615. */
  10616. _actionManager: ActionManager;
  10617. /**
  10618. * Internal only
  10619. * @hidden
  10620. */
  10621. private _target;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. private _effectiveTarget;
  10627. /**
  10628. * Internal only
  10629. * @hidden
  10630. */
  10631. private _property;
  10632. /**
  10633. * Creates a new ValueCondition
  10634. * @param actionManager manager for the action the condition applies to
  10635. * @param target for the action
  10636. * @param propertyPath path to specify the property of the target the conditional operator uses
  10637. * @param value the value compared by the conditional operator against the current value of the property
  10638. * @param operator the conditional operator, default ValueCondition.IsEqual
  10639. */
  10640. constructor(actionManager: ActionManager, target: any,
  10641. /** path to specify the property of the target the conditional operator uses */
  10642. propertyPath: string,
  10643. /** the value compared by the conditional operator against the current value of the property */
  10644. value: any,
  10645. /** the conditional operator, default ValueCondition.IsEqual */
  10646. operator?: number);
  10647. /**
  10648. * Compares the given value with the property value for the specified conditional operator
  10649. * @returns the result of the comparison
  10650. */
  10651. isValid(): boolean;
  10652. /**
  10653. * Serialize the ValueCondition into a JSON compatible object
  10654. * @returns serialization object
  10655. */
  10656. serialize(): any;
  10657. /**
  10658. * Gets the name of the conditional operator for the ValueCondition
  10659. * @param operator the conditional operator
  10660. * @returns the name
  10661. */
  10662. static GetOperatorName(operator: number): string;
  10663. }
  10664. /**
  10665. * Defines a predicate condition as an extension of Condition
  10666. */
  10667. export class PredicateCondition extends Condition {
  10668. /** defines the predicate function used to validate the condition */
  10669. predicate: () => boolean;
  10670. /**
  10671. * Internal only - manager for action
  10672. * @hidden
  10673. */
  10674. _actionManager: ActionManager;
  10675. /**
  10676. * Creates a new PredicateCondition
  10677. * @param actionManager manager for the action the condition applies to
  10678. * @param predicate defines the predicate function used to validate the condition
  10679. */
  10680. constructor(actionManager: ActionManager,
  10681. /** defines the predicate function used to validate the condition */
  10682. predicate: () => boolean);
  10683. /**
  10684. * @returns the validity of the predicate condition
  10685. */
  10686. isValid(): boolean;
  10687. }
  10688. /**
  10689. * Defines a state condition as an extension of Condition
  10690. */
  10691. export class StateCondition extends Condition {
  10692. /** Value to compare with target state */
  10693. value: string;
  10694. /**
  10695. * Internal only - manager for action
  10696. * @hidden
  10697. */
  10698. _actionManager: ActionManager;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. private _target;
  10704. /**
  10705. * Creates a new StateCondition
  10706. * @param actionManager manager for the action the condition applies to
  10707. * @param target of the condition
  10708. * @param value to compare with target state
  10709. */
  10710. constructor(actionManager: ActionManager, target: any,
  10711. /** Value to compare with target state */
  10712. value: string);
  10713. /**
  10714. * Gets a boolean indicating if the current condition is met
  10715. * @returns the validity of the state
  10716. */
  10717. isValid(): boolean;
  10718. /**
  10719. * Serialize the StateCondition into a JSON compatible object
  10720. * @returns serialization object
  10721. */
  10722. serialize(): any;
  10723. }
  10724. }
  10725. declare module "babylonjs/Actions/directActions" {
  10726. import { Action } from "babylonjs/Actions/action";
  10727. import { Condition } from "babylonjs/Actions/condition";
  10728. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10729. /**
  10730. * This defines an action responsible to toggle a boolean once triggered.
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10732. */
  10733. export class SwitchBooleanAction extends Action {
  10734. /**
  10735. * The path to the boolean property in the target object
  10736. */
  10737. propertyPath: string;
  10738. private _target;
  10739. private _effectiveTarget;
  10740. private _property;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param target defines the object containing the boolean
  10745. * @param propertyPath defines the path to the boolean property in the target object
  10746. * @param condition defines the trigger related conditions
  10747. */
  10748. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10749. /** @hidden */
  10750. _prepare(): void;
  10751. /**
  10752. * Execute the action toggle the boolean value.
  10753. */
  10754. execute(): void;
  10755. /**
  10756. * Serializes the actions and its related information.
  10757. * @param parent defines the object to serialize in
  10758. * @returns the serialized object
  10759. */
  10760. serialize(parent: any): any;
  10761. }
  10762. /**
  10763. * This defines an action responsible to set a the state field of the target
  10764. * to a desired value once triggered.
  10765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10766. */
  10767. export class SetStateAction extends Action {
  10768. /**
  10769. * The value to store in the state field.
  10770. */
  10771. value: string;
  10772. private _target;
  10773. /**
  10774. * Instantiate the action
  10775. * @param triggerOptions defines the trigger options
  10776. * @param target defines the object containing the state property
  10777. * @param value defines the value to store in the state field
  10778. * @param condition defines the trigger related conditions
  10779. */
  10780. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10781. /**
  10782. * Execute the action and store the value on the target state property.
  10783. */
  10784. execute(): void;
  10785. /**
  10786. * Serializes the actions and its related information.
  10787. * @param parent defines the object to serialize in
  10788. * @returns the serialized object
  10789. */
  10790. serialize(parent: any): any;
  10791. }
  10792. /**
  10793. * This defines an action responsible to set a property of the target
  10794. * to a desired value once triggered.
  10795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10796. */
  10797. export class SetValueAction extends Action {
  10798. /**
  10799. * The path of the property to set in the target.
  10800. */
  10801. propertyPath: string;
  10802. /**
  10803. * The value to set in the property
  10804. */
  10805. value: any;
  10806. private _target;
  10807. private _effectiveTarget;
  10808. private _property;
  10809. /**
  10810. * Instantiate the action
  10811. * @param triggerOptions defines the trigger options
  10812. * @param target defines the object containing the property
  10813. * @param propertyPath defines the path of the property to set in the target
  10814. * @param value defines the value to set in the property
  10815. * @param condition defines the trigger related conditions
  10816. */
  10817. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10818. /** @hidden */
  10819. _prepare(): void;
  10820. /**
  10821. * Execute the action and set the targetted property to the desired value.
  10822. */
  10823. execute(): void;
  10824. /**
  10825. * Serializes the actions and its related information.
  10826. * @param parent defines the object to serialize in
  10827. * @returns the serialized object
  10828. */
  10829. serialize(parent: any): any;
  10830. }
  10831. /**
  10832. * This defines an action responsible to increment the target value
  10833. * to a desired value once triggered.
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10835. */
  10836. export class IncrementValueAction extends Action {
  10837. /**
  10838. * The path of the property to increment in the target.
  10839. */
  10840. propertyPath: string;
  10841. /**
  10842. * The value we should increment the property by.
  10843. */
  10844. value: any;
  10845. private _target;
  10846. private _effectiveTarget;
  10847. private _property;
  10848. /**
  10849. * Instantiate the action
  10850. * @param triggerOptions defines the trigger options
  10851. * @param target defines the object containing the property
  10852. * @param propertyPath defines the path of the property to increment in the target
  10853. * @param value defines the value value we should increment the property by
  10854. * @param condition defines the trigger related conditions
  10855. */
  10856. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10857. /** @hidden */
  10858. _prepare(): void;
  10859. /**
  10860. * Execute the action and increment the target of the value amount.
  10861. */
  10862. execute(): void;
  10863. /**
  10864. * Serializes the actions and its related information.
  10865. * @param parent defines the object to serialize in
  10866. * @returns the serialized object
  10867. */
  10868. serialize(parent: any): any;
  10869. }
  10870. /**
  10871. * This defines an action responsible to start an animation once triggered.
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10873. */
  10874. export class PlayAnimationAction extends Action {
  10875. /**
  10876. * Where the animation should start (animation frame)
  10877. */
  10878. from: number;
  10879. /**
  10880. * Where the animation should stop (animation frame)
  10881. */
  10882. to: number;
  10883. /**
  10884. * Define if the animation should loop or stop after the first play.
  10885. */
  10886. loop?: boolean;
  10887. private _target;
  10888. /**
  10889. * Instantiate the action
  10890. * @param triggerOptions defines the trigger options
  10891. * @param target defines the target animation or animation name
  10892. * @param from defines from where the animation should start (animation frame)
  10893. * @param end defines where the animation should stop (animation frame)
  10894. * @param loop defines if the animation should loop or stop after the first play
  10895. * @param condition defines the trigger related conditions
  10896. */
  10897. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10898. /** @hidden */
  10899. _prepare(): void;
  10900. /**
  10901. * Execute the action and play the animation.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. /**
  10912. * This defines an action responsible to stop an animation once triggered.
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10914. */
  10915. export class StopAnimationAction extends Action {
  10916. private _target;
  10917. /**
  10918. * Instantiate the action
  10919. * @param triggerOptions defines the trigger options
  10920. * @param target defines the target animation or animation name
  10921. * @param condition defines the trigger related conditions
  10922. */
  10923. constructor(triggerOptions: any, target: any, condition?: Condition);
  10924. /** @hidden */
  10925. _prepare(): void;
  10926. /**
  10927. * Execute the action and stop the animation.
  10928. */
  10929. execute(): void;
  10930. /**
  10931. * Serializes the actions and its related information.
  10932. * @param parent defines the object to serialize in
  10933. * @returns the serialized object
  10934. */
  10935. serialize(parent: any): any;
  10936. }
  10937. /**
  10938. * This defines an action responsible that does nothing once triggered.
  10939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10940. */
  10941. export class DoNothingAction extends Action {
  10942. /**
  10943. * Instantiate the action
  10944. * @param triggerOptions defines the trigger options
  10945. * @param condition defines the trigger related conditions
  10946. */
  10947. constructor(triggerOptions?: any, condition?: Condition);
  10948. /**
  10949. * Execute the action and do nothing.
  10950. */
  10951. execute(): void;
  10952. /**
  10953. * Serializes the actions and its related information.
  10954. * @param parent defines the object to serialize in
  10955. * @returns the serialized object
  10956. */
  10957. serialize(parent: any): any;
  10958. }
  10959. /**
  10960. * This defines an action responsible to trigger several actions once triggered.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class CombineAction extends Action {
  10964. /**
  10965. * The list of aggregated animations to run.
  10966. */
  10967. children: Action[];
  10968. /**
  10969. * Instantiate the action
  10970. * @param triggerOptions defines the trigger options
  10971. * @param children defines the list of aggregated animations to run
  10972. * @param condition defines the trigger related conditions
  10973. */
  10974. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10975. /** @hidden */
  10976. _prepare(): void;
  10977. /**
  10978. * Execute the action and executes all the aggregated actions.
  10979. */
  10980. execute(evt: ActionEvent): void;
  10981. /**
  10982. * Serializes the actions and its related information.
  10983. * @param parent defines the object to serialize in
  10984. * @returns the serialized object
  10985. */
  10986. serialize(parent: any): any;
  10987. }
  10988. /**
  10989. * This defines an action responsible to run code (external event) once triggered.
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10991. */
  10992. export class ExecuteCodeAction extends Action {
  10993. /**
  10994. * The callback function to run.
  10995. */
  10996. func: (evt: ActionEvent) => void;
  10997. /**
  10998. * Instantiate the action
  10999. * @param triggerOptions defines the trigger options
  11000. * @param func defines the callback function to run
  11001. * @param condition defines the trigger related conditions
  11002. */
  11003. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11004. /**
  11005. * Execute the action and run the attached code.
  11006. */
  11007. execute(evt: ActionEvent): void;
  11008. }
  11009. /**
  11010. * This defines an action responsible to set the parent property of the target once triggered.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class SetParentAction extends Action {
  11014. private _parent;
  11015. private _target;
  11016. /**
  11017. * Instantiate the action
  11018. * @param triggerOptions defines the trigger options
  11019. * @param target defines the target containing the parent property
  11020. * @param parent defines from where the animation should start (animation frame)
  11021. * @param condition defines the trigger related conditions
  11022. */
  11023. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11024. /** @hidden */
  11025. _prepare(): void;
  11026. /**
  11027. * Execute the action and set the parent property.
  11028. */
  11029. execute(): void;
  11030. /**
  11031. * Serializes the actions and its related information.
  11032. * @param parent defines the object to serialize in
  11033. * @returns the serialized object
  11034. */
  11035. serialize(parent: any): any;
  11036. }
  11037. }
  11038. declare module "babylonjs/Actions/actionManager" {
  11039. import { Nullable } from "babylonjs/types";
  11040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11041. import { Scene } from "babylonjs/scene";
  11042. import { IAction } from "babylonjs/Actions/action";
  11043. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11044. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11045. /**
  11046. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11047. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11049. */
  11050. export class ActionManager extends AbstractActionManager {
  11051. /**
  11052. * Nothing
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11054. */
  11055. static readonly NothingTrigger: number;
  11056. /**
  11057. * On pick
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly OnPickTrigger: number;
  11061. /**
  11062. * On left pick
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnLeftPickTrigger: number;
  11066. /**
  11067. * On right pick
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnRightPickTrigger: number;
  11071. /**
  11072. * On center pick
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnCenterPickTrigger: number;
  11076. /**
  11077. * On pick down
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnPickDownTrigger: number;
  11081. /**
  11082. * On double pick
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnDoublePickTrigger: number;
  11086. /**
  11087. * On pick up
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnPickUpTrigger: number;
  11091. /**
  11092. * On pick out.
  11093. * This trigger will only be raised if you also declared a OnPickDown
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11095. */
  11096. static readonly OnPickOutTrigger: number;
  11097. /**
  11098. * On long press
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnLongPressTrigger: number;
  11102. /**
  11103. * On pointer over
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnPointerOverTrigger: number;
  11107. /**
  11108. * On pointer out
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11110. */
  11111. static readonly OnPointerOutTrigger: number;
  11112. /**
  11113. * On every frame
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11115. */
  11116. static readonly OnEveryFrameTrigger: number;
  11117. /**
  11118. * On intersection enter
  11119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11120. */
  11121. static readonly OnIntersectionEnterTrigger: number;
  11122. /**
  11123. * On intersection exit
  11124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11125. */
  11126. static readonly OnIntersectionExitTrigger: number;
  11127. /**
  11128. * On key down
  11129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11130. */
  11131. static readonly OnKeyDownTrigger: number;
  11132. /**
  11133. * On key up
  11134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11135. */
  11136. static readonly OnKeyUpTrigger: number;
  11137. private _scene;
  11138. /**
  11139. * Creates a new action manager
  11140. * @param scene defines the hosting scene
  11141. */
  11142. constructor(scene: Scene);
  11143. /**
  11144. * Releases all associated resources
  11145. */
  11146. dispose(): void;
  11147. /**
  11148. * Gets hosting scene
  11149. * @returns the hosting scene
  11150. */
  11151. getScene(): Scene;
  11152. /**
  11153. * Does this action manager handles actions of any of the given triggers
  11154. * @param triggers defines the triggers to be tested
  11155. * @return a boolean indicating whether one (or more) of the triggers is handled
  11156. */
  11157. hasSpecificTriggers(triggers: number[]): boolean;
  11158. /**
  11159. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11160. * speed.
  11161. * @param triggerA defines the trigger to be tested
  11162. * @param triggerB defines the trigger to be tested
  11163. * @return a boolean indicating whether one (or more) of the triggers is handled
  11164. */
  11165. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11166. /**
  11167. * Does this action manager handles actions of a given trigger
  11168. * @param trigger defines the trigger to be tested
  11169. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11170. * @return whether the trigger is handled
  11171. */
  11172. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11173. /**
  11174. * Does this action manager has pointer triggers
  11175. */
  11176. readonly hasPointerTriggers: boolean;
  11177. /**
  11178. * Does this action manager has pick triggers
  11179. */
  11180. readonly hasPickTriggers: boolean;
  11181. /**
  11182. * Registers an action to this action manager
  11183. * @param action defines the action to be registered
  11184. * @return the action amended (prepared) after registration
  11185. */
  11186. registerAction(action: IAction): Nullable<IAction>;
  11187. /**
  11188. * Unregisters an action to this action manager
  11189. * @param action defines the action to be unregistered
  11190. * @return a boolean indicating whether the action has been unregistered
  11191. */
  11192. unregisterAction(action: IAction): Boolean;
  11193. /**
  11194. * Process a specific trigger
  11195. * @param trigger defines the trigger to process
  11196. * @param evt defines the event details to be processed
  11197. */
  11198. processTrigger(trigger: number, evt?: IActionEvent): void;
  11199. /** @hidden */
  11200. _getEffectiveTarget(target: any, propertyPath: string): any;
  11201. /** @hidden */
  11202. _getProperty(propertyPath: string): string;
  11203. /**
  11204. * Serialize this manager to a JSON object
  11205. * @param name defines the property name to store this manager
  11206. * @returns a JSON representation of this manager
  11207. */
  11208. serialize(name: string): any;
  11209. /**
  11210. * Creates a new ActionManager from a JSON data
  11211. * @param parsedActions defines the JSON data to read from
  11212. * @param object defines the hosting mesh
  11213. * @param scene defines the hosting scene
  11214. */
  11215. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11216. /**
  11217. * Get a trigger name by index
  11218. * @param trigger defines the trigger index
  11219. * @returns a trigger name
  11220. */
  11221. static GetTriggerName(trigger: number): string;
  11222. }
  11223. }
  11224. declare module "babylonjs/Culling/ray" {
  11225. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11226. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11228. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11229. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11230. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11231. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11232. import { Plane } from "babylonjs/Maths/math.plane";
  11233. /**
  11234. * Class representing a ray with position and direction
  11235. */
  11236. export class Ray {
  11237. /** origin point */
  11238. origin: Vector3;
  11239. /** direction */
  11240. direction: Vector3;
  11241. /** length of the ray */
  11242. length: number;
  11243. private static readonly TmpVector3;
  11244. private _tmpRay;
  11245. /**
  11246. * Creates a new ray
  11247. * @param origin origin point
  11248. * @param direction direction
  11249. * @param length length of the ray
  11250. */
  11251. constructor(
  11252. /** origin point */
  11253. origin: Vector3,
  11254. /** direction */
  11255. direction: Vector3,
  11256. /** length of the ray */
  11257. length?: number);
  11258. /**
  11259. * Checks if the ray intersects a box
  11260. * @param minimum bound of the box
  11261. * @param maximum bound of the box
  11262. * @param intersectionTreshold extra extend to be added to the box in all direction
  11263. * @returns if the box was hit
  11264. */
  11265. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11266. /**
  11267. * Checks if the ray intersects a box
  11268. * @param box the bounding box to check
  11269. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11270. * @returns if the box was hit
  11271. */
  11272. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11273. /**
  11274. * If the ray hits a sphere
  11275. * @param sphere the bounding sphere to check
  11276. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11277. * @returns true if it hits the sphere
  11278. */
  11279. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11280. /**
  11281. * If the ray hits a triange
  11282. * @param vertex0 triangle vertex
  11283. * @param vertex1 triangle vertex
  11284. * @param vertex2 triangle vertex
  11285. * @returns intersection information if hit
  11286. */
  11287. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11288. /**
  11289. * Checks if ray intersects a plane
  11290. * @param plane the plane to check
  11291. * @returns the distance away it was hit
  11292. */
  11293. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11294. /**
  11295. * Calculate the intercept of a ray on a given axis
  11296. * @param axis to check 'x' | 'y' | 'z'
  11297. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11298. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11299. */
  11300. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11301. /**
  11302. * Checks if ray intersects a mesh
  11303. * @param mesh the mesh to check
  11304. * @param fastCheck if only the bounding box should checked
  11305. * @returns picking info of the intersecton
  11306. */
  11307. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11308. /**
  11309. * Checks if ray intersects a mesh
  11310. * @param meshes the meshes to check
  11311. * @param fastCheck if only the bounding box should checked
  11312. * @param results array to store result in
  11313. * @returns Array of picking infos
  11314. */
  11315. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11316. private _comparePickingInfo;
  11317. private static smallnum;
  11318. private static rayl;
  11319. /**
  11320. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11321. * @param sega the first point of the segment to test the intersection against
  11322. * @param segb the second point of the segment to test the intersection against
  11323. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11324. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11325. */
  11326. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11327. /**
  11328. * Update the ray from viewport position
  11329. * @param x position
  11330. * @param y y position
  11331. * @param viewportWidth viewport width
  11332. * @param viewportHeight viewport height
  11333. * @param world world matrix
  11334. * @param view view matrix
  11335. * @param projection projection matrix
  11336. * @returns this ray updated
  11337. */
  11338. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11339. /**
  11340. * Creates a ray with origin and direction of 0,0,0
  11341. * @returns the new ray
  11342. */
  11343. static Zero(): Ray;
  11344. /**
  11345. * Creates a new ray from screen space and viewport
  11346. * @param x position
  11347. * @param y y position
  11348. * @param viewportWidth viewport width
  11349. * @param viewportHeight viewport height
  11350. * @param world world matrix
  11351. * @param view view matrix
  11352. * @param projection projection matrix
  11353. * @returns new ray
  11354. */
  11355. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11356. /**
  11357. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11358. * transformed to the given world matrix.
  11359. * @param origin The origin point
  11360. * @param end The end point
  11361. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11362. * @returns the new ray
  11363. */
  11364. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11365. /**
  11366. * Transforms a ray by a matrix
  11367. * @param ray ray to transform
  11368. * @param matrix matrix to apply
  11369. * @returns the resulting new ray
  11370. */
  11371. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11372. /**
  11373. * Transforms a ray by a matrix
  11374. * @param ray ray to transform
  11375. * @param matrix matrix to apply
  11376. * @param result ray to store result in
  11377. */
  11378. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11379. /**
  11380. * Unproject a ray from screen space to object space
  11381. * @param sourceX defines the screen space x coordinate to use
  11382. * @param sourceY defines the screen space y coordinate to use
  11383. * @param viewportWidth defines the current width of the viewport
  11384. * @param viewportHeight defines the current height of the viewport
  11385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11386. * @param view defines the view matrix to use
  11387. * @param projection defines the projection matrix to use
  11388. */
  11389. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11390. }
  11391. /**
  11392. * Type used to define predicate used to select faces when a mesh intersection is detected
  11393. */
  11394. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11395. module "babylonjs/scene" {
  11396. interface Scene {
  11397. /** @hidden */
  11398. _tempPickingRay: Nullable<Ray>;
  11399. /** @hidden */
  11400. _cachedRayForTransform: Ray;
  11401. /** @hidden */
  11402. _pickWithRayInverseMatrix: Matrix;
  11403. /** @hidden */
  11404. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11405. /** @hidden */
  11406. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11407. }
  11408. }
  11409. }
  11410. declare module "babylonjs/sceneComponent" {
  11411. import { Scene } from "babylonjs/scene";
  11412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11413. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11414. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11415. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11416. import { Nullable } from "babylonjs/types";
  11417. import { Camera } from "babylonjs/Cameras/camera";
  11418. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11419. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11420. import { AbstractScene } from "babylonjs/abstractScene";
  11421. import { Mesh } from "babylonjs/Meshes/mesh";
  11422. /**
  11423. * Groups all the scene component constants in one place to ease maintenance.
  11424. * @hidden
  11425. */
  11426. export class SceneComponentConstants {
  11427. static readonly NAME_EFFECTLAYER: string;
  11428. static readonly NAME_LAYER: string;
  11429. static readonly NAME_LENSFLARESYSTEM: string;
  11430. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11431. static readonly NAME_PARTICLESYSTEM: string;
  11432. static readonly NAME_GAMEPAD: string;
  11433. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11434. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11435. static readonly NAME_DEPTHRENDERER: string;
  11436. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11437. static readonly NAME_SPRITE: string;
  11438. static readonly NAME_OUTLINERENDERER: string;
  11439. static readonly NAME_PROCEDURALTEXTURE: string;
  11440. static readonly NAME_SHADOWGENERATOR: string;
  11441. static readonly NAME_OCTREE: string;
  11442. static readonly NAME_PHYSICSENGINE: string;
  11443. static readonly NAME_AUDIO: string;
  11444. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11445. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11446. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11447. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11448. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11449. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11450. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11451. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11452. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11453. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11454. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11455. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11456. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11457. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11458. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11459. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11460. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11461. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11462. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11463. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11464. static readonly STEP_AFTERRENDER_AUDIO: number;
  11465. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11466. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11467. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11468. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11469. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11470. static readonly STEP_POINTERMOVE_SPRITE: number;
  11471. static readonly STEP_POINTERDOWN_SPRITE: number;
  11472. static readonly STEP_POINTERUP_SPRITE: number;
  11473. }
  11474. /**
  11475. * This represents a scene component.
  11476. *
  11477. * This is used to decouple the dependency the scene is having on the different workloads like
  11478. * layers, post processes...
  11479. */
  11480. export interface ISceneComponent {
  11481. /**
  11482. * The name of the component. Each component must have a unique name.
  11483. */
  11484. name: string;
  11485. /**
  11486. * The scene the component belongs to.
  11487. */
  11488. scene: Scene;
  11489. /**
  11490. * Register the component to one instance of a scene.
  11491. */
  11492. register(): void;
  11493. /**
  11494. * Rebuilds the elements related to this component in case of
  11495. * context lost for instance.
  11496. */
  11497. rebuild(): void;
  11498. /**
  11499. * Disposes the component and the associated ressources.
  11500. */
  11501. dispose(): void;
  11502. }
  11503. /**
  11504. * This represents a SERIALIZABLE scene component.
  11505. *
  11506. * This extends Scene Component to add Serialization methods on top.
  11507. */
  11508. export interface ISceneSerializableComponent extends ISceneComponent {
  11509. /**
  11510. * Adds all the elements from the container to the scene
  11511. * @param container the container holding the elements
  11512. */
  11513. addFromContainer(container: AbstractScene): void;
  11514. /**
  11515. * Removes all the elements in the container from the scene
  11516. * @param container contains the elements to remove
  11517. * @param dispose if the removed element should be disposed (default: false)
  11518. */
  11519. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11520. /**
  11521. * Serializes the component data to the specified json object
  11522. * @param serializationObject The object to serialize to
  11523. */
  11524. serialize(serializationObject: any): void;
  11525. }
  11526. /**
  11527. * Strong typing of a Mesh related stage step action
  11528. */
  11529. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11530. /**
  11531. * Strong typing of a Evaluate Sub Mesh related stage step action
  11532. */
  11533. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11534. /**
  11535. * Strong typing of a Active Mesh related stage step action
  11536. */
  11537. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11538. /**
  11539. * Strong typing of a Camera related stage step action
  11540. */
  11541. export type CameraStageAction = (camera: Camera) => void;
  11542. /**
  11543. * Strong typing of a Camera Frame buffer related stage step action
  11544. */
  11545. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11546. /**
  11547. * Strong typing of a Render Target related stage step action
  11548. */
  11549. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11550. /**
  11551. * Strong typing of a RenderingGroup related stage step action
  11552. */
  11553. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11554. /**
  11555. * Strong typing of a Mesh Render related stage step action
  11556. */
  11557. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11558. /**
  11559. * Strong typing of a simple stage step action
  11560. */
  11561. export type SimpleStageAction = () => void;
  11562. /**
  11563. * Strong typing of a render target action.
  11564. */
  11565. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11566. /**
  11567. * Strong typing of a pointer move action.
  11568. */
  11569. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11570. /**
  11571. * Strong typing of a pointer up/down action.
  11572. */
  11573. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11574. /**
  11575. * Representation of a stage in the scene (Basically a list of ordered steps)
  11576. * @hidden
  11577. */
  11578. export class Stage<T extends Function> extends Array<{
  11579. index: number;
  11580. component: ISceneComponent;
  11581. action: T;
  11582. }> {
  11583. /**
  11584. * Hide ctor from the rest of the world.
  11585. * @param items The items to add.
  11586. */
  11587. private constructor();
  11588. /**
  11589. * Creates a new Stage.
  11590. * @returns A new instance of a Stage
  11591. */
  11592. static Create<T extends Function>(): Stage<T>;
  11593. /**
  11594. * Registers a step in an ordered way in the targeted stage.
  11595. * @param index Defines the position to register the step in
  11596. * @param component Defines the component attached to the step
  11597. * @param action Defines the action to launch during the step
  11598. */
  11599. registerStep(index: number, component: ISceneComponent, action: T): void;
  11600. /**
  11601. * Clears all the steps from the stage.
  11602. */
  11603. clear(): void;
  11604. }
  11605. }
  11606. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11607. import { Nullable } from "babylonjs/types";
  11608. import { Observable } from "babylonjs/Misc/observable";
  11609. import { Scene } from "babylonjs/scene";
  11610. import { Sprite } from "babylonjs/Sprites/sprite";
  11611. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11612. import { Ray } from "babylonjs/Culling/ray";
  11613. import { Camera } from "babylonjs/Cameras/camera";
  11614. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11615. import { ISceneComponent } from "babylonjs/sceneComponent";
  11616. module "babylonjs/scene" {
  11617. interface Scene {
  11618. /** @hidden */
  11619. _pointerOverSprite: Nullable<Sprite>;
  11620. /** @hidden */
  11621. _pickedDownSprite: Nullable<Sprite>;
  11622. /** @hidden */
  11623. _tempSpritePickingRay: Nullable<Ray>;
  11624. /**
  11625. * All of the sprite managers added to this scene
  11626. * @see http://doc.babylonjs.com/babylon101/sprites
  11627. */
  11628. spriteManagers: Array<ISpriteManager>;
  11629. /**
  11630. * An event triggered when sprites rendering is about to start
  11631. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11632. */
  11633. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11634. /**
  11635. * An event triggered when sprites rendering is done
  11636. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11637. */
  11638. onAfterSpritesRenderingObservable: Observable<Scene>;
  11639. /** @hidden */
  11640. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11641. /** Launch a ray to try to pick a sprite in the scene
  11642. * @param x position on screen
  11643. * @param y position on screen
  11644. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11645. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11646. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11647. * @returns a PickingInfo
  11648. */
  11649. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11650. /** Use the given ray to pick a sprite in the scene
  11651. * @param ray The ray (in world space) to use to pick meshes
  11652. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11653. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11654. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11655. * @returns a PickingInfo
  11656. */
  11657. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11658. /** @hidden */
  11659. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11660. /** Launch a ray to try to pick sprites in the scene
  11661. * @param x position on screen
  11662. * @param y position on screen
  11663. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11664. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11665. * @returns a PickingInfo array
  11666. */
  11667. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11668. /** Use the given ray to pick sprites in the scene
  11669. * @param ray The ray (in world space) to use to pick meshes
  11670. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11671. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11672. * @returns a PickingInfo array
  11673. */
  11674. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11675. /**
  11676. * Force the sprite under the pointer
  11677. * @param sprite defines the sprite to use
  11678. */
  11679. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11680. /**
  11681. * Gets the sprite under the pointer
  11682. * @returns a Sprite or null if no sprite is under the pointer
  11683. */
  11684. getPointerOverSprite(): Nullable<Sprite>;
  11685. }
  11686. }
  11687. /**
  11688. * Defines the sprite scene component responsible to manage sprites
  11689. * in a given scene.
  11690. */
  11691. export class SpriteSceneComponent implements ISceneComponent {
  11692. /**
  11693. * The component name helpfull to identify the component in the list of scene components.
  11694. */
  11695. readonly name: string;
  11696. /**
  11697. * The scene the component belongs to.
  11698. */
  11699. scene: Scene;
  11700. /** @hidden */
  11701. private _spritePredicate;
  11702. /**
  11703. * Creates a new instance of the component for the given scene
  11704. * @param scene Defines the scene to register the component in
  11705. */
  11706. constructor(scene: Scene);
  11707. /**
  11708. * Registers the component in a given scene
  11709. */
  11710. register(): void;
  11711. /**
  11712. * Rebuilds the elements related to this component in case of
  11713. * context lost for instance.
  11714. */
  11715. rebuild(): void;
  11716. /**
  11717. * Disposes the component and the associated ressources.
  11718. */
  11719. dispose(): void;
  11720. private _pickSpriteButKeepRay;
  11721. private _pointerMove;
  11722. private _pointerDown;
  11723. private _pointerUp;
  11724. }
  11725. }
  11726. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11727. /** @hidden */
  11728. export var fogFragmentDeclaration: {
  11729. name: string;
  11730. shader: string;
  11731. };
  11732. }
  11733. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11734. /** @hidden */
  11735. export var fogFragment: {
  11736. name: string;
  11737. shader: string;
  11738. };
  11739. }
  11740. declare module "babylonjs/Shaders/sprites.fragment" {
  11741. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11742. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11743. /** @hidden */
  11744. export var spritesPixelShader: {
  11745. name: string;
  11746. shader: string;
  11747. };
  11748. }
  11749. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11750. /** @hidden */
  11751. export var fogVertexDeclaration: {
  11752. name: string;
  11753. shader: string;
  11754. };
  11755. }
  11756. declare module "babylonjs/Shaders/sprites.vertex" {
  11757. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11758. /** @hidden */
  11759. export var spritesVertexShader: {
  11760. name: string;
  11761. shader: string;
  11762. };
  11763. }
  11764. declare module "babylonjs/Sprites/spriteManager" {
  11765. import { IDisposable, Scene } from "babylonjs/scene";
  11766. import { Nullable } from "babylonjs/types";
  11767. import { Observable } from "babylonjs/Misc/observable";
  11768. import { Sprite } from "babylonjs/Sprites/sprite";
  11769. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11770. import { Camera } from "babylonjs/Cameras/camera";
  11771. import { Texture } from "babylonjs/Materials/Textures/texture";
  11772. import "babylonjs/Shaders/sprites.fragment";
  11773. import "babylonjs/Shaders/sprites.vertex";
  11774. import { Ray } from "babylonjs/Culling/ray";
  11775. /**
  11776. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11777. */
  11778. export interface ISpriteManager extends IDisposable {
  11779. /**
  11780. * Restricts the camera to viewing objects with the same layerMask.
  11781. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11782. */
  11783. layerMask: number;
  11784. /**
  11785. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11786. */
  11787. isPickable: boolean;
  11788. /**
  11789. * Specifies the rendering group id for this mesh (0 by default)
  11790. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11791. */
  11792. renderingGroupId: number;
  11793. /**
  11794. * Defines the list of sprites managed by the manager.
  11795. */
  11796. sprites: Array<Sprite>;
  11797. /**
  11798. * Tests the intersection of a sprite with a specific ray.
  11799. * @param ray The ray we are sending to test the collision
  11800. * @param camera The camera space we are sending rays in
  11801. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11802. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11803. * @returns picking info or null.
  11804. */
  11805. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11806. /**
  11807. * Intersects the sprites with a ray
  11808. * @param ray defines the ray to intersect with
  11809. * @param camera defines the current active camera
  11810. * @param predicate defines a predicate used to select candidate sprites
  11811. * @returns null if no hit or a PickingInfo array
  11812. */
  11813. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11814. /**
  11815. * Renders the list of sprites on screen.
  11816. */
  11817. render(): void;
  11818. }
  11819. /**
  11820. * Class used to manage multiple sprites on the same spritesheet
  11821. * @see http://doc.babylonjs.com/babylon101/sprites
  11822. */
  11823. export class SpriteManager implements ISpriteManager {
  11824. /** defines the manager's name */
  11825. name: string;
  11826. /** Gets the list of sprites */
  11827. sprites: Sprite[];
  11828. /** Gets or sets the rendering group id (0 by default) */
  11829. renderingGroupId: number;
  11830. /** Gets or sets camera layer mask */
  11831. layerMask: number;
  11832. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11833. fogEnabled: boolean;
  11834. /** Gets or sets a boolean indicating if the sprites are pickable */
  11835. isPickable: boolean;
  11836. /** Defines the default width of a cell in the spritesheet */
  11837. cellWidth: number;
  11838. /** Defines the default height of a cell in the spritesheet */
  11839. cellHeight: number;
  11840. /** Associative array from JSON sprite data file */
  11841. private _cellData;
  11842. /** Array of sprite names from JSON sprite data file */
  11843. private _spriteMap;
  11844. /** True when packed cell data from JSON file is ready*/
  11845. private _packedAndReady;
  11846. /**
  11847. * An event triggered when the manager is disposed.
  11848. */
  11849. onDisposeObservable: Observable<SpriteManager>;
  11850. private _onDisposeObserver;
  11851. /**
  11852. * Callback called when the manager is disposed
  11853. */
  11854. onDispose: () => void;
  11855. private _capacity;
  11856. private _fromPacked;
  11857. private _spriteTexture;
  11858. private _epsilon;
  11859. private _scene;
  11860. private _vertexData;
  11861. private _buffer;
  11862. private _vertexBuffers;
  11863. private _indexBuffer;
  11864. private _effectBase;
  11865. private _effectFog;
  11866. /**
  11867. * Gets or sets the spritesheet texture
  11868. */
  11869. texture: Texture;
  11870. /**
  11871. * Creates a new sprite manager
  11872. * @param name defines the manager's name
  11873. * @param imgUrl defines the sprite sheet url
  11874. * @param capacity defines the maximum allowed number of sprites
  11875. * @param cellSize defines the size of a sprite cell
  11876. * @param scene defines the hosting scene
  11877. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11878. * @param samplingMode defines the smapling mode to use with spritesheet
  11879. * @param fromPacked set to false; do not alter
  11880. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11881. */
  11882. constructor(
  11883. /** defines the manager's name */
  11884. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11885. private _makePacked;
  11886. private _appendSpriteVertex;
  11887. /**
  11888. * Intersects the sprites with a ray
  11889. * @param ray defines the ray to intersect with
  11890. * @param camera defines the current active camera
  11891. * @param predicate defines a predicate used to select candidate sprites
  11892. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11893. * @returns null if no hit or a PickingInfo
  11894. */
  11895. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11896. /**
  11897. * Intersects the sprites with a ray
  11898. * @param ray defines the ray to intersect with
  11899. * @param camera defines the current active camera
  11900. * @param predicate defines a predicate used to select candidate sprites
  11901. * @returns null if no hit or a PickingInfo array
  11902. */
  11903. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11904. /**
  11905. * Render all child sprites
  11906. */
  11907. render(): void;
  11908. /**
  11909. * Release associated resources
  11910. */
  11911. dispose(): void;
  11912. }
  11913. }
  11914. declare module "babylonjs/Sprites/sprite" {
  11915. import { Vector3 } from "babylonjs/Maths/math.vector";
  11916. import { Nullable } from "babylonjs/types";
  11917. import { ActionManager } from "babylonjs/Actions/actionManager";
  11918. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11919. import { Color4 } from "babylonjs/Maths/math.color";
  11920. /**
  11921. * Class used to represent a sprite
  11922. * @see http://doc.babylonjs.com/babylon101/sprites
  11923. */
  11924. export class Sprite {
  11925. /** defines the name */
  11926. name: string;
  11927. /** Gets or sets the current world position */
  11928. position: Vector3;
  11929. /** Gets or sets the main color */
  11930. color: Color4;
  11931. /** Gets or sets the width */
  11932. width: number;
  11933. /** Gets or sets the height */
  11934. height: number;
  11935. /** Gets or sets rotation angle */
  11936. angle: number;
  11937. /** Gets or sets the cell index in the sprite sheet */
  11938. cellIndex: number;
  11939. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11940. cellRef: string;
  11941. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11942. invertU: number;
  11943. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11944. invertV: number;
  11945. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11946. disposeWhenFinishedAnimating: boolean;
  11947. /** Gets the list of attached animations */
  11948. animations: Animation[];
  11949. /** Gets or sets a boolean indicating if the sprite can be picked */
  11950. isPickable: boolean;
  11951. /**
  11952. * Gets or sets the associated action manager
  11953. */
  11954. actionManager: Nullable<ActionManager>;
  11955. private _animationStarted;
  11956. private _loopAnimation;
  11957. private _fromIndex;
  11958. private _toIndex;
  11959. private _delay;
  11960. private _direction;
  11961. private _manager;
  11962. private _time;
  11963. private _onAnimationEnd;
  11964. /**
  11965. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11966. */
  11967. isVisible: boolean;
  11968. /**
  11969. * Gets or sets the sprite size
  11970. */
  11971. size: number;
  11972. /**
  11973. * Creates a new Sprite
  11974. * @param name defines the name
  11975. * @param manager defines the manager
  11976. */
  11977. constructor(
  11978. /** defines the name */
  11979. name: string, manager: ISpriteManager);
  11980. /**
  11981. * Starts an animation
  11982. * @param from defines the initial key
  11983. * @param to defines the end key
  11984. * @param loop defines if the animation must loop
  11985. * @param delay defines the start delay (in ms)
  11986. * @param onAnimationEnd defines a callback to call when animation ends
  11987. */
  11988. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11989. /** Stops current animation (if any) */
  11990. stopAnimation(): void;
  11991. /** @hidden */
  11992. _animate(deltaTime: number): void;
  11993. /** Release associated resources */
  11994. dispose(): void;
  11995. }
  11996. }
  11997. declare module "babylonjs/Collisions/pickingInfo" {
  11998. import { Nullable } from "babylonjs/types";
  11999. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12001. import { Sprite } from "babylonjs/Sprites/sprite";
  12002. import { Ray } from "babylonjs/Culling/ray";
  12003. /**
  12004. * Information about the result of picking within a scene
  12005. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12006. */
  12007. export class PickingInfo {
  12008. /** @hidden */
  12009. _pickingUnavailable: boolean;
  12010. /**
  12011. * If the pick collided with an object
  12012. */
  12013. hit: boolean;
  12014. /**
  12015. * Distance away where the pick collided
  12016. */
  12017. distance: number;
  12018. /**
  12019. * The location of pick collision
  12020. */
  12021. pickedPoint: Nullable<Vector3>;
  12022. /**
  12023. * The mesh corresponding the the pick collision
  12024. */
  12025. pickedMesh: Nullable<AbstractMesh>;
  12026. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12027. bu: number;
  12028. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12029. bv: number;
  12030. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12031. faceId: number;
  12032. /** Id of the the submesh that was picked */
  12033. subMeshId: number;
  12034. /** If a sprite was picked, this will be the sprite the pick collided with */
  12035. pickedSprite: Nullable<Sprite>;
  12036. /**
  12037. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12038. */
  12039. originMesh: Nullable<AbstractMesh>;
  12040. /**
  12041. * The ray that was used to perform the picking.
  12042. */
  12043. ray: Nullable<Ray>;
  12044. /**
  12045. * Gets the normal correspodning to the face the pick collided with
  12046. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12047. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12048. * @returns The normal correspodning to the face the pick collided with
  12049. */
  12050. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12051. /**
  12052. * Gets the texture coordinates of where the pick occured
  12053. * @returns the vector containing the coordnates of the texture
  12054. */
  12055. getTextureCoordinates(): Nullable<Vector2>;
  12056. }
  12057. }
  12058. declare module "babylonjs/Events/pointerEvents" {
  12059. import { Nullable } from "babylonjs/types";
  12060. import { Vector2 } from "babylonjs/Maths/math.vector";
  12061. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12062. import { Ray } from "babylonjs/Culling/ray";
  12063. /**
  12064. * Gather the list of pointer event types as constants.
  12065. */
  12066. export class PointerEventTypes {
  12067. /**
  12068. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  12069. */
  12070. static readonly POINTERDOWN: number;
  12071. /**
  12072. * The pointerup event is fired when a pointer is no longer active.
  12073. */
  12074. static readonly POINTERUP: number;
  12075. /**
  12076. * The pointermove event is fired when a pointer changes coordinates.
  12077. */
  12078. static readonly POINTERMOVE: number;
  12079. /**
  12080. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12081. */
  12082. static readonly POINTERWHEEL: number;
  12083. /**
  12084. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12085. */
  12086. static readonly POINTERPICK: number;
  12087. /**
  12088. * The pointertap event is fired when a the object has been touched and released without drag.
  12089. */
  12090. static readonly POINTERTAP: number;
  12091. /**
  12092. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12093. */
  12094. static readonly POINTERDOUBLETAP: number;
  12095. }
  12096. /**
  12097. * Base class of pointer info types.
  12098. */
  12099. export class PointerInfoBase {
  12100. /**
  12101. * Defines the type of event (PointerEventTypes)
  12102. */
  12103. type: number;
  12104. /**
  12105. * Defines the related dom event
  12106. */
  12107. event: PointerEvent | MouseWheelEvent;
  12108. /**
  12109. * Instantiates the base class of pointers info.
  12110. * @param type Defines the type of event (PointerEventTypes)
  12111. * @param event Defines the related dom event
  12112. */
  12113. constructor(
  12114. /**
  12115. * Defines the type of event (PointerEventTypes)
  12116. */
  12117. type: number,
  12118. /**
  12119. * Defines the related dom event
  12120. */
  12121. event: PointerEvent | MouseWheelEvent);
  12122. }
  12123. /**
  12124. * This class is used to store pointer related info for the onPrePointerObservable event.
  12125. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12126. */
  12127. export class PointerInfoPre extends PointerInfoBase {
  12128. /**
  12129. * Ray from a pointer if availible (eg. 6dof controller)
  12130. */
  12131. ray: Nullable<Ray>;
  12132. /**
  12133. * Defines the local position of the pointer on the canvas.
  12134. */
  12135. localPosition: Vector2;
  12136. /**
  12137. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12138. */
  12139. skipOnPointerObservable: boolean;
  12140. /**
  12141. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12142. * @param type Defines the type of event (PointerEventTypes)
  12143. * @param event Defines the related dom event
  12144. * @param localX Defines the local x coordinates of the pointer when the event occured
  12145. * @param localY Defines the local y coordinates of the pointer when the event occured
  12146. */
  12147. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12148. }
  12149. /**
  12150. * This type contains all the data related to a pointer event in Babylon.js.
  12151. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12152. */
  12153. export class PointerInfo extends PointerInfoBase {
  12154. /**
  12155. * Defines the picking info associated to the info (if any)\
  12156. */
  12157. pickInfo: Nullable<PickingInfo>;
  12158. /**
  12159. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12160. * @param type Defines the type of event (PointerEventTypes)
  12161. * @param event Defines the related dom event
  12162. * @param pickInfo Defines the picking info associated to the info (if any)\
  12163. */
  12164. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12165. /**
  12166. * Defines the picking info associated to the info (if any)\
  12167. */
  12168. pickInfo: Nullable<PickingInfo>);
  12169. }
  12170. /**
  12171. * Data relating to a touch event on the screen.
  12172. */
  12173. export interface PointerTouch {
  12174. /**
  12175. * X coordinate of touch.
  12176. */
  12177. x: number;
  12178. /**
  12179. * Y coordinate of touch.
  12180. */
  12181. y: number;
  12182. /**
  12183. * Id of touch. Unique for each finger.
  12184. */
  12185. pointerId: number;
  12186. /**
  12187. * Event type passed from DOM.
  12188. */
  12189. type: any;
  12190. }
  12191. }
  12192. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12193. import { Observable } from "babylonjs/Misc/observable";
  12194. import { Nullable } from "babylonjs/types";
  12195. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12197. /**
  12198. * Manage the mouse inputs to control the movement of a free camera.
  12199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12200. */
  12201. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12202. /**
  12203. * Define if touch is enabled in the mouse input
  12204. */
  12205. touchEnabled: boolean;
  12206. /**
  12207. * Defines the camera the input is attached to.
  12208. */
  12209. camera: FreeCamera;
  12210. /**
  12211. * Defines the buttons associated with the input to handle camera move.
  12212. */
  12213. buttons: number[];
  12214. /**
  12215. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12216. */
  12217. angularSensibility: number;
  12218. private _pointerInput;
  12219. private _onMouseMove;
  12220. private _observer;
  12221. private previousPosition;
  12222. /**
  12223. * Observable for when a pointer move event occurs containing the move offset
  12224. */
  12225. onPointerMovedObservable: Observable<{
  12226. offsetX: number;
  12227. offsetY: number;
  12228. }>;
  12229. /**
  12230. * @hidden
  12231. * If the camera should be rotated automatically based on pointer movement
  12232. */
  12233. _allowCameraRotation: boolean;
  12234. /**
  12235. * Manage the mouse inputs to control the movement of a free camera.
  12236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12237. * @param touchEnabled Defines if touch is enabled or not
  12238. */
  12239. constructor(
  12240. /**
  12241. * Define if touch is enabled in the mouse input
  12242. */
  12243. touchEnabled?: boolean);
  12244. /**
  12245. * Attach the input controls to a specific dom element to get the input from.
  12246. * @param element Defines the element the controls should be listened from
  12247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12248. */
  12249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12250. /**
  12251. * Called on JS contextmenu event.
  12252. * Override this method to provide functionality.
  12253. */
  12254. protected onContextMenu(evt: PointerEvent): void;
  12255. /**
  12256. * Detach the current controls from the specified dom element.
  12257. * @param element Defines the element to stop listening the inputs from
  12258. */
  12259. detachControl(element: Nullable<HTMLElement>): void;
  12260. /**
  12261. * Gets the class name of the current intput.
  12262. * @returns the class name
  12263. */
  12264. getClassName(): string;
  12265. /**
  12266. * Get the friendly name associated with the input class.
  12267. * @returns the input friendly name
  12268. */
  12269. getSimpleName(): string;
  12270. }
  12271. }
  12272. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12273. import { Nullable } from "babylonjs/types";
  12274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12276. /**
  12277. * Manage the touch inputs to control the movement of a free camera.
  12278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12279. */
  12280. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12281. /**
  12282. * Defines the camera the input is attached to.
  12283. */
  12284. camera: FreeCamera;
  12285. /**
  12286. * Defines the touch sensibility for rotation.
  12287. * The higher the faster.
  12288. */
  12289. touchAngularSensibility: number;
  12290. /**
  12291. * Defines the touch sensibility for move.
  12292. * The higher the faster.
  12293. */
  12294. touchMoveSensibility: number;
  12295. private _offsetX;
  12296. private _offsetY;
  12297. private _pointerPressed;
  12298. private _pointerInput;
  12299. private _observer;
  12300. private _onLostFocus;
  12301. /**
  12302. * Attach the input controls to a specific dom element to get the input from.
  12303. * @param element Defines the element the controls should be listened from
  12304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12305. */
  12306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12307. /**
  12308. * Detach the current controls from the specified dom element.
  12309. * @param element Defines the element to stop listening the inputs from
  12310. */
  12311. detachControl(element: Nullable<HTMLElement>): void;
  12312. /**
  12313. * Update the current camera state depending on the inputs that have been used this frame.
  12314. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12315. */
  12316. checkInputs(): void;
  12317. /**
  12318. * Gets the class name of the current intput.
  12319. * @returns the class name
  12320. */
  12321. getClassName(): string;
  12322. /**
  12323. * Get the friendly name associated with the input class.
  12324. * @returns the input friendly name
  12325. */
  12326. getSimpleName(): string;
  12327. }
  12328. }
  12329. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12330. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12331. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12332. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12333. import { Nullable } from "babylonjs/types";
  12334. /**
  12335. * Default Inputs manager for the FreeCamera.
  12336. * It groups all the default supported inputs for ease of use.
  12337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12338. */
  12339. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12340. /**
  12341. * @hidden
  12342. */
  12343. _mouseInput: Nullable<FreeCameraMouseInput>;
  12344. /**
  12345. * Instantiates a new FreeCameraInputsManager.
  12346. * @param camera Defines the camera the inputs belong to
  12347. */
  12348. constructor(camera: FreeCamera);
  12349. /**
  12350. * Add keyboard input support to the input manager.
  12351. * @returns the current input manager
  12352. */
  12353. addKeyboard(): FreeCameraInputsManager;
  12354. /**
  12355. * Add mouse input support to the input manager.
  12356. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12357. * @returns the current input manager
  12358. */
  12359. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12360. /**
  12361. * Removes the mouse input support from the manager
  12362. * @returns the current input manager
  12363. */
  12364. removeMouse(): FreeCameraInputsManager;
  12365. /**
  12366. * Add touch input support to the input manager.
  12367. * @returns the current input manager
  12368. */
  12369. addTouch(): FreeCameraInputsManager;
  12370. /**
  12371. * Remove all attached input methods from a camera
  12372. */
  12373. clear(): void;
  12374. }
  12375. }
  12376. declare module "babylonjs/Cameras/freeCamera" {
  12377. import { Vector3 } from "babylonjs/Maths/math.vector";
  12378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12379. import { Scene } from "babylonjs/scene";
  12380. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12381. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12382. /**
  12383. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12384. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12385. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12386. */
  12387. export class FreeCamera extends TargetCamera {
  12388. /**
  12389. * Define the collision ellipsoid of the camera.
  12390. * This is helpful to simulate a camera body like the player body around the camera
  12391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12392. */
  12393. ellipsoid: Vector3;
  12394. /**
  12395. * Define an offset for the position of the ellipsoid around the camera.
  12396. * This can be helpful to determine the center of the body near the gravity center of the body
  12397. * instead of its head.
  12398. */
  12399. ellipsoidOffset: Vector3;
  12400. /**
  12401. * Enable or disable collisions of the camera with the rest of the scene objects.
  12402. */
  12403. checkCollisions: boolean;
  12404. /**
  12405. * Enable or disable gravity on the camera.
  12406. */
  12407. applyGravity: boolean;
  12408. /**
  12409. * Define the input manager associated to the camera.
  12410. */
  12411. inputs: FreeCameraInputsManager;
  12412. /**
  12413. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12414. * Higher values reduce sensitivity.
  12415. */
  12416. /**
  12417. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12418. * Higher values reduce sensitivity.
  12419. */
  12420. angularSensibility: number;
  12421. /**
  12422. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12423. */
  12424. keysUp: number[];
  12425. /**
  12426. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12427. */
  12428. keysDown: number[];
  12429. /**
  12430. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12431. */
  12432. keysLeft: number[];
  12433. /**
  12434. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12435. */
  12436. keysRight: number[];
  12437. /**
  12438. * Event raised when the camera collide with a mesh in the scene.
  12439. */
  12440. onCollide: (collidedMesh: AbstractMesh) => void;
  12441. private _collider;
  12442. private _needMoveForGravity;
  12443. private _oldPosition;
  12444. private _diffPosition;
  12445. private _newPosition;
  12446. /** @hidden */
  12447. _localDirection: Vector3;
  12448. /** @hidden */
  12449. _transformedDirection: Vector3;
  12450. /**
  12451. * Instantiates a Free Camera.
  12452. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12453. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12454. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12455. * @param name Define the name of the camera in the scene
  12456. * @param position Define the start position of the camera in the scene
  12457. * @param scene Define the scene the camera belongs to
  12458. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12459. */
  12460. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12461. /**
  12462. * Attached controls to the current camera.
  12463. * @param element Defines the element the controls should be listened from
  12464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12465. */
  12466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12467. /**
  12468. * Detach the current controls from the camera.
  12469. * The camera will stop reacting to inputs.
  12470. * @param element Defines the element to stop listening the inputs from
  12471. */
  12472. detachControl(element: HTMLElement): void;
  12473. private _collisionMask;
  12474. /**
  12475. * Define a collision mask to limit the list of object the camera can collide with
  12476. */
  12477. collisionMask: number;
  12478. /** @hidden */
  12479. _collideWithWorld(displacement: Vector3): void;
  12480. private _onCollisionPositionChange;
  12481. /** @hidden */
  12482. _checkInputs(): void;
  12483. /** @hidden */
  12484. _decideIfNeedsToMove(): boolean;
  12485. /** @hidden */
  12486. _updatePosition(): void;
  12487. /**
  12488. * Destroy the camera and release the current resources hold by it.
  12489. */
  12490. dispose(): void;
  12491. /**
  12492. * Gets the current object class name.
  12493. * @return the class name
  12494. */
  12495. getClassName(): string;
  12496. }
  12497. }
  12498. declare module "babylonjs/Gamepads/gamepad" {
  12499. import { Observable } from "babylonjs/Misc/observable";
  12500. /**
  12501. * Represents a gamepad control stick position
  12502. */
  12503. export class StickValues {
  12504. /**
  12505. * The x component of the control stick
  12506. */
  12507. x: number;
  12508. /**
  12509. * The y component of the control stick
  12510. */
  12511. y: number;
  12512. /**
  12513. * Initializes the gamepad x and y control stick values
  12514. * @param x The x component of the gamepad control stick value
  12515. * @param y The y component of the gamepad control stick value
  12516. */
  12517. constructor(
  12518. /**
  12519. * The x component of the control stick
  12520. */
  12521. x: number,
  12522. /**
  12523. * The y component of the control stick
  12524. */
  12525. y: number);
  12526. }
  12527. /**
  12528. * An interface which manages callbacks for gamepad button changes
  12529. */
  12530. export interface GamepadButtonChanges {
  12531. /**
  12532. * Called when a gamepad has been changed
  12533. */
  12534. changed: boolean;
  12535. /**
  12536. * Called when a gamepad press event has been triggered
  12537. */
  12538. pressChanged: boolean;
  12539. /**
  12540. * Called when a touch event has been triggered
  12541. */
  12542. touchChanged: boolean;
  12543. /**
  12544. * Called when a value has changed
  12545. */
  12546. valueChanged: boolean;
  12547. }
  12548. /**
  12549. * Represents a gamepad
  12550. */
  12551. export class Gamepad {
  12552. /**
  12553. * The id of the gamepad
  12554. */
  12555. id: string;
  12556. /**
  12557. * The index of the gamepad
  12558. */
  12559. index: number;
  12560. /**
  12561. * The browser gamepad
  12562. */
  12563. browserGamepad: any;
  12564. /**
  12565. * Specifies what type of gamepad this represents
  12566. */
  12567. type: number;
  12568. private _leftStick;
  12569. private _rightStick;
  12570. /** @hidden */
  12571. _isConnected: boolean;
  12572. private _leftStickAxisX;
  12573. private _leftStickAxisY;
  12574. private _rightStickAxisX;
  12575. private _rightStickAxisY;
  12576. /**
  12577. * Triggered when the left control stick has been changed
  12578. */
  12579. private _onleftstickchanged;
  12580. /**
  12581. * Triggered when the right control stick has been changed
  12582. */
  12583. private _onrightstickchanged;
  12584. /**
  12585. * Represents a gamepad controller
  12586. */
  12587. static GAMEPAD: number;
  12588. /**
  12589. * Represents a generic controller
  12590. */
  12591. static GENERIC: number;
  12592. /**
  12593. * Represents an XBox controller
  12594. */
  12595. static XBOX: number;
  12596. /**
  12597. * Represents a pose-enabled controller
  12598. */
  12599. static POSE_ENABLED: number;
  12600. /**
  12601. * Represents an Dual Shock controller
  12602. */
  12603. static DUALSHOCK: number;
  12604. /**
  12605. * Specifies whether the left control stick should be Y-inverted
  12606. */
  12607. protected _invertLeftStickY: boolean;
  12608. /**
  12609. * Specifies if the gamepad has been connected
  12610. */
  12611. readonly isConnected: boolean;
  12612. /**
  12613. * Initializes the gamepad
  12614. * @param id The id of the gamepad
  12615. * @param index The index of the gamepad
  12616. * @param browserGamepad The browser gamepad
  12617. * @param leftStickX The x component of the left joystick
  12618. * @param leftStickY The y component of the left joystick
  12619. * @param rightStickX The x component of the right joystick
  12620. * @param rightStickY The y component of the right joystick
  12621. */
  12622. constructor(
  12623. /**
  12624. * The id of the gamepad
  12625. */
  12626. id: string,
  12627. /**
  12628. * The index of the gamepad
  12629. */
  12630. index: number,
  12631. /**
  12632. * The browser gamepad
  12633. */
  12634. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12635. /**
  12636. * Callback triggered when the left joystick has changed
  12637. * @param callback
  12638. */
  12639. onleftstickchanged(callback: (values: StickValues) => void): void;
  12640. /**
  12641. * Callback triggered when the right joystick has changed
  12642. * @param callback
  12643. */
  12644. onrightstickchanged(callback: (values: StickValues) => void): void;
  12645. /**
  12646. * Gets the left joystick
  12647. */
  12648. /**
  12649. * Sets the left joystick values
  12650. */
  12651. leftStick: StickValues;
  12652. /**
  12653. * Gets the right joystick
  12654. */
  12655. /**
  12656. * Sets the right joystick value
  12657. */
  12658. rightStick: StickValues;
  12659. /**
  12660. * Updates the gamepad joystick positions
  12661. */
  12662. update(): void;
  12663. /**
  12664. * Disposes the gamepad
  12665. */
  12666. dispose(): void;
  12667. }
  12668. /**
  12669. * Represents a generic gamepad
  12670. */
  12671. export class GenericPad extends Gamepad {
  12672. private _buttons;
  12673. private _onbuttondown;
  12674. private _onbuttonup;
  12675. /**
  12676. * Observable triggered when a button has been pressed
  12677. */
  12678. onButtonDownObservable: Observable<number>;
  12679. /**
  12680. * Observable triggered when a button has been released
  12681. */
  12682. onButtonUpObservable: Observable<number>;
  12683. /**
  12684. * Callback triggered when a button has been pressed
  12685. * @param callback Called when a button has been pressed
  12686. */
  12687. onbuttondown(callback: (buttonPressed: number) => void): void;
  12688. /**
  12689. * Callback triggered when a button has been released
  12690. * @param callback Called when a button has been released
  12691. */
  12692. onbuttonup(callback: (buttonReleased: number) => void): void;
  12693. /**
  12694. * Initializes the generic gamepad
  12695. * @param id The id of the generic gamepad
  12696. * @param index The index of the generic gamepad
  12697. * @param browserGamepad The browser gamepad
  12698. */
  12699. constructor(id: string, index: number, browserGamepad: any);
  12700. private _setButtonValue;
  12701. /**
  12702. * Updates the generic gamepad
  12703. */
  12704. update(): void;
  12705. /**
  12706. * Disposes the generic gamepad
  12707. */
  12708. dispose(): void;
  12709. }
  12710. }
  12711. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12712. import { Nullable } from "babylonjs/types";
  12713. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12714. import { Scene } from "babylonjs/scene";
  12715. module "babylonjs/Engines/engine" {
  12716. interface Engine {
  12717. /**
  12718. * Creates a raw texture
  12719. * @param data defines the data to store in the texture
  12720. * @param width defines the width of the texture
  12721. * @param height defines the height of the texture
  12722. * @param format defines the format of the data
  12723. * @param generateMipMaps defines if the engine should generate the mip levels
  12724. * @param invertY defines if data must be stored with Y axis inverted
  12725. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12726. * @param compression defines the compression used (null by default)
  12727. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12728. * @returns the raw texture inside an InternalTexture
  12729. */
  12730. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12731. /**
  12732. * Update a raw texture
  12733. * @param texture defines the texture to update
  12734. * @param data defines the data to store in the texture
  12735. * @param format defines the format of the data
  12736. * @param invertY defines if data must be stored with Y axis inverted
  12737. */
  12738. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12739. /**
  12740. * Update a raw texture
  12741. * @param texture defines the texture to update
  12742. * @param data defines the data to store in the texture
  12743. * @param format defines the format of the data
  12744. * @param invertY defines if data must be stored with Y axis inverted
  12745. * @param compression defines the compression used (null by default)
  12746. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12747. */
  12748. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12749. /**
  12750. * Creates a new raw cube texture
  12751. * @param data defines the array of data to use to create each face
  12752. * @param size defines the size of the textures
  12753. * @param format defines the format of the data
  12754. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12755. * @param generateMipMaps defines if the engine should generate the mip levels
  12756. * @param invertY defines if data must be stored with Y axis inverted
  12757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12758. * @param compression defines the compression used (null by default)
  12759. * @returns the cube texture as an InternalTexture
  12760. */
  12761. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12762. /**
  12763. * Update a raw cube texture
  12764. * @param texture defines the texture to udpdate
  12765. * @param data defines the data to store
  12766. * @param format defines the data format
  12767. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12768. * @param invertY defines if data must be stored with Y axis inverted
  12769. */
  12770. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12771. /**
  12772. * Update a raw cube texture
  12773. * @param texture defines the texture to udpdate
  12774. * @param data defines the data to store
  12775. * @param format defines the data format
  12776. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12777. * @param invertY defines if data must be stored with Y axis inverted
  12778. * @param compression defines the compression used (null by default)
  12779. */
  12780. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12781. /**
  12782. * Update a raw cube texture
  12783. * @param texture defines the texture to udpdate
  12784. * @param data defines the data to store
  12785. * @param format defines the data format
  12786. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12787. * @param invertY defines if data must be stored with Y axis inverted
  12788. * @param compression defines the compression used (null by default)
  12789. * @param level defines which level of the texture to update
  12790. */
  12791. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12792. /**
  12793. * Creates a new raw cube texture from a specified url
  12794. * @param url defines the url where the data is located
  12795. * @param scene defines the current scene
  12796. * @param size defines the size of the textures
  12797. * @param format defines the format of the data
  12798. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12799. * @param noMipmap defines if the engine should avoid generating the mip levels
  12800. * @param callback defines a callback used to extract texture data from loaded data
  12801. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12802. * @param onLoad defines a callback called when texture is loaded
  12803. * @param onError defines a callback called if there is an error
  12804. * @returns the cube texture as an InternalTexture
  12805. */
  12806. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12807. /**
  12808. * Creates a new raw cube texture from a specified url
  12809. * @param url defines the url where the data is located
  12810. * @param scene defines the current scene
  12811. * @param size defines the size of the textures
  12812. * @param format defines the format of the data
  12813. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12814. * @param noMipmap defines if the engine should avoid generating the mip levels
  12815. * @param callback defines a callback used to extract texture data from loaded data
  12816. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12817. * @param onLoad defines a callback called when texture is loaded
  12818. * @param onError defines a callback called if there is an error
  12819. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12820. * @param invertY defines if data must be stored with Y axis inverted
  12821. * @returns the cube texture as an InternalTexture
  12822. */
  12823. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12824. /**
  12825. * Creates a new raw 3D texture
  12826. * @param data defines the data used to create the texture
  12827. * @param width defines the width of the texture
  12828. * @param height defines the height of the texture
  12829. * @param depth defines the depth of the texture
  12830. * @param format defines the format of the texture
  12831. * @param generateMipMaps defines if the engine must generate mip levels
  12832. * @param invertY defines if data must be stored with Y axis inverted
  12833. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12834. * @param compression defines the compressed used (can be null)
  12835. * @param textureType defines the compressed used (can be null)
  12836. * @returns a new raw 3D texture (stored in an InternalTexture)
  12837. */
  12838. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12839. /**
  12840. * Update a raw 3D texture
  12841. * @param texture defines the texture to update
  12842. * @param data defines the data to store
  12843. * @param format defines the data format
  12844. * @param invertY defines if data must be stored with Y axis inverted
  12845. */
  12846. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12847. /**
  12848. * Update a raw 3D texture
  12849. * @param texture defines the texture to update
  12850. * @param data defines the data to store
  12851. * @param format defines the data format
  12852. * @param invertY defines if data must be stored with Y axis inverted
  12853. * @param compression defines the used compression (can be null)
  12854. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12855. */
  12856. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12857. /**
  12858. * Creates a new raw 2D array texture
  12859. * @param data defines the data used to create the texture
  12860. * @param width defines the width of the texture
  12861. * @param height defines the height of the texture
  12862. * @param depth defines the number of layers of the texture
  12863. * @param format defines the format of the texture
  12864. * @param generateMipMaps defines if the engine must generate mip levels
  12865. * @param invertY defines if data must be stored with Y axis inverted
  12866. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12867. * @param compression defines the compressed used (can be null)
  12868. * @param textureType defines the compressed used (can be null)
  12869. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12870. */
  12871. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12872. /**
  12873. * Update a raw 2D array texture
  12874. * @param texture defines the texture to update
  12875. * @param data defines the data to store
  12876. * @param format defines the data format
  12877. * @param invertY defines if data must be stored with Y axis inverted
  12878. */
  12879. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12880. /**
  12881. * Update a raw 2D array texture
  12882. * @param texture defines the texture to update
  12883. * @param data defines the data to store
  12884. * @param format defines the data format
  12885. * @param invertY defines if data must be stored with Y axis inverted
  12886. * @param compression defines the used compression (can be null)
  12887. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12888. */
  12889. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12890. }
  12891. }
  12892. }
  12893. declare module "babylonjs/Materials/Textures/rawTexture" {
  12894. import { Scene } from "babylonjs/scene";
  12895. import { Texture } from "babylonjs/Materials/Textures/texture";
  12896. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12897. /**
  12898. * Raw texture can help creating a texture directly from an array of data.
  12899. * This can be super useful if you either get the data from an uncompressed source or
  12900. * if you wish to create your texture pixel by pixel.
  12901. */
  12902. export class RawTexture extends Texture {
  12903. /**
  12904. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12905. */
  12906. format: number;
  12907. private _engine;
  12908. /**
  12909. * Instantiates a new RawTexture.
  12910. * Raw texture can help creating a texture directly from an array of data.
  12911. * This can be super useful if you either get the data from an uncompressed source or
  12912. * if you wish to create your texture pixel by pixel.
  12913. * @param data define the array of data to use to create the texture
  12914. * @param width define the width of the texture
  12915. * @param height define the height of the texture
  12916. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12917. * @param scene define the scene the texture belongs to
  12918. * @param generateMipMaps define whether mip maps should be generated or not
  12919. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12920. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12921. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12922. */
  12923. constructor(data: ArrayBufferView, width: number, height: number,
  12924. /**
  12925. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12926. */
  12927. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12928. /**
  12929. * Updates the texture underlying data.
  12930. * @param data Define the new data of the texture
  12931. */
  12932. update(data: ArrayBufferView): void;
  12933. /**
  12934. * Creates a luminance texture from some data.
  12935. * @param data Define the texture data
  12936. * @param width Define the width of the texture
  12937. * @param height Define the height of the texture
  12938. * @param scene Define the scene the texture belongs to
  12939. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12940. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12941. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12942. * @returns the luminance texture
  12943. */
  12944. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12945. /**
  12946. * Creates a luminance alpha texture from some data.
  12947. * @param data Define the texture data
  12948. * @param width Define the width of the texture
  12949. * @param height Define the height of the texture
  12950. * @param scene Define the scene the texture belongs to
  12951. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12952. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12953. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12954. * @returns the luminance alpha texture
  12955. */
  12956. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12957. /**
  12958. * Creates an alpha texture from some data.
  12959. * @param data Define the texture data
  12960. * @param width Define the width of the texture
  12961. * @param height Define the height of the texture
  12962. * @param scene Define the scene the texture belongs to
  12963. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12964. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12965. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12966. * @returns the alpha texture
  12967. */
  12968. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12969. /**
  12970. * Creates a RGB texture from some data.
  12971. * @param data Define the texture data
  12972. * @param width Define the width of the texture
  12973. * @param height Define the height of the texture
  12974. * @param scene Define the scene the texture belongs to
  12975. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12976. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12977. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12978. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12979. * @returns the RGB alpha texture
  12980. */
  12981. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12982. /**
  12983. * Creates a RGBA texture from some data.
  12984. * @param data Define the texture data
  12985. * @param width Define the width of the texture
  12986. * @param height Define the height of the texture
  12987. * @param scene Define the scene the texture belongs to
  12988. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12989. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12990. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12991. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12992. * @returns the RGBA texture
  12993. */
  12994. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12995. /**
  12996. * Creates a R texture from some data.
  12997. * @param data Define the texture data
  12998. * @param width Define the width of the texture
  12999. * @param height Define the height of the texture
  13000. * @param scene Define the scene the texture belongs to
  13001. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13002. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13003. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13004. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13005. * @returns the R texture
  13006. */
  13007. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13008. }
  13009. }
  13010. declare module "babylonjs/Maths/math.size" {
  13011. /**
  13012. * Interface for the size containing width and height
  13013. */
  13014. export interface ISize {
  13015. /**
  13016. * Width
  13017. */
  13018. width: number;
  13019. /**
  13020. * Heighht
  13021. */
  13022. height: number;
  13023. }
  13024. /**
  13025. * Size containing widht and height
  13026. */
  13027. export class Size implements ISize {
  13028. /**
  13029. * Width
  13030. */
  13031. width: number;
  13032. /**
  13033. * Height
  13034. */
  13035. height: number;
  13036. /**
  13037. * Creates a Size object from the given width and height (floats).
  13038. * @param width width of the new size
  13039. * @param height height of the new size
  13040. */
  13041. constructor(width: number, height: number);
  13042. /**
  13043. * Returns a string with the Size width and height
  13044. * @returns a string with the Size width and height
  13045. */
  13046. toString(): string;
  13047. /**
  13048. * "Size"
  13049. * @returns the string "Size"
  13050. */
  13051. getClassName(): string;
  13052. /**
  13053. * Returns the Size hash code.
  13054. * @returns a hash code for a unique width and height
  13055. */
  13056. getHashCode(): number;
  13057. /**
  13058. * Updates the current size from the given one.
  13059. * @param src the given size
  13060. */
  13061. copyFrom(src: Size): void;
  13062. /**
  13063. * Updates in place the current Size from the given floats.
  13064. * @param width width of the new size
  13065. * @param height height of the new size
  13066. * @returns the updated Size.
  13067. */
  13068. copyFromFloats(width: number, height: number): Size;
  13069. /**
  13070. * Updates in place the current Size from the given floats.
  13071. * @param width width to set
  13072. * @param height height to set
  13073. * @returns the updated Size.
  13074. */
  13075. set(width: number, height: number): Size;
  13076. /**
  13077. * Multiplies the width and height by numbers
  13078. * @param w factor to multiple the width by
  13079. * @param h factor to multiple the height by
  13080. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13081. */
  13082. multiplyByFloats(w: number, h: number): Size;
  13083. /**
  13084. * Clones the size
  13085. * @returns a new Size copied from the given one.
  13086. */
  13087. clone(): Size;
  13088. /**
  13089. * True if the current Size and the given one width and height are strictly equal.
  13090. * @param other the other size to compare against
  13091. * @returns True if the current Size and the given one width and height are strictly equal.
  13092. */
  13093. equals(other: Size): boolean;
  13094. /**
  13095. * The surface of the Size : width * height (float).
  13096. */
  13097. readonly surface: number;
  13098. /**
  13099. * Create a new size of zero
  13100. * @returns a new Size set to (0.0, 0.0)
  13101. */
  13102. static Zero(): Size;
  13103. /**
  13104. * Sums the width and height of two sizes
  13105. * @param otherSize size to add to this size
  13106. * @returns a new Size set as the addition result of the current Size and the given one.
  13107. */
  13108. add(otherSize: Size): Size;
  13109. /**
  13110. * Subtracts the width and height of two
  13111. * @param otherSize size to subtract to this size
  13112. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13113. */
  13114. subtract(otherSize: Size): Size;
  13115. /**
  13116. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13117. * @param start starting size to lerp between
  13118. * @param end end size to lerp between
  13119. * @param amount amount to lerp between the start and end values
  13120. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13121. */
  13122. static Lerp(start: Size, end: Size, amount: number): Size;
  13123. }
  13124. }
  13125. declare module "babylonjs/Animations/runtimeAnimation" {
  13126. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13127. import { Animatable } from "babylonjs/Animations/animatable";
  13128. import { Scene } from "babylonjs/scene";
  13129. /**
  13130. * Defines a runtime animation
  13131. */
  13132. export class RuntimeAnimation {
  13133. private _events;
  13134. /**
  13135. * The current frame of the runtime animation
  13136. */
  13137. private _currentFrame;
  13138. /**
  13139. * The animation used by the runtime animation
  13140. */
  13141. private _animation;
  13142. /**
  13143. * The target of the runtime animation
  13144. */
  13145. private _target;
  13146. /**
  13147. * The initiating animatable
  13148. */
  13149. private _host;
  13150. /**
  13151. * The original value of the runtime animation
  13152. */
  13153. private _originalValue;
  13154. /**
  13155. * The original blend value of the runtime animation
  13156. */
  13157. private _originalBlendValue;
  13158. /**
  13159. * The offsets cache of the runtime animation
  13160. */
  13161. private _offsetsCache;
  13162. /**
  13163. * The high limits cache of the runtime animation
  13164. */
  13165. private _highLimitsCache;
  13166. /**
  13167. * Specifies if the runtime animation has been stopped
  13168. */
  13169. private _stopped;
  13170. /**
  13171. * The blending factor of the runtime animation
  13172. */
  13173. private _blendingFactor;
  13174. /**
  13175. * The BabylonJS scene
  13176. */
  13177. private _scene;
  13178. /**
  13179. * The current value of the runtime animation
  13180. */
  13181. private _currentValue;
  13182. /** @hidden */
  13183. _animationState: _IAnimationState;
  13184. /**
  13185. * The active target of the runtime animation
  13186. */
  13187. private _activeTargets;
  13188. private _currentActiveTarget;
  13189. private _directTarget;
  13190. /**
  13191. * The target path of the runtime animation
  13192. */
  13193. private _targetPath;
  13194. /**
  13195. * The weight of the runtime animation
  13196. */
  13197. private _weight;
  13198. /**
  13199. * The ratio offset of the runtime animation
  13200. */
  13201. private _ratioOffset;
  13202. /**
  13203. * The previous delay of the runtime animation
  13204. */
  13205. private _previousDelay;
  13206. /**
  13207. * The previous ratio of the runtime animation
  13208. */
  13209. private _previousRatio;
  13210. private _enableBlending;
  13211. private _keys;
  13212. private _minFrame;
  13213. private _maxFrame;
  13214. private _minValue;
  13215. private _maxValue;
  13216. private _targetIsArray;
  13217. /**
  13218. * Gets the current frame of the runtime animation
  13219. */
  13220. readonly currentFrame: number;
  13221. /**
  13222. * Gets the weight of the runtime animation
  13223. */
  13224. readonly weight: number;
  13225. /**
  13226. * Gets the current value of the runtime animation
  13227. */
  13228. readonly currentValue: any;
  13229. /**
  13230. * Gets the target path of the runtime animation
  13231. */
  13232. readonly targetPath: string;
  13233. /**
  13234. * Gets the actual target of the runtime animation
  13235. */
  13236. readonly target: any;
  13237. /** @hidden */
  13238. _onLoop: () => void;
  13239. /**
  13240. * Create a new RuntimeAnimation object
  13241. * @param target defines the target of the animation
  13242. * @param animation defines the source animation object
  13243. * @param scene defines the hosting scene
  13244. * @param host defines the initiating Animatable
  13245. */
  13246. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13247. private _preparePath;
  13248. /**
  13249. * Gets the animation from the runtime animation
  13250. */
  13251. readonly animation: Animation;
  13252. /**
  13253. * Resets the runtime animation to the beginning
  13254. * @param restoreOriginal defines whether to restore the target property to the original value
  13255. */
  13256. reset(restoreOriginal?: boolean): void;
  13257. /**
  13258. * Specifies if the runtime animation is stopped
  13259. * @returns Boolean specifying if the runtime animation is stopped
  13260. */
  13261. isStopped(): boolean;
  13262. /**
  13263. * Disposes of the runtime animation
  13264. */
  13265. dispose(): void;
  13266. /**
  13267. * Apply the interpolated value to the target
  13268. * @param currentValue defines the value computed by the animation
  13269. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13270. */
  13271. setValue(currentValue: any, weight: number): void;
  13272. private _getOriginalValues;
  13273. private _setValue;
  13274. /**
  13275. * Gets the loop pmode of the runtime animation
  13276. * @returns Loop Mode
  13277. */
  13278. private _getCorrectLoopMode;
  13279. /**
  13280. * Move the current animation to a given frame
  13281. * @param frame defines the frame to move to
  13282. */
  13283. goToFrame(frame: number): void;
  13284. /**
  13285. * @hidden Internal use only
  13286. */
  13287. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13288. /**
  13289. * Execute the current animation
  13290. * @param delay defines the delay to add to the current frame
  13291. * @param from defines the lower bound of the animation range
  13292. * @param to defines the upper bound of the animation range
  13293. * @param loop defines if the current animation must loop
  13294. * @param speedRatio defines the current speed ratio
  13295. * @param weight defines the weight of the animation (default is -1 so no weight)
  13296. * @param onLoop optional callback called when animation loops
  13297. * @returns a boolean indicating if the animation is running
  13298. */
  13299. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13300. }
  13301. }
  13302. declare module "babylonjs/Animations/animatable" {
  13303. import { Animation } from "babylonjs/Animations/animation";
  13304. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13305. import { Nullable } from "babylonjs/types";
  13306. import { Observable } from "babylonjs/Misc/observable";
  13307. import { Scene } from "babylonjs/scene";
  13308. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13309. import { Node } from "babylonjs/node";
  13310. /**
  13311. * Class used to store an actual running animation
  13312. */
  13313. export class Animatable {
  13314. /** defines the target object */
  13315. target: any;
  13316. /** defines the starting frame number (default is 0) */
  13317. fromFrame: number;
  13318. /** defines the ending frame number (default is 100) */
  13319. toFrame: number;
  13320. /** defines if the animation must loop (default is false) */
  13321. loopAnimation: boolean;
  13322. /** defines a callback to call when animation ends if it is not looping */
  13323. onAnimationEnd?: (() => void) | null | undefined;
  13324. /** defines a callback to call when animation loops */
  13325. onAnimationLoop?: (() => void) | null | undefined;
  13326. private _localDelayOffset;
  13327. private _pausedDelay;
  13328. private _runtimeAnimations;
  13329. private _paused;
  13330. private _scene;
  13331. private _speedRatio;
  13332. private _weight;
  13333. private _syncRoot;
  13334. /**
  13335. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13336. * This will only apply for non looping animation (default is true)
  13337. */
  13338. disposeOnEnd: boolean;
  13339. /**
  13340. * Gets a boolean indicating if the animation has started
  13341. */
  13342. animationStarted: boolean;
  13343. /**
  13344. * Observer raised when the animation ends
  13345. */
  13346. onAnimationEndObservable: Observable<Animatable>;
  13347. /**
  13348. * Observer raised when the animation loops
  13349. */
  13350. onAnimationLoopObservable: Observable<Animatable>;
  13351. /**
  13352. * Gets the root Animatable used to synchronize and normalize animations
  13353. */
  13354. readonly syncRoot: Nullable<Animatable>;
  13355. /**
  13356. * Gets the current frame of the first RuntimeAnimation
  13357. * Used to synchronize Animatables
  13358. */
  13359. readonly masterFrame: number;
  13360. /**
  13361. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13362. */
  13363. weight: number;
  13364. /**
  13365. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13366. */
  13367. speedRatio: number;
  13368. /**
  13369. * Creates a new Animatable
  13370. * @param scene defines the hosting scene
  13371. * @param target defines the target object
  13372. * @param fromFrame defines the starting frame number (default is 0)
  13373. * @param toFrame defines the ending frame number (default is 100)
  13374. * @param loopAnimation defines if the animation must loop (default is false)
  13375. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13376. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13377. * @param animations defines a group of animation to add to the new Animatable
  13378. * @param onAnimationLoop defines a callback to call when animation loops
  13379. */
  13380. constructor(scene: Scene,
  13381. /** defines the target object */
  13382. target: any,
  13383. /** defines the starting frame number (default is 0) */
  13384. fromFrame?: number,
  13385. /** defines the ending frame number (default is 100) */
  13386. toFrame?: number,
  13387. /** defines if the animation must loop (default is false) */
  13388. loopAnimation?: boolean, speedRatio?: number,
  13389. /** defines a callback to call when animation ends if it is not looping */
  13390. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13391. /** defines a callback to call when animation loops */
  13392. onAnimationLoop?: (() => void) | null | undefined);
  13393. /**
  13394. * Synchronize and normalize current Animatable with a source Animatable
  13395. * This is useful when using animation weights and when animations are not of the same length
  13396. * @param root defines the root Animatable to synchronize with
  13397. * @returns the current Animatable
  13398. */
  13399. syncWith(root: Animatable): Animatable;
  13400. /**
  13401. * Gets the list of runtime animations
  13402. * @returns an array of RuntimeAnimation
  13403. */
  13404. getAnimations(): RuntimeAnimation[];
  13405. /**
  13406. * Adds more animations to the current animatable
  13407. * @param target defines the target of the animations
  13408. * @param animations defines the new animations to add
  13409. */
  13410. appendAnimations(target: any, animations: Animation[]): void;
  13411. /**
  13412. * Gets the source animation for a specific property
  13413. * @param property defines the propertyu to look for
  13414. * @returns null or the source animation for the given property
  13415. */
  13416. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13417. /**
  13418. * Gets the runtime animation for a specific property
  13419. * @param property defines the propertyu to look for
  13420. * @returns null or the runtime animation for the given property
  13421. */
  13422. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13423. /**
  13424. * Resets the animatable to its original state
  13425. */
  13426. reset(): void;
  13427. /**
  13428. * Allows the animatable to blend with current running animations
  13429. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13430. * @param blendingSpeed defines the blending speed to use
  13431. */
  13432. enableBlending(blendingSpeed: number): void;
  13433. /**
  13434. * Disable animation blending
  13435. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13436. */
  13437. disableBlending(): void;
  13438. /**
  13439. * Jump directly to a given frame
  13440. * @param frame defines the frame to jump to
  13441. */
  13442. goToFrame(frame: number): void;
  13443. /**
  13444. * Pause the animation
  13445. */
  13446. pause(): void;
  13447. /**
  13448. * Restart the animation
  13449. */
  13450. restart(): void;
  13451. private _raiseOnAnimationEnd;
  13452. /**
  13453. * Stop and delete the current animation
  13454. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13455. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13456. */
  13457. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13458. /**
  13459. * Wait asynchronously for the animation to end
  13460. * @returns a promise which will be fullfilled when the animation ends
  13461. */
  13462. waitAsync(): Promise<Animatable>;
  13463. /** @hidden */
  13464. _animate(delay: number): boolean;
  13465. }
  13466. module "babylonjs/scene" {
  13467. interface Scene {
  13468. /** @hidden */
  13469. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13470. /** @hidden */
  13471. _processLateAnimationBindingsForMatrices(holder: {
  13472. totalWeight: number;
  13473. animations: RuntimeAnimation[];
  13474. originalValue: Matrix;
  13475. }): any;
  13476. /** @hidden */
  13477. _processLateAnimationBindingsForQuaternions(holder: {
  13478. totalWeight: number;
  13479. animations: RuntimeAnimation[];
  13480. originalValue: Quaternion;
  13481. }, refQuaternion: Quaternion): Quaternion;
  13482. /** @hidden */
  13483. _processLateAnimationBindings(): void;
  13484. /**
  13485. * Will start the animation sequence of a given target
  13486. * @param target defines the target
  13487. * @param from defines from which frame should animation start
  13488. * @param to defines until which frame should animation run.
  13489. * @param weight defines the weight to apply to the animation (1.0 by default)
  13490. * @param loop defines if the animation loops
  13491. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13492. * @param onAnimationEnd defines the function to be executed when the animation ends
  13493. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13494. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13495. * @param onAnimationLoop defines the callback to call when an animation loops
  13496. * @returns the animatable object created for this animation
  13497. */
  13498. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13499. /**
  13500. * Will start the animation sequence of a given target
  13501. * @param target defines the target
  13502. * @param from defines from which frame should animation start
  13503. * @param to defines until which frame should animation run.
  13504. * @param loop defines if the animation loops
  13505. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13506. * @param onAnimationEnd defines the function to be executed when the animation ends
  13507. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13508. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13509. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13510. * @param onAnimationLoop defines the callback to call when an animation loops
  13511. * @returns the animatable object created for this animation
  13512. */
  13513. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13514. /**
  13515. * Will start the animation sequence of a given target and its hierarchy
  13516. * @param target defines the target
  13517. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13518. * @param from defines from which frame should animation start
  13519. * @param to defines until which frame should animation run.
  13520. * @param loop defines if the animation loops
  13521. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13522. * @param onAnimationEnd defines the function to be executed when the animation ends
  13523. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13524. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13525. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13526. * @param onAnimationLoop defines the callback to call when an animation loops
  13527. * @returns the list of created animatables
  13528. */
  13529. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13530. /**
  13531. * Begin a new animation on a given node
  13532. * @param target defines the target where the animation will take place
  13533. * @param animations defines the list of animations to start
  13534. * @param from defines the initial value
  13535. * @param to defines the final value
  13536. * @param loop defines if you want animation to loop (off by default)
  13537. * @param speedRatio defines the speed ratio to apply to all animations
  13538. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13539. * @param onAnimationLoop defines the callback to call when an animation loops
  13540. * @returns the list of created animatables
  13541. */
  13542. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13543. /**
  13544. * Begin a new animation on a given node and its hierarchy
  13545. * @param target defines the root node where the animation will take place
  13546. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13547. * @param animations defines the list of animations to start
  13548. * @param from defines the initial value
  13549. * @param to defines the final value
  13550. * @param loop defines if you want animation to loop (off by default)
  13551. * @param speedRatio defines the speed ratio to apply to all animations
  13552. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13553. * @param onAnimationLoop defines the callback to call when an animation loops
  13554. * @returns the list of animatables created for all nodes
  13555. */
  13556. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13557. /**
  13558. * Gets the animatable associated with a specific target
  13559. * @param target defines the target of the animatable
  13560. * @returns the required animatable if found
  13561. */
  13562. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13563. /**
  13564. * Gets all animatables associated with a given target
  13565. * @param target defines the target to look animatables for
  13566. * @returns an array of Animatables
  13567. */
  13568. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13569. /**
  13570. * Stops and removes all animations that have been applied to the scene
  13571. */
  13572. stopAllAnimations(): void;
  13573. /**
  13574. * Gets the current delta time used by animation engine
  13575. */
  13576. deltaTime: number;
  13577. }
  13578. }
  13579. module "babylonjs/Bones/bone" {
  13580. interface Bone {
  13581. /**
  13582. * Copy an animation range from another bone
  13583. * @param source defines the source bone
  13584. * @param rangeName defines the range name to copy
  13585. * @param frameOffset defines the frame offset
  13586. * @param rescaleAsRequired defines if rescaling must be applied if required
  13587. * @param skelDimensionsRatio defines the scaling ratio
  13588. * @returns true if operation was successful
  13589. */
  13590. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13591. }
  13592. }
  13593. }
  13594. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13595. /**
  13596. * Class used to override all child animations of a given target
  13597. */
  13598. export class AnimationPropertiesOverride {
  13599. /**
  13600. * Gets or sets a value indicating if animation blending must be used
  13601. */
  13602. enableBlending: boolean;
  13603. /**
  13604. * Gets or sets the blending speed to use when enableBlending is true
  13605. */
  13606. blendingSpeed: number;
  13607. /**
  13608. * Gets or sets the default loop mode to use
  13609. */
  13610. loopMode: number;
  13611. }
  13612. }
  13613. declare module "babylonjs/Bones/skeleton" {
  13614. import { Bone } from "babylonjs/Bones/bone";
  13615. import { Observable } from "babylonjs/Misc/observable";
  13616. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13617. import { Scene } from "babylonjs/scene";
  13618. import { Nullable } from "babylonjs/types";
  13619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13620. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13621. import { Animatable } from "babylonjs/Animations/animatable";
  13622. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13623. import { Animation } from "babylonjs/Animations/animation";
  13624. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13625. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13626. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13627. /**
  13628. * Class used to handle skinning animations
  13629. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13630. */
  13631. export class Skeleton implements IAnimatable {
  13632. /** defines the skeleton name */
  13633. name: string;
  13634. /** defines the skeleton Id */
  13635. id: string;
  13636. /**
  13637. * Defines the list of child bones
  13638. */
  13639. bones: Bone[];
  13640. /**
  13641. * Defines an estimate of the dimension of the skeleton at rest
  13642. */
  13643. dimensionsAtRest: Vector3;
  13644. /**
  13645. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13646. */
  13647. needInitialSkinMatrix: boolean;
  13648. /**
  13649. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13650. */
  13651. overrideMesh: Nullable<AbstractMesh>;
  13652. /**
  13653. * Gets the list of animations attached to this skeleton
  13654. */
  13655. animations: Array<Animation>;
  13656. private _scene;
  13657. private _isDirty;
  13658. private _transformMatrices;
  13659. private _transformMatrixTexture;
  13660. private _meshesWithPoseMatrix;
  13661. private _animatables;
  13662. private _identity;
  13663. private _synchronizedWithMesh;
  13664. private _ranges;
  13665. private _lastAbsoluteTransformsUpdateId;
  13666. private _canUseTextureForBones;
  13667. private _uniqueId;
  13668. /** @hidden */
  13669. _numBonesWithLinkedTransformNode: number;
  13670. /** @hidden */
  13671. _hasWaitingData: Nullable<boolean>;
  13672. /**
  13673. * Specifies if the skeleton should be serialized
  13674. */
  13675. doNotSerialize: boolean;
  13676. private _useTextureToStoreBoneMatrices;
  13677. /**
  13678. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13679. * Please note that this option is not available if the hardware does not support it
  13680. */
  13681. useTextureToStoreBoneMatrices: boolean;
  13682. private _animationPropertiesOverride;
  13683. /**
  13684. * Gets or sets the animation properties override
  13685. */
  13686. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13687. /**
  13688. * List of inspectable custom properties (used by the Inspector)
  13689. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13690. */
  13691. inspectableCustomProperties: IInspectable[];
  13692. /**
  13693. * An observable triggered before computing the skeleton's matrices
  13694. */
  13695. onBeforeComputeObservable: Observable<Skeleton>;
  13696. /**
  13697. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13698. */
  13699. readonly isUsingTextureForMatrices: boolean;
  13700. /**
  13701. * Gets the unique ID of this skeleton
  13702. */
  13703. readonly uniqueId: number;
  13704. /**
  13705. * Creates a new skeleton
  13706. * @param name defines the skeleton name
  13707. * @param id defines the skeleton Id
  13708. * @param scene defines the hosting scene
  13709. */
  13710. constructor(
  13711. /** defines the skeleton name */
  13712. name: string,
  13713. /** defines the skeleton Id */
  13714. id: string, scene: Scene);
  13715. /**
  13716. * Gets the current object class name.
  13717. * @return the class name
  13718. */
  13719. getClassName(): string;
  13720. /**
  13721. * Returns an array containing the root bones
  13722. * @returns an array containing the root bones
  13723. */
  13724. getChildren(): Array<Bone>;
  13725. /**
  13726. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13727. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13728. * @returns a Float32Array containing matrices data
  13729. */
  13730. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13731. /**
  13732. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13733. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13734. * @returns a raw texture containing the data
  13735. */
  13736. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13737. /**
  13738. * Gets the current hosting scene
  13739. * @returns a scene object
  13740. */
  13741. getScene(): Scene;
  13742. /**
  13743. * Gets a string representing the current skeleton data
  13744. * @param fullDetails defines a boolean indicating if we want a verbose version
  13745. * @returns a string representing the current skeleton data
  13746. */
  13747. toString(fullDetails?: boolean): string;
  13748. /**
  13749. * Get bone's index searching by name
  13750. * @param name defines bone's name to search for
  13751. * @return the indice of the bone. Returns -1 if not found
  13752. */
  13753. getBoneIndexByName(name: string): number;
  13754. /**
  13755. * Creater a new animation range
  13756. * @param name defines the name of the range
  13757. * @param from defines the start key
  13758. * @param to defines the end key
  13759. */
  13760. createAnimationRange(name: string, from: number, to: number): void;
  13761. /**
  13762. * Delete a specific animation range
  13763. * @param name defines the name of the range
  13764. * @param deleteFrames defines if frames must be removed as well
  13765. */
  13766. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13767. /**
  13768. * Gets a specific animation range
  13769. * @param name defines the name of the range to look for
  13770. * @returns the requested animation range or null if not found
  13771. */
  13772. getAnimationRange(name: string): Nullable<AnimationRange>;
  13773. /**
  13774. * Gets the list of all animation ranges defined on this skeleton
  13775. * @returns an array
  13776. */
  13777. getAnimationRanges(): Nullable<AnimationRange>[];
  13778. /**
  13779. * Copy animation range from a source skeleton.
  13780. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13781. * @param source defines the source skeleton
  13782. * @param name defines the name of the range to copy
  13783. * @param rescaleAsRequired defines if rescaling must be applied if required
  13784. * @returns true if operation was successful
  13785. */
  13786. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13787. /**
  13788. * Forces the skeleton to go to rest pose
  13789. */
  13790. returnToRest(): void;
  13791. private _getHighestAnimationFrame;
  13792. /**
  13793. * Begin a specific animation range
  13794. * @param name defines the name of the range to start
  13795. * @param loop defines if looping must be turned on (false by default)
  13796. * @param speedRatio defines the speed ratio to apply (1 by default)
  13797. * @param onAnimationEnd defines a callback which will be called when animation will end
  13798. * @returns a new animatable
  13799. */
  13800. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13801. /** @hidden */
  13802. _markAsDirty(): void;
  13803. /** @hidden */
  13804. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13805. /** @hidden */
  13806. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13807. private _computeTransformMatrices;
  13808. /**
  13809. * Build all resources required to render a skeleton
  13810. */
  13811. prepare(): void;
  13812. /**
  13813. * Gets the list of animatables currently running for this skeleton
  13814. * @returns an array of animatables
  13815. */
  13816. getAnimatables(): IAnimatable[];
  13817. /**
  13818. * Clone the current skeleton
  13819. * @param name defines the name of the new skeleton
  13820. * @param id defines the id of the new skeleton
  13821. * @returns the new skeleton
  13822. */
  13823. clone(name: string, id?: string): Skeleton;
  13824. /**
  13825. * Enable animation blending for this skeleton
  13826. * @param blendingSpeed defines the blending speed to apply
  13827. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13828. */
  13829. enableBlending(blendingSpeed?: number): void;
  13830. /**
  13831. * Releases all resources associated with the current skeleton
  13832. */
  13833. dispose(): void;
  13834. /**
  13835. * Serialize the skeleton in a JSON object
  13836. * @returns a JSON object
  13837. */
  13838. serialize(): any;
  13839. /**
  13840. * Creates a new skeleton from serialized data
  13841. * @param parsedSkeleton defines the serialized data
  13842. * @param scene defines the hosting scene
  13843. * @returns a new skeleton
  13844. */
  13845. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13846. /**
  13847. * Compute all node absolute transforms
  13848. * @param forceUpdate defines if computation must be done even if cache is up to date
  13849. */
  13850. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13851. /**
  13852. * Gets the root pose matrix
  13853. * @returns a matrix
  13854. */
  13855. getPoseMatrix(): Nullable<Matrix>;
  13856. /**
  13857. * Sorts bones per internal index
  13858. */
  13859. sortBones(): void;
  13860. private _sortBones;
  13861. }
  13862. }
  13863. declare module "babylonjs/Bones/bone" {
  13864. import { Skeleton } from "babylonjs/Bones/skeleton";
  13865. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13866. import { Nullable } from "babylonjs/types";
  13867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13868. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13869. import { Node } from "babylonjs/node";
  13870. import { Space } from "babylonjs/Maths/math.axis";
  13871. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13872. /**
  13873. * Class used to store bone information
  13874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13875. */
  13876. export class Bone extends Node {
  13877. /**
  13878. * defines the bone name
  13879. */
  13880. name: string;
  13881. private static _tmpVecs;
  13882. private static _tmpQuat;
  13883. private static _tmpMats;
  13884. /**
  13885. * Gets the list of child bones
  13886. */
  13887. children: Bone[];
  13888. /** Gets the animations associated with this bone */
  13889. animations: import("babylonjs/Animations/animation").Animation[];
  13890. /**
  13891. * Gets or sets bone length
  13892. */
  13893. length: number;
  13894. /**
  13895. * @hidden Internal only
  13896. * Set this value to map this bone to a different index in the transform matrices
  13897. * Set this value to -1 to exclude the bone from the transform matrices
  13898. */
  13899. _index: Nullable<number>;
  13900. private _skeleton;
  13901. private _localMatrix;
  13902. private _restPose;
  13903. private _baseMatrix;
  13904. private _absoluteTransform;
  13905. private _invertedAbsoluteTransform;
  13906. private _parent;
  13907. private _scalingDeterminant;
  13908. private _worldTransform;
  13909. private _localScaling;
  13910. private _localRotation;
  13911. private _localPosition;
  13912. private _needToDecompose;
  13913. private _needToCompose;
  13914. /** @hidden */
  13915. _linkedTransformNode: Nullable<TransformNode>;
  13916. /** @hidden */
  13917. _waitingTransformNodeId: Nullable<string>;
  13918. /** @hidden */
  13919. /** @hidden */
  13920. _matrix: Matrix;
  13921. /**
  13922. * Create a new bone
  13923. * @param name defines the bone name
  13924. * @param skeleton defines the parent skeleton
  13925. * @param parentBone defines the parent (can be null if the bone is the root)
  13926. * @param localMatrix defines the local matrix
  13927. * @param restPose defines the rest pose matrix
  13928. * @param baseMatrix defines the base matrix
  13929. * @param index defines index of the bone in the hiearchy
  13930. */
  13931. constructor(
  13932. /**
  13933. * defines the bone name
  13934. */
  13935. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13936. /**
  13937. * Gets the current object class name.
  13938. * @return the class name
  13939. */
  13940. getClassName(): string;
  13941. /**
  13942. * Gets the parent skeleton
  13943. * @returns a skeleton
  13944. */
  13945. getSkeleton(): Skeleton;
  13946. /**
  13947. * Gets parent bone
  13948. * @returns a bone or null if the bone is the root of the bone hierarchy
  13949. */
  13950. getParent(): Nullable<Bone>;
  13951. /**
  13952. * Returns an array containing the root bones
  13953. * @returns an array containing the root bones
  13954. */
  13955. getChildren(): Array<Bone>;
  13956. /**
  13957. * Gets the node index in matrix array generated for rendering
  13958. * @returns the node index
  13959. */
  13960. getIndex(): number;
  13961. /**
  13962. * Sets the parent bone
  13963. * @param parent defines the parent (can be null if the bone is the root)
  13964. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13965. */
  13966. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13967. /**
  13968. * Gets the local matrix
  13969. * @returns a matrix
  13970. */
  13971. getLocalMatrix(): Matrix;
  13972. /**
  13973. * Gets the base matrix (initial matrix which remains unchanged)
  13974. * @returns a matrix
  13975. */
  13976. getBaseMatrix(): Matrix;
  13977. /**
  13978. * Gets the rest pose matrix
  13979. * @returns a matrix
  13980. */
  13981. getRestPose(): Matrix;
  13982. /**
  13983. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13984. */
  13985. getWorldMatrix(): Matrix;
  13986. /**
  13987. * Sets the local matrix to rest pose matrix
  13988. */
  13989. returnToRest(): void;
  13990. /**
  13991. * Gets the inverse of the absolute transform matrix.
  13992. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13993. * @returns a matrix
  13994. */
  13995. getInvertedAbsoluteTransform(): Matrix;
  13996. /**
  13997. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13998. * @returns a matrix
  13999. */
  14000. getAbsoluteTransform(): Matrix;
  14001. /**
  14002. * Links with the given transform node.
  14003. * The local matrix of this bone is copied from the transform node every frame.
  14004. * @param transformNode defines the transform node to link to
  14005. */
  14006. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14007. /**
  14008. * Gets the node used to drive the bone's transformation
  14009. * @returns a transform node or null
  14010. */
  14011. getTransformNode(): Nullable<TransformNode>;
  14012. /** Gets or sets current position (in local space) */
  14013. position: Vector3;
  14014. /** Gets or sets current rotation (in local space) */
  14015. rotation: Vector3;
  14016. /** Gets or sets current rotation quaternion (in local space) */
  14017. rotationQuaternion: Quaternion;
  14018. /** Gets or sets current scaling (in local space) */
  14019. scaling: Vector3;
  14020. /**
  14021. * Gets the animation properties override
  14022. */
  14023. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14024. private _decompose;
  14025. private _compose;
  14026. /**
  14027. * Update the base and local matrices
  14028. * @param matrix defines the new base or local matrix
  14029. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14030. * @param updateLocalMatrix defines if the local matrix should be updated
  14031. */
  14032. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14033. /** @hidden */
  14034. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14035. /**
  14036. * Flag the bone as dirty (Forcing it to update everything)
  14037. */
  14038. markAsDirty(): void;
  14039. /** @hidden */
  14040. _markAsDirtyAndCompose(): void;
  14041. private _markAsDirtyAndDecompose;
  14042. /**
  14043. * Translate the bone in local or world space
  14044. * @param vec The amount to translate the bone
  14045. * @param space The space that the translation is in
  14046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14047. */
  14048. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14049. /**
  14050. * Set the postion of the bone in local or world space
  14051. * @param position The position to set the bone
  14052. * @param space The space that the position is in
  14053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14054. */
  14055. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14056. /**
  14057. * Set the absolute position of the bone (world space)
  14058. * @param position The position to set the bone
  14059. * @param mesh The mesh that this bone is attached to
  14060. */
  14061. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14062. /**
  14063. * Scale the bone on the x, y and z axes (in local space)
  14064. * @param x The amount to scale the bone on the x axis
  14065. * @param y The amount to scale the bone on the y axis
  14066. * @param z The amount to scale the bone on the z axis
  14067. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14068. */
  14069. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14070. /**
  14071. * Set the bone scaling in local space
  14072. * @param scale defines the scaling vector
  14073. */
  14074. setScale(scale: Vector3): void;
  14075. /**
  14076. * Gets the current scaling in local space
  14077. * @returns the current scaling vector
  14078. */
  14079. getScale(): Vector3;
  14080. /**
  14081. * Gets the current scaling in local space and stores it in a target vector
  14082. * @param result defines the target vector
  14083. */
  14084. getScaleToRef(result: Vector3): void;
  14085. /**
  14086. * Set the yaw, pitch, and roll of the bone in local or world space
  14087. * @param yaw The rotation of the bone on the y axis
  14088. * @param pitch The rotation of the bone on the x axis
  14089. * @param roll The rotation of the bone on the z axis
  14090. * @param space The space that the axes of rotation are in
  14091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14092. */
  14093. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14094. /**
  14095. * Add a rotation to the bone on an axis in local or world space
  14096. * @param axis The axis to rotate the bone on
  14097. * @param amount The amount to rotate the bone
  14098. * @param space The space that the axis is in
  14099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14100. */
  14101. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14102. /**
  14103. * Set the rotation of the bone to a particular axis angle in local or world space
  14104. * @param axis The axis to rotate the bone on
  14105. * @param angle The angle that the bone should be rotated to
  14106. * @param space The space that the axis is in
  14107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14108. */
  14109. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14110. /**
  14111. * Set the euler rotation of the bone in local of world space
  14112. * @param rotation The euler rotation that the bone should be set to
  14113. * @param space The space that the rotation is in
  14114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14115. */
  14116. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14117. /**
  14118. * Set the quaternion rotation of the bone in local of world space
  14119. * @param quat The quaternion rotation that the bone should be set to
  14120. * @param space The space that the rotation is in
  14121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14122. */
  14123. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14124. /**
  14125. * Set the rotation matrix of the bone in local of world space
  14126. * @param rotMat The rotation matrix that the bone should be set to
  14127. * @param space The space that the rotation is in
  14128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14129. */
  14130. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14131. private _rotateWithMatrix;
  14132. private _getNegativeRotationToRef;
  14133. /**
  14134. * Get the position of the bone in local or world space
  14135. * @param space The space that the returned position is in
  14136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14137. * @returns The position of the bone
  14138. */
  14139. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14140. /**
  14141. * Copy the position of the bone to a vector3 in local or world space
  14142. * @param space The space that the returned position is in
  14143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14144. * @param result The vector3 to copy the position to
  14145. */
  14146. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14147. /**
  14148. * Get the absolute position of the bone (world space)
  14149. * @param mesh The mesh that this bone is attached to
  14150. * @returns The absolute position of the bone
  14151. */
  14152. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14153. /**
  14154. * Copy the absolute position of the bone (world space) to the result param
  14155. * @param mesh The mesh that this bone is attached to
  14156. * @param result The vector3 to copy the absolute position to
  14157. */
  14158. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14159. /**
  14160. * Compute the absolute transforms of this bone and its children
  14161. */
  14162. computeAbsoluteTransforms(): void;
  14163. /**
  14164. * Get the world direction from an axis that is in the local space of the bone
  14165. * @param localAxis The local direction that is used to compute the world direction
  14166. * @param mesh The mesh that this bone is attached to
  14167. * @returns The world direction
  14168. */
  14169. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14170. /**
  14171. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14172. * @param localAxis The local direction that is used to compute the world direction
  14173. * @param mesh The mesh that this bone is attached to
  14174. * @param result The vector3 that the world direction will be copied to
  14175. */
  14176. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14177. /**
  14178. * Get the euler rotation of the bone in local or world space
  14179. * @param space The space that the rotation should be in
  14180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14181. * @returns The euler rotation
  14182. */
  14183. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14184. /**
  14185. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14186. * @param space The space that the rotation should be in
  14187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14188. * @param result The vector3 that the rotation should be copied to
  14189. */
  14190. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14191. /**
  14192. * Get the quaternion rotation of the bone in either local or world space
  14193. * @param space The space that the rotation should be in
  14194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14195. * @returns The quaternion rotation
  14196. */
  14197. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14198. /**
  14199. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14200. * @param space The space that the rotation should be in
  14201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14202. * @param result The quaternion that the rotation should be copied to
  14203. */
  14204. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14205. /**
  14206. * Get the rotation matrix of the bone in local or world space
  14207. * @param space The space that the rotation should be in
  14208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14209. * @returns The rotation matrix
  14210. */
  14211. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14212. /**
  14213. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14214. * @param space The space that the rotation should be in
  14215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14216. * @param result The quaternion that the rotation should be copied to
  14217. */
  14218. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14219. /**
  14220. * Get the world position of a point that is in the local space of the bone
  14221. * @param position The local position
  14222. * @param mesh The mesh that this bone is attached to
  14223. * @returns The world position
  14224. */
  14225. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14226. /**
  14227. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14228. * @param position The local position
  14229. * @param mesh The mesh that this bone is attached to
  14230. * @param result The vector3 that the world position should be copied to
  14231. */
  14232. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14233. /**
  14234. * Get the local position of a point that is in world space
  14235. * @param position The world position
  14236. * @param mesh The mesh that this bone is attached to
  14237. * @returns The local position
  14238. */
  14239. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14240. /**
  14241. * Get the local position of a point that is in world space and copy it to the result param
  14242. * @param position The world position
  14243. * @param mesh The mesh that this bone is attached to
  14244. * @param result The vector3 that the local position should be copied to
  14245. */
  14246. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14247. }
  14248. }
  14249. declare module "babylonjs/Meshes/transformNode" {
  14250. import { DeepImmutable } from "babylonjs/types";
  14251. import { Observable } from "babylonjs/Misc/observable";
  14252. import { Nullable } from "babylonjs/types";
  14253. import { Camera } from "babylonjs/Cameras/camera";
  14254. import { Scene } from "babylonjs/scene";
  14255. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14256. import { Node } from "babylonjs/node";
  14257. import { Bone } from "babylonjs/Bones/bone";
  14258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14259. import { Space } from "babylonjs/Maths/math.axis";
  14260. /**
  14261. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14262. * @see https://doc.babylonjs.com/how_to/transformnode
  14263. */
  14264. export class TransformNode extends Node {
  14265. /**
  14266. * Object will not rotate to face the camera
  14267. */
  14268. static BILLBOARDMODE_NONE: number;
  14269. /**
  14270. * Object will rotate to face the camera but only on the x axis
  14271. */
  14272. static BILLBOARDMODE_X: number;
  14273. /**
  14274. * Object will rotate to face the camera but only on the y axis
  14275. */
  14276. static BILLBOARDMODE_Y: number;
  14277. /**
  14278. * Object will rotate to face the camera but only on the z axis
  14279. */
  14280. static BILLBOARDMODE_Z: number;
  14281. /**
  14282. * Object will rotate to face the camera
  14283. */
  14284. static BILLBOARDMODE_ALL: number;
  14285. /**
  14286. * Object will rotate to face the camera's position instead of orientation
  14287. */
  14288. static BILLBOARDMODE_USE_POSITION: number;
  14289. private _forward;
  14290. private _forwardInverted;
  14291. private _up;
  14292. private _right;
  14293. private _rightInverted;
  14294. private _position;
  14295. private _rotation;
  14296. private _rotationQuaternion;
  14297. protected _scaling: Vector3;
  14298. protected _isDirty: boolean;
  14299. private _transformToBoneReferal;
  14300. private _isAbsoluteSynced;
  14301. private _billboardMode;
  14302. /**
  14303. * Gets or sets the billboard mode. Default is 0.
  14304. *
  14305. * | Value | Type | Description |
  14306. * | --- | --- | --- |
  14307. * | 0 | BILLBOARDMODE_NONE | |
  14308. * | 1 | BILLBOARDMODE_X | |
  14309. * | 2 | BILLBOARDMODE_Y | |
  14310. * | 4 | BILLBOARDMODE_Z | |
  14311. * | 7 | BILLBOARDMODE_ALL | |
  14312. *
  14313. */
  14314. billboardMode: number;
  14315. private _preserveParentRotationForBillboard;
  14316. /**
  14317. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14318. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14319. */
  14320. preserveParentRotationForBillboard: boolean;
  14321. /**
  14322. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14323. */
  14324. scalingDeterminant: number;
  14325. private _infiniteDistance;
  14326. /**
  14327. * Gets or sets the distance of the object to max, often used by skybox
  14328. */
  14329. infiniteDistance: boolean;
  14330. /**
  14331. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14332. * By default the system will update normals to compensate
  14333. */
  14334. ignoreNonUniformScaling: boolean;
  14335. /**
  14336. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14337. */
  14338. reIntegrateRotationIntoRotationQuaternion: boolean;
  14339. /** @hidden */
  14340. _poseMatrix: Nullable<Matrix>;
  14341. /** @hidden */
  14342. _localMatrix: Matrix;
  14343. private _usePivotMatrix;
  14344. private _absolutePosition;
  14345. private _absoluteScaling;
  14346. private _absoluteRotationQuaternion;
  14347. private _pivotMatrix;
  14348. private _pivotMatrixInverse;
  14349. protected _postMultiplyPivotMatrix: boolean;
  14350. protected _isWorldMatrixFrozen: boolean;
  14351. /** @hidden */
  14352. _indexInSceneTransformNodesArray: number;
  14353. /**
  14354. * An event triggered after the world matrix is updated
  14355. */
  14356. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14357. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14358. /**
  14359. * Gets a string identifying the name of the class
  14360. * @returns "TransformNode" string
  14361. */
  14362. getClassName(): string;
  14363. /**
  14364. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14365. */
  14366. position: Vector3;
  14367. /**
  14368. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14369. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14370. */
  14371. rotation: Vector3;
  14372. /**
  14373. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14374. */
  14375. scaling: Vector3;
  14376. /**
  14377. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14378. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14379. */
  14380. rotationQuaternion: Nullable<Quaternion>;
  14381. /**
  14382. * The forward direction of that transform in world space.
  14383. */
  14384. readonly forward: Vector3;
  14385. /**
  14386. * The up direction of that transform in world space.
  14387. */
  14388. readonly up: Vector3;
  14389. /**
  14390. * The right direction of that transform in world space.
  14391. */
  14392. readonly right: Vector3;
  14393. /**
  14394. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14395. * @param matrix the matrix to copy the pose from
  14396. * @returns this TransformNode.
  14397. */
  14398. updatePoseMatrix(matrix: Matrix): TransformNode;
  14399. /**
  14400. * Returns the mesh Pose matrix.
  14401. * @returns the pose matrix
  14402. */
  14403. getPoseMatrix(): Matrix;
  14404. /** @hidden */
  14405. _isSynchronized(): boolean;
  14406. /** @hidden */
  14407. _initCache(): void;
  14408. /**
  14409. * Flag the transform node as dirty (Forcing it to update everything)
  14410. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14411. * @returns this transform node
  14412. */
  14413. markAsDirty(property: string): TransformNode;
  14414. /**
  14415. * Returns the current mesh absolute position.
  14416. * Returns a Vector3.
  14417. */
  14418. readonly absolutePosition: Vector3;
  14419. /**
  14420. * Returns the current mesh absolute scaling.
  14421. * Returns a Vector3.
  14422. */
  14423. readonly absoluteScaling: Vector3;
  14424. /**
  14425. * Returns the current mesh absolute rotation.
  14426. * Returns a Quaternion.
  14427. */
  14428. readonly absoluteRotationQuaternion: Quaternion;
  14429. /**
  14430. * Sets a new matrix to apply before all other transformation
  14431. * @param matrix defines the transform matrix
  14432. * @returns the current TransformNode
  14433. */
  14434. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14435. /**
  14436. * Sets a new pivot matrix to the current node
  14437. * @param matrix defines the new pivot matrix to use
  14438. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14439. * @returns the current TransformNode
  14440. */
  14441. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14442. /**
  14443. * Returns the mesh pivot matrix.
  14444. * Default : Identity.
  14445. * @returns the matrix
  14446. */
  14447. getPivotMatrix(): Matrix;
  14448. /**
  14449. * Instantiate (when possible) or clone that node with its hierarchy
  14450. * @param newParent defines the new parent to use for the instance (or clone)
  14451. * @param options defines options to configure how copy is done
  14452. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14453. * @returns an instance (or a clone) of the current node with its hiearchy
  14454. */
  14455. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14456. doNotInstantiate: boolean;
  14457. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14458. /**
  14459. * Prevents the World matrix to be computed any longer
  14460. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14461. * @returns the TransformNode.
  14462. */
  14463. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14464. /**
  14465. * Allows back the World matrix computation.
  14466. * @returns the TransformNode.
  14467. */
  14468. unfreezeWorldMatrix(): this;
  14469. /**
  14470. * True if the World matrix has been frozen.
  14471. */
  14472. readonly isWorldMatrixFrozen: boolean;
  14473. /**
  14474. * Retuns the mesh absolute position in the World.
  14475. * @returns a Vector3.
  14476. */
  14477. getAbsolutePosition(): Vector3;
  14478. /**
  14479. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14480. * @param absolutePosition the absolute position to set
  14481. * @returns the TransformNode.
  14482. */
  14483. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14484. /**
  14485. * Sets the mesh position in its local space.
  14486. * @param vector3 the position to set in localspace
  14487. * @returns the TransformNode.
  14488. */
  14489. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14490. /**
  14491. * Returns the mesh position in the local space from the current World matrix values.
  14492. * @returns a new Vector3.
  14493. */
  14494. getPositionExpressedInLocalSpace(): Vector3;
  14495. /**
  14496. * Translates the mesh along the passed Vector3 in its local space.
  14497. * @param vector3 the distance to translate in localspace
  14498. * @returns the TransformNode.
  14499. */
  14500. locallyTranslate(vector3: Vector3): TransformNode;
  14501. private static _lookAtVectorCache;
  14502. /**
  14503. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14504. * @param targetPoint the position (must be in same space as current mesh) to look at
  14505. * @param yawCor optional yaw (y-axis) correction in radians
  14506. * @param pitchCor optional pitch (x-axis) correction in radians
  14507. * @param rollCor optional roll (z-axis) correction in radians
  14508. * @param space the choosen space of the target
  14509. * @returns the TransformNode.
  14510. */
  14511. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14512. /**
  14513. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14514. * This Vector3 is expressed in the World space.
  14515. * @param localAxis axis to rotate
  14516. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14517. */
  14518. getDirection(localAxis: Vector3): Vector3;
  14519. /**
  14520. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14521. * localAxis is expressed in the mesh local space.
  14522. * result is computed in the Wordl space from the mesh World matrix.
  14523. * @param localAxis axis to rotate
  14524. * @param result the resulting transformnode
  14525. * @returns this TransformNode.
  14526. */
  14527. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14528. /**
  14529. * Sets this transform node rotation to the given local axis.
  14530. * @param localAxis the axis in local space
  14531. * @param yawCor optional yaw (y-axis) correction in radians
  14532. * @param pitchCor optional pitch (x-axis) correction in radians
  14533. * @param rollCor optional roll (z-axis) correction in radians
  14534. * @returns this TransformNode
  14535. */
  14536. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14537. /**
  14538. * Sets a new pivot point to the current node
  14539. * @param point defines the new pivot point to use
  14540. * @param space defines if the point is in world or local space (local by default)
  14541. * @returns the current TransformNode
  14542. */
  14543. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14544. /**
  14545. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14546. * @returns the pivot point
  14547. */
  14548. getPivotPoint(): Vector3;
  14549. /**
  14550. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14551. * @param result the vector3 to store the result
  14552. * @returns this TransformNode.
  14553. */
  14554. getPivotPointToRef(result: Vector3): TransformNode;
  14555. /**
  14556. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14557. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14558. */
  14559. getAbsolutePivotPoint(): Vector3;
  14560. /**
  14561. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14562. * @param result vector3 to store the result
  14563. * @returns this TransformNode.
  14564. */
  14565. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14566. /**
  14567. * Defines the passed node as the parent of the current node.
  14568. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14569. * @see https://doc.babylonjs.com/how_to/parenting
  14570. * @param node the node ot set as the parent
  14571. * @returns this TransformNode.
  14572. */
  14573. setParent(node: Nullable<Node>): TransformNode;
  14574. private _nonUniformScaling;
  14575. /**
  14576. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14577. */
  14578. readonly nonUniformScaling: boolean;
  14579. /** @hidden */
  14580. _updateNonUniformScalingState(value: boolean): boolean;
  14581. /**
  14582. * Attach the current TransformNode to another TransformNode associated with a bone
  14583. * @param bone Bone affecting the TransformNode
  14584. * @param affectedTransformNode TransformNode associated with the bone
  14585. * @returns this object
  14586. */
  14587. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14588. /**
  14589. * Detach the transform node if its associated with a bone
  14590. * @returns this object
  14591. */
  14592. detachFromBone(): TransformNode;
  14593. private static _rotationAxisCache;
  14594. /**
  14595. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14596. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14597. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14598. * The passed axis is also normalized.
  14599. * @param axis the axis to rotate around
  14600. * @param amount the amount to rotate in radians
  14601. * @param space Space to rotate in (Default: local)
  14602. * @returns the TransformNode.
  14603. */
  14604. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14605. /**
  14606. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14607. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14608. * The passed axis is also normalized. .
  14609. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14610. * @param point the point to rotate around
  14611. * @param axis the axis to rotate around
  14612. * @param amount the amount to rotate in radians
  14613. * @returns the TransformNode
  14614. */
  14615. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14616. /**
  14617. * Translates the mesh along the axis vector for the passed distance in the given space.
  14618. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14619. * @param axis the axis to translate in
  14620. * @param distance the distance to translate
  14621. * @param space Space to rotate in (Default: local)
  14622. * @returns the TransformNode.
  14623. */
  14624. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14625. /**
  14626. * Adds a rotation step to the mesh current rotation.
  14627. * x, y, z are Euler angles expressed in radians.
  14628. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14629. * This means this rotation is made in the mesh local space only.
  14630. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14631. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14632. * ```javascript
  14633. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14634. * ```
  14635. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14636. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14637. * @param x Rotation to add
  14638. * @param y Rotation to add
  14639. * @param z Rotation to add
  14640. * @returns the TransformNode.
  14641. */
  14642. addRotation(x: number, y: number, z: number): TransformNode;
  14643. /**
  14644. * @hidden
  14645. */
  14646. protected _getEffectiveParent(): Nullable<Node>;
  14647. /**
  14648. * Computes the world matrix of the node
  14649. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14650. * @returns the world matrix
  14651. */
  14652. computeWorldMatrix(force?: boolean): Matrix;
  14653. protected _afterComputeWorldMatrix(): void;
  14654. /**
  14655. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14656. * @param func callback function to add
  14657. *
  14658. * @returns the TransformNode.
  14659. */
  14660. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14661. /**
  14662. * Removes a registered callback function.
  14663. * @param func callback function to remove
  14664. * @returns the TransformNode.
  14665. */
  14666. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14667. /**
  14668. * Gets the position of the current mesh in camera space
  14669. * @param camera defines the camera to use
  14670. * @returns a position
  14671. */
  14672. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14673. /**
  14674. * Returns the distance from the mesh to the active camera
  14675. * @param camera defines the camera to use
  14676. * @returns the distance
  14677. */
  14678. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14679. /**
  14680. * Clone the current transform node
  14681. * @param name Name of the new clone
  14682. * @param newParent New parent for the clone
  14683. * @param doNotCloneChildren Do not clone children hierarchy
  14684. * @returns the new transform node
  14685. */
  14686. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14687. /**
  14688. * Serializes the objects information.
  14689. * @param currentSerializationObject defines the object to serialize in
  14690. * @returns the serialized object
  14691. */
  14692. serialize(currentSerializationObject?: any): any;
  14693. /**
  14694. * Returns a new TransformNode object parsed from the source provided.
  14695. * @param parsedTransformNode is the source.
  14696. * @param scene the scne the object belongs to
  14697. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14698. * @returns a new TransformNode object parsed from the source provided.
  14699. */
  14700. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14701. /**
  14702. * Get all child-transformNodes of this node
  14703. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14704. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14705. * @returns an array of TransformNode
  14706. */
  14707. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14708. /**
  14709. * Releases resources associated with this transform node.
  14710. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14711. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14712. */
  14713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14714. /**
  14715. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14716. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14717. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14718. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14719. * @returns the current mesh
  14720. */
  14721. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14722. private _syncAbsoluteScalingAndRotation;
  14723. }
  14724. }
  14725. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14726. import { Observable } from "babylonjs/Misc/observable";
  14727. import { Nullable } from "babylonjs/types";
  14728. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14729. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14731. import { Ray } from "babylonjs/Culling/ray";
  14732. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14733. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14734. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14735. /**
  14736. * Defines the types of pose enabled controllers that are supported
  14737. */
  14738. export enum PoseEnabledControllerType {
  14739. /**
  14740. * HTC Vive
  14741. */
  14742. VIVE = 0,
  14743. /**
  14744. * Oculus Rift
  14745. */
  14746. OCULUS = 1,
  14747. /**
  14748. * Windows mixed reality
  14749. */
  14750. WINDOWS = 2,
  14751. /**
  14752. * Samsung gear VR
  14753. */
  14754. GEAR_VR = 3,
  14755. /**
  14756. * Google Daydream
  14757. */
  14758. DAYDREAM = 4,
  14759. /**
  14760. * Generic
  14761. */
  14762. GENERIC = 5
  14763. }
  14764. /**
  14765. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14766. */
  14767. export interface MutableGamepadButton {
  14768. /**
  14769. * Value of the button/trigger
  14770. */
  14771. value: number;
  14772. /**
  14773. * If the button/trigger is currently touched
  14774. */
  14775. touched: boolean;
  14776. /**
  14777. * If the button/trigger is currently pressed
  14778. */
  14779. pressed: boolean;
  14780. }
  14781. /**
  14782. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14783. * @hidden
  14784. */
  14785. export interface ExtendedGamepadButton extends GamepadButton {
  14786. /**
  14787. * If the button/trigger is currently pressed
  14788. */
  14789. readonly pressed: boolean;
  14790. /**
  14791. * If the button/trigger is currently touched
  14792. */
  14793. readonly touched: boolean;
  14794. /**
  14795. * Value of the button/trigger
  14796. */
  14797. readonly value: number;
  14798. }
  14799. /** @hidden */
  14800. export interface _GamePadFactory {
  14801. /**
  14802. * Returns wether or not the current gamepad can be created for this type of controller.
  14803. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14804. * @returns true if it can be created, otherwise false
  14805. */
  14806. canCreate(gamepadInfo: any): boolean;
  14807. /**
  14808. * Creates a new instance of the Gamepad.
  14809. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14810. * @returns the new gamepad instance
  14811. */
  14812. create(gamepadInfo: any): Gamepad;
  14813. }
  14814. /**
  14815. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14816. */
  14817. export class PoseEnabledControllerHelper {
  14818. /** @hidden */
  14819. static _ControllerFactories: _GamePadFactory[];
  14820. /** @hidden */
  14821. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14822. /**
  14823. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14824. * @param vrGamepad the gamepad to initialized
  14825. * @returns a vr controller of the type the gamepad identified as
  14826. */
  14827. static InitiateController(vrGamepad: any): Gamepad;
  14828. }
  14829. /**
  14830. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14831. */
  14832. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14833. /**
  14834. * If the controller is used in a webXR session
  14835. */
  14836. isXR: boolean;
  14837. private _deviceRoomPosition;
  14838. private _deviceRoomRotationQuaternion;
  14839. /**
  14840. * The device position in babylon space
  14841. */
  14842. devicePosition: Vector3;
  14843. /**
  14844. * The device rotation in babylon space
  14845. */
  14846. deviceRotationQuaternion: Quaternion;
  14847. /**
  14848. * The scale factor of the device in babylon space
  14849. */
  14850. deviceScaleFactor: number;
  14851. /**
  14852. * (Likely devicePosition should be used instead) The device position in its room space
  14853. */
  14854. position: Vector3;
  14855. /**
  14856. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14857. */
  14858. rotationQuaternion: Quaternion;
  14859. /**
  14860. * The type of controller (Eg. Windows mixed reality)
  14861. */
  14862. controllerType: PoseEnabledControllerType;
  14863. protected _calculatedPosition: Vector3;
  14864. private _calculatedRotation;
  14865. /**
  14866. * The raw pose from the device
  14867. */
  14868. rawPose: DevicePose;
  14869. private _trackPosition;
  14870. private _maxRotationDistFromHeadset;
  14871. private _draggedRoomRotation;
  14872. /**
  14873. * @hidden
  14874. */
  14875. _disableTrackPosition(fixedPosition: Vector3): void;
  14876. /**
  14877. * Internal, the mesh attached to the controller
  14878. * @hidden
  14879. */
  14880. _mesh: Nullable<AbstractMesh>;
  14881. private _poseControlledCamera;
  14882. private _leftHandSystemQuaternion;
  14883. /**
  14884. * Internal, matrix used to convert room space to babylon space
  14885. * @hidden
  14886. */
  14887. _deviceToWorld: Matrix;
  14888. /**
  14889. * Node to be used when casting a ray from the controller
  14890. * @hidden
  14891. */
  14892. _pointingPoseNode: Nullable<TransformNode>;
  14893. /**
  14894. * Name of the child mesh that can be used to cast a ray from the controller
  14895. */
  14896. static readonly POINTING_POSE: string;
  14897. /**
  14898. * Creates a new PoseEnabledController from a gamepad
  14899. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14900. */
  14901. constructor(browserGamepad: any);
  14902. private _workingMatrix;
  14903. /**
  14904. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14905. */
  14906. update(): void;
  14907. /**
  14908. * Updates only the pose device and mesh without doing any button event checking
  14909. */
  14910. protected _updatePoseAndMesh(): void;
  14911. /**
  14912. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14913. * @param poseData raw pose fromthe device
  14914. */
  14915. updateFromDevice(poseData: DevicePose): void;
  14916. /**
  14917. * @hidden
  14918. */
  14919. _meshAttachedObservable: Observable<AbstractMesh>;
  14920. /**
  14921. * Attaches a mesh to the controller
  14922. * @param mesh the mesh to be attached
  14923. */
  14924. attachToMesh(mesh: AbstractMesh): void;
  14925. /**
  14926. * Attaches the controllers mesh to a camera
  14927. * @param camera the camera the mesh should be attached to
  14928. */
  14929. attachToPoseControlledCamera(camera: TargetCamera): void;
  14930. /**
  14931. * Disposes of the controller
  14932. */
  14933. dispose(): void;
  14934. /**
  14935. * The mesh that is attached to the controller
  14936. */
  14937. readonly mesh: Nullable<AbstractMesh>;
  14938. /**
  14939. * Gets the ray of the controller in the direction the controller is pointing
  14940. * @param length the length the resulting ray should be
  14941. * @returns a ray in the direction the controller is pointing
  14942. */
  14943. getForwardRay(length?: number): Ray;
  14944. }
  14945. }
  14946. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14947. import { Observable } from "babylonjs/Misc/observable";
  14948. import { Scene } from "babylonjs/scene";
  14949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14950. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14951. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14952. import { Nullable } from "babylonjs/types";
  14953. /**
  14954. * Defines the WebVRController object that represents controllers tracked in 3D space
  14955. */
  14956. export abstract class WebVRController extends PoseEnabledController {
  14957. /**
  14958. * Internal, the default controller model for the controller
  14959. */
  14960. protected _defaultModel: Nullable<AbstractMesh>;
  14961. /**
  14962. * Fired when the trigger state has changed
  14963. */
  14964. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14965. /**
  14966. * Fired when the main button state has changed
  14967. */
  14968. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14969. /**
  14970. * Fired when the secondary button state has changed
  14971. */
  14972. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14973. /**
  14974. * Fired when the pad state has changed
  14975. */
  14976. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14977. /**
  14978. * Fired when controllers stick values have changed
  14979. */
  14980. onPadValuesChangedObservable: Observable<StickValues>;
  14981. /**
  14982. * Array of button availible on the controller
  14983. */
  14984. protected _buttons: Array<MutableGamepadButton>;
  14985. private _onButtonStateChange;
  14986. /**
  14987. * Fired when a controller button's state has changed
  14988. * @param callback the callback containing the button that was modified
  14989. */
  14990. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14991. /**
  14992. * X and Y axis corresponding to the controllers joystick
  14993. */
  14994. pad: StickValues;
  14995. /**
  14996. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14997. */
  14998. hand: string;
  14999. /**
  15000. * The default controller model for the controller
  15001. */
  15002. readonly defaultModel: Nullable<AbstractMesh>;
  15003. /**
  15004. * Creates a new WebVRController from a gamepad
  15005. * @param vrGamepad the gamepad that the WebVRController should be created from
  15006. */
  15007. constructor(vrGamepad: any);
  15008. /**
  15009. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15010. */
  15011. update(): void;
  15012. /**
  15013. * Function to be called when a button is modified
  15014. */
  15015. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15016. /**
  15017. * Loads a mesh and attaches it to the controller
  15018. * @param scene the scene the mesh should be added to
  15019. * @param meshLoaded callback for when the mesh has been loaded
  15020. */
  15021. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15022. private _setButtonValue;
  15023. private _changes;
  15024. private _checkChanges;
  15025. /**
  15026. * Disposes of th webVRCOntroller
  15027. */
  15028. dispose(): void;
  15029. }
  15030. }
  15031. declare module "babylonjs/Lights/hemisphericLight" {
  15032. import { Nullable } from "babylonjs/types";
  15033. import { Scene } from "babylonjs/scene";
  15034. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15035. import { Color3 } from "babylonjs/Maths/math.color";
  15036. import { Effect } from "babylonjs/Materials/effect";
  15037. import { Light } from "babylonjs/Lights/light";
  15038. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15039. /**
  15040. * The HemisphericLight simulates the ambient environment light,
  15041. * so the passed direction is the light reflection direction, not the incoming direction.
  15042. */
  15043. export class HemisphericLight extends Light {
  15044. /**
  15045. * The groundColor is the light in the opposite direction to the one specified during creation.
  15046. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  15047. */
  15048. groundColor: Color3;
  15049. /**
  15050. * The light reflection direction, not the incoming direction.
  15051. */
  15052. direction: Vector3;
  15053. /**
  15054. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15055. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15056. * The HemisphericLight can't cast shadows.
  15057. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15058. * @param name The friendly name of the light
  15059. * @param direction The direction of the light reflection
  15060. * @param scene The scene the light belongs to
  15061. */
  15062. constructor(name: string, direction: Vector3, scene: Scene);
  15063. protected _buildUniformLayout(): void;
  15064. /**
  15065. * Returns the string "HemisphericLight".
  15066. * @return The class name
  15067. */
  15068. getClassName(): string;
  15069. /**
  15070. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15071. * Returns the updated direction.
  15072. * @param target The target the direction should point to
  15073. * @return The computed direction
  15074. */
  15075. setDirectionToTarget(target: Vector3): Vector3;
  15076. /**
  15077. * Returns the shadow generator associated to the light.
  15078. * @returns Always null for hemispheric lights because it does not support shadows.
  15079. */
  15080. getShadowGenerator(): Nullable<IShadowGenerator>;
  15081. /**
  15082. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15083. * @param effect The effect to update
  15084. * @param lightIndex The index of the light in the effect to update
  15085. * @returns The hemispheric light
  15086. */
  15087. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15088. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15089. /**
  15090. * Computes the world matrix of the node
  15091. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15092. * @param useWasUpdatedFlag defines a reserved property
  15093. * @returns the world matrix
  15094. */
  15095. computeWorldMatrix(): Matrix;
  15096. /**
  15097. * Returns the integer 3.
  15098. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15099. */
  15100. getTypeID(): number;
  15101. /**
  15102. * Prepares the list of defines specific to the light type.
  15103. * @param defines the list of defines
  15104. * @param lightIndex defines the index of the light for the effect
  15105. */
  15106. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15107. }
  15108. }
  15109. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15110. /** @hidden */
  15111. export var vrMultiviewToSingleviewPixelShader: {
  15112. name: string;
  15113. shader: string;
  15114. };
  15115. }
  15116. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15117. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15118. import { Scene } from "babylonjs/scene";
  15119. /**
  15120. * Renders to multiple views with a single draw call
  15121. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15122. */
  15123. export class MultiviewRenderTarget extends RenderTargetTexture {
  15124. /**
  15125. * Creates a multiview render target
  15126. * @param scene scene used with the render target
  15127. * @param size the size of the render target (used for each view)
  15128. */
  15129. constructor(scene: Scene, size?: number | {
  15130. width: number;
  15131. height: number;
  15132. } | {
  15133. ratio: number;
  15134. });
  15135. /**
  15136. * @hidden
  15137. * @param faceIndex the face index, if its a cube texture
  15138. */
  15139. _bindFrameBuffer(faceIndex?: number): void;
  15140. /**
  15141. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15142. * @returns the view count
  15143. */
  15144. getViewCount(): number;
  15145. }
  15146. }
  15147. declare module "babylonjs/Maths/math.frustum" {
  15148. import { Matrix } from "babylonjs/Maths/math.vector";
  15149. import { DeepImmutable } from "babylonjs/types";
  15150. import { Plane } from "babylonjs/Maths/math.plane";
  15151. /**
  15152. * Represents a camera frustum
  15153. */
  15154. export class Frustum {
  15155. /**
  15156. * Gets the planes representing the frustum
  15157. * @param transform matrix to be applied to the returned planes
  15158. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15159. */
  15160. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15161. /**
  15162. * Gets the near frustum plane transformed by the transform matrix
  15163. * @param transform transformation matrix to be applied to the resulting frustum plane
  15164. * @param frustumPlane the resuling frustum plane
  15165. */
  15166. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15167. /**
  15168. * Gets the far frustum plane transformed by the transform matrix
  15169. * @param transform transformation matrix to be applied to the resulting frustum plane
  15170. * @param frustumPlane the resuling frustum plane
  15171. */
  15172. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15173. /**
  15174. * Gets the left frustum plane transformed by the transform matrix
  15175. * @param transform transformation matrix to be applied to the resulting frustum plane
  15176. * @param frustumPlane the resuling frustum plane
  15177. */
  15178. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15179. /**
  15180. * Gets the right frustum plane transformed by the transform matrix
  15181. * @param transform transformation matrix to be applied to the resulting frustum plane
  15182. * @param frustumPlane the resuling frustum plane
  15183. */
  15184. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15185. /**
  15186. * Gets the top frustum plane transformed by the transform matrix
  15187. * @param transform transformation matrix to be applied to the resulting frustum plane
  15188. * @param frustumPlane the resuling frustum plane
  15189. */
  15190. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15191. /**
  15192. * Gets the bottom frustum plane transformed by the transform matrix
  15193. * @param transform transformation matrix to be applied to the resulting frustum plane
  15194. * @param frustumPlane the resuling frustum plane
  15195. */
  15196. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15197. /**
  15198. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15199. * @param transform transformation matrix to be applied to the resulting frustum planes
  15200. * @param frustumPlanes the resuling frustum planes
  15201. */
  15202. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15203. }
  15204. }
  15205. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15206. import { Camera } from "babylonjs/Cameras/camera";
  15207. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15208. import { Nullable } from "babylonjs/types";
  15209. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15210. import { Matrix } from "babylonjs/Maths/math.vector";
  15211. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15212. module "babylonjs/Engines/engine" {
  15213. interface Engine {
  15214. /**
  15215. * Creates a new multiview render target
  15216. * @param width defines the width of the texture
  15217. * @param height defines the height of the texture
  15218. * @returns the created multiview texture
  15219. */
  15220. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15221. /**
  15222. * Binds a multiview framebuffer to be drawn to
  15223. * @param multiviewTexture texture to bind
  15224. */
  15225. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15226. }
  15227. }
  15228. module "babylonjs/Cameras/camera" {
  15229. interface Camera {
  15230. /**
  15231. * @hidden
  15232. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  15233. */
  15234. _useMultiviewToSingleView: boolean;
  15235. /**
  15236. * @hidden
  15237. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  15238. */
  15239. _multiviewTexture: Nullable<RenderTargetTexture>;
  15240. /**
  15241. * @hidden
  15242. * ensures the multiview texture of the camera exists and has the specified width/height
  15243. * @param width height to set on the multiview texture
  15244. * @param height width to set on the multiview texture
  15245. */
  15246. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15247. }
  15248. }
  15249. module "babylonjs/scene" {
  15250. interface Scene {
  15251. /** @hidden */
  15252. _transformMatrixR: Matrix;
  15253. /** @hidden */
  15254. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15255. /** @hidden */
  15256. _createMultiviewUbo(): void;
  15257. /** @hidden */
  15258. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15259. /** @hidden */
  15260. _renderMultiviewToSingleView(camera: Camera): void;
  15261. }
  15262. }
  15263. }
  15264. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15265. import { Camera } from "babylonjs/Cameras/camera";
  15266. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15267. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15268. import "babylonjs/Engines/Extensions/engine.multiview";
  15269. /**
  15270. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15271. * This will not be used for webXR as it supports displaying texture arrays directly
  15272. */
  15273. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15274. /**
  15275. * Initializes a VRMultiviewToSingleview
  15276. * @param name name of the post process
  15277. * @param camera camera to be applied to
  15278. * @param scaleFactor scaling factor to the size of the output texture
  15279. */
  15280. constructor(name: string, camera: Camera, scaleFactor: number);
  15281. }
  15282. }
  15283. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15284. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15285. import { Nullable } from "babylonjs/types";
  15286. import { Size } from "babylonjs/Maths/math.size";
  15287. import { Observable } from "babylonjs/Misc/observable";
  15288. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15289. /**
  15290. * Interface used to define additional presentation attributes
  15291. */
  15292. export interface IVRPresentationAttributes {
  15293. /**
  15294. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15295. */
  15296. highRefreshRate: boolean;
  15297. /**
  15298. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15299. */
  15300. foveationLevel: number;
  15301. }
  15302. module "babylonjs/Engines/engine" {
  15303. interface Engine {
  15304. /** @hidden */
  15305. _vrDisplay: any;
  15306. /** @hidden */
  15307. _vrSupported: boolean;
  15308. /** @hidden */
  15309. _oldSize: Size;
  15310. /** @hidden */
  15311. _oldHardwareScaleFactor: number;
  15312. /** @hidden */
  15313. _vrExclusivePointerMode: boolean;
  15314. /** @hidden */
  15315. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15316. /** @hidden */
  15317. _onVRDisplayPointerRestricted: () => void;
  15318. /** @hidden */
  15319. _onVRDisplayPointerUnrestricted: () => void;
  15320. /** @hidden */
  15321. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15322. /** @hidden */
  15323. _onVrDisplayDisconnect: Nullable<() => void>;
  15324. /** @hidden */
  15325. _onVrDisplayPresentChange: Nullable<() => void>;
  15326. /**
  15327. * Observable signaled when VR display mode changes
  15328. */
  15329. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15330. /**
  15331. * Observable signaled when VR request present is complete
  15332. */
  15333. onVRRequestPresentComplete: Observable<boolean>;
  15334. /**
  15335. * Observable signaled when VR request present starts
  15336. */
  15337. onVRRequestPresentStart: Observable<Engine>;
  15338. /**
  15339. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15340. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15341. */
  15342. isInVRExclusivePointerMode: boolean;
  15343. /**
  15344. * Gets a boolean indicating if a webVR device was detected
  15345. * @returns true if a webVR device was detected
  15346. */
  15347. isVRDevicePresent(): boolean;
  15348. /**
  15349. * Gets the current webVR device
  15350. * @returns the current webVR device (or null)
  15351. */
  15352. getVRDevice(): any;
  15353. /**
  15354. * Initializes a webVR display and starts listening to display change events
  15355. * The onVRDisplayChangedObservable will be notified upon these changes
  15356. * @returns A promise containing a VRDisplay and if vr is supported
  15357. */
  15358. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15359. /** @hidden */
  15360. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15361. /**
  15362. * Gets or sets the presentation attributes used to configure VR rendering
  15363. */
  15364. vrPresentationAttributes?: IVRPresentationAttributes;
  15365. /**
  15366. * Call this function to switch to webVR mode
  15367. * Will do nothing if webVR is not supported or if there is no webVR device
  15368. * @param options the webvr options provided to the camera. mainly used for multiview
  15369. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15370. */
  15371. enableVR(options: WebVROptions): void;
  15372. /** @hidden */
  15373. _onVRFullScreenTriggered(): void;
  15374. }
  15375. }
  15376. }
  15377. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15378. import { Nullable } from "babylonjs/types";
  15379. import { Observable } from "babylonjs/Misc/observable";
  15380. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15381. import { Scene } from "babylonjs/scene";
  15382. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15383. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15384. import { Node } from "babylonjs/node";
  15385. import { Ray } from "babylonjs/Culling/ray";
  15386. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15387. import "babylonjs/Engines/Extensions/engine.webVR";
  15388. /**
  15389. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15390. * IMPORTANT!! The data is right-hand data.
  15391. * @export
  15392. * @interface DevicePose
  15393. */
  15394. export interface DevicePose {
  15395. /**
  15396. * The position of the device, values in array are [x,y,z].
  15397. */
  15398. readonly position: Nullable<Float32Array>;
  15399. /**
  15400. * The linearVelocity of the device, values in array are [x,y,z].
  15401. */
  15402. readonly linearVelocity: Nullable<Float32Array>;
  15403. /**
  15404. * The linearAcceleration of the device, values in array are [x,y,z].
  15405. */
  15406. readonly linearAcceleration: Nullable<Float32Array>;
  15407. /**
  15408. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15409. */
  15410. readonly orientation: Nullable<Float32Array>;
  15411. /**
  15412. * The angularVelocity of the device, values in array are [x,y,z].
  15413. */
  15414. readonly angularVelocity: Nullable<Float32Array>;
  15415. /**
  15416. * The angularAcceleration of the device, values in array are [x,y,z].
  15417. */
  15418. readonly angularAcceleration: Nullable<Float32Array>;
  15419. }
  15420. /**
  15421. * Interface representing a pose controlled object in Babylon.
  15422. * A pose controlled object has both regular pose values as well as pose values
  15423. * from an external device such as a VR head mounted display
  15424. */
  15425. export interface PoseControlled {
  15426. /**
  15427. * The position of the object in babylon space.
  15428. */
  15429. position: Vector3;
  15430. /**
  15431. * The rotation quaternion of the object in babylon space.
  15432. */
  15433. rotationQuaternion: Quaternion;
  15434. /**
  15435. * The position of the device in babylon space.
  15436. */
  15437. devicePosition?: Vector3;
  15438. /**
  15439. * The rotation quaternion of the device in babylon space.
  15440. */
  15441. deviceRotationQuaternion: Quaternion;
  15442. /**
  15443. * The raw pose coming from the device.
  15444. */
  15445. rawPose: Nullable<DevicePose>;
  15446. /**
  15447. * The scale of the device to be used when translating from device space to babylon space.
  15448. */
  15449. deviceScaleFactor: number;
  15450. /**
  15451. * Updates the poseControlled values based on the input device pose.
  15452. * @param poseData the pose data to update the object with
  15453. */
  15454. updateFromDevice(poseData: DevicePose): void;
  15455. }
  15456. /**
  15457. * Set of options to customize the webVRCamera
  15458. */
  15459. export interface WebVROptions {
  15460. /**
  15461. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15462. */
  15463. trackPosition?: boolean;
  15464. /**
  15465. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15466. */
  15467. positionScale?: number;
  15468. /**
  15469. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15470. */
  15471. displayName?: string;
  15472. /**
  15473. * Should the native controller meshes be initialized. (default: true)
  15474. */
  15475. controllerMeshes?: boolean;
  15476. /**
  15477. * Creating a default HemiLight only on controllers. (default: true)
  15478. */
  15479. defaultLightingOnControllers?: boolean;
  15480. /**
  15481. * If you don't want to use the default VR button of the helper. (default: false)
  15482. */
  15483. useCustomVRButton?: boolean;
  15484. /**
  15485. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15486. */
  15487. customVRButton?: HTMLButtonElement;
  15488. /**
  15489. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15490. */
  15491. rayLength?: number;
  15492. /**
  15493. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15494. */
  15495. defaultHeight?: number;
  15496. /**
  15497. * If multiview should be used if availible (default: false)
  15498. */
  15499. useMultiview?: boolean;
  15500. }
  15501. /**
  15502. * This represents a WebVR camera.
  15503. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15504. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15505. */
  15506. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15507. private webVROptions;
  15508. /**
  15509. * @hidden
  15510. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15511. */
  15512. _vrDevice: any;
  15513. /**
  15514. * The rawPose of the vrDevice.
  15515. */
  15516. rawPose: Nullable<DevicePose>;
  15517. private _onVREnabled;
  15518. private _specsVersion;
  15519. private _attached;
  15520. private _frameData;
  15521. protected _descendants: Array<Node>;
  15522. private _deviceRoomPosition;
  15523. /** @hidden */
  15524. _deviceRoomRotationQuaternion: Quaternion;
  15525. private _standingMatrix;
  15526. /**
  15527. * Represents device position in babylon space.
  15528. */
  15529. devicePosition: Vector3;
  15530. /**
  15531. * Represents device rotation in babylon space.
  15532. */
  15533. deviceRotationQuaternion: Quaternion;
  15534. /**
  15535. * The scale of the device to be used when translating from device space to babylon space.
  15536. */
  15537. deviceScaleFactor: number;
  15538. private _deviceToWorld;
  15539. private _worldToDevice;
  15540. /**
  15541. * References to the webVR controllers for the vrDevice.
  15542. */
  15543. controllers: Array<WebVRController>;
  15544. /**
  15545. * Emits an event when a controller is attached.
  15546. */
  15547. onControllersAttachedObservable: Observable<WebVRController[]>;
  15548. /**
  15549. * Emits an event when a controller's mesh has been loaded;
  15550. */
  15551. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15552. /**
  15553. * Emits an event when the HMD's pose has been updated.
  15554. */
  15555. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15556. private _poseSet;
  15557. /**
  15558. * If the rig cameras be used as parent instead of this camera.
  15559. */
  15560. rigParenting: boolean;
  15561. private _lightOnControllers;
  15562. private _defaultHeight?;
  15563. /**
  15564. * Instantiates a WebVRFreeCamera.
  15565. * @param name The name of the WebVRFreeCamera
  15566. * @param position The starting anchor position for the camera
  15567. * @param scene The scene the camera belongs to
  15568. * @param webVROptions a set of customizable options for the webVRCamera
  15569. */
  15570. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15571. /**
  15572. * Gets the device distance from the ground in meters.
  15573. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  15574. */
  15575. deviceDistanceToRoomGround(): number;
  15576. /**
  15577. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15578. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15579. */
  15580. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15581. /**
  15582. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15583. * @returns A promise with a boolean set to if the standing matrix is supported.
  15584. */
  15585. useStandingMatrixAsync(): Promise<boolean>;
  15586. /**
  15587. * Disposes the camera
  15588. */
  15589. dispose(): void;
  15590. /**
  15591. * Gets a vrController by name.
  15592. * @param name The name of the controller to retreive
  15593. * @returns the controller matching the name specified or null if not found
  15594. */
  15595. getControllerByName(name: string): Nullable<WebVRController>;
  15596. private _leftController;
  15597. /**
  15598. * The controller corresponding to the users left hand.
  15599. */
  15600. readonly leftController: Nullable<WebVRController>;
  15601. private _rightController;
  15602. /**
  15603. * The controller corresponding to the users right hand.
  15604. */
  15605. readonly rightController: Nullable<WebVRController>;
  15606. /**
  15607. * Casts a ray forward from the vrCamera's gaze.
  15608. * @param length Length of the ray (default: 100)
  15609. * @returns the ray corresponding to the gaze
  15610. */
  15611. getForwardRay(length?: number): Ray;
  15612. /**
  15613. * @hidden
  15614. * Updates the camera based on device's frame data
  15615. */
  15616. _checkInputs(): void;
  15617. /**
  15618. * Updates the poseControlled values based on the input device pose.
  15619. * @param poseData Pose coming from the device
  15620. */
  15621. updateFromDevice(poseData: DevicePose): void;
  15622. private _htmlElementAttached;
  15623. private _detachIfAttached;
  15624. /**
  15625. * WebVR's attach control will start broadcasting frames to the device.
  15626. * Note that in certain browsers (chrome for example) this function must be called
  15627. * within a user-interaction callback. Example:
  15628. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15629. *
  15630. * @param element html element to attach the vrDevice to
  15631. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15632. */
  15633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15634. /**
  15635. * Detaches the camera from the html element and disables VR
  15636. *
  15637. * @param element html element to detach from
  15638. */
  15639. detachControl(element: HTMLElement): void;
  15640. /**
  15641. * @returns the name of this class
  15642. */
  15643. getClassName(): string;
  15644. /**
  15645. * Calls resetPose on the vrDisplay
  15646. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15647. */
  15648. resetToCurrentRotation(): void;
  15649. /**
  15650. * @hidden
  15651. * Updates the rig cameras (left and right eye)
  15652. */
  15653. _updateRigCameras(): void;
  15654. private _workingVector;
  15655. private _oneVector;
  15656. private _workingMatrix;
  15657. private updateCacheCalled;
  15658. private _correctPositionIfNotTrackPosition;
  15659. /**
  15660. * @hidden
  15661. * Updates the cached values of the camera
  15662. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15663. */
  15664. _updateCache(ignoreParentClass?: boolean): void;
  15665. /**
  15666. * @hidden
  15667. * Get current device position in babylon world
  15668. */
  15669. _computeDevicePosition(): void;
  15670. /**
  15671. * Updates the current device position and rotation in the babylon world
  15672. */
  15673. update(): void;
  15674. /**
  15675. * @hidden
  15676. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15677. * @returns an identity matrix
  15678. */
  15679. _getViewMatrix(): Matrix;
  15680. private _tmpMatrix;
  15681. /**
  15682. * This function is called by the two RIG cameras.
  15683. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15684. * @hidden
  15685. */
  15686. _getWebVRViewMatrix(): Matrix;
  15687. /** @hidden */
  15688. _getWebVRProjectionMatrix(): Matrix;
  15689. private _onGamepadConnectedObserver;
  15690. private _onGamepadDisconnectedObserver;
  15691. private _updateCacheWhenTrackingDisabledObserver;
  15692. /**
  15693. * Initializes the controllers and their meshes
  15694. */
  15695. initControllers(): void;
  15696. }
  15697. }
  15698. declare module "babylonjs/PostProcesses/postProcess" {
  15699. import { Nullable } from "babylonjs/types";
  15700. import { SmartArray } from "babylonjs/Misc/smartArray";
  15701. import { Observable } from "babylonjs/Misc/observable";
  15702. import { Vector2 } from "babylonjs/Maths/math.vector";
  15703. import { Camera } from "babylonjs/Cameras/camera";
  15704. import { Effect } from "babylonjs/Materials/effect";
  15705. import "babylonjs/Shaders/postprocess.vertex";
  15706. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15707. import { Engine } from "babylonjs/Engines/engine";
  15708. import { Color4 } from "babylonjs/Maths/math.color";
  15709. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15711. /**
  15712. * Size options for a post process
  15713. */
  15714. export type PostProcessOptions = {
  15715. width: number;
  15716. height: number;
  15717. };
  15718. /**
  15719. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15720. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15721. */
  15722. export class PostProcess {
  15723. /** Name of the PostProcess. */
  15724. name: string;
  15725. /**
  15726. * Gets or sets the unique id of the post process
  15727. */
  15728. uniqueId: number;
  15729. /**
  15730. * Width of the texture to apply the post process on
  15731. */
  15732. width: number;
  15733. /**
  15734. * Height of the texture to apply the post process on
  15735. */
  15736. height: number;
  15737. /**
  15738. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15739. * @hidden
  15740. */
  15741. _outputTexture: Nullable<InternalTexture>;
  15742. /**
  15743. * Sampling mode used by the shader
  15744. * See https://doc.babylonjs.com/classes/3.1/texture
  15745. */
  15746. renderTargetSamplingMode: number;
  15747. /**
  15748. * Clear color to use when screen clearing
  15749. */
  15750. clearColor: Color4;
  15751. /**
  15752. * If the buffer needs to be cleared before applying the post process. (default: true)
  15753. * Should be set to false if shader will overwrite all previous pixels.
  15754. */
  15755. autoClear: boolean;
  15756. /**
  15757. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15758. */
  15759. alphaMode: number;
  15760. /**
  15761. * Sets the setAlphaBlendConstants of the babylon engine
  15762. */
  15763. alphaConstants: Color4;
  15764. /**
  15765. * Animations to be used for the post processing
  15766. */
  15767. animations: import("babylonjs/Animations/animation").Animation[];
  15768. /**
  15769. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15770. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15771. */
  15772. enablePixelPerfectMode: boolean;
  15773. /**
  15774. * Force the postprocess to be applied without taking in account viewport
  15775. */
  15776. forceFullscreenViewport: boolean;
  15777. /**
  15778. * List of inspectable custom properties (used by the Inspector)
  15779. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15780. */
  15781. inspectableCustomProperties: IInspectable[];
  15782. /**
  15783. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15784. *
  15785. * | Value | Type | Description |
  15786. * | ----- | ----------------------------------- | ----------- |
  15787. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15788. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15789. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15790. *
  15791. */
  15792. scaleMode: number;
  15793. /**
  15794. * Force textures to be a power of two (default: false)
  15795. */
  15796. alwaysForcePOT: boolean;
  15797. private _samples;
  15798. /**
  15799. * Number of sample textures (default: 1)
  15800. */
  15801. samples: number;
  15802. /**
  15803. * Modify the scale of the post process to be the same as the viewport (default: false)
  15804. */
  15805. adaptScaleToCurrentViewport: boolean;
  15806. private _camera;
  15807. private _scene;
  15808. private _engine;
  15809. private _options;
  15810. private _reusable;
  15811. private _textureType;
  15812. /**
  15813. * Smart array of input and output textures for the post process.
  15814. * @hidden
  15815. */
  15816. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15817. /**
  15818. * The index in _textures that corresponds to the output texture.
  15819. * @hidden
  15820. */
  15821. _currentRenderTextureInd: number;
  15822. private _effect;
  15823. private _samplers;
  15824. private _fragmentUrl;
  15825. private _vertexUrl;
  15826. private _parameters;
  15827. private _scaleRatio;
  15828. protected _indexParameters: any;
  15829. private _shareOutputWithPostProcess;
  15830. private _texelSize;
  15831. private _forcedOutputTexture;
  15832. /**
  15833. * Returns the fragment url or shader name used in the post process.
  15834. * @returns the fragment url or name in the shader store.
  15835. */
  15836. getEffectName(): string;
  15837. /**
  15838. * An event triggered when the postprocess is activated.
  15839. */
  15840. onActivateObservable: Observable<Camera>;
  15841. private _onActivateObserver;
  15842. /**
  15843. * A function that is added to the onActivateObservable
  15844. */
  15845. onActivate: Nullable<(camera: Camera) => void>;
  15846. /**
  15847. * An event triggered when the postprocess changes its size.
  15848. */
  15849. onSizeChangedObservable: Observable<PostProcess>;
  15850. private _onSizeChangedObserver;
  15851. /**
  15852. * A function that is added to the onSizeChangedObservable
  15853. */
  15854. onSizeChanged: (postProcess: PostProcess) => void;
  15855. /**
  15856. * An event triggered when the postprocess applies its effect.
  15857. */
  15858. onApplyObservable: Observable<Effect>;
  15859. private _onApplyObserver;
  15860. /**
  15861. * A function that is added to the onApplyObservable
  15862. */
  15863. onApply: (effect: Effect) => void;
  15864. /**
  15865. * An event triggered before rendering the postprocess
  15866. */
  15867. onBeforeRenderObservable: Observable<Effect>;
  15868. private _onBeforeRenderObserver;
  15869. /**
  15870. * A function that is added to the onBeforeRenderObservable
  15871. */
  15872. onBeforeRender: (effect: Effect) => void;
  15873. /**
  15874. * An event triggered after rendering the postprocess
  15875. */
  15876. onAfterRenderObservable: Observable<Effect>;
  15877. private _onAfterRenderObserver;
  15878. /**
  15879. * A function that is added to the onAfterRenderObservable
  15880. */
  15881. onAfterRender: (efect: Effect) => void;
  15882. /**
  15883. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15884. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15885. */
  15886. inputTexture: InternalTexture;
  15887. /**
  15888. * Gets the camera which post process is applied to.
  15889. * @returns The camera the post process is applied to.
  15890. */
  15891. getCamera(): Camera;
  15892. /**
  15893. * Gets the texel size of the postprocess.
  15894. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15895. */
  15896. readonly texelSize: Vector2;
  15897. /**
  15898. * Creates a new instance PostProcess
  15899. * @param name The name of the PostProcess.
  15900. * @param fragmentUrl The url of the fragment shader to be used.
  15901. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15902. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15903. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15904. * @param camera The camera to apply the render pass to.
  15905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15906. * @param engine The engine which the post process will be applied. (default: current engine)
  15907. * @param reusable If the post process can be reused on the same frame. (default: false)
  15908. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15909. * @param textureType Type of textures used when performing the post process. (default: 0)
  15910. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15911. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15912. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15913. */
  15914. constructor(
  15915. /** Name of the PostProcess. */
  15916. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15917. /**
  15918. * Gets a string idenfifying the name of the class
  15919. * @returns "PostProcess" string
  15920. */
  15921. getClassName(): string;
  15922. /**
  15923. * Gets the engine which this post process belongs to.
  15924. * @returns The engine the post process was enabled with.
  15925. */
  15926. getEngine(): Engine;
  15927. /**
  15928. * The effect that is created when initializing the post process.
  15929. * @returns The created effect corresponding the the postprocess.
  15930. */
  15931. getEffect(): Effect;
  15932. /**
  15933. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15934. * @param postProcess The post process to share the output with.
  15935. * @returns This post process.
  15936. */
  15937. shareOutputWith(postProcess: PostProcess): PostProcess;
  15938. /**
  15939. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15940. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15941. */
  15942. useOwnOutput(): void;
  15943. /**
  15944. * Updates the effect with the current post process compile time values and recompiles the shader.
  15945. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15946. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15947. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15948. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15949. * @param onCompiled Called when the shader has been compiled.
  15950. * @param onError Called if there is an error when compiling a shader.
  15951. */
  15952. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15953. /**
  15954. * The post process is reusable if it can be used multiple times within one frame.
  15955. * @returns If the post process is reusable
  15956. */
  15957. isReusable(): boolean;
  15958. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15959. markTextureDirty(): void;
  15960. /**
  15961. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15962. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15963. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15964. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15965. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15966. * @returns The target texture that was bound to be written to.
  15967. */
  15968. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15969. /**
  15970. * If the post process is supported.
  15971. */
  15972. readonly isSupported: boolean;
  15973. /**
  15974. * The aspect ratio of the output texture.
  15975. */
  15976. readonly aspectRatio: number;
  15977. /**
  15978. * Get a value indicating if the post-process is ready to be used
  15979. * @returns true if the post-process is ready (shader is compiled)
  15980. */
  15981. isReady(): boolean;
  15982. /**
  15983. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15984. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15985. */
  15986. apply(): Nullable<Effect>;
  15987. private _disposeTextures;
  15988. /**
  15989. * Disposes the post process.
  15990. * @param camera The camera to dispose the post process on.
  15991. */
  15992. dispose(camera?: Camera): void;
  15993. }
  15994. }
  15995. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15996. /** @hidden */
  15997. export var kernelBlurVaryingDeclaration: {
  15998. name: string;
  15999. shader: string;
  16000. };
  16001. }
  16002. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16003. /** @hidden */
  16004. export var kernelBlurFragment: {
  16005. name: string;
  16006. shader: string;
  16007. };
  16008. }
  16009. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16010. /** @hidden */
  16011. export var kernelBlurFragment2: {
  16012. name: string;
  16013. shader: string;
  16014. };
  16015. }
  16016. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16017. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16018. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16019. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16020. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16021. /** @hidden */
  16022. export var kernelBlurPixelShader: {
  16023. name: string;
  16024. shader: string;
  16025. };
  16026. }
  16027. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16028. /** @hidden */
  16029. export var kernelBlurVertex: {
  16030. name: string;
  16031. shader: string;
  16032. };
  16033. }
  16034. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16035. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16036. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16037. /** @hidden */
  16038. export var kernelBlurVertexShader: {
  16039. name: string;
  16040. shader: string;
  16041. };
  16042. }
  16043. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16044. import { Vector2 } from "babylonjs/Maths/math.vector";
  16045. import { Nullable } from "babylonjs/types";
  16046. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16047. import { Camera } from "babylonjs/Cameras/camera";
  16048. import { Effect } from "babylonjs/Materials/effect";
  16049. import { Engine } from "babylonjs/Engines/engine";
  16050. import "babylonjs/Shaders/kernelBlur.fragment";
  16051. import "babylonjs/Shaders/kernelBlur.vertex";
  16052. /**
  16053. * The Blur Post Process which blurs an image based on a kernel and direction.
  16054. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16055. */
  16056. export class BlurPostProcess extends PostProcess {
  16057. /** The direction in which to blur the image. */
  16058. direction: Vector2;
  16059. private blockCompilation;
  16060. protected _kernel: number;
  16061. protected _idealKernel: number;
  16062. protected _packedFloat: boolean;
  16063. private _staticDefines;
  16064. /**
  16065. * Sets the length in pixels of the blur sample region
  16066. */
  16067. /**
  16068. * Gets the length in pixels of the blur sample region
  16069. */
  16070. kernel: number;
  16071. /**
  16072. * Sets wether or not the blur needs to unpack/repack floats
  16073. */
  16074. /**
  16075. * Gets wether or not the blur is unpacking/repacking floats
  16076. */
  16077. packedFloat: boolean;
  16078. /**
  16079. * Creates a new instance BlurPostProcess
  16080. * @param name The name of the effect.
  16081. * @param direction The direction in which to blur the image.
  16082. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  16083. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16084. * @param camera The camera to apply the render pass to.
  16085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16086. * @param engine The engine which the post process will be applied. (default: current engine)
  16087. * @param reusable If the post process can be reused on the same frame. (default: false)
  16088. * @param textureType Type of textures used when performing the post process. (default: 0)
  16089. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  16090. */
  16091. constructor(name: string,
  16092. /** The direction in which to blur the image. */
  16093. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16094. /**
  16095. * Updates the effect with the current post process compile time values and recompiles the shader.
  16096. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16097. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16098. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16099. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  16100. * @param onCompiled Called when the shader has been compiled.
  16101. * @param onError Called if there is an error when compiling a shader.
  16102. */
  16103. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16104. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16105. /**
  16106. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16107. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16108. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16109. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16110. * The gaps between physical kernels are compensated for in the weighting of the samples
  16111. * @param idealKernel Ideal blur kernel.
  16112. * @return Nearest best kernel.
  16113. */
  16114. protected _nearestBestKernel(idealKernel: number): number;
  16115. /**
  16116. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16117. * @param x The point on the Gaussian distribution to sample.
  16118. * @return the value of the Gaussian function at x.
  16119. */
  16120. protected _gaussianWeight(x: number): number;
  16121. /**
  16122. * Generates a string that can be used as a floating point number in GLSL.
  16123. * @param x Value to print.
  16124. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16125. * @return GLSL float string.
  16126. */
  16127. protected _glslFloat(x: number, decimalFigures?: number): string;
  16128. }
  16129. }
  16130. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16131. import { Scene } from "babylonjs/scene";
  16132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16133. import { Plane } from "babylonjs/Maths/math.plane";
  16134. /**
  16135. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16136. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16137. * You can then easily use it as a reflectionTexture on a flat surface.
  16138. * In case the surface is not a plane, please consider relying on reflection probes.
  16139. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16140. */
  16141. export class MirrorTexture extends RenderTargetTexture {
  16142. private scene;
  16143. /**
  16144. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16145. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  16146. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16147. */
  16148. mirrorPlane: Plane;
  16149. /**
  16150. * Define the blur ratio used to blur the reflection if needed.
  16151. */
  16152. blurRatio: number;
  16153. /**
  16154. * Define the adaptive blur kernel used to blur the reflection if needed.
  16155. * This will autocompute the closest best match for the `blurKernel`
  16156. */
  16157. adaptiveBlurKernel: number;
  16158. /**
  16159. * Define the blur kernel used to blur the reflection if needed.
  16160. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16161. */
  16162. blurKernel: number;
  16163. /**
  16164. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16165. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16166. */
  16167. blurKernelX: number;
  16168. /**
  16169. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16170. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16171. */
  16172. blurKernelY: number;
  16173. private _autoComputeBlurKernel;
  16174. protected _onRatioRescale(): void;
  16175. private _updateGammaSpace;
  16176. private _imageProcessingConfigChangeObserver;
  16177. private _transformMatrix;
  16178. private _mirrorMatrix;
  16179. private _savedViewMatrix;
  16180. private _blurX;
  16181. private _blurY;
  16182. private _adaptiveBlurKernel;
  16183. private _blurKernelX;
  16184. private _blurKernelY;
  16185. private _blurRatio;
  16186. /**
  16187. * Instantiates a Mirror Texture.
  16188. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16189. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16190. * You can then easily use it as a reflectionTexture on a flat surface.
  16191. * In case the surface is not a plane, please consider relying on reflection probes.
  16192. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16193. * @param name
  16194. * @param size
  16195. * @param scene
  16196. * @param generateMipMaps
  16197. * @param type
  16198. * @param samplingMode
  16199. * @param generateDepthBuffer
  16200. */
  16201. constructor(name: string, size: number | {
  16202. width: number;
  16203. height: number;
  16204. } | {
  16205. ratio: number;
  16206. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16207. private _preparePostProcesses;
  16208. /**
  16209. * Clone the mirror texture.
  16210. * @returns the cloned texture
  16211. */
  16212. clone(): MirrorTexture;
  16213. /**
  16214. * Serialize the texture to a JSON representation you could use in Parse later on
  16215. * @returns the serialized JSON representation
  16216. */
  16217. serialize(): any;
  16218. /**
  16219. * Dispose the texture and release its associated resources.
  16220. */
  16221. dispose(): void;
  16222. }
  16223. }
  16224. declare module "babylonjs/Materials/Textures/texture" {
  16225. import { Observable } from "babylonjs/Misc/observable";
  16226. import { Nullable } from "babylonjs/types";
  16227. import { Matrix } from "babylonjs/Maths/math.vector";
  16228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16229. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16230. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16231. import { Scene } from "babylonjs/scene";
  16232. /**
  16233. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16234. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16235. */
  16236. export class Texture extends BaseTexture {
  16237. /**
  16238. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16239. */
  16240. static SerializeBuffers: boolean;
  16241. /** @hidden */
  16242. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16243. /** @hidden */
  16244. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16245. /** @hidden */
  16246. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16247. /** nearest is mag = nearest and min = nearest and mip = linear */
  16248. static readonly NEAREST_SAMPLINGMODE: number;
  16249. /** nearest is mag = nearest and min = nearest and mip = linear */
  16250. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16251. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16252. static readonly BILINEAR_SAMPLINGMODE: number;
  16253. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16254. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16255. /** Trilinear is mag = linear and min = linear and mip = linear */
  16256. static readonly TRILINEAR_SAMPLINGMODE: number;
  16257. /** Trilinear is mag = linear and min = linear and mip = linear */
  16258. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16259. /** mag = nearest and min = nearest and mip = nearest */
  16260. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16261. /** mag = nearest and min = linear and mip = nearest */
  16262. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16263. /** mag = nearest and min = linear and mip = linear */
  16264. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16265. /** mag = nearest and min = linear and mip = none */
  16266. static readonly NEAREST_LINEAR: number;
  16267. /** mag = nearest and min = nearest and mip = none */
  16268. static readonly NEAREST_NEAREST: number;
  16269. /** mag = linear and min = nearest and mip = nearest */
  16270. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16271. /** mag = linear and min = nearest and mip = linear */
  16272. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16273. /** mag = linear and min = linear and mip = none */
  16274. static readonly LINEAR_LINEAR: number;
  16275. /** mag = linear and min = nearest and mip = none */
  16276. static readonly LINEAR_NEAREST: number;
  16277. /** Explicit coordinates mode */
  16278. static readonly EXPLICIT_MODE: number;
  16279. /** Spherical coordinates mode */
  16280. static readonly SPHERICAL_MODE: number;
  16281. /** Planar coordinates mode */
  16282. static readonly PLANAR_MODE: number;
  16283. /** Cubic coordinates mode */
  16284. static readonly CUBIC_MODE: number;
  16285. /** Projection coordinates mode */
  16286. static readonly PROJECTION_MODE: number;
  16287. /** Inverse Cubic coordinates mode */
  16288. static readonly SKYBOX_MODE: number;
  16289. /** Inverse Cubic coordinates mode */
  16290. static readonly INVCUBIC_MODE: number;
  16291. /** Equirectangular coordinates mode */
  16292. static readonly EQUIRECTANGULAR_MODE: number;
  16293. /** Equirectangular Fixed coordinates mode */
  16294. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16295. /** Equirectangular Fixed Mirrored coordinates mode */
  16296. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16297. /** Texture is not repeating outside of 0..1 UVs */
  16298. static readonly CLAMP_ADDRESSMODE: number;
  16299. /** Texture is repeating outside of 0..1 UVs */
  16300. static readonly WRAP_ADDRESSMODE: number;
  16301. /** Texture is repeating and mirrored */
  16302. static readonly MIRROR_ADDRESSMODE: number;
  16303. /**
  16304. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  16305. */
  16306. static UseSerializedUrlIfAny: boolean;
  16307. /**
  16308. * Define the url of the texture.
  16309. */
  16310. url: Nullable<string>;
  16311. /**
  16312. * Define an offset on the texture to offset the u coordinates of the UVs
  16313. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16314. */
  16315. uOffset: number;
  16316. /**
  16317. * Define an offset on the texture to offset the v coordinates of the UVs
  16318. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16319. */
  16320. vOffset: number;
  16321. /**
  16322. * Define an offset on the texture to scale the u coordinates of the UVs
  16323. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16324. */
  16325. uScale: number;
  16326. /**
  16327. * Define an offset on the texture to scale the v coordinates of the UVs
  16328. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16329. */
  16330. vScale: number;
  16331. /**
  16332. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16333. * @see http://doc.babylonjs.com/how_to/more_materials
  16334. */
  16335. uAng: number;
  16336. /**
  16337. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16338. * @see http://doc.babylonjs.com/how_to/more_materials
  16339. */
  16340. vAng: number;
  16341. /**
  16342. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16343. * @see http://doc.babylonjs.com/how_to/more_materials
  16344. */
  16345. wAng: number;
  16346. /**
  16347. * Defines the center of rotation (U)
  16348. */
  16349. uRotationCenter: number;
  16350. /**
  16351. * Defines the center of rotation (V)
  16352. */
  16353. vRotationCenter: number;
  16354. /**
  16355. * Defines the center of rotation (W)
  16356. */
  16357. wRotationCenter: number;
  16358. /**
  16359. * Are mip maps generated for this texture or not.
  16360. */
  16361. readonly noMipmap: boolean;
  16362. /**
  16363. * List of inspectable custom properties (used by the Inspector)
  16364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16365. */
  16366. inspectableCustomProperties: Nullable<IInspectable[]>;
  16367. private _noMipmap;
  16368. /** @hidden */
  16369. _invertY: boolean;
  16370. private _rowGenerationMatrix;
  16371. private _cachedTextureMatrix;
  16372. private _projectionModeMatrix;
  16373. private _t0;
  16374. private _t1;
  16375. private _t2;
  16376. private _cachedUOffset;
  16377. private _cachedVOffset;
  16378. private _cachedUScale;
  16379. private _cachedVScale;
  16380. private _cachedUAng;
  16381. private _cachedVAng;
  16382. private _cachedWAng;
  16383. private _cachedProjectionMatrixId;
  16384. private _cachedCoordinatesMode;
  16385. /** @hidden */
  16386. protected _initialSamplingMode: number;
  16387. /** @hidden */
  16388. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16389. private _deleteBuffer;
  16390. protected _format: Nullable<number>;
  16391. private _delayedOnLoad;
  16392. private _delayedOnError;
  16393. private _mimeType?;
  16394. /**
  16395. * Observable triggered once the texture has been loaded.
  16396. */
  16397. onLoadObservable: Observable<Texture>;
  16398. protected _isBlocking: boolean;
  16399. /**
  16400. * Is the texture preventing material to render while loading.
  16401. * If false, a default texture will be used instead of the loading one during the preparation step.
  16402. */
  16403. isBlocking: boolean;
  16404. /**
  16405. * Get the current sampling mode associated with the texture.
  16406. */
  16407. readonly samplingMode: number;
  16408. /**
  16409. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16410. */
  16411. readonly invertY: boolean;
  16412. /**
  16413. * Instantiates a new texture.
  16414. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16415. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16416. * @param url defines the url of the picture to load as a texture
  16417. * @param scene defines the scene or engine the texture will belong to
  16418. * @param noMipmap defines if the texture will require mip maps or not
  16419. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16420. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16421. * @param onLoad defines a callback triggered when the texture has been loaded
  16422. * @param onError defines a callback triggered when an error occurred during the loading session
  16423. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16424. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16425. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16426. * @param mimeType defines an optional mime type information
  16427. */
  16428. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16429. /**
  16430. * Update the url (and optional buffer) of this texture if url was null during construction.
  16431. * @param url the url of the texture
  16432. * @param buffer the buffer of the texture (defaults to null)
  16433. * @param onLoad callback called when the texture is loaded (defaults to null)
  16434. */
  16435. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16436. /**
  16437. * Finish the loading sequence of a texture flagged as delayed load.
  16438. * @hidden
  16439. */
  16440. delayLoad(): void;
  16441. private _prepareRowForTextureGeneration;
  16442. /**
  16443. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16444. * @returns the transform matrix of the texture.
  16445. */
  16446. getTextureMatrix(uBase?: number): Matrix;
  16447. /**
  16448. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16449. * @returns The reflection texture transform
  16450. */
  16451. getReflectionTextureMatrix(): Matrix;
  16452. /**
  16453. * Clones the texture.
  16454. * @returns the cloned texture
  16455. */
  16456. clone(): Texture;
  16457. /**
  16458. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16459. * @returns The JSON representation of the texture
  16460. */
  16461. serialize(): any;
  16462. /**
  16463. * Get the current class name of the texture useful for serialization or dynamic coding.
  16464. * @returns "Texture"
  16465. */
  16466. getClassName(): string;
  16467. /**
  16468. * Dispose the texture and release its associated resources.
  16469. */
  16470. dispose(): void;
  16471. /**
  16472. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16473. * @param parsedTexture Define the JSON representation of the texture
  16474. * @param scene Define the scene the parsed texture should be instantiated in
  16475. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16476. * @returns The parsed texture if successful
  16477. */
  16478. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16479. /**
  16480. * Creates a texture from its base 64 representation.
  16481. * @param data Define the base64 payload without the data: prefix
  16482. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16483. * @param scene Define the scene the texture should belong to
  16484. * @param noMipmap Forces the texture to not create mip map information if true
  16485. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16486. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16487. * @param onLoad define a callback triggered when the texture has been loaded
  16488. * @param onError define a callback triggered when an error occurred during the loading session
  16489. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16490. * @returns the created texture
  16491. */
  16492. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16493. /**
  16494. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16495. * @param data Define the base64 payload without the data: prefix
  16496. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16497. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16498. * @param scene Define the scene the texture should belong to
  16499. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16500. * @param noMipmap Forces the texture to not create mip map information if true
  16501. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16502. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16503. * @param onLoad define a callback triggered when the texture has been loaded
  16504. * @param onError define a callback triggered when an error occurred during the loading session
  16505. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16506. * @returns the created texture
  16507. */
  16508. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  16509. }
  16510. }
  16511. declare module "babylonjs/PostProcesses/postProcessManager" {
  16512. import { Nullable } from "babylonjs/types";
  16513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16515. import { Scene } from "babylonjs/scene";
  16516. /**
  16517. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16518. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16519. */
  16520. export class PostProcessManager {
  16521. private _scene;
  16522. private _indexBuffer;
  16523. private _vertexBuffers;
  16524. /**
  16525. * Creates a new instance PostProcess
  16526. * @param scene The scene that the post process is associated with.
  16527. */
  16528. constructor(scene: Scene);
  16529. private _prepareBuffers;
  16530. private _buildIndexBuffer;
  16531. /**
  16532. * Rebuilds the vertex buffers of the manager.
  16533. * @hidden
  16534. */
  16535. _rebuild(): void;
  16536. /**
  16537. * Prepares a frame to be run through a post process.
  16538. * @param sourceTexture The input texture to the post procesess. (default: null)
  16539. * @param postProcesses An array of post processes to be run. (default: null)
  16540. * @returns True if the post processes were able to be run.
  16541. * @hidden
  16542. */
  16543. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16544. /**
  16545. * Manually render a set of post processes to a texture.
  16546. * @param postProcesses An array of post processes to be run.
  16547. * @param targetTexture The target texture to render to.
  16548. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16549. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16550. * @param lodLevel defines which lod of the texture to render to
  16551. */
  16552. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16553. /**
  16554. * Finalize the result of the output of the postprocesses.
  16555. * @param doNotPresent If true the result will not be displayed to the screen.
  16556. * @param targetTexture The target texture to render to.
  16557. * @param faceIndex The index of the face to bind the target texture to.
  16558. * @param postProcesses The array of post processes to render.
  16559. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16560. * @hidden
  16561. */
  16562. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16563. /**
  16564. * Disposes of the post process manager.
  16565. */
  16566. dispose(): void;
  16567. }
  16568. }
  16569. declare module "babylonjs/Misc/gradients" {
  16570. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16571. /** Interface used by value gradients (color, factor, ...) */
  16572. export interface IValueGradient {
  16573. /**
  16574. * Gets or sets the gradient value (between 0 and 1)
  16575. */
  16576. gradient: number;
  16577. }
  16578. /** Class used to store color4 gradient */
  16579. export class ColorGradient implements IValueGradient {
  16580. /**
  16581. * Gets or sets the gradient value (between 0 and 1)
  16582. */
  16583. gradient: number;
  16584. /**
  16585. * Gets or sets first associated color
  16586. */
  16587. color1: Color4;
  16588. /**
  16589. * Gets or sets second associated color
  16590. */
  16591. color2?: Color4;
  16592. /**
  16593. * Will get a color picked randomly between color1 and color2.
  16594. * If color2 is undefined then color1 will be used
  16595. * @param result defines the target Color4 to store the result in
  16596. */
  16597. getColorToRef(result: Color4): void;
  16598. }
  16599. /** Class used to store color 3 gradient */
  16600. export class Color3Gradient implements IValueGradient {
  16601. /**
  16602. * Gets or sets the gradient value (between 0 and 1)
  16603. */
  16604. gradient: number;
  16605. /**
  16606. * Gets or sets the associated color
  16607. */
  16608. color: Color3;
  16609. }
  16610. /** Class used to store factor gradient */
  16611. export class FactorGradient implements IValueGradient {
  16612. /**
  16613. * Gets or sets the gradient value (between 0 and 1)
  16614. */
  16615. gradient: number;
  16616. /**
  16617. * Gets or sets first associated factor
  16618. */
  16619. factor1: number;
  16620. /**
  16621. * Gets or sets second associated factor
  16622. */
  16623. factor2?: number;
  16624. /**
  16625. * Will get a number picked randomly between factor1 and factor2.
  16626. * If factor2 is undefined then factor1 will be used
  16627. * @returns the picked number
  16628. */
  16629. getFactor(): number;
  16630. }
  16631. /**
  16632. * Helper used to simplify some generic gradient tasks
  16633. */
  16634. export class GradientHelper {
  16635. /**
  16636. * Gets the current gradient from an array of IValueGradient
  16637. * @param ratio defines the current ratio to get
  16638. * @param gradients defines the array of IValueGradient
  16639. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16640. */
  16641. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16642. }
  16643. }
  16644. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16645. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16646. import { Nullable } from "babylonjs/types";
  16647. module "babylonjs/Engines/thinEngine" {
  16648. interface ThinEngine {
  16649. /**
  16650. * Creates a dynamic texture
  16651. * @param width defines the width of the texture
  16652. * @param height defines the height of the texture
  16653. * @param generateMipMaps defines if the engine should generate the mip levels
  16654. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16655. * @returns the dynamic texture inside an InternalTexture
  16656. */
  16657. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16658. /**
  16659. * Update the content of a dynamic texture
  16660. * @param texture defines the texture to update
  16661. * @param canvas defines the canvas containing the source
  16662. * @param invertY defines if data must be stored with Y axis inverted
  16663. * @param premulAlpha defines if alpha is stored as premultiplied
  16664. * @param format defines the format of the data
  16665. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16666. */
  16667. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16668. }
  16669. }
  16670. }
  16671. declare module "babylonjs/Misc/canvasGenerator" {
  16672. /**
  16673. * Helper class used to generate a canvas to manipulate images
  16674. */
  16675. export class CanvasGenerator {
  16676. /**
  16677. * Create a new canvas (or offscreen canvas depending on the context)
  16678. * @param width defines the expected width
  16679. * @param height defines the expected height
  16680. * @return a new canvas or offscreen canvas
  16681. */
  16682. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16683. }
  16684. }
  16685. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16686. import { Scene } from "babylonjs/scene";
  16687. import { Texture } from "babylonjs/Materials/Textures/texture";
  16688. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16689. /**
  16690. * A class extending Texture allowing drawing on a texture
  16691. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16692. */
  16693. export class DynamicTexture extends Texture {
  16694. private _generateMipMaps;
  16695. private _canvas;
  16696. private _context;
  16697. private _engine;
  16698. /**
  16699. * Creates a DynamicTexture
  16700. * @param name defines the name of the texture
  16701. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  16702. * @param scene defines the scene where you want the texture
  16703. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16704. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16705. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16706. */
  16707. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16708. /**
  16709. * Get the current class name of the texture useful for serialization or dynamic coding.
  16710. * @returns "DynamicTexture"
  16711. */
  16712. getClassName(): string;
  16713. /**
  16714. * Gets the current state of canRescale
  16715. */
  16716. readonly canRescale: boolean;
  16717. private _recreate;
  16718. /**
  16719. * Scales the texture
  16720. * @param ratio the scale factor to apply to both width and height
  16721. */
  16722. scale(ratio: number): void;
  16723. /**
  16724. * Resizes the texture
  16725. * @param width the new width
  16726. * @param height the new height
  16727. */
  16728. scaleTo(width: number, height: number): void;
  16729. /**
  16730. * Gets the context of the canvas used by the texture
  16731. * @returns the canvas context of the dynamic texture
  16732. */
  16733. getContext(): CanvasRenderingContext2D;
  16734. /**
  16735. * Clears the texture
  16736. */
  16737. clear(): void;
  16738. /**
  16739. * Updates the texture
  16740. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16741. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16742. */
  16743. update(invertY?: boolean, premulAlpha?: boolean): void;
  16744. /**
  16745. * Draws text onto the texture
  16746. * @param text defines the text to be drawn
  16747. * @param x defines the placement of the text from the left
  16748. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16749. * @param font defines the font to be used with font-style, font-size, font-name
  16750. * @param color defines the color used for the text
  16751. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16752. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16753. * @param update defines whether texture is immediately update (default is true)
  16754. */
  16755. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16756. /**
  16757. * Clones the texture
  16758. * @returns the clone of the texture.
  16759. */
  16760. clone(): DynamicTexture;
  16761. /**
  16762. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16763. * @returns a serialized dynamic texture object
  16764. */
  16765. serialize(): any;
  16766. /** @hidden */
  16767. _rebuild(): void;
  16768. }
  16769. }
  16770. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16771. import { Scene } from "babylonjs/scene";
  16772. import { ISceneComponent } from "babylonjs/sceneComponent";
  16773. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16774. module "babylonjs/abstractScene" {
  16775. interface AbstractScene {
  16776. /**
  16777. * The list of procedural textures added to the scene
  16778. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16779. */
  16780. proceduralTextures: Array<ProceduralTexture>;
  16781. }
  16782. }
  16783. /**
  16784. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16785. * in a given scene.
  16786. */
  16787. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16788. /**
  16789. * The component name helpfull to identify the component in the list of scene components.
  16790. */
  16791. readonly name: string;
  16792. /**
  16793. * The scene the component belongs to.
  16794. */
  16795. scene: Scene;
  16796. /**
  16797. * Creates a new instance of the component for the given scene
  16798. * @param scene Defines the scene to register the component in
  16799. */
  16800. constructor(scene: Scene);
  16801. /**
  16802. * Registers the component in a given scene
  16803. */
  16804. register(): void;
  16805. /**
  16806. * Rebuilds the elements related to this component in case of
  16807. * context lost for instance.
  16808. */
  16809. rebuild(): void;
  16810. /**
  16811. * Disposes the component and the associated ressources.
  16812. */
  16813. dispose(): void;
  16814. private _beforeClear;
  16815. }
  16816. }
  16817. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16818. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16819. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16820. module "babylonjs/Engines/thinEngine" {
  16821. interface ThinEngine {
  16822. /**
  16823. * Creates a new render target cube texture
  16824. * @param size defines the size of the texture
  16825. * @param options defines the options used to create the texture
  16826. * @returns a new render target cube texture stored in an InternalTexture
  16827. */
  16828. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16829. }
  16830. }
  16831. }
  16832. declare module "babylonjs/Shaders/procedural.vertex" {
  16833. /** @hidden */
  16834. export var proceduralVertexShader: {
  16835. name: string;
  16836. shader: string;
  16837. };
  16838. }
  16839. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16840. import { Observable } from "babylonjs/Misc/observable";
  16841. import { Nullable } from "babylonjs/types";
  16842. import { Scene } from "babylonjs/scene";
  16843. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16844. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16845. import { Effect } from "babylonjs/Materials/effect";
  16846. import { Texture } from "babylonjs/Materials/Textures/texture";
  16847. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16848. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16849. import "babylonjs/Shaders/procedural.vertex";
  16850. /**
  16851. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  16852. * This is the base class of any Procedural texture and contains most of the shareable code.
  16853. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16854. */
  16855. export class ProceduralTexture extends Texture {
  16856. isCube: boolean;
  16857. /**
  16858. * Define if the texture is enabled or not (disabled texture will not render)
  16859. */
  16860. isEnabled: boolean;
  16861. /**
  16862. * Define if the texture must be cleared before rendering (default is true)
  16863. */
  16864. autoClear: boolean;
  16865. /**
  16866. * Callback called when the texture is generated
  16867. */
  16868. onGenerated: () => void;
  16869. /**
  16870. * Event raised when the texture is generated
  16871. */
  16872. onGeneratedObservable: Observable<ProceduralTexture>;
  16873. /** @hidden */
  16874. _generateMipMaps: boolean;
  16875. /** @hidden **/
  16876. _effect: Effect;
  16877. /** @hidden */
  16878. _textures: {
  16879. [key: string]: Texture;
  16880. };
  16881. private _size;
  16882. private _currentRefreshId;
  16883. private _refreshRate;
  16884. private _vertexBuffers;
  16885. private _indexBuffer;
  16886. private _uniforms;
  16887. private _samplers;
  16888. private _fragment;
  16889. private _floats;
  16890. private _ints;
  16891. private _floatsArrays;
  16892. private _colors3;
  16893. private _colors4;
  16894. private _vectors2;
  16895. private _vectors3;
  16896. private _matrices;
  16897. private _fallbackTexture;
  16898. private _fallbackTextureUsed;
  16899. private _engine;
  16900. private _cachedDefines;
  16901. private _contentUpdateId;
  16902. private _contentData;
  16903. /**
  16904. * Instantiates a new procedural texture.
  16905. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16906. * This is the base class of any Procedural texture and contains most of the shareable code.
  16907. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16908. * @param name Define the name of the texture
  16909. * @param size Define the size of the texture to create
  16910. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16911. * @param scene Define the scene the texture belongs to
  16912. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16913. * @param generateMipMaps Define if the texture should creates mip maps or not
  16914. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16915. */
  16916. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16917. /**
  16918. * The effect that is created when initializing the post process.
  16919. * @returns The created effect corresponding the the postprocess.
  16920. */
  16921. getEffect(): Effect;
  16922. /**
  16923. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16924. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16925. */
  16926. getContent(): Nullable<ArrayBufferView>;
  16927. private _createIndexBuffer;
  16928. /** @hidden */
  16929. _rebuild(): void;
  16930. /**
  16931. * Resets the texture in order to recreate its associated resources.
  16932. * This can be called in case of context loss
  16933. */
  16934. reset(): void;
  16935. protected _getDefines(): string;
  16936. /**
  16937. * Is the texture ready to be used ? (rendered at least once)
  16938. * @returns true if ready, otherwise, false.
  16939. */
  16940. isReady(): boolean;
  16941. /**
  16942. * Resets the refresh counter of the texture and start bak from scratch.
  16943. * Could be useful to regenerate the texture if it is setup to render only once.
  16944. */
  16945. resetRefreshCounter(): void;
  16946. /**
  16947. * Set the fragment shader to use in order to render the texture.
  16948. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16949. */
  16950. setFragment(fragment: any): void;
  16951. /**
  16952. * Define the refresh rate of the texture or the rendering frequency.
  16953. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16954. */
  16955. refreshRate: number;
  16956. /** @hidden */
  16957. _shouldRender(): boolean;
  16958. /**
  16959. * Get the size the texture is rendering at.
  16960. * @returns the size (texture is always squared)
  16961. */
  16962. getRenderSize(): number;
  16963. /**
  16964. * Resize the texture to new value.
  16965. * @param size Define the new size the texture should have
  16966. * @param generateMipMaps Define whether the new texture should create mip maps
  16967. */
  16968. resize(size: number, generateMipMaps: boolean): void;
  16969. private _checkUniform;
  16970. /**
  16971. * Set a texture in the shader program used to render.
  16972. * @param name Define the name of the uniform samplers as defined in the shader
  16973. * @param texture Define the texture to bind to this sampler
  16974. * @return the texture itself allowing "fluent" like uniform updates
  16975. */
  16976. setTexture(name: string, texture: Texture): ProceduralTexture;
  16977. /**
  16978. * Set a float in the shader.
  16979. * @param name Define the name of the uniform as defined in the shader
  16980. * @param value Define the value to give to the uniform
  16981. * @return the texture itself allowing "fluent" like uniform updates
  16982. */
  16983. setFloat(name: string, value: number): ProceduralTexture;
  16984. /**
  16985. * Set a int in the shader.
  16986. * @param name Define the name of the uniform as defined in the shader
  16987. * @param value Define the value to give to the uniform
  16988. * @return the texture itself allowing "fluent" like uniform updates
  16989. */
  16990. setInt(name: string, value: number): ProceduralTexture;
  16991. /**
  16992. * Set an array of floats in the shader.
  16993. * @param name Define the name of the uniform as defined in the shader
  16994. * @param value Define the value to give to the uniform
  16995. * @return the texture itself allowing "fluent" like uniform updates
  16996. */
  16997. setFloats(name: string, value: number[]): ProceduralTexture;
  16998. /**
  16999. * Set a vec3 in the shader from a Color3.
  17000. * @param name Define the name of the uniform as defined in the shader
  17001. * @param value Define the value to give to the uniform
  17002. * @return the texture itself allowing "fluent" like uniform updates
  17003. */
  17004. setColor3(name: string, value: Color3): ProceduralTexture;
  17005. /**
  17006. * Set a vec4 in the shader from a Color4.
  17007. * @param name Define the name of the uniform as defined in the shader
  17008. * @param value Define the value to give to the uniform
  17009. * @return the texture itself allowing "fluent" like uniform updates
  17010. */
  17011. setColor4(name: string, value: Color4): ProceduralTexture;
  17012. /**
  17013. * Set a vec2 in the shader from a Vector2.
  17014. * @param name Define the name of the uniform as defined in the shader
  17015. * @param value Define the value to give to the uniform
  17016. * @return the texture itself allowing "fluent" like uniform updates
  17017. */
  17018. setVector2(name: string, value: Vector2): ProceduralTexture;
  17019. /**
  17020. * Set a vec3 in the shader from a Vector3.
  17021. * @param name Define the name of the uniform as defined in the shader
  17022. * @param value Define the value to give to the uniform
  17023. * @return the texture itself allowing "fluent" like uniform updates
  17024. */
  17025. setVector3(name: string, value: Vector3): ProceduralTexture;
  17026. /**
  17027. * Set a mat4 in the shader from a MAtrix.
  17028. * @param name Define the name of the uniform as defined in the shader
  17029. * @param value Define the value to give to the uniform
  17030. * @return the texture itself allowing "fluent" like uniform updates
  17031. */
  17032. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17033. /**
  17034. * Render the texture to its associated render target.
  17035. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17036. */
  17037. render(useCameraPostProcess?: boolean): void;
  17038. /**
  17039. * Clone the texture.
  17040. * @returns the cloned texture
  17041. */
  17042. clone(): ProceduralTexture;
  17043. /**
  17044. * Dispose the texture and release its asoociated resources.
  17045. */
  17046. dispose(): void;
  17047. }
  17048. }
  17049. declare module "babylonjs/Particles/baseParticleSystem" {
  17050. import { Nullable } from "babylonjs/types";
  17051. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17053. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17054. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17055. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17056. import { Scene } from "babylonjs/scene";
  17057. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17058. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17059. import { Texture } from "babylonjs/Materials/Textures/texture";
  17060. import { Color4 } from "babylonjs/Maths/math.color";
  17061. import { Animation } from "babylonjs/Animations/animation";
  17062. /**
  17063. * This represents the base class for particle system in Babylon.
  17064. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17065. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17066. * @example https://doc.babylonjs.com/babylon101/particles
  17067. */
  17068. export class BaseParticleSystem {
  17069. /**
  17070. * Source color is added to the destination color without alpha affecting the result
  17071. */
  17072. static BLENDMODE_ONEONE: number;
  17073. /**
  17074. * Blend current color and particle color using particle’s alpha
  17075. */
  17076. static BLENDMODE_STANDARD: number;
  17077. /**
  17078. * Add current color and particle color multiplied by particle’s alpha
  17079. */
  17080. static BLENDMODE_ADD: number;
  17081. /**
  17082. * Multiply current color with particle color
  17083. */
  17084. static BLENDMODE_MULTIPLY: number;
  17085. /**
  17086. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17087. */
  17088. static BLENDMODE_MULTIPLYADD: number;
  17089. /**
  17090. * List of animations used by the particle system.
  17091. */
  17092. animations: Animation[];
  17093. /**
  17094. * The id of the Particle system.
  17095. */
  17096. id: string;
  17097. /**
  17098. * The friendly name of the Particle system.
  17099. */
  17100. name: string;
  17101. /**
  17102. * The rendering group used by the Particle system to chose when to render.
  17103. */
  17104. renderingGroupId: number;
  17105. /**
  17106. * The emitter represents the Mesh or position we are attaching the particle system to.
  17107. */
  17108. emitter: Nullable<AbstractMesh | Vector3>;
  17109. /**
  17110. * The maximum number of particles to emit per frame
  17111. */
  17112. emitRate: number;
  17113. /**
  17114. * If you want to launch only a few particles at once, that can be done, as well.
  17115. */
  17116. manualEmitCount: number;
  17117. /**
  17118. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17119. */
  17120. updateSpeed: number;
  17121. /**
  17122. * The amount of time the particle system is running (depends of the overall update speed).
  17123. */
  17124. targetStopDuration: number;
  17125. /**
  17126. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17127. */
  17128. disposeOnStop: boolean;
  17129. /**
  17130. * Minimum power of emitting particles.
  17131. */
  17132. minEmitPower: number;
  17133. /**
  17134. * Maximum power of emitting particles.
  17135. */
  17136. maxEmitPower: number;
  17137. /**
  17138. * Minimum life time of emitting particles.
  17139. */
  17140. minLifeTime: number;
  17141. /**
  17142. * Maximum life time of emitting particles.
  17143. */
  17144. maxLifeTime: number;
  17145. /**
  17146. * Minimum Size of emitting particles.
  17147. */
  17148. minSize: number;
  17149. /**
  17150. * Maximum Size of emitting particles.
  17151. */
  17152. maxSize: number;
  17153. /**
  17154. * Minimum scale of emitting particles on X axis.
  17155. */
  17156. minScaleX: number;
  17157. /**
  17158. * Maximum scale of emitting particles on X axis.
  17159. */
  17160. maxScaleX: number;
  17161. /**
  17162. * Minimum scale of emitting particles on Y axis.
  17163. */
  17164. minScaleY: number;
  17165. /**
  17166. * Maximum scale of emitting particles on Y axis.
  17167. */
  17168. maxScaleY: number;
  17169. /**
  17170. * Gets or sets the minimal initial rotation in radians.
  17171. */
  17172. minInitialRotation: number;
  17173. /**
  17174. * Gets or sets the maximal initial rotation in radians.
  17175. */
  17176. maxInitialRotation: number;
  17177. /**
  17178. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17179. */
  17180. minAngularSpeed: number;
  17181. /**
  17182. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17183. */
  17184. maxAngularSpeed: number;
  17185. /**
  17186. * The texture used to render each particle. (this can be a spritesheet)
  17187. */
  17188. particleTexture: Nullable<Texture>;
  17189. /**
  17190. * The layer mask we are rendering the particles through.
  17191. */
  17192. layerMask: number;
  17193. /**
  17194. * This can help using your own shader to render the particle system.
  17195. * The according effect will be created
  17196. */
  17197. customShader: any;
  17198. /**
  17199. * By default particle system starts as soon as they are created. This prevents the
  17200. * automatic start to happen and let you decide when to start emitting particles.
  17201. */
  17202. preventAutoStart: boolean;
  17203. private _noiseTexture;
  17204. /**
  17205. * Gets or sets a texture used to add random noise to particle positions
  17206. */
  17207. noiseTexture: Nullable<ProceduralTexture>;
  17208. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17209. noiseStrength: Vector3;
  17210. /**
  17211. * Callback triggered when the particle animation is ending.
  17212. */
  17213. onAnimationEnd: Nullable<() => void>;
  17214. /**
  17215. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17216. */
  17217. blendMode: number;
  17218. /**
  17219. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17220. * to override the particles.
  17221. */
  17222. forceDepthWrite: boolean;
  17223. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  17224. preWarmCycles: number;
  17225. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17226. preWarmStepOffset: number;
  17227. /**
  17228. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  17229. */
  17230. spriteCellChangeSpeed: number;
  17231. /**
  17232. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17233. */
  17234. startSpriteCellID: number;
  17235. /**
  17236. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17237. */
  17238. endSpriteCellID: number;
  17239. /**
  17240. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17241. */
  17242. spriteCellWidth: number;
  17243. /**
  17244. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17245. */
  17246. spriteCellHeight: number;
  17247. /**
  17248. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17249. */
  17250. spriteRandomStartCell: boolean;
  17251. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17252. translationPivot: Vector2;
  17253. /** @hidden */
  17254. protected _isAnimationSheetEnabled: boolean;
  17255. /**
  17256. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17257. */
  17258. beginAnimationOnStart: boolean;
  17259. /**
  17260. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17261. */
  17262. beginAnimationFrom: number;
  17263. /**
  17264. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17265. */
  17266. beginAnimationTo: number;
  17267. /**
  17268. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17269. */
  17270. beginAnimationLoop: boolean;
  17271. /**
  17272. * Gets or sets a world offset applied to all particles
  17273. */
  17274. worldOffset: Vector3;
  17275. /**
  17276. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17277. */
  17278. isAnimationSheetEnabled: boolean;
  17279. /**
  17280. * Get hosting scene
  17281. * @returns the scene
  17282. */
  17283. getScene(): Scene;
  17284. /**
  17285. * You can use gravity if you want to give an orientation to your particles.
  17286. */
  17287. gravity: Vector3;
  17288. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17289. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17290. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17291. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17292. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17293. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17294. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17295. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17296. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17297. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17298. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17299. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17300. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17301. /**
  17302. * Defines the delay in milliseconds before starting the system (0 by default)
  17303. */
  17304. startDelay: number;
  17305. /**
  17306. * Gets the current list of drag gradients.
  17307. * You must use addDragGradient and removeDragGradient to udpate this list
  17308. * @returns the list of drag gradients
  17309. */
  17310. getDragGradients(): Nullable<Array<FactorGradient>>;
  17311. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17312. limitVelocityDamping: number;
  17313. /**
  17314. * Gets the current list of limit velocity gradients.
  17315. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17316. * @returns the list of limit velocity gradients
  17317. */
  17318. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17319. /**
  17320. * Gets the current list of color gradients.
  17321. * You must use addColorGradient and removeColorGradient to udpate this list
  17322. * @returns the list of color gradients
  17323. */
  17324. getColorGradients(): Nullable<Array<ColorGradient>>;
  17325. /**
  17326. * Gets the current list of size gradients.
  17327. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17328. * @returns the list of size gradients
  17329. */
  17330. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17331. /**
  17332. * Gets the current list of color remap gradients.
  17333. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17334. * @returns the list of color remap gradients
  17335. */
  17336. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17337. /**
  17338. * Gets the current list of alpha remap gradients.
  17339. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17340. * @returns the list of alpha remap gradients
  17341. */
  17342. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17343. /**
  17344. * Gets the current list of life time gradients.
  17345. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17346. * @returns the list of life time gradients
  17347. */
  17348. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17349. /**
  17350. * Gets the current list of angular speed gradients.
  17351. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17352. * @returns the list of angular speed gradients
  17353. */
  17354. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17355. /**
  17356. * Gets the current list of velocity gradients.
  17357. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17358. * @returns the list of velocity gradients
  17359. */
  17360. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17361. /**
  17362. * Gets the current list of start size gradients.
  17363. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17364. * @returns the list of start size gradients
  17365. */
  17366. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17367. /**
  17368. * Gets the current list of emit rate gradients.
  17369. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17370. * @returns the list of emit rate gradients
  17371. */
  17372. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17373. /**
  17374. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17375. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17376. */
  17377. direction1: Vector3;
  17378. /**
  17379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17380. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17381. */
  17382. direction2: Vector3;
  17383. /**
  17384. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17385. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17386. */
  17387. minEmitBox: Vector3;
  17388. /**
  17389. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17390. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17391. */
  17392. maxEmitBox: Vector3;
  17393. /**
  17394. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17395. */
  17396. color1: Color4;
  17397. /**
  17398. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17399. */
  17400. color2: Color4;
  17401. /**
  17402. * Color the particle will have at the end of its lifetime
  17403. */
  17404. colorDead: Color4;
  17405. /**
  17406. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17407. */
  17408. textureMask: Color4;
  17409. /**
  17410. * The particle emitter type defines the emitter used by the particle system.
  17411. * It can be for example box, sphere, or cone...
  17412. */
  17413. particleEmitterType: IParticleEmitterType;
  17414. /** @hidden */
  17415. _isSubEmitter: boolean;
  17416. /**
  17417. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17418. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17419. */
  17420. billboardMode: number;
  17421. protected _isBillboardBased: boolean;
  17422. /**
  17423. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17424. */
  17425. isBillboardBased: boolean;
  17426. /**
  17427. * The scene the particle system belongs to.
  17428. */
  17429. protected _scene: Scene;
  17430. /**
  17431. * Local cache of defines for image processing.
  17432. */
  17433. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17434. /**
  17435. * Default configuration related to image processing available in the standard Material.
  17436. */
  17437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17438. /**
  17439. * Gets the image processing configuration used either in this material.
  17440. */
  17441. /**
  17442. * Sets the Default image processing configuration used either in the this material.
  17443. *
  17444. * If sets to null, the scene one is in use.
  17445. */
  17446. imageProcessingConfiguration: ImageProcessingConfiguration;
  17447. /**
  17448. * Attaches a new image processing configuration to the Standard Material.
  17449. * @param configuration
  17450. */
  17451. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17452. /** @hidden */
  17453. protected _reset(): void;
  17454. /** @hidden */
  17455. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17456. /**
  17457. * Instantiates a particle system.
  17458. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17459. * @param name The name of the particle system
  17460. */
  17461. constructor(name: string);
  17462. /**
  17463. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17464. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17465. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17466. * @returns the emitter
  17467. */
  17468. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17469. /**
  17470. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17471. * @param radius The radius of the hemisphere to emit from
  17472. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17473. * @returns the emitter
  17474. */
  17475. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17476. /**
  17477. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17478. * @param radius The radius of the sphere to emit from
  17479. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17480. * @returns the emitter
  17481. */
  17482. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17483. /**
  17484. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17485. * @param radius The radius of the sphere to emit from
  17486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17488. * @returns the emitter
  17489. */
  17490. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17491. /**
  17492. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17493. * @param radius The radius of the emission cylinder
  17494. * @param height The height of the emission cylinder
  17495. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17496. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17497. * @returns the emitter
  17498. */
  17499. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17500. /**
  17501. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17502. * @param radius The radius of the cylinder to emit from
  17503. * @param height The height of the emission cylinder
  17504. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17505. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17506. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17507. * @returns the emitter
  17508. */
  17509. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17510. /**
  17511. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17512. * @param radius The radius of the cone to emit from
  17513. * @param angle The base angle of the cone
  17514. * @returns the emitter
  17515. */
  17516. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17517. /**
  17518. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17519. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17520. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17521. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17522. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17523. * @returns the emitter
  17524. */
  17525. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17526. }
  17527. }
  17528. declare module "babylonjs/Particles/subEmitter" {
  17529. import { Scene } from "babylonjs/scene";
  17530. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17531. /**
  17532. * Type of sub emitter
  17533. */
  17534. export enum SubEmitterType {
  17535. /**
  17536. * Attached to the particle over it's lifetime
  17537. */
  17538. ATTACHED = 0,
  17539. /**
  17540. * Created when the particle dies
  17541. */
  17542. END = 1
  17543. }
  17544. /**
  17545. * Sub emitter class used to emit particles from an existing particle
  17546. */
  17547. export class SubEmitter {
  17548. /**
  17549. * the particle system to be used by the sub emitter
  17550. */
  17551. particleSystem: ParticleSystem;
  17552. /**
  17553. * Type of the submitter (Default: END)
  17554. */
  17555. type: SubEmitterType;
  17556. /**
  17557. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  17558. * Note: This only is supported when using an emitter of type Mesh
  17559. */
  17560. inheritDirection: boolean;
  17561. /**
  17562. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17563. */
  17564. inheritedVelocityAmount: number;
  17565. /**
  17566. * Creates a sub emitter
  17567. * @param particleSystem the particle system to be used by the sub emitter
  17568. */
  17569. constructor(
  17570. /**
  17571. * the particle system to be used by the sub emitter
  17572. */
  17573. particleSystem: ParticleSystem);
  17574. /**
  17575. * Clones the sub emitter
  17576. * @returns the cloned sub emitter
  17577. */
  17578. clone(): SubEmitter;
  17579. /**
  17580. * Serialize current object to a JSON object
  17581. * @returns the serialized object
  17582. */
  17583. serialize(): any;
  17584. /** @hidden */
  17585. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17586. /**
  17587. * Creates a new SubEmitter from a serialized JSON version
  17588. * @param serializationObject defines the JSON object to read from
  17589. * @param scene defines the hosting scene
  17590. * @param rootUrl defines the rootUrl for data loading
  17591. * @returns a new SubEmitter
  17592. */
  17593. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17594. /** Release associated resources */
  17595. dispose(): void;
  17596. }
  17597. }
  17598. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17599. /** @hidden */
  17600. export var clipPlaneFragmentDeclaration: {
  17601. name: string;
  17602. shader: string;
  17603. };
  17604. }
  17605. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17606. /** @hidden */
  17607. export var imageProcessingDeclaration: {
  17608. name: string;
  17609. shader: string;
  17610. };
  17611. }
  17612. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17613. /** @hidden */
  17614. export var imageProcessingFunctions: {
  17615. name: string;
  17616. shader: string;
  17617. };
  17618. }
  17619. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17620. /** @hidden */
  17621. export var clipPlaneFragment: {
  17622. name: string;
  17623. shader: string;
  17624. };
  17625. }
  17626. declare module "babylonjs/Shaders/particles.fragment" {
  17627. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17628. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17629. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17630. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17631. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17632. /** @hidden */
  17633. export var particlesPixelShader: {
  17634. name: string;
  17635. shader: string;
  17636. };
  17637. }
  17638. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17639. /** @hidden */
  17640. export var clipPlaneVertexDeclaration: {
  17641. name: string;
  17642. shader: string;
  17643. };
  17644. }
  17645. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17646. /** @hidden */
  17647. export var clipPlaneVertex: {
  17648. name: string;
  17649. shader: string;
  17650. };
  17651. }
  17652. declare module "babylonjs/Shaders/particles.vertex" {
  17653. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17654. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17655. /** @hidden */
  17656. export var particlesVertexShader: {
  17657. name: string;
  17658. shader: string;
  17659. };
  17660. }
  17661. declare module "babylonjs/Particles/particleSystem" {
  17662. import { Nullable } from "babylonjs/types";
  17663. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17664. import { Observable } from "babylonjs/Misc/observable";
  17665. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17666. import { Effect } from "babylonjs/Materials/effect";
  17667. import { Scene, IDisposable } from "babylonjs/scene";
  17668. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17669. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17670. import { Particle } from "babylonjs/Particles/particle";
  17671. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17672. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17673. import "babylonjs/Shaders/particles.fragment";
  17674. import "babylonjs/Shaders/particles.vertex";
  17675. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17676. /**
  17677. * This represents a particle system in Babylon.
  17678. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17679. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17680. * @example https://doc.babylonjs.com/babylon101/particles
  17681. */
  17682. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17683. /**
  17684. * Billboard mode will only apply to Y axis
  17685. */
  17686. static readonly BILLBOARDMODE_Y: number;
  17687. /**
  17688. * Billboard mode will apply to all axes
  17689. */
  17690. static readonly BILLBOARDMODE_ALL: number;
  17691. /**
  17692. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17693. */
  17694. static readonly BILLBOARDMODE_STRETCHED: number;
  17695. /**
  17696. * This function can be defined to provide custom update for active particles.
  17697. * This function will be called instead of regular update (age, position, color, etc.).
  17698. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17699. */
  17700. updateFunction: (particles: Particle[]) => void;
  17701. private _emitterWorldMatrix;
  17702. /**
  17703. * This function can be defined to specify initial direction for every new particle.
  17704. * It by default use the emitterType defined function
  17705. */
  17706. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17707. /**
  17708. * This function can be defined to specify initial position for every new particle.
  17709. * It by default use the emitterType defined function
  17710. */
  17711. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17712. /**
  17713. * @hidden
  17714. */
  17715. _inheritedVelocityOffset: Vector3;
  17716. /**
  17717. * An event triggered when the system is disposed
  17718. */
  17719. onDisposeObservable: Observable<ParticleSystem>;
  17720. private _onDisposeObserver;
  17721. /**
  17722. * Sets a callback that will be triggered when the system is disposed
  17723. */
  17724. onDispose: () => void;
  17725. private _particles;
  17726. private _epsilon;
  17727. private _capacity;
  17728. private _stockParticles;
  17729. private _newPartsExcess;
  17730. private _vertexData;
  17731. private _vertexBuffer;
  17732. private _vertexBuffers;
  17733. private _spriteBuffer;
  17734. private _indexBuffer;
  17735. private _effect;
  17736. private _customEffect;
  17737. private _cachedDefines;
  17738. private _scaledColorStep;
  17739. private _colorDiff;
  17740. private _scaledDirection;
  17741. private _scaledGravity;
  17742. private _currentRenderId;
  17743. private _alive;
  17744. private _useInstancing;
  17745. private _started;
  17746. private _stopped;
  17747. private _actualFrame;
  17748. private _scaledUpdateSpeed;
  17749. private _vertexBufferSize;
  17750. /** @hidden */
  17751. _currentEmitRateGradient: Nullable<FactorGradient>;
  17752. /** @hidden */
  17753. _currentEmitRate1: number;
  17754. /** @hidden */
  17755. _currentEmitRate2: number;
  17756. /** @hidden */
  17757. _currentStartSizeGradient: Nullable<FactorGradient>;
  17758. /** @hidden */
  17759. _currentStartSize1: number;
  17760. /** @hidden */
  17761. _currentStartSize2: number;
  17762. private readonly _rawTextureWidth;
  17763. private _rampGradientsTexture;
  17764. private _useRampGradients;
  17765. /** Gets or sets a boolean indicating that ramp gradients must be used
  17766. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17767. */
  17768. useRampGradients: boolean;
  17769. /**
  17770. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  17771. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  17772. */
  17773. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17774. private _subEmitters;
  17775. /**
  17776. * @hidden
  17777. * If the particle systems emitter should be disposed when the particle system is disposed
  17778. */
  17779. _disposeEmitterOnDispose: boolean;
  17780. /**
  17781. * The current active Sub-systems, this property is used by the root particle system only.
  17782. */
  17783. activeSubSystems: Array<ParticleSystem>;
  17784. private _rootParticleSystem;
  17785. /**
  17786. * Gets the current list of active particles
  17787. */
  17788. readonly particles: Particle[];
  17789. /**
  17790. * Returns the string "ParticleSystem"
  17791. * @returns a string containing the class name
  17792. */
  17793. getClassName(): string;
  17794. /**
  17795. * Instantiates a particle system.
  17796. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17797. * @param name The name of the particle system
  17798. * @param capacity The max number of particles alive at the same time
  17799. * @param scene The scene the particle system belongs to
  17800. * @param customEffect a custom effect used to change the way particles are rendered by default
  17801. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17802. * @param epsilon Offset used to render the particles
  17803. */
  17804. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17805. private _addFactorGradient;
  17806. private _removeFactorGradient;
  17807. /**
  17808. * Adds a new life time gradient
  17809. * @param gradient defines the gradient to use (between 0 and 1)
  17810. * @param factor defines the life time factor to affect to the specified gradient
  17811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17812. * @returns the current particle system
  17813. */
  17814. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17815. /**
  17816. * Remove a specific life time gradient
  17817. * @param gradient defines the gradient to remove
  17818. * @returns the current particle system
  17819. */
  17820. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17821. /**
  17822. * Adds a new size gradient
  17823. * @param gradient defines the gradient to use (between 0 and 1)
  17824. * @param factor defines the size factor to affect to the specified gradient
  17825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17826. * @returns the current particle system
  17827. */
  17828. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17829. /**
  17830. * Remove a specific size gradient
  17831. * @param gradient defines the gradient to remove
  17832. * @returns the current particle system
  17833. */
  17834. removeSizeGradient(gradient: number): IParticleSystem;
  17835. /**
  17836. * Adds a new color remap gradient
  17837. * @param gradient defines the gradient to use (between 0 and 1)
  17838. * @param min defines the color remap minimal range
  17839. * @param max defines the color remap maximal range
  17840. * @returns the current particle system
  17841. */
  17842. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17843. /**
  17844. * Remove a specific color remap gradient
  17845. * @param gradient defines the gradient to remove
  17846. * @returns the current particle system
  17847. */
  17848. removeColorRemapGradient(gradient: number): IParticleSystem;
  17849. /**
  17850. * Adds a new alpha remap gradient
  17851. * @param gradient defines the gradient to use (between 0 and 1)
  17852. * @param min defines the alpha remap minimal range
  17853. * @param max defines the alpha remap maximal range
  17854. * @returns the current particle system
  17855. */
  17856. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17857. /**
  17858. * Remove a specific alpha remap gradient
  17859. * @param gradient defines the gradient to remove
  17860. * @returns the current particle system
  17861. */
  17862. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17863. /**
  17864. * Adds a new angular speed gradient
  17865. * @param gradient defines the gradient to use (between 0 and 1)
  17866. * @param factor defines the angular speed to affect to the specified gradient
  17867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17868. * @returns the current particle system
  17869. */
  17870. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17871. /**
  17872. * Remove a specific angular speed gradient
  17873. * @param gradient defines the gradient to remove
  17874. * @returns the current particle system
  17875. */
  17876. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17877. /**
  17878. * Adds a new velocity gradient
  17879. * @param gradient defines the gradient to use (between 0 and 1)
  17880. * @param factor defines the velocity to affect to the specified gradient
  17881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17882. * @returns the current particle system
  17883. */
  17884. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17885. /**
  17886. * Remove a specific velocity gradient
  17887. * @param gradient defines the gradient to remove
  17888. * @returns the current particle system
  17889. */
  17890. removeVelocityGradient(gradient: number): IParticleSystem;
  17891. /**
  17892. * Adds a new limit velocity gradient
  17893. * @param gradient defines the gradient to use (between 0 and 1)
  17894. * @param factor defines the limit velocity value to affect to the specified gradient
  17895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17896. * @returns the current particle system
  17897. */
  17898. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17899. /**
  17900. * Remove a specific limit velocity gradient
  17901. * @param gradient defines the gradient to remove
  17902. * @returns the current particle system
  17903. */
  17904. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17905. /**
  17906. * Adds a new drag gradient
  17907. * @param gradient defines the gradient to use (between 0 and 1)
  17908. * @param factor defines the drag value to affect to the specified gradient
  17909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17910. * @returns the current particle system
  17911. */
  17912. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17913. /**
  17914. * Remove a specific drag gradient
  17915. * @param gradient defines the gradient to remove
  17916. * @returns the current particle system
  17917. */
  17918. removeDragGradient(gradient: number): IParticleSystem;
  17919. /**
  17920. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17921. * @param gradient defines the gradient to use (between 0 and 1)
  17922. * @param factor defines the emit rate value to affect to the specified gradient
  17923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17924. * @returns the current particle system
  17925. */
  17926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17927. /**
  17928. * Remove a specific emit rate gradient
  17929. * @param gradient defines the gradient to remove
  17930. * @returns the current particle system
  17931. */
  17932. removeEmitRateGradient(gradient: number): IParticleSystem;
  17933. /**
  17934. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17935. * @param gradient defines the gradient to use (between 0 and 1)
  17936. * @param factor defines the start size value to affect to the specified gradient
  17937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17938. * @returns the current particle system
  17939. */
  17940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17941. /**
  17942. * Remove a specific start size gradient
  17943. * @param gradient defines the gradient to remove
  17944. * @returns the current particle system
  17945. */
  17946. removeStartSizeGradient(gradient: number): IParticleSystem;
  17947. private _createRampGradientTexture;
  17948. /**
  17949. * Gets the current list of ramp gradients.
  17950. * You must use addRampGradient and removeRampGradient to udpate this list
  17951. * @returns the list of ramp gradients
  17952. */
  17953. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17954. /**
  17955. * Adds a new ramp gradient used to remap particle colors
  17956. * @param gradient defines the gradient to use (between 0 and 1)
  17957. * @param color defines the color to affect to the specified gradient
  17958. * @returns the current particle system
  17959. */
  17960. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17961. /**
  17962. * Remove a specific ramp gradient
  17963. * @param gradient defines the gradient to remove
  17964. * @returns the current particle system
  17965. */
  17966. removeRampGradient(gradient: number): ParticleSystem;
  17967. /**
  17968. * Adds a new color gradient
  17969. * @param gradient defines the gradient to use (between 0 and 1)
  17970. * @param color1 defines the color to affect to the specified gradient
  17971. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17972. * @returns this particle system
  17973. */
  17974. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17975. /**
  17976. * Remove a specific color gradient
  17977. * @param gradient defines the gradient to remove
  17978. * @returns this particle system
  17979. */
  17980. removeColorGradient(gradient: number): IParticleSystem;
  17981. private _fetchR;
  17982. protected _reset(): void;
  17983. private _resetEffect;
  17984. private _createVertexBuffers;
  17985. private _createIndexBuffer;
  17986. /**
  17987. * Gets the maximum number of particles active at the same time.
  17988. * @returns The max number of active particles.
  17989. */
  17990. getCapacity(): number;
  17991. /**
  17992. * Gets whether there are still active particles in the system.
  17993. * @returns True if it is alive, otherwise false.
  17994. */
  17995. isAlive(): boolean;
  17996. /**
  17997. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17998. * @returns True if it has been started, otherwise false.
  17999. */
  18000. isStarted(): boolean;
  18001. private _prepareSubEmitterInternalArray;
  18002. /**
  18003. * Starts the particle system and begins to emit
  18004. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18005. */
  18006. start(delay?: number): void;
  18007. /**
  18008. * Stops the particle system.
  18009. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  18010. */
  18011. stop(stopSubEmitters?: boolean): void;
  18012. /**
  18013. * Remove all active particles
  18014. */
  18015. reset(): void;
  18016. /**
  18017. * @hidden (for internal use only)
  18018. */
  18019. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18020. /**
  18021. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18022. * Its lifetime will start back at 0.
  18023. */
  18024. recycleParticle: (particle: Particle) => void;
  18025. private _stopSubEmitters;
  18026. private _createParticle;
  18027. private _removeFromRoot;
  18028. private _emitFromParticle;
  18029. private _update;
  18030. /** @hidden */
  18031. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18032. /** @hidden */
  18033. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18034. /** @hidden */
  18035. private _getEffect;
  18036. /**
  18037. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18038. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18039. */
  18040. animate(preWarmOnly?: boolean): void;
  18041. private _appendParticleVertices;
  18042. /**
  18043. * Rebuilds the particle system.
  18044. */
  18045. rebuild(): void;
  18046. /**
  18047. * Is this system ready to be used/rendered
  18048. * @return true if the system is ready
  18049. */
  18050. isReady(): boolean;
  18051. private _render;
  18052. /**
  18053. * Renders the particle system in its current state.
  18054. * @returns the current number of particles
  18055. */
  18056. render(): number;
  18057. /**
  18058. * Disposes the particle system and free the associated resources
  18059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18060. */
  18061. dispose(disposeTexture?: boolean): void;
  18062. /**
  18063. * Clones the particle system.
  18064. * @param name The name of the cloned object
  18065. * @param newEmitter The new emitter to use
  18066. * @returns the cloned particle system
  18067. */
  18068. clone(name: string, newEmitter: any): ParticleSystem;
  18069. /**
  18070. * Serializes the particle system to a JSON object.
  18071. * @returns the JSON object
  18072. */
  18073. serialize(): any;
  18074. /** @hidden */
  18075. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18076. /** @hidden */
  18077. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18078. /**
  18079. * Parses a JSON object to create a particle system.
  18080. * @param parsedParticleSystem The JSON object to parse
  18081. * @param scene The scene to create the particle system in
  18082. * @param rootUrl The root url to use to load external dependencies like texture
  18083. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18084. * @returns the Parsed particle system
  18085. */
  18086. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18087. }
  18088. }
  18089. declare module "babylonjs/Particles/particle" {
  18090. import { Nullable } from "babylonjs/types";
  18091. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18092. import { Color4 } from "babylonjs/Maths/math.color";
  18093. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18094. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18095. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18096. /**
  18097. * A particle represents one of the element emitted by a particle system.
  18098. * This is mainly define by its coordinates, direction, velocity and age.
  18099. */
  18100. export class Particle {
  18101. /**
  18102. * The particle system the particle belongs to.
  18103. */
  18104. particleSystem: ParticleSystem;
  18105. private static _Count;
  18106. /**
  18107. * Unique ID of the particle
  18108. */
  18109. id: number;
  18110. /**
  18111. * The world position of the particle in the scene.
  18112. */
  18113. position: Vector3;
  18114. /**
  18115. * The world direction of the particle in the scene.
  18116. */
  18117. direction: Vector3;
  18118. /**
  18119. * The color of the particle.
  18120. */
  18121. color: Color4;
  18122. /**
  18123. * The color change of the particle per step.
  18124. */
  18125. colorStep: Color4;
  18126. /**
  18127. * Defines how long will the life of the particle be.
  18128. */
  18129. lifeTime: number;
  18130. /**
  18131. * The current age of the particle.
  18132. */
  18133. age: number;
  18134. /**
  18135. * The current size of the particle.
  18136. */
  18137. size: number;
  18138. /**
  18139. * The current scale of the particle.
  18140. */
  18141. scale: Vector2;
  18142. /**
  18143. * The current angle of the particle.
  18144. */
  18145. angle: number;
  18146. /**
  18147. * Defines how fast is the angle changing.
  18148. */
  18149. angularSpeed: number;
  18150. /**
  18151. * Defines the cell index used by the particle to be rendered from a sprite.
  18152. */
  18153. cellIndex: number;
  18154. /**
  18155. * The information required to support color remapping
  18156. */
  18157. remapData: Vector4;
  18158. /** @hidden */
  18159. _randomCellOffset?: number;
  18160. /** @hidden */
  18161. _initialDirection: Nullable<Vector3>;
  18162. /** @hidden */
  18163. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18164. /** @hidden */
  18165. _initialStartSpriteCellID: number;
  18166. /** @hidden */
  18167. _initialEndSpriteCellID: number;
  18168. /** @hidden */
  18169. _currentColorGradient: Nullable<ColorGradient>;
  18170. /** @hidden */
  18171. _currentColor1: Color4;
  18172. /** @hidden */
  18173. _currentColor2: Color4;
  18174. /** @hidden */
  18175. _currentSizeGradient: Nullable<FactorGradient>;
  18176. /** @hidden */
  18177. _currentSize1: number;
  18178. /** @hidden */
  18179. _currentSize2: number;
  18180. /** @hidden */
  18181. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18182. /** @hidden */
  18183. _currentAngularSpeed1: number;
  18184. /** @hidden */
  18185. _currentAngularSpeed2: number;
  18186. /** @hidden */
  18187. _currentVelocityGradient: Nullable<FactorGradient>;
  18188. /** @hidden */
  18189. _currentVelocity1: number;
  18190. /** @hidden */
  18191. _currentVelocity2: number;
  18192. /** @hidden */
  18193. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18194. /** @hidden */
  18195. _currentLimitVelocity1: number;
  18196. /** @hidden */
  18197. _currentLimitVelocity2: number;
  18198. /** @hidden */
  18199. _currentDragGradient: Nullable<FactorGradient>;
  18200. /** @hidden */
  18201. _currentDrag1: number;
  18202. /** @hidden */
  18203. _currentDrag2: number;
  18204. /** @hidden */
  18205. _randomNoiseCoordinates1: Vector3;
  18206. /** @hidden */
  18207. _randomNoiseCoordinates2: Vector3;
  18208. /**
  18209. * Creates a new instance Particle
  18210. * @param particleSystem the particle system the particle belongs to
  18211. */
  18212. constructor(
  18213. /**
  18214. * The particle system the particle belongs to.
  18215. */
  18216. particleSystem: ParticleSystem);
  18217. private updateCellInfoFromSystem;
  18218. /**
  18219. * Defines how the sprite cell index is updated for the particle
  18220. */
  18221. updateCellIndex(): void;
  18222. /** @hidden */
  18223. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18224. /** @hidden */
  18225. _inheritParticleInfoToSubEmitters(): void;
  18226. /** @hidden */
  18227. _reset(): void;
  18228. /**
  18229. * Copy the properties of particle to another one.
  18230. * @param other the particle to copy the information to.
  18231. */
  18232. copyTo(other: Particle): void;
  18233. }
  18234. }
  18235. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18236. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18237. import { Effect } from "babylonjs/Materials/effect";
  18238. import { Particle } from "babylonjs/Particles/particle";
  18239. /**
  18240. * Particle emitter represents a volume emitting particles.
  18241. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18242. */
  18243. export interface IParticleEmitterType {
  18244. /**
  18245. * Called by the particle System when the direction is computed for the created particle.
  18246. * @param worldMatrix is the world matrix of the particle system
  18247. * @param directionToUpdate is the direction vector to update with the result
  18248. * @param particle is the particle we are computed the direction for
  18249. */
  18250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18251. /**
  18252. * Called by the particle System when the position is computed for the created particle.
  18253. * @param worldMatrix is the world matrix of the particle system
  18254. * @param positionToUpdate is the position vector to update with the result
  18255. * @param particle is the particle we are computed the position for
  18256. */
  18257. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18258. /**
  18259. * Clones the current emitter and returns a copy of it
  18260. * @returns the new emitter
  18261. */
  18262. clone(): IParticleEmitterType;
  18263. /**
  18264. * Called by the GPUParticleSystem to setup the update shader
  18265. * @param effect defines the update shader
  18266. */
  18267. applyToShader(effect: Effect): void;
  18268. /**
  18269. * Returns a string to use to update the GPU particles update shader
  18270. * @returns the effect defines string
  18271. */
  18272. getEffectDefines(): string;
  18273. /**
  18274. * Returns a string representing the class name
  18275. * @returns a string containing the class name
  18276. */
  18277. getClassName(): string;
  18278. /**
  18279. * Serializes the particle system to a JSON object.
  18280. * @returns the JSON object
  18281. */
  18282. serialize(): any;
  18283. /**
  18284. * Parse properties from a JSON object
  18285. * @param serializationObject defines the JSON object
  18286. */
  18287. parse(serializationObject: any): void;
  18288. }
  18289. }
  18290. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18291. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18292. import { Effect } from "babylonjs/Materials/effect";
  18293. import { Particle } from "babylonjs/Particles/particle";
  18294. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18295. /**
  18296. * Particle emitter emitting particles from the inside of a box.
  18297. * It emits the particles randomly between 2 given directions.
  18298. */
  18299. export class BoxParticleEmitter implements IParticleEmitterType {
  18300. /**
  18301. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18302. */
  18303. direction1: Vector3;
  18304. /**
  18305. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18306. */
  18307. direction2: Vector3;
  18308. /**
  18309. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18310. */
  18311. minEmitBox: Vector3;
  18312. /**
  18313. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18314. */
  18315. maxEmitBox: Vector3;
  18316. /**
  18317. * Creates a new instance BoxParticleEmitter
  18318. */
  18319. constructor();
  18320. /**
  18321. * Called by the particle System when the direction is computed for the created particle.
  18322. * @param worldMatrix is the world matrix of the particle system
  18323. * @param directionToUpdate is the direction vector to update with the result
  18324. * @param particle is the particle we are computed the direction for
  18325. */
  18326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18327. /**
  18328. * Called by the particle System when the position is computed for the created particle.
  18329. * @param worldMatrix is the world matrix of the particle system
  18330. * @param positionToUpdate is the position vector to update with the result
  18331. * @param particle is the particle we are computed the position for
  18332. */
  18333. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18334. /**
  18335. * Clones the current emitter and returns a copy of it
  18336. * @returns the new emitter
  18337. */
  18338. clone(): BoxParticleEmitter;
  18339. /**
  18340. * Called by the GPUParticleSystem to setup the update shader
  18341. * @param effect defines the update shader
  18342. */
  18343. applyToShader(effect: Effect): void;
  18344. /**
  18345. * Returns a string to use to update the GPU particles update shader
  18346. * @returns a string containng the defines string
  18347. */
  18348. getEffectDefines(): string;
  18349. /**
  18350. * Returns the string "BoxParticleEmitter"
  18351. * @returns a string containing the class name
  18352. */
  18353. getClassName(): string;
  18354. /**
  18355. * Serializes the particle system to a JSON object.
  18356. * @returns the JSON object
  18357. */
  18358. serialize(): any;
  18359. /**
  18360. * Parse properties from a JSON object
  18361. * @param serializationObject defines the JSON object
  18362. */
  18363. parse(serializationObject: any): void;
  18364. }
  18365. }
  18366. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18367. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18368. import { Effect } from "babylonjs/Materials/effect";
  18369. import { Particle } from "babylonjs/Particles/particle";
  18370. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18371. /**
  18372. * Particle emitter emitting particles from the inside of a cone.
  18373. * It emits the particles alongside the cone volume from the base to the particle.
  18374. * The emission direction might be randomized.
  18375. */
  18376. export class ConeParticleEmitter implements IParticleEmitterType {
  18377. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18378. directionRandomizer: number;
  18379. private _radius;
  18380. private _angle;
  18381. private _height;
  18382. /**
  18383. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18384. */
  18385. radiusRange: number;
  18386. /**
  18387. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18388. */
  18389. heightRange: number;
  18390. /**
  18391. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18392. */
  18393. emitFromSpawnPointOnly: boolean;
  18394. /**
  18395. * Gets or sets the radius of the emission cone
  18396. */
  18397. radius: number;
  18398. /**
  18399. * Gets or sets the angle of the emission cone
  18400. */
  18401. angle: number;
  18402. private _buildHeight;
  18403. /**
  18404. * Creates a new instance ConeParticleEmitter
  18405. * @param radius the radius of the emission cone (1 by default)
  18406. * @param angle the cone base angle (PI by default)
  18407. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18408. */
  18409. constructor(radius?: number, angle?: number,
  18410. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18411. directionRandomizer?: number);
  18412. /**
  18413. * Called by the particle System when the direction is computed for the created particle.
  18414. * @param worldMatrix is the world matrix of the particle system
  18415. * @param directionToUpdate is the direction vector to update with the result
  18416. * @param particle is the particle we are computed the direction for
  18417. */
  18418. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18419. /**
  18420. * Called by the particle System when the position is computed for the created particle.
  18421. * @param worldMatrix is the world matrix of the particle system
  18422. * @param positionToUpdate is the position vector to update with the result
  18423. * @param particle is the particle we are computed the position for
  18424. */
  18425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18426. /**
  18427. * Clones the current emitter and returns a copy of it
  18428. * @returns the new emitter
  18429. */
  18430. clone(): ConeParticleEmitter;
  18431. /**
  18432. * Called by the GPUParticleSystem to setup the update shader
  18433. * @param effect defines the update shader
  18434. */
  18435. applyToShader(effect: Effect): void;
  18436. /**
  18437. * Returns a string to use to update the GPU particles update shader
  18438. * @returns a string containng the defines string
  18439. */
  18440. getEffectDefines(): string;
  18441. /**
  18442. * Returns the string "ConeParticleEmitter"
  18443. * @returns a string containing the class name
  18444. */
  18445. getClassName(): string;
  18446. /**
  18447. * Serializes the particle system to a JSON object.
  18448. * @returns the JSON object
  18449. */
  18450. serialize(): any;
  18451. /**
  18452. * Parse properties from a JSON object
  18453. * @param serializationObject defines the JSON object
  18454. */
  18455. parse(serializationObject: any): void;
  18456. }
  18457. }
  18458. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18459. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18460. import { Effect } from "babylonjs/Materials/effect";
  18461. import { Particle } from "babylonjs/Particles/particle";
  18462. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18463. /**
  18464. * Particle emitter emitting particles from the inside of a cylinder.
  18465. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18466. */
  18467. export class CylinderParticleEmitter implements IParticleEmitterType {
  18468. /**
  18469. * The radius of the emission cylinder.
  18470. */
  18471. radius: number;
  18472. /**
  18473. * The height of the emission cylinder.
  18474. */
  18475. height: number;
  18476. /**
  18477. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18478. */
  18479. radiusRange: number;
  18480. /**
  18481. * How much to randomize the particle direction [0-1].
  18482. */
  18483. directionRandomizer: number;
  18484. /**
  18485. * Creates a new instance CylinderParticleEmitter
  18486. * @param radius the radius of the emission cylinder (1 by default)
  18487. * @param height the height of the emission cylinder (1 by default)
  18488. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18489. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18490. */
  18491. constructor(
  18492. /**
  18493. * The radius of the emission cylinder.
  18494. */
  18495. radius?: number,
  18496. /**
  18497. * The height of the emission cylinder.
  18498. */
  18499. height?: number,
  18500. /**
  18501. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18502. */
  18503. radiusRange?: number,
  18504. /**
  18505. * How much to randomize the particle direction [0-1].
  18506. */
  18507. directionRandomizer?: number);
  18508. /**
  18509. * Called by the particle System when the direction is computed for the created particle.
  18510. * @param worldMatrix is the world matrix of the particle system
  18511. * @param directionToUpdate is the direction vector to update with the result
  18512. * @param particle is the particle we are computed the direction for
  18513. */
  18514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18515. /**
  18516. * Called by the particle System when the position is computed for the created particle.
  18517. * @param worldMatrix is the world matrix of the particle system
  18518. * @param positionToUpdate is the position vector to update with the result
  18519. * @param particle is the particle we are computed the position for
  18520. */
  18521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18522. /**
  18523. * Clones the current emitter and returns a copy of it
  18524. * @returns the new emitter
  18525. */
  18526. clone(): CylinderParticleEmitter;
  18527. /**
  18528. * Called by the GPUParticleSystem to setup the update shader
  18529. * @param effect defines the update shader
  18530. */
  18531. applyToShader(effect: Effect): void;
  18532. /**
  18533. * Returns a string to use to update the GPU particles update shader
  18534. * @returns a string containng the defines string
  18535. */
  18536. getEffectDefines(): string;
  18537. /**
  18538. * Returns the string "CylinderParticleEmitter"
  18539. * @returns a string containing the class name
  18540. */
  18541. getClassName(): string;
  18542. /**
  18543. * Serializes the particle system to a JSON object.
  18544. * @returns the JSON object
  18545. */
  18546. serialize(): any;
  18547. /**
  18548. * Parse properties from a JSON object
  18549. * @param serializationObject defines the JSON object
  18550. */
  18551. parse(serializationObject: any): void;
  18552. }
  18553. /**
  18554. * Particle emitter emitting particles from the inside of a cylinder.
  18555. * It emits the particles randomly between two vectors.
  18556. */
  18557. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18558. /**
  18559. * The min limit of the emission direction.
  18560. */
  18561. direction1: Vector3;
  18562. /**
  18563. * The max limit of the emission direction.
  18564. */
  18565. direction2: Vector3;
  18566. /**
  18567. * Creates a new instance CylinderDirectedParticleEmitter
  18568. * @param radius the radius of the emission cylinder (1 by default)
  18569. * @param height the height of the emission cylinder (1 by default)
  18570. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18571. * @param direction1 the min limit of the emission direction (up vector by default)
  18572. * @param direction2 the max limit of the emission direction (up vector by default)
  18573. */
  18574. constructor(radius?: number, height?: number, radiusRange?: number,
  18575. /**
  18576. * The min limit of the emission direction.
  18577. */
  18578. direction1?: Vector3,
  18579. /**
  18580. * The max limit of the emission direction.
  18581. */
  18582. direction2?: Vector3);
  18583. /**
  18584. * Called by the particle System when the direction is computed for the created particle.
  18585. * @param worldMatrix is the world matrix of the particle system
  18586. * @param directionToUpdate is the direction vector to update with the result
  18587. * @param particle is the particle we are computed the direction for
  18588. */
  18589. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18590. /**
  18591. * Clones the current emitter and returns a copy of it
  18592. * @returns the new emitter
  18593. */
  18594. clone(): CylinderDirectedParticleEmitter;
  18595. /**
  18596. * Called by the GPUParticleSystem to setup the update shader
  18597. * @param effect defines the update shader
  18598. */
  18599. applyToShader(effect: Effect): void;
  18600. /**
  18601. * Returns a string to use to update the GPU particles update shader
  18602. * @returns a string containng the defines string
  18603. */
  18604. getEffectDefines(): string;
  18605. /**
  18606. * Returns the string "CylinderDirectedParticleEmitter"
  18607. * @returns a string containing the class name
  18608. */
  18609. getClassName(): string;
  18610. /**
  18611. * Serializes the particle system to a JSON object.
  18612. * @returns the JSON object
  18613. */
  18614. serialize(): any;
  18615. /**
  18616. * Parse properties from a JSON object
  18617. * @param serializationObject defines the JSON object
  18618. */
  18619. parse(serializationObject: any): void;
  18620. }
  18621. }
  18622. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18623. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18624. import { Effect } from "babylonjs/Materials/effect";
  18625. import { Particle } from "babylonjs/Particles/particle";
  18626. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18627. /**
  18628. * Particle emitter emitting particles from the inside of a hemisphere.
  18629. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18630. */
  18631. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18632. /**
  18633. * The radius of the emission hemisphere.
  18634. */
  18635. radius: number;
  18636. /**
  18637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18638. */
  18639. radiusRange: number;
  18640. /**
  18641. * How much to randomize the particle direction [0-1].
  18642. */
  18643. directionRandomizer: number;
  18644. /**
  18645. * Creates a new instance HemisphericParticleEmitter
  18646. * @param radius the radius of the emission hemisphere (1 by default)
  18647. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18648. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18649. */
  18650. constructor(
  18651. /**
  18652. * The radius of the emission hemisphere.
  18653. */
  18654. radius?: number,
  18655. /**
  18656. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18657. */
  18658. radiusRange?: number,
  18659. /**
  18660. * How much to randomize the particle direction [0-1].
  18661. */
  18662. directionRandomizer?: number);
  18663. /**
  18664. * Called by the particle System when the direction is computed for the created particle.
  18665. * @param worldMatrix is the world matrix of the particle system
  18666. * @param directionToUpdate is the direction vector to update with the result
  18667. * @param particle is the particle we are computed the direction for
  18668. */
  18669. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18670. /**
  18671. * Called by the particle System when the position is computed for the created particle.
  18672. * @param worldMatrix is the world matrix of the particle system
  18673. * @param positionToUpdate is the position vector to update with the result
  18674. * @param particle is the particle we are computed the position for
  18675. */
  18676. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18677. /**
  18678. * Clones the current emitter and returns a copy of it
  18679. * @returns the new emitter
  18680. */
  18681. clone(): HemisphericParticleEmitter;
  18682. /**
  18683. * Called by the GPUParticleSystem to setup the update shader
  18684. * @param effect defines the update shader
  18685. */
  18686. applyToShader(effect: Effect): void;
  18687. /**
  18688. * Returns a string to use to update the GPU particles update shader
  18689. * @returns a string containng the defines string
  18690. */
  18691. getEffectDefines(): string;
  18692. /**
  18693. * Returns the string "HemisphericParticleEmitter"
  18694. * @returns a string containing the class name
  18695. */
  18696. getClassName(): string;
  18697. /**
  18698. * Serializes the particle system to a JSON object.
  18699. * @returns the JSON object
  18700. */
  18701. serialize(): any;
  18702. /**
  18703. * Parse properties from a JSON object
  18704. * @param serializationObject defines the JSON object
  18705. */
  18706. parse(serializationObject: any): void;
  18707. }
  18708. }
  18709. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18710. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18711. import { Effect } from "babylonjs/Materials/effect";
  18712. import { Particle } from "babylonjs/Particles/particle";
  18713. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18714. /**
  18715. * Particle emitter emitting particles from a point.
  18716. * It emits the particles randomly between 2 given directions.
  18717. */
  18718. export class PointParticleEmitter implements IParticleEmitterType {
  18719. /**
  18720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18721. */
  18722. direction1: Vector3;
  18723. /**
  18724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18725. */
  18726. direction2: Vector3;
  18727. /**
  18728. * Creates a new instance PointParticleEmitter
  18729. */
  18730. constructor();
  18731. /**
  18732. * Called by the particle System when the direction is computed for the created particle.
  18733. * @param worldMatrix is the world matrix of the particle system
  18734. * @param directionToUpdate is the direction vector to update with the result
  18735. * @param particle is the particle we are computed the direction for
  18736. */
  18737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18738. /**
  18739. * Called by the particle System when the position is computed for the created particle.
  18740. * @param worldMatrix is the world matrix of the particle system
  18741. * @param positionToUpdate is the position vector to update with the result
  18742. * @param particle is the particle we are computed the position for
  18743. */
  18744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18745. /**
  18746. * Clones the current emitter and returns a copy of it
  18747. * @returns the new emitter
  18748. */
  18749. clone(): PointParticleEmitter;
  18750. /**
  18751. * Called by the GPUParticleSystem to setup the update shader
  18752. * @param effect defines the update shader
  18753. */
  18754. applyToShader(effect: Effect): void;
  18755. /**
  18756. * Returns a string to use to update the GPU particles update shader
  18757. * @returns a string containng the defines string
  18758. */
  18759. getEffectDefines(): string;
  18760. /**
  18761. * Returns the string "PointParticleEmitter"
  18762. * @returns a string containing the class name
  18763. */
  18764. getClassName(): string;
  18765. /**
  18766. * Serializes the particle system to a JSON object.
  18767. * @returns the JSON object
  18768. */
  18769. serialize(): any;
  18770. /**
  18771. * Parse properties from a JSON object
  18772. * @param serializationObject defines the JSON object
  18773. */
  18774. parse(serializationObject: any): void;
  18775. }
  18776. }
  18777. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18778. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18779. import { Effect } from "babylonjs/Materials/effect";
  18780. import { Particle } from "babylonjs/Particles/particle";
  18781. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18782. /**
  18783. * Particle emitter emitting particles from the inside of a sphere.
  18784. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18785. */
  18786. export class SphereParticleEmitter implements IParticleEmitterType {
  18787. /**
  18788. * The radius of the emission sphere.
  18789. */
  18790. radius: number;
  18791. /**
  18792. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18793. */
  18794. radiusRange: number;
  18795. /**
  18796. * How much to randomize the particle direction [0-1].
  18797. */
  18798. directionRandomizer: number;
  18799. /**
  18800. * Creates a new instance SphereParticleEmitter
  18801. * @param radius the radius of the emission sphere (1 by default)
  18802. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18803. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18804. */
  18805. constructor(
  18806. /**
  18807. * The radius of the emission sphere.
  18808. */
  18809. radius?: number,
  18810. /**
  18811. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18812. */
  18813. radiusRange?: number,
  18814. /**
  18815. * How much to randomize the particle direction [0-1].
  18816. */
  18817. directionRandomizer?: number);
  18818. /**
  18819. * Called by the particle System when the direction is computed for the created particle.
  18820. * @param worldMatrix is the world matrix of the particle system
  18821. * @param directionToUpdate is the direction vector to update with the result
  18822. * @param particle is the particle we are computed the direction for
  18823. */
  18824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18825. /**
  18826. * Called by the particle System when the position is computed for the created particle.
  18827. * @param worldMatrix is the world matrix of the particle system
  18828. * @param positionToUpdate is the position vector to update with the result
  18829. * @param particle is the particle we are computed the position for
  18830. */
  18831. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18832. /**
  18833. * Clones the current emitter and returns a copy of it
  18834. * @returns the new emitter
  18835. */
  18836. clone(): SphereParticleEmitter;
  18837. /**
  18838. * Called by the GPUParticleSystem to setup the update shader
  18839. * @param effect defines the update shader
  18840. */
  18841. applyToShader(effect: Effect): void;
  18842. /**
  18843. * Returns a string to use to update the GPU particles update shader
  18844. * @returns a string containng the defines string
  18845. */
  18846. getEffectDefines(): string;
  18847. /**
  18848. * Returns the string "SphereParticleEmitter"
  18849. * @returns a string containing the class name
  18850. */
  18851. getClassName(): string;
  18852. /**
  18853. * Serializes the particle system to a JSON object.
  18854. * @returns the JSON object
  18855. */
  18856. serialize(): any;
  18857. /**
  18858. * Parse properties from a JSON object
  18859. * @param serializationObject defines the JSON object
  18860. */
  18861. parse(serializationObject: any): void;
  18862. }
  18863. /**
  18864. * Particle emitter emitting particles from the inside of a sphere.
  18865. * It emits the particles randomly between two vectors.
  18866. */
  18867. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18868. /**
  18869. * The min limit of the emission direction.
  18870. */
  18871. direction1: Vector3;
  18872. /**
  18873. * The max limit of the emission direction.
  18874. */
  18875. direction2: Vector3;
  18876. /**
  18877. * Creates a new instance SphereDirectedParticleEmitter
  18878. * @param radius the radius of the emission sphere (1 by default)
  18879. * @param direction1 the min limit of the emission direction (up vector by default)
  18880. * @param direction2 the max limit of the emission direction (up vector by default)
  18881. */
  18882. constructor(radius?: number,
  18883. /**
  18884. * The min limit of the emission direction.
  18885. */
  18886. direction1?: Vector3,
  18887. /**
  18888. * The max limit of the emission direction.
  18889. */
  18890. direction2?: Vector3);
  18891. /**
  18892. * Called by the particle System when the direction is computed for the created particle.
  18893. * @param worldMatrix is the world matrix of the particle system
  18894. * @param directionToUpdate is the direction vector to update with the result
  18895. * @param particle is the particle we are computed the direction for
  18896. */
  18897. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18898. /**
  18899. * Clones the current emitter and returns a copy of it
  18900. * @returns the new emitter
  18901. */
  18902. clone(): SphereDirectedParticleEmitter;
  18903. /**
  18904. * Called by the GPUParticleSystem to setup the update shader
  18905. * @param effect defines the update shader
  18906. */
  18907. applyToShader(effect: Effect): void;
  18908. /**
  18909. * Returns a string to use to update the GPU particles update shader
  18910. * @returns a string containng the defines string
  18911. */
  18912. getEffectDefines(): string;
  18913. /**
  18914. * Returns the string "SphereDirectedParticleEmitter"
  18915. * @returns a string containing the class name
  18916. */
  18917. getClassName(): string;
  18918. /**
  18919. * Serializes the particle system to a JSON object.
  18920. * @returns the JSON object
  18921. */
  18922. serialize(): any;
  18923. /**
  18924. * Parse properties from a JSON object
  18925. * @param serializationObject defines the JSON object
  18926. */
  18927. parse(serializationObject: any): void;
  18928. }
  18929. }
  18930. declare module "babylonjs/Particles/EmitterTypes/index" {
  18931. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18932. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18933. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18934. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18935. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18936. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18937. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18938. }
  18939. declare module "babylonjs/Particles/IParticleSystem" {
  18940. import { Nullable } from "babylonjs/types";
  18941. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18942. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18945. import { Texture } from "babylonjs/Materials/Textures/texture";
  18946. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18947. import { Scene } from "babylonjs/scene";
  18948. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18949. import { Animation } from "babylonjs/Animations/animation";
  18950. /**
  18951. * Interface representing a particle system in Babylon.js.
  18952. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18953. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18954. */
  18955. export interface IParticleSystem {
  18956. /**
  18957. * List of animations used by the particle system.
  18958. */
  18959. animations: Animation[];
  18960. /**
  18961. * The id of the Particle system.
  18962. */
  18963. id: string;
  18964. /**
  18965. * The name of the Particle system.
  18966. */
  18967. name: string;
  18968. /**
  18969. * The emitter represents the Mesh or position we are attaching the particle system to.
  18970. */
  18971. emitter: Nullable<AbstractMesh | Vector3>;
  18972. /**
  18973. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18974. */
  18975. isBillboardBased: boolean;
  18976. /**
  18977. * The rendering group used by the Particle system to chose when to render.
  18978. */
  18979. renderingGroupId: number;
  18980. /**
  18981. * The layer mask we are rendering the particles through.
  18982. */
  18983. layerMask: number;
  18984. /**
  18985. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18986. */
  18987. updateSpeed: number;
  18988. /**
  18989. * The amount of time the particle system is running (depends of the overall update speed).
  18990. */
  18991. targetStopDuration: number;
  18992. /**
  18993. * The texture used to render each particle. (this can be a spritesheet)
  18994. */
  18995. particleTexture: Nullable<Texture>;
  18996. /**
  18997. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18998. */
  18999. blendMode: number;
  19000. /**
  19001. * Minimum life time of emitting particles.
  19002. */
  19003. minLifeTime: number;
  19004. /**
  19005. * Maximum life time of emitting particles.
  19006. */
  19007. maxLifeTime: number;
  19008. /**
  19009. * Minimum Size of emitting particles.
  19010. */
  19011. minSize: number;
  19012. /**
  19013. * Maximum Size of emitting particles.
  19014. */
  19015. maxSize: number;
  19016. /**
  19017. * Minimum scale of emitting particles on X axis.
  19018. */
  19019. minScaleX: number;
  19020. /**
  19021. * Maximum scale of emitting particles on X axis.
  19022. */
  19023. maxScaleX: number;
  19024. /**
  19025. * Minimum scale of emitting particles on Y axis.
  19026. */
  19027. minScaleY: number;
  19028. /**
  19029. * Maximum scale of emitting particles on Y axis.
  19030. */
  19031. maxScaleY: number;
  19032. /**
  19033. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19034. */
  19035. color1: Color4;
  19036. /**
  19037. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19038. */
  19039. color2: Color4;
  19040. /**
  19041. * Color the particle will have at the end of its lifetime.
  19042. */
  19043. colorDead: Color4;
  19044. /**
  19045. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19046. */
  19047. emitRate: number;
  19048. /**
  19049. * You can use gravity if you want to give an orientation to your particles.
  19050. */
  19051. gravity: Vector3;
  19052. /**
  19053. * Minimum power of emitting particles.
  19054. */
  19055. minEmitPower: number;
  19056. /**
  19057. * Maximum power of emitting particles.
  19058. */
  19059. maxEmitPower: number;
  19060. /**
  19061. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19062. */
  19063. minAngularSpeed: number;
  19064. /**
  19065. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19066. */
  19067. maxAngularSpeed: number;
  19068. /**
  19069. * Gets or sets the minimal initial rotation in radians.
  19070. */
  19071. minInitialRotation: number;
  19072. /**
  19073. * Gets or sets the maximal initial rotation in radians.
  19074. */
  19075. maxInitialRotation: number;
  19076. /**
  19077. * The particle emitter type defines the emitter used by the particle system.
  19078. * It can be for example box, sphere, or cone...
  19079. */
  19080. particleEmitterType: Nullable<IParticleEmitterType>;
  19081. /**
  19082. * Defines the delay in milliseconds before starting the system (0 by default)
  19083. */
  19084. startDelay: number;
  19085. /**
  19086. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  19087. */
  19088. preWarmCycles: number;
  19089. /**
  19090. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19091. */
  19092. preWarmStepOffset: number;
  19093. /**
  19094. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  19095. */
  19096. spriteCellChangeSpeed: number;
  19097. /**
  19098. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19099. */
  19100. startSpriteCellID: number;
  19101. /**
  19102. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19103. */
  19104. endSpriteCellID: number;
  19105. /**
  19106. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19107. */
  19108. spriteCellWidth: number;
  19109. /**
  19110. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19111. */
  19112. spriteCellHeight: number;
  19113. /**
  19114. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19115. */
  19116. spriteRandomStartCell: boolean;
  19117. /**
  19118. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19119. */
  19120. isAnimationSheetEnabled: boolean;
  19121. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19122. translationPivot: Vector2;
  19123. /**
  19124. * Gets or sets a texture used to add random noise to particle positions
  19125. */
  19126. noiseTexture: Nullable<BaseTexture>;
  19127. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19128. noiseStrength: Vector3;
  19129. /**
  19130. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19131. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19132. */
  19133. billboardMode: number;
  19134. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19135. limitVelocityDamping: number;
  19136. /**
  19137. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19138. */
  19139. beginAnimationOnStart: boolean;
  19140. /**
  19141. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19142. */
  19143. beginAnimationFrom: number;
  19144. /**
  19145. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19146. */
  19147. beginAnimationTo: number;
  19148. /**
  19149. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19150. */
  19151. beginAnimationLoop: boolean;
  19152. /**
  19153. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19154. */
  19155. disposeOnStop: boolean;
  19156. /**
  19157. * Gets the maximum number of particles active at the same time.
  19158. * @returns The max number of active particles.
  19159. */
  19160. getCapacity(): number;
  19161. /**
  19162. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19163. * @returns True if it has been started, otherwise false.
  19164. */
  19165. isStarted(): boolean;
  19166. /**
  19167. * Animates the particle system for this frame.
  19168. */
  19169. animate(): void;
  19170. /**
  19171. * Renders the particle system in its current state.
  19172. * @returns the current number of particles
  19173. */
  19174. render(): number;
  19175. /**
  19176. * Dispose the particle system and frees its associated resources.
  19177. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19178. */
  19179. dispose(disposeTexture?: boolean): void;
  19180. /**
  19181. * Clones the particle system.
  19182. * @param name The name of the cloned object
  19183. * @param newEmitter The new emitter to use
  19184. * @returns the cloned particle system
  19185. */
  19186. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19187. /**
  19188. * Serializes the particle system to a JSON object.
  19189. * @returns the JSON object
  19190. */
  19191. serialize(): any;
  19192. /**
  19193. * Rebuild the particle system
  19194. */
  19195. rebuild(): void;
  19196. /**
  19197. * Starts the particle system and begins to emit
  19198. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19199. */
  19200. start(delay?: number): void;
  19201. /**
  19202. * Stops the particle system.
  19203. */
  19204. stop(): void;
  19205. /**
  19206. * Remove all active particles
  19207. */
  19208. reset(): void;
  19209. /**
  19210. * Is this system ready to be used/rendered
  19211. * @return true if the system is ready
  19212. */
  19213. isReady(): boolean;
  19214. /**
  19215. * Adds a new color gradient
  19216. * @param gradient defines the gradient to use (between 0 and 1)
  19217. * @param color1 defines the color to affect to the specified gradient
  19218. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19219. * @returns the current particle system
  19220. */
  19221. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19222. /**
  19223. * Remove a specific color gradient
  19224. * @param gradient defines the gradient to remove
  19225. * @returns the current particle system
  19226. */
  19227. removeColorGradient(gradient: number): IParticleSystem;
  19228. /**
  19229. * Adds a new size gradient
  19230. * @param gradient defines the gradient to use (between 0 and 1)
  19231. * @param factor defines the size factor to affect to the specified gradient
  19232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19233. * @returns the current particle system
  19234. */
  19235. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19236. /**
  19237. * Remove a specific size gradient
  19238. * @param gradient defines the gradient to remove
  19239. * @returns the current particle system
  19240. */
  19241. removeSizeGradient(gradient: number): IParticleSystem;
  19242. /**
  19243. * Gets the current list of color gradients.
  19244. * You must use addColorGradient and removeColorGradient to udpate this list
  19245. * @returns the list of color gradients
  19246. */
  19247. getColorGradients(): Nullable<Array<ColorGradient>>;
  19248. /**
  19249. * Gets the current list of size gradients.
  19250. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19251. * @returns the list of size gradients
  19252. */
  19253. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19254. /**
  19255. * Gets the current list of angular speed gradients.
  19256. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19257. * @returns the list of angular speed gradients
  19258. */
  19259. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19260. /**
  19261. * Adds a new angular speed gradient
  19262. * @param gradient defines the gradient to use (between 0 and 1)
  19263. * @param factor defines the angular speed to affect to the specified gradient
  19264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19265. * @returns the current particle system
  19266. */
  19267. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19268. /**
  19269. * Remove a specific angular speed gradient
  19270. * @param gradient defines the gradient to remove
  19271. * @returns the current particle system
  19272. */
  19273. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19274. /**
  19275. * Gets the current list of velocity gradients.
  19276. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19277. * @returns the list of velocity gradients
  19278. */
  19279. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19280. /**
  19281. * Adds a new velocity gradient
  19282. * @param gradient defines the gradient to use (between 0 and 1)
  19283. * @param factor defines the velocity to affect to the specified gradient
  19284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19285. * @returns the current particle system
  19286. */
  19287. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19288. /**
  19289. * Remove a specific velocity gradient
  19290. * @param gradient defines the gradient to remove
  19291. * @returns the current particle system
  19292. */
  19293. removeVelocityGradient(gradient: number): IParticleSystem;
  19294. /**
  19295. * Gets the current list of limit velocity gradients.
  19296. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19297. * @returns the list of limit velocity gradients
  19298. */
  19299. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19300. /**
  19301. * Adds a new limit velocity gradient
  19302. * @param gradient defines the gradient to use (between 0 and 1)
  19303. * @param factor defines the limit velocity to affect to the specified gradient
  19304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19305. * @returns the current particle system
  19306. */
  19307. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19308. /**
  19309. * Remove a specific limit velocity gradient
  19310. * @param gradient defines the gradient to remove
  19311. * @returns the current particle system
  19312. */
  19313. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19314. /**
  19315. * Adds a new drag gradient
  19316. * @param gradient defines the gradient to use (between 0 and 1)
  19317. * @param factor defines the drag to affect to the specified gradient
  19318. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19319. * @returns the current particle system
  19320. */
  19321. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19322. /**
  19323. * Remove a specific drag gradient
  19324. * @param gradient defines the gradient to remove
  19325. * @returns the current particle system
  19326. */
  19327. removeDragGradient(gradient: number): IParticleSystem;
  19328. /**
  19329. * Gets the current list of drag gradients.
  19330. * You must use addDragGradient and removeDragGradient to udpate this list
  19331. * @returns the list of drag gradients
  19332. */
  19333. getDragGradients(): Nullable<Array<FactorGradient>>;
  19334. /**
  19335. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19336. * @param gradient defines the gradient to use (between 0 and 1)
  19337. * @param factor defines the emit rate to affect to the specified gradient
  19338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19339. * @returns the current particle system
  19340. */
  19341. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19342. /**
  19343. * Remove a specific emit rate gradient
  19344. * @param gradient defines the gradient to remove
  19345. * @returns the current particle system
  19346. */
  19347. removeEmitRateGradient(gradient: number): IParticleSystem;
  19348. /**
  19349. * Gets the current list of emit rate gradients.
  19350. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19351. * @returns the list of emit rate gradients
  19352. */
  19353. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19354. /**
  19355. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19356. * @param gradient defines the gradient to use (between 0 and 1)
  19357. * @param factor defines the start size to affect to the specified gradient
  19358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19359. * @returns the current particle system
  19360. */
  19361. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19362. /**
  19363. * Remove a specific start size gradient
  19364. * @param gradient defines the gradient to remove
  19365. * @returns the current particle system
  19366. */
  19367. removeStartSizeGradient(gradient: number): IParticleSystem;
  19368. /**
  19369. * Gets the current list of start size gradients.
  19370. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19371. * @returns the list of start size gradients
  19372. */
  19373. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19374. /**
  19375. * Adds a new life time gradient
  19376. * @param gradient defines the gradient to use (between 0 and 1)
  19377. * @param factor defines the life time factor to affect to the specified gradient
  19378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19379. * @returns the current particle system
  19380. */
  19381. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19382. /**
  19383. * Remove a specific life time gradient
  19384. * @param gradient defines the gradient to remove
  19385. * @returns the current particle system
  19386. */
  19387. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19388. /**
  19389. * Gets the current list of life time gradients.
  19390. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19391. * @returns the list of life time gradients
  19392. */
  19393. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19394. /**
  19395. * Gets the current list of color gradients.
  19396. * You must use addColorGradient and removeColorGradient to udpate this list
  19397. * @returns the list of color gradients
  19398. */
  19399. getColorGradients(): Nullable<Array<ColorGradient>>;
  19400. /**
  19401. * Adds a new ramp gradient used to remap particle colors
  19402. * @param gradient defines the gradient to use (between 0 and 1)
  19403. * @param color defines the color to affect to the specified gradient
  19404. * @returns the current particle system
  19405. */
  19406. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19407. /**
  19408. * Gets the current list of ramp gradients.
  19409. * You must use addRampGradient and removeRampGradient to udpate this list
  19410. * @returns the list of ramp gradients
  19411. */
  19412. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19413. /** Gets or sets a boolean indicating that ramp gradients must be used
  19414. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19415. */
  19416. useRampGradients: boolean;
  19417. /**
  19418. * Adds a new color remap gradient
  19419. * @param gradient defines the gradient to use (between 0 and 1)
  19420. * @param min defines the color remap minimal range
  19421. * @param max defines the color remap maximal range
  19422. * @returns the current particle system
  19423. */
  19424. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19425. /**
  19426. * Gets the current list of color remap gradients.
  19427. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19428. * @returns the list of color remap gradients
  19429. */
  19430. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19431. /**
  19432. * Adds a new alpha remap gradient
  19433. * @param gradient defines the gradient to use (between 0 and 1)
  19434. * @param min defines the alpha remap minimal range
  19435. * @param max defines the alpha remap maximal range
  19436. * @returns the current particle system
  19437. */
  19438. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19439. /**
  19440. * Gets the current list of alpha remap gradients.
  19441. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19442. * @returns the list of alpha remap gradients
  19443. */
  19444. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19445. /**
  19446. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19449. * @returns the emitter
  19450. */
  19451. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19452. /**
  19453. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19454. * @param radius The radius of the hemisphere to emit from
  19455. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19456. * @returns the emitter
  19457. */
  19458. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19459. /**
  19460. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19461. * @param radius The radius of the sphere to emit from
  19462. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19463. * @returns the emitter
  19464. */
  19465. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19466. /**
  19467. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19468. * @param radius The radius of the sphere to emit from
  19469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19471. * @returns the emitter
  19472. */
  19473. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19474. /**
  19475. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19476. * @param radius The radius of the emission cylinder
  19477. * @param height The height of the emission cylinder
  19478. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19479. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19480. * @returns the emitter
  19481. */
  19482. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19483. /**
  19484. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19485. * @param radius The radius of the cylinder to emit from
  19486. * @param height The height of the emission cylinder
  19487. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19490. * @returns the emitter
  19491. */
  19492. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19493. /**
  19494. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19495. * @param radius The radius of the cone to emit from
  19496. * @param angle The base angle of the cone
  19497. * @returns the emitter
  19498. */
  19499. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19500. /**
  19501. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19502. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19503. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19504. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19505. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19506. * @returns the emitter
  19507. */
  19508. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19509. /**
  19510. * Get hosting scene
  19511. * @returns the scene
  19512. */
  19513. getScene(): Scene;
  19514. }
  19515. }
  19516. declare module "babylonjs/Meshes/instancedMesh" {
  19517. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19518. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19519. import { Camera } from "babylonjs/Cameras/camera";
  19520. import { Node } from "babylonjs/node";
  19521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19522. import { Mesh } from "babylonjs/Meshes/mesh";
  19523. import { Material } from "babylonjs/Materials/material";
  19524. import { Skeleton } from "babylonjs/Bones/skeleton";
  19525. import { Light } from "babylonjs/Lights/light";
  19526. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19527. /**
  19528. * Creates an instance based on a source mesh.
  19529. */
  19530. export class InstancedMesh extends AbstractMesh {
  19531. private _sourceMesh;
  19532. private _currentLOD;
  19533. /** @hidden */
  19534. _indexInSourceMeshInstanceArray: number;
  19535. constructor(name: string, source: Mesh);
  19536. /**
  19537. * Returns the string "InstancedMesh".
  19538. */
  19539. getClassName(): string;
  19540. /** Gets the list of lights affecting that mesh */
  19541. readonly lightSources: Light[];
  19542. _resyncLightSources(): void;
  19543. _resyncLightSource(light: Light): void;
  19544. _removeLightSource(light: Light, dispose: boolean): void;
  19545. /**
  19546. * If the source mesh receives shadows
  19547. */
  19548. readonly receiveShadows: boolean;
  19549. /**
  19550. * The material of the source mesh
  19551. */
  19552. readonly material: Nullable<Material>;
  19553. /**
  19554. * Visibility of the source mesh
  19555. */
  19556. readonly visibility: number;
  19557. /**
  19558. * Skeleton of the source mesh
  19559. */
  19560. readonly skeleton: Nullable<Skeleton>;
  19561. /**
  19562. * Rendering ground id of the source mesh
  19563. */
  19564. renderingGroupId: number;
  19565. /**
  19566. * Returns the total number of vertices (integer).
  19567. */
  19568. getTotalVertices(): number;
  19569. /**
  19570. * Returns a positive integer : the total number of indices in this mesh geometry.
  19571. * @returns the numner of indices or zero if the mesh has no geometry.
  19572. */
  19573. getTotalIndices(): number;
  19574. /**
  19575. * The source mesh of the instance
  19576. */
  19577. readonly sourceMesh: Mesh;
  19578. /**
  19579. * Is this node ready to be used/rendered
  19580. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19581. * @return {boolean} is it ready
  19582. */
  19583. isReady(completeCheck?: boolean): boolean;
  19584. /**
  19585. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19586. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19587. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  19588. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19589. */
  19590. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19591. /**
  19592. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19593. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19594. * The `data` are either a numeric array either a Float32Array.
  19595. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19596. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  19597. * Note that a new underlying VertexBuffer object is created each call.
  19598. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19599. *
  19600. * Possible `kind` values :
  19601. * - VertexBuffer.PositionKind
  19602. * - VertexBuffer.UVKind
  19603. * - VertexBuffer.UV2Kind
  19604. * - VertexBuffer.UV3Kind
  19605. * - VertexBuffer.UV4Kind
  19606. * - VertexBuffer.UV5Kind
  19607. * - VertexBuffer.UV6Kind
  19608. * - VertexBuffer.ColorKind
  19609. * - VertexBuffer.MatricesIndicesKind
  19610. * - VertexBuffer.MatricesIndicesExtraKind
  19611. * - VertexBuffer.MatricesWeightsKind
  19612. * - VertexBuffer.MatricesWeightsExtraKind
  19613. *
  19614. * Returns the Mesh.
  19615. */
  19616. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19617. /**
  19618. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19619. * If the mesh has no geometry, it is simply returned as it is.
  19620. * The `data` are either a numeric array either a Float32Array.
  19621. * No new underlying VertexBuffer object is created.
  19622. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19623. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19624. *
  19625. * Possible `kind` values :
  19626. * - VertexBuffer.PositionKind
  19627. * - VertexBuffer.UVKind
  19628. * - VertexBuffer.UV2Kind
  19629. * - VertexBuffer.UV3Kind
  19630. * - VertexBuffer.UV4Kind
  19631. * - VertexBuffer.UV5Kind
  19632. * - VertexBuffer.UV6Kind
  19633. * - VertexBuffer.ColorKind
  19634. * - VertexBuffer.MatricesIndicesKind
  19635. * - VertexBuffer.MatricesIndicesExtraKind
  19636. * - VertexBuffer.MatricesWeightsKind
  19637. * - VertexBuffer.MatricesWeightsExtraKind
  19638. *
  19639. * Returns the Mesh.
  19640. */
  19641. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19642. /**
  19643. * Sets the mesh indices.
  19644. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19645. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19646. * This method creates a new index buffer each call.
  19647. * Returns the Mesh.
  19648. */
  19649. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19650. /**
  19651. * Boolean : True if the mesh owns the requested kind of data.
  19652. */
  19653. isVerticesDataPresent(kind: string): boolean;
  19654. /**
  19655. * Returns an array of indices (IndicesArray).
  19656. */
  19657. getIndices(): Nullable<IndicesArray>;
  19658. readonly _positions: Nullable<Vector3[]>;
  19659. /**
  19660. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19661. * This means the mesh underlying bounding box and sphere are recomputed.
  19662. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19663. * @returns the current mesh
  19664. */
  19665. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19666. /** @hidden */
  19667. _preActivate(): InstancedMesh;
  19668. /** @hidden */
  19669. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19670. /** @hidden */
  19671. _postActivate(): void;
  19672. getWorldMatrix(): Matrix;
  19673. readonly isAnInstance: boolean;
  19674. /**
  19675. * Returns the current associated LOD AbstractMesh.
  19676. */
  19677. getLOD(camera: Camera): AbstractMesh;
  19678. /** @hidden */
  19679. _syncSubMeshes(): InstancedMesh;
  19680. /** @hidden */
  19681. _generatePointsArray(): boolean;
  19682. /**
  19683. * Creates a new InstancedMesh from the current mesh.
  19684. * - name (string) : the cloned mesh name
  19685. * - newParent (optional Node) : the optional Node to parent the clone to.
  19686. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19687. *
  19688. * Returns the clone.
  19689. */
  19690. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19691. /**
  19692. * Disposes the InstancedMesh.
  19693. * Returns nothing.
  19694. */
  19695. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19696. }
  19697. module "babylonjs/Meshes/mesh" {
  19698. interface Mesh {
  19699. /**
  19700. * Register a custom buffer that will be instanced
  19701. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19702. * @param kind defines the buffer kind
  19703. * @param stride defines the stride in floats
  19704. */
  19705. registerInstancedBuffer(kind: string, stride: number): void;
  19706. /** @hidden */
  19707. _userInstancedBuffersStorage: {
  19708. data: {
  19709. [key: string]: Float32Array;
  19710. };
  19711. sizes: {
  19712. [key: string]: number;
  19713. };
  19714. vertexBuffers: {
  19715. [key: string]: Nullable<VertexBuffer>;
  19716. };
  19717. strides: {
  19718. [key: string]: number;
  19719. };
  19720. };
  19721. }
  19722. }
  19723. module "babylonjs/Meshes/abstractMesh" {
  19724. interface AbstractMesh {
  19725. /**
  19726. * Object used to store instanced buffers defined by user
  19727. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19728. */
  19729. instancedBuffers: {
  19730. [key: string]: any;
  19731. };
  19732. }
  19733. }
  19734. }
  19735. declare module "babylonjs/Materials/shaderMaterial" {
  19736. import { Scene } from "babylonjs/scene";
  19737. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19739. import { Mesh } from "babylonjs/Meshes/mesh";
  19740. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19742. import { Texture } from "babylonjs/Materials/Textures/texture";
  19743. import { Material } from "babylonjs/Materials/material";
  19744. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19745. /**
  19746. * Defines the options associated with the creation of a shader material.
  19747. */
  19748. export interface IShaderMaterialOptions {
  19749. /**
  19750. * Does the material work in alpha blend mode
  19751. */
  19752. needAlphaBlending: boolean;
  19753. /**
  19754. * Does the material work in alpha test mode
  19755. */
  19756. needAlphaTesting: boolean;
  19757. /**
  19758. * The list of attribute names used in the shader
  19759. */
  19760. attributes: string[];
  19761. /**
  19762. * The list of unifrom names used in the shader
  19763. */
  19764. uniforms: string[];
  19765. /**
  19766. * The list of UBO names used in the shader
  19767. */
  19768. uniformBuffers: string[];
  19769. /**
  19770. * The list of sampler names used in the shader
  19771. */
  19772. samplers: string[];
  19773. /**
  19774. * The list of defines used in the shader
  19775. */
  19776. defines: string[];
  19777. }
  19778. /**
  19779. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19780. *
  19781. * This returned material effects how the mesh will look based on the code in the shaders.
  19782. *
  19783. * @see http://doc.babylonjs.com/how_to/shader_material
  19784. */
  19785. export class ShaderMaterial extends Material {
  19786. private _shaderPath;
  19787. private _options;
  19788. private _textures;
  19789. private _textureArrays;
  19790. private _floats;
  19791. private _ints;
  19792. private _floatsArrays;
  19793. private _colors3;
  19794. private _colors3Arrays;
  19795. private _colors4;
  19796. private _colors4Arrays;
  19797. private _vectors2;
  19798. private _vectors3;
  19799. private _vectors4;
  19800. private _matrices;
  19801. private _matrixArrays;
  19802. private _matrices3x3;
  19803. private _matrices2x2;
  19804. private _vectors2Arrays;
  19805. private _vectors3Arrays;
  19806. private _vectors4Arrays;
  19807. private _cachedWorldViewMatrix;
  19808. private _cachedWorldViewProjectionMatrix;
  19809. private _renderId;
  19810. private _multiview;
  19811. /**
  19812. * Instantiate a new shader material.
  19813. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19814. * This returned material effects how the mesh will look based on the code in the shaders.
  19815. * @see http://doc.babylonjs.com/how_to/shader_material
  19816. * @param name Define the name of the material in the scene
  19817. * @param scene Define the scene the material belongs to
  19818. * @param shaderPath Defines the route to the shader code in one of three ways:
  19819. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19820. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19821. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19822. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19823. * @param options Define the options used to create the shader
  19824. */
  19825. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19826. /**
  19827. * Gets the shader path used to define the shader code
  19828. * It can be modified to trigger a new compilation
  19829. */
  19830. /**
  19831. * Sets the shader path used to define the shader code
  19832. * It can be modified to trigger a new compilation
  19833. */
  19834. shaderPath: any;
  19835. /**
  19836. * Gets the options used to compile the shader.
  19837. * They can be modified to trigger a new compilation
  19838. */
  19839. readonly options: IShaderMaterialOptions;
  19840. /**
  19841. * Gets the current class name of the material e.g. "ShaderMaterial"
  19842. * Mainly use in serialization.
  19843. * @returns the class name
  19844. */
  19845. getClassName(): string;
  19846. /**
  19847. * Specifies if the material will require alpha blending
  19848. * @returns a boolean specifying if alpha blending is needed
  19849. */
  19850. needAlphaBlending(): boolean;
  19851. /**
  19852. * Specifies if this material should be rendered in alpha test mode
  19853. * @returns a boolean specifying if an alpha test is needed.
  19854. */
  19855. needAlphaTesting(): boolean;
  19856. private _checkUniform;
  19857. /**
  19858. * Set a texture in the shader.
  19859. * @param name Define the name of the uniform samplers as defined in the shader
  19860. * @param texture Define the texture to bind to this sampler
  19861. * @return the material itself allowing "fluent" like uniform updates
  19862. */
  19863. setTexture(name: string, texture: Texture): ShaderMaterial;
  19864. /**
  19865. * Set a texture array in the shader.
  19866. * @param name Define the name of the uniform sampler array as defined in the shader
  19867. * @param textures Define the list of textures to bind to this sampler
  19868. * @return the material itself allowing "fluent" like uniform updates
  19869. */
  19870. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19871. /**
  19872. * Set a float in the shader.
  19873. * @param name Define the name of the uniform as defined in the shader
  19874. * @param value Define the value to give to the uniform
  19875. * @return the material itself allowing "fluent" like uniform updates
  19876. */
  19877. setFloat(name: string, value: number): ShaderMaterial;
  19878. /**
  19879. * Set a int in the shader.
  19880. * @param name Define the name of the uniform as defined in the shader
  19881. * @param value Define the value to give to the uniform
  19882. * @return the material itself allowing "fluent" like uniform updates
  19883. */
  19884. setInt(name: string, value: number): ShaderMaterial;
  19885. /**
  19886. * Set an array of floats in the shader.
  19887. * @param name Define the name of the uniform as defined in the shader
  19888. * @param value Define the value to give to the uniform
  19889. * @return the material itself allowing "fluent" like uniform updates
  19890. */
  19891. setFloats(name: string, value: number[]): ShaderMaterial;
  19892. /**
  19893. * Set a vec3 in the shader from a Color3.
  19894. * @param name Define the name of the uniform as defined in the shader
  19895. * @param value Define the value to give to the uniform
  19896. * @return the material itself allowing "fluent" like uniform updates
  19897. */
  19898. setColor3(name: string, value: Color3): ShaderMaterial;
  19899. /**
  19900. * Set a vec3 array in the shader from a Color3 array.
  19901. * @param name Define the name of the uniform as defined in the shader
  19902. * @param value Define the value to give to the uniform
  19903. * @return the material itself allowing "fluent" like uniform updates
  19904. */
  19905. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19906. /**
  19907. * Set a vec4 in the shader from a Color4.
  19908. * @param name Define the name of the uniform as defined in the shader
  19909. * @param value Define the value to give to the uniform
  19910. * @return the material itself allowing "fluent" like uniform updates
  19911. */
  19912. setColor4(name: string, value: Color4): ShaderMaterial;
  19913. /**
  19914. * Set a vec4 array in the shader from a Color4 array.
  19915. * @param name Define the name of the uniform as defined in the shader
  19916. * @param value Define the value to give to the uniform
  19917. * @return the material itself allowing "fluent" like uniform updates
  19918. */
  19919. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19920. /**
  19921. * Set a vec2 in the shader from a Vector2.
  19922. * @param name Define the name of the uniform as defined in the shader
  19923. * @param value Define the value to give to the uniform
  19924. * @return the material itself allowing "fluent" like uniform updates
  19925. */
  19926. setVector2(name: string, value: Vector2): ShaderMaterial;
  19927. /**
  19928. * Set a vec3 in the shader from a Vector3.
  19929. * @param name Define the name of the uniform as defined in the shader
  19930. * @param value Define the value to give to the uniform
  19931. * @return the material itself allowing "fluent" like uniform updates
  19932. */
  19933. setVector3(name: string, value: Vector3): ShaderMaterial;
  19934. /**
  19935. * Set a vec4 in the shader from a Vector4.
  19936. * @param name Define the name of the uniform as defined in the shader
  19937. * @param value Define the value to give to the uniform
  19938. * @return the material itself allowing "fluent" like uniform updates
  19939. */
  19940. setVector4(name: string, value: Vector4): ShaderMaterial;
  19941. /**
  19942. * Set a mat4 in the shader from a Matrix.
  19943. * @param name Define the name of the uniform as defined in the shader
  19944. * @param value Define the value to give to the uniform
  19945. * @return the material itself allowing "fluent" like uniform updates
  19946. */
  19947. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19948. /**
  19949. * Set a float32Array in the shader from a matrix array.
  19950. * @param name Define the name of the uniform as defined in the shader
  19951. * @param value Define the value to give to the uniform
  19952. * @return the material itself allowing "fluent" like uniform updates
  19953. */
  19954. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19955. /**
  19956. * Set a mat3 in the shader from a Float32Array.
  19957. * @param name Define the name of the uniform as defined in the shader
  19958. * @param value Define the value to give to the uniform
  19959. * @return the material itself allowing "fluent" like uniform updates
  19960. */
  19961. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19962. /**
  19963. * Set a mat2 in the shader from a Float32Array.
  19964. * @param name Define the name of the uniform as defined in the shader
  19965. * @param value Define the value to give to the uniform
  19966. * @return the material itself allowing "fluent" like uniform updates
  19967. */
  19968. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19969. /**
  19970. * Set a vec2 array in the shader from a number array.
  19971. * @param name Define the name of the uniform as defined in the shader
  19972. * @param value Define the value to give to the uniform
  19973. * @return the material itself allowing "fluent" like uniform updates
  19974. */
  19975. setArray2(name: string, value: number[]): ShaderMaterial;
  19976. /**
  19977. * Set a vec3 array in the shader from a number array.
  19978. * @param name Define the name of the uniform as defined in the shader
  19979. * @param value Define the value to give to the uniform
  19980. * @return the material itself allowing "fluent" like uniform updates
  19981. */
  19982. setArray3(name: string, value: number[]): ShaderMaterial;
  19983. /**
  19984. * Set a vec4 array in the shader from a number array.
  19985. * @param name Define the name of the uniform as defined in the shader
  19986. * @param value Define the value to give to the uniform
  19987. * @return the material itself allowing "fluent" like uniform updates
  19988. */
  19989. setArray4(name: string, value: number[]): ShaderMaterial;
  19990. private _checkCache;
  19991. /**
  19992. * Specifies that the submesh is ready to be used
  19993. * @param mesh defines the mesh to check
  19994. * @param subMesh defines which submesh to check
  19995. * @param useInstances specifies that instances should be used
  19996. * @returns a boolean indicating that the submesh is ready or not
  19997. */
  19998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19999. /**
  20000. * Checks if the material is ready to render the requested mesh
  20001. * @param mesh Define the mesh to render
  20002. * @param useInstances Define whether or not the material is used with instances
  20003. * @returns true if ready, otherwise false
  20004. */
  20005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20006. /**
  20007. * Binds the world matrix to the material
  20008. * @param world defines the world transformation matrix
  20009. */
  20010. bindOnlyWorldMatrix(world: Matrix): void;
  20011. /**
  20012. * Binds the material to the mesh
  20013. * @param world defines the world transformation matrix
  20014. * @param mesh defines the mesh to bind the material to
  20015. */
  20016. bind(world: Matrix, mesh?: Mesh): void;
  20017. /**
  20018. * Gets the active textures from the material
  20019. * @returns an array of textures
  20020. */
  20021. getActiveTextures(): BaseTexture[];
  20022. /**
  20023. * Specifies if the material uses a texture
  20024. * @param texture defines the texture to check against the material
  20025. * @returns a boolean specifying if the material uses the texture
  20026. */
  20027. hasTexture(texture: BaseTexture): boolean;
  20028. /**
  20029. * Makes a duplicate of the material, and gives it a new name
  20030. * @param name defines the new name for the duplicated material
  20031. * @returns the cloned material
  20032. */
  20033. clone(name: string): ShaderMaterial;
  20034. /**
  20035. * Disposes the material
  20036. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20037. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20038. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20039. */
  20040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20041. /**
  20042. * Serializes this material in a JSON representation
  20043. * @returns the serialized material object
  20044. */
  20045. serialize(): any;
  20046. /**
  20047. * Creates a shader material from parsed shader material data
  20048. * @param source defines the JSON represnetation of the material
  20049. * @param scene defines the hosting scene
  20050. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20051. * @returns a new material
  20052. */
  20053. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20054. }
  20055. }
  20056. declare module "babylonjs/Shaders/color.fragment" {
  20057. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20058. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20059. /** @hidden */
  20060. export var colorPixelShader: {
  20061. name: string;
  20062. shader: string;
  20063. };
  20064. }
  20065. declare module "babylonjs/Shaders/color.vertex" {
  20066. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20067. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20068. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20069. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20070. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20071. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20072. /** @hidden */
  20073. export var colorVertexShader: {
  20074. name: string;
  20075. shader: string;
  20076. };
  20077. }
  20078. declare module "babylonjs/Meshes/linesMesh" {
  20079. import { Nullable } from "babylonjs/types";
  20080. import { Scene } from "babylonjs/scene";
  20081. import { Color3 } from "babylonjs/Maths/math.color";
  20082. import { Node } from "babylonjs/node";
  20083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20084. import { Mesh } from "babylonjs/Meshes/mesh";
  20085. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20086. import { Effect } from "babylonjs/Materials/effect";
  20087. import { Material } from "babylonjs/Materials/material";
  20088. import "babylonjs/Shaders/color.fragment";
  20089. import "babylonjs/Shaders/color.vertex";
  20090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20091. /**
  20092. * Line mesh
  20093. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20094. */
  20095. export class LinesMesh extends Mesh {
  20096. /**
  20097. * If vertex color should be applied to the mesh
  20098. */
  20099. readonly useVertexColor?: boolean | undefined;
  20100. /**
  20101. * If vertex alpha should be applied to the mesh
  20102. */
  20103. readonly useVertexAlpha?: boolean | undefined;
  20104. /**
  20105. * Color of the line (Default: White)
  20106. */
  20107. color: Color3;
  20108. /**
  20109. * Alpha of the line (Default: 1)
  20110. */
  20111. alpha: number;
  20112. /**
  20113. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20114. * This margin is expressed in world space coordinates, so its value may vary.
  20115. * Default value is 0.1
  20116. */
  20117. intersectionThreshold: number;
  20118. private _colorShader;
  20119. private color4;
  20120. /**
  20121. * Creates a new LinesMesh
  20122. * @param name defines the name
  20123. * @param scene defines the hosting scene
  20124. * @param parent defines the parent mesh if any
  20125. * @param source defines the optional source LinesMesh used to clone data from
  20126. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20127. * When false, achieved by calling a clone(), also passing False.
  20128. * This will make creation of children, recursive.
  20129. * @param useVertexColor defines if this LinesMesh supports vertex color
  20130. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20131. */
  20132. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20133. /**
  20134. * If vertex color should be applied to the mesh
  20135. */
  20136. useVertexColor?: boolean | undefined,
  20137. /**
  20138. * If vertex alpha should be applied to the mesh
  20139. */
  20140. useVertexAlpha?: boolean | undefined);
  20141. private _addClipPlaneDefine;
  20142. private _removeClipPlaneDefine;
  20143. isReady(): boolean;
  20144. /**
  20145. * Returns the string "LineMesh"
  20146. */
  20147. getClassName(): string;
  20148. /**
  20149. * @hidden
  20150. */
  20151. /**
  20152. * @hidden
  20153. */
  20154. material: Material;
  20155. /**
  20156. * @hidden
  20157. */
  20158. readonly checkCollisions: boolean;
  20159. /** @hidden */
  20160. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20161. /** @hidden */
  20162. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20163. /**
  20164. * Disposes of the line mesh
  20165. * @param doNotRecurse If children should be disposed
  20166. */
  20167. dispose(doNotRecurse?: boolean): void;
  20168. /**
  20169. * Returns a new LineMesh object cloned from the current one.
  20170. */
  20171. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20172. /**
  20173. * Creates a new InstancedLinesMesh object from the mesh model.
  20174. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20175. * @param name defines the name of the new instance
  20176. * @returns a new InstancedLinesMesh
  20177. */
  20178. createInstance(name: string): InstancedLinesMesh;
  20179. }
  20180. /**
  20181. * Creates an instance based on a source LinesMesh
  20182. */
  20183. export class InstancedLinesMesh extends InstancedMesh {
  20184. /**
  20185. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20186. * This margin is expressed in world space coordinates, so its value may vary.
  20187. * Initilized with the intersectionThreshold value of the source LinesMesh
  20188. */
  20189. intersectionThreshold: number;
  20190. constructor(name: string, source: LinesMesh);
  20191. /**
  20192. * Returns the string "InstancedLinesMesh".
  20193. */
  20194. getClassName(): string;
  20195. }
  20196. }
  20197. declare module "babylonjs/Shaders/line.fragment" {
  20198. /** @hidden */
  20199. export var linePixelShader: {
  20200. name: string;
  20201. shader: string;
  20202. };
  20203. }
  20204. declare module "babylonjs/Shaders/line.vertex" {
  20205. /** @hidden */
  20206. export var lineVertexShader: {
  20207. name: string;
  20208. shader: string;
  20209. };
  20210. }
  20211. declare module "babylonjs/Rendering/edgesRenderer" {
  20212. import { Nullable } from "babylonjs/types";
  20213. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20215. import { Vector3 } from "babylonjs/Maths/math.vector";
  20216. import { IDisposable } from "babylonjs/scene";
  20217. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20218. import "babylonjs/Shaders/line.fragment";
  20219. import "babylonjs/Shaders/line.vertex";
  20220. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20221. module "babylonjs/Meshes/abstractMesh" {
  20222. interface AbstractMesh {
  20223. /**
  20224. * Gets the edgesRenderer associated with the mesh
  20225. */
  20226. edgesRenderer: Nullable<EdgesRenderer>;
  20227. }
  20228. }
  20229. module "babylonjs/Meshes/linesMesh" {
  20230. interface LinesMesh {
  20231. /**
  20232. * Enables the edge rendering mode on the mesh.
  20233. * This mode makes the mesh edges visible
  20234. * @param epsilon defines the maximal distance between two angles to detect a face
  20235. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20236. * @returns the currentAbstractMesh
  20237. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20238. */
  20239. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20240. }
  20241. }
  20242. module "babylonjs/Meshes/linesMesh" {
  20243. interface InstancedLinesMesh {
  20244. /**
  20245. * Enables the edge rendering mode on the mesh.
  20246. * This mode makes the mesh edges visible
  20247. * @param epsilon defines the maximal distance between two angles to detect a face
  20248. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20249. * @returns the current InstancedLinesMesh
  20250. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20251. */
  20252. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20253. }
  20254. }
  20255. /**
  20256. * Defines the minimum contract an Edges renderer should follow.
  20257. */
  20258. export interface IEdgesRenderer extends IDisposable {
  20259. /**
  20260. * Gets or sets a boolean indicating if the edgesRenderer is active
  20261. */
  20262. isEnabled: boolean;
  20263. /**
  20264. * Renders the edges of the attached mesh,
  20265. */
  20266. render(): void;
  20267. /**
  20268. * Checks wether or not the edges renderer is ready to render.
  20269. * @return true if ready, otherwise false.
  20270. */
  20271. isReady(): boolean;
  20272. }
  20273. /**
  20274. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20275. */
  20276. export class EdgesRenderer implements IEdgesRenderer {
  20277. /**
  20278. * Define the size of the edges with an orthographic camera
  20279. */
  20280. edgesWidthScalerForOrthographic: number;
  20281. /**
  20282. * Define the size of the edges with a perspective camera
  20283. */
  20284. edgesWidthScalerForPerspective: number;
  20285. protected _source: AbstractMesh;
  20286. protected _linesPositions: number[];
  20287. protected _linesNormals: number[];
  20288. protected _linesIndices: number[];
  20289. protected _epsilon: number;
  20290. protected _indicesCount: number;
  20291. protected _lineShader: ShaderMaterial;
  20292. protected _ib: DataBuffer;
  20293. protected _buffers: {
  20294. [key: string]: Nullable<VertexBuffer>;
  20295. };
  20296. protected _checkVerticesInsteadOfIndices: boolean;
  20297. private _meshRebuildObserver;
  20298. private _meshDisposeObserver;
  20299. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20300. isEnabled: boolean;
  20301. /**
  20302. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20303. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20304. * @param source Mesh used to create edges
  20305. * @param epsilon sum of angles in adjacency to check for edge
  20306. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20307. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20308. */
  20309. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20310. protected _prepareRessources(): void;
  20311. /** @hidden */
  20312. _rebuild(): void;
  20313. /**
  20314. * Releases the required resources for the edges renderer
  20315. */
  20316. dispose(): void;
  20317. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20318. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20319. /**
  20320. * Checks if the pair of p0 and p1 is en edge
  20321. * @param faceIndex
  20322. * @param edge
  20323. * @param faceNormals
  20324. * @param p0
  20325. * @param p1
  20326. * @private
  20327. */
  20328. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20329. /**
  20330. * push line into the position, normal and index buffer
  20331. * @protected
  20332. */
  20333. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20334. /**
  20335. * Generates lines edges from adjacencjes
  20336. * @private
  20337. */
  20338. _generateEdgesLines(): void;
  20339. /**
  20340. * Checks wether or not the edges renderer is ready to render.
  20341. * @return true if ready, otherwise false.
  20342. */
  20343. isReady(): boolean;
  20344. /**
  20345. * Renders the edges of the attached mesh,
  20346. */
  20347. render(): void;
  20348. }
  20349. /**
  20350. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20351. */
  20352. export class LineEdgesRenderer extends EdgesRenderer {
  20353. /**
  20354. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20355. * @param source LineMesh used to generate edges
  20356. * @param epsilon not important (specified angle for edge detection)
  20357. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20358. */
  20359. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20360. /**
  20361. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20362. */
  20363. _generateEdgesLines(): void;
  20364. }
  20365. }
  20366. declare module "babylonjs/Rendering/renderingGroup" {
  20367. import { SmartArray } from "babylonjs/Misc/smartArray";
  20368. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20370. import { Nullable } from "babylonjs/types";
  20371. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20372. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20373. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20374. import { Material } from "babylonjs/Materials/material";
  20375. import { Scene } from "babylonjs/scene";
  20376. /**
  20377. * This represents the object necessary to create a rendering group.
  20378. * This is exclusively used and created by the rendering manager.
  20379. * To modify the behavior, you use the available helpers in your scene or meshes.
  20380. * @hidden
  20381. */
  20382. export class RenderingGroup {
  20383. index: number;
  20384. private static _zeroVector;
  20385. private _scene;
  20386. private _opaqueSubMeshes;
  20387. private _transparentSubMeshes;
  20388. private _alphaTestSubMeshes;
  20389. private _depthOnlySubMeshes;
  20390. private _particleSystems;
  20391. private _spriteManagers;
  20392. private _opaqueSortCompareFn;
  20393. private _alphaTestSortCompareFn;
  20394. private _transparentSortCompareFn;
  20395. private _renderOpaque;
  20396. private _renderAlphaTest;
  20397. private _renderTransparent;
  20398. /** @hidden */
  20399. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20400. onBeforeTransparentRendering: () => void;
  20401. /**
  20402. * Set the opaque sort comparison function.
  20403. * If null the sub meshes will be render in the order they were created
  20404. */
  20405. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20406. /**
  20407. * Set the alpha test sort comparison function.
  20408. * If null the sub meshes will be render in the order they were created
  20409. */
  20410. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20411. /**
  20412. * Set the transparent sort comparison function.
  20413. * If null the sub meshes will be render in the order they were created
  20414. */
  20415. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20416. /**
  20417. * Creates a new rendering group.
  20418. * @param index The rendering group index
  20419. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20420. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20421. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20422. */
  20423. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20424. /**
  20425. * Render all the sub meshes contained in the group.
  20426. * @param customRenderFunction Used to override the default render behaviour of the group.
  20427. * @returns true if rendered some submeshes.
  20428. */
  20429. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20430. /**
  20431. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20432. * @param subMeshes The submeshes to render
  20433. */
  20434. private renderOpaqueSorted;
  20435. /**
  20436. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20437. * @param subMeshes The submeshes to render
  20438. */
  20439. private renderAlphaTestSorted;
  20440. /**
  20441. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20442. * @param subMeshes The submeshes to render
  20443. */
  20444. private renderTransparentSorted;
  20445. /**
  20446. * Renders the submeshes in a specified order.
  20447. * @param subMeshes The submeshes to sort before render
  20448. * @param sortCompareFn The comparison function use to sort
  20449. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20450. * @param transparent Specifies to activate blending if true
  20451. */
  20452. private static renderSorted;
  20453. /**
  20454. * Renders the submeshes in the order they were dispatched (no sort applied).
  20455. * @param subMeshes The submeshes to render
  20456. */
  20457. private static renderUnsorted;
  20458. /**
  20459. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20460. * are rendered back to front if in the same alpha index.
  20461. *
  20462. * @param a The first submesh
  20463. * @param b The second submesh
  20464. * @returns The result of the comparison
  20465. */
  20466. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20467. /**
  20468. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20469. * are rendered back to front.
  20470. *
  20471. * @param a The first submesh
  20472. * @param b The second submesh
  20473. * @returns The result of the comparison
  20474. */
  20475. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20476. /**
  20477. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20478. * are rendered front to back (prevent overdraw).
  20479. *
  20480. * @param a The first submesh
  20481. * @param b The second submesh
  20482. * @returns The result of the comparison
  20483. */
  20484. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20485. /**
  20486. * Resets the different lists of submeshes to prepare a new frame.
  20487. */
  20488. prepare(): void;
  20489. dispose(): void;
  20490. /**
  20491. * Inserts the submesh in its correct queue depending on its material.
  20492. * @param subMesh The submesh to dispatch
  20493. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20494. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20495. */
  20496. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20497. dispatchSprites(spriteManager: ISpriteManager): void;
  20498. dispatchParticles(particleSystem: IParticleSystem): void;
  20499. private _renderParticles;
  20500. private _renderSprites;
  20501. }
  20502. }
  20503. declare module "babylonjs/Rendering/renderingManager" {
  20504. import { Nullable } from "babylonjs/types";
  20505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20506. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20507. import { SmartArray } from "babylonjs/Misc/smartArray";
  20508. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20509. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20510. import { Material } from "babylonjs/Materials/material";
  20511. import { Scene } from "babylonjs/scene";
  20512. import { Camera } from "babylonjs/Cameras/camera";
  20513. /**
  20514. * Interface describing the different options available in the rendering manager
  20515. * regarding Auto Clear between groups.
  20516. */
  20517. export interface IRenderingManagerAutoClearSetup {
  20518. /**
  20519. * Defines whether or not autoclear is enable.
  20520. */
  20521. autoClear: boolean;
  20522. /**
  20523. * Defines whether or not to autoclear the depth buffer.
  20524. */
  20525. depth: boolean;
  20526. /**
  20527. * Defines whether or not to autoclear the stencil buffer.
  20528. */
  20529. stencil: boolean;
  20530. }
  20531. /**
  20532. * This class is used by the onRenderingGroupObservable
  20533. */
  20534. export class RenderingGroupInfo {
  20535. /**
  20536. * The Scene that being rendered
  20537. */
  20538. scene: Scene;
  20539. /**
  20540. * The camera currently used for the rendering pass
  20541. */
  20542. camera: Nullable<Camera>;
  20543. /**
  20544. * The ID of the renderingGroup being processed
  20545. */
  20546. renderingGroupId: number;
  20547. }
  20548. /**
  20549. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20550. * It is enable to manage the different groups as well as the different necessary sort functions.
  20551. * This should not be used directly aside of the few static configurations
  20552. */
  20553. export class RenderingManager {
  20554. /**
  20555. * The max id used for rendering groups (not included)
  20556. */
  20557. static MAX_RENDERINGGROUPS: number;
  20558. /**
  20559. * The min id used for rendering groups (included)
  20560. */
  20561. static MIN_RENDERINGGROUPS: number;
  20562. /**
  20563. * Used to globally prevent autoclearing scenes.
  20564. */
  20565. static AUTOCLEAR: boolean;
  20566. /**
  20567. * @hidden
  20568. */
  20569. _useSceneAutoClearSetup: boolean;
  20570. private _scene;
  20571. private _renderingGroups;
  20572. private _depthStencilBufferAlreadyCleaned;
  20573. private _autoClearDepthStencil;
  20574. private _customOpaqueSortCompareFn;
  20575. private _customAlphaTestSortCompareFn;
  20576. private _customTransparentSortCompareFn;
  20577. private _renderingGroupInfo;
  20578. /**
  20579. * Instantiates a new rendering group for a particular scene
  20580. * @param scene Defines the scene the groups belongs to
  20581. */
  20582. constructor(scene: Scene);
  20583. private _clearDepthStencilBuffer;
  20584. /**
  20585. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20586. * @hidden
  20587. */
  20588. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20589. /**
  20590. * Resets the different information of the group to prepare a new frame
  20591. * @hidden
  20592. */
  20593. reset(): void;
  20594. /**
  20595. * Dispose and release the group and its associated resources.
  20596. * @hidden
  20597. */
  20598. dispose(): void;
  20599. /**
  20600. * Clear the info related to rendering groups preventing retention points during dispose.
  20601. */
  20602. freeRenderingGroups(): void;
  20603. private _prepareRenderingGroup;
  20604. /**
  20605. * Add a sprite manager to the rendering manager in order to render it this frame.
  20606. * @param spriteManager Define the sprite manager to render
  20607. */
  20608. dispatchSprites(spriteManager: ISpriteManager): void;
  20609. /**
  20610. * Add a particle system to the rendering manager in order to render it this frame.
  20611. * @param particleSystem Define the particle system to render
  20612. */
  20613. dispatchParticles(particleSystem: IParticleSystem): void;
  20614. /**
  20615. * Add a submesh to the manager in order to render it this frame
  20616. * @param subMesh The submesh to dispatch
  20617. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20618. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20619. */
  20620. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20621. /**
  20622. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20623. * This allowed control for front to back rendering or reversly depending of the special needs.
  20624. *
  20625. * @param renderingGroupId The rendering group id corresponding to its index
  20626. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20627. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20628. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20629. */
  20630. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20631. /**
  20632. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20633. *
  20634. * @param renderingGroupId The rendering group id corresponding to its index
  20635. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20636. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20637. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20638. */
  20639. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20640. /**
  20641. * Gets the current auto clear configuration for one rendering group of the rendering
  20642. * manager.
  20643. * @param index the rendering group index to get the information for
  20644. * @returns The auto clear setup for the requested rendering group
  20645. */
  20646. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20647. }
  20648. }
  20649. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20650. import { Observable } from "babylonjs/Misc/observable";
  20651. import { SmartArray } from "babylonjs/Misc/smartArray";
  20652. import { Nullable } from "babylonjs/types";
  20653. import { Camera } from "babylonjs/Cameras/camera";
  20654. import { Scene } from "babylonjs/scene";
  20655. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20656. import { Color4 } from "babylonjs/Maths/math.color";
  20657. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20659. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20660. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20661. import { Texture } from "babylonjs/Materials/Textures/texture";
  20662. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20663. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20664. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20665. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20666. import { Engine } from "babylonjs/Engines/engine";
  20667. /**
  20668. * This Helps creating a texture that will be created from a camera in your scene.
  20669. * It is basically a dynamic texture that could be used to create special effects for instance.
  20670. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20671. */
  20672. export class RenderTargetTexture extends Texture {
  20673. isCube: boolean;
  20674. /**
  20675. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20676. */
  20677. static readonly REFRESHRATE_RENDER_ONCE: number;
  20678. /**
  20679. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20680. */
  20681. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20682. /**
  20683. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20684. * the central point of your effect and can save a lot of performances.
  20685. */
  20686. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20687. /**
  20688. * Use this predicate to dynamically define the list of mesh you want to render.
  20689. * If set, the renderList property will be overwritten.
  20690. */
  20691. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20692. private _renderList;
  20693. /**
  20694. * Use this list to define the list of mesh you want to render.
  20695. */
  20696. renderList: Nullable<Array<AbstractMesh>>;
  20697. private _hookArray;
  20698. /**
  20699. * Define if particles should be rendered in your texture.
  20700. */
  20701. renderParticles: boolean;
  20702. /**
  20703. * Define if sprites should be rendered in your texture.
  20704. */
  20705. renderSprites: boolean;
  20706. /**
  20707. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20708. */
  20709. coordinatesMode: number;
  20710. /**
  20711. * Define the camera used to render the texture.
  20712. */
  20713. activeCamera: Nullable<Camera>;
  20714. /**
  20715. * Override the render function of the texture with your own one.
  20716. */
  20717. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20718. /**
  20719. * Define if camera post processes should be use while rendering the texture.
  20720. */
  20721. useCameraPostProcesses: boolean;
  20722. /**
  20723. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20724. */
  20725. ignoreCameraViewport: boolean;
  20726. private _postProcessManager;
  20727. private _postProcesses;
  20728. private _resizeObserver;
  20729. /**
  20730. * An event triggered when the texture is unbind.
  20731. */
  20732. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20733. /**
  20734. * An event triggered when the texture is unbind.
  20735. */
  20736. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20737. private _onAfterUnbindObserver;
  20738. /**
  20739. * Set a after unbind callback in the texture.
  20740. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20741. */
  20742. onAfterUnbind: () => void;
  20743. /**
  20744. * An event triggered before rendering the texture
  20745. */
  20746. onBeforeRenderObservable: Observable<number>;
  20747. private _onBeforeRenderObserver;
  20748. /**
  20749. * Set a before render callback in the texture.
  20750. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20751. */
  20752. onBeforeRender: (faceIndex: number) => void;
  20753. /**
  20754. * An event triggered after rendering the texture
  20755. */
  20756. onAfterRenderObservable: Observable<number>;
  20757. private _onAfterRenderObserver;
  20758. /**
  20759. * Set a after render callback in the texture.
  20760. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20761. */
  20762. onAfterRender: (faceIndex: number) => void;
  20763. /**
  20764. * An event triggered after the texture clear
  20765. */
  20766. onClearObservable: Observable<Engine>;
  20767. private _onClearObserver;
  20768. /**
  20769. * Set a clear callback in the texture.
  20770. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20771. */
  20772. onClear: (Engine: Engine) => void;
  20773. /**
  20774. * An event triggered when the texture is resized.
  20775. */
  20776. onResizeObservable: Observable<RenderTargetTexture>;
  20777. /**
  20778. * Define the clear color of the Render Target if it should be different from the scene.
  20779. */
  20780. clearColor: Color4;
  20781. protected _size: number | {
  20782. width: number;
  20783. height: number;
  20784. };
  20785. protected _initialSizeParameter: number | {
  20786. width: number;
  20787. height: number;
  20788. } | {
  20789. ratio: number;
  20790. };
  20791. protected _sizeRatio: Nullable<number>;
  20792. /** @hidden */
  20793. _generateMipMaps: boolean;
  20794. protected _renderingManager: RenderingManager;
  20795. /** @hidden */
  20796. _waitingRenderList: string[];
  20797. protected _doNotChangeAspectRatio: boolean;
  20798. protected _currentRefreshId: number;
  20799. protected _refreshRate: number;
  20800. protected _textureMatrix: Matrix;
  20801. protected _samples: number;
  20802. protected _renderTargetOptions: RenderTargetCreationOptions;
  20803. /**
  20804. * Gets render target creation options that were used.
  20805. */
  20806. readonly renderTargetOptions: RenderTargetCreationOptions;
  20807. protected _engine: Engine;
  20808. protected _onRatioRescale(): void;
  20809. /**
  20810. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20811. * It must define where the camera used to render the texture is set
  20812. */
  20813. boundingBoxPosition: Vector3;
  20814. private _boundingBoxSize;
  20815. /**
  20816. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20817. * When defined, the cubemap will switch to local mode
  20818. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20819. * @example https://www.babylonjs-playground.com/#RNASML
  20820. */
  20821. boundingBoxSize: Vector3;
  20822. /**
  20823. * In case the RTT has been created with a depth texture, get the associated
  20824. * depth texture.
  20825. * Otherwise, return null.
  20826. */
  20827. depthStencilTexture: Nullable<InternalTexture>;
  20828. /**
  20829. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20830. * or used a shadow, depth texture...
  20831. * @param name The friendly name of the texture
  20832. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20833. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20834. * @param generateMipMaps True if mip maps need to be generated after render.
  20835. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20836. * @param type The type of the buffer in the RTT (int, half float, float...)
  20837. * @param isCube True if a cube texture needs to be created
  20838. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20839. * @param generateDepthBuffer True to generate a depth buffer
  20840. * @param generateStencilBuffer True to generate a stencil buffer
  20841. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20842. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20843. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20844. */
  20845. constructor(name: string, size: number | {
  20846. width: number;
  20847. height: number;
  20848. } | {
  20849. ratio: number;
  20850. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20851. /**
  20852. * Creates a depth stencil texture.
  20853. * This is only available in WebGL 2 or with the depth texture extension available.
  20854. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20855. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20856. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20857. */
  20858. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20859. private _processSizeParameter;
  20860. /**
  20861. * Define the number of samples to use in case of MSAA.
  20862. * It defaults to one meaning no MSAA has been enabled.
  20863. */
  20864. samples: number;
  20865. /**
  20866. * Resets the refresh counter of the texture and start bak from scratch.
  20867. * Could be useful to regenerate the texture if it is setup to render only once.
  20868. */
  20869. resetRefreshCounter(): void;
  20870. /**
  20871. * Define the refresh rate of the texture or the rendering frequency.
  20872. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20873. */
  20874. refreshRate: number;
  20875. /**
  20876. * Adds a post process to the render target rendering passes.
  20877. * @param postProcess define the post process to add
  20878. */
  20879. addPostProcess(postProcess: PostProcess): void;
  20880. /**
  20881. * Clear all the post processes attached to the render target
  20882. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20883. */
  20884. clearPostProcesses(dispose?: boolean): void;
  20885. /**
  20886. * Remove one of the post process from the list of attached post processes to the texture
  20887. * @param postProcess define the post process to remove from the list
  20888. */
  20889. removePostProcess(postProcess: PostProcess): void;
  20890. /** @hidden */
  20891. _shouldRender(): boolean;
  20892. /**
  20893. * Gets the actual render size of the texture.
  20894. * @returns the width of the render size
  20895. */
  20896. getRenderSize(): number;
  20897. /**
  20898. * Gets the actual render width of the texture.
  20899. * @returns the width of the render size
  20900. */
  20901. getRenderWidth(): number;
  20902. /**
  20903. * Gets the actual render height of the texture.
  20904. * @returns the height of the render size
  20905. */
  20906. getRenderHeight(): number;
  20907. /**
  20908. * Get if the texture can be rescaled or not.
  20909. */
  20910. readonly canRescale: boolean;
  20911. /**
  20912. * Resize the texture using a ratio.
  20913. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20914. */
  20915. scale(ratio: number): void;
  20916. /**
  20917. * Get the texture reflection matrix used to rotate/transform the reflection.
  20918. * @returns the reflection matrix
  20919. */
  20920. getReflectionTextureMatrix(): Matrix;
  20921. /**
  20922. * Resize the texture to a new desired size.
  20923. * Be carrefull as it will recreate all the data in the new texture.
  20924. * @param size Define the new size. It can be:
  20925. * - a number for squared texture,
  20926. * - an object containing { width: number, height: number }
  20927. * - or an object containing a ratio { ratio: number }
  20928. */
  20929. resize(size: number | {
  20930. width: number;
  20931. height: number;
  20932. } | {
  20933. ratio: number;
  20934. }): void;
  20935. /**
  20936. * Renders all the objects from the render list into the texture.
  20937. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20938. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20939. */
  20940. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20941. private _bestReflectionRenderTargetDimension;
  20942. /**
  20943. * @hidden
  20944. * @param faceIndex face index to bind to if this is a cubetexture
  20945. */
  20946. _bindFrameBuffer(faceIndex?: number): void;
  20947. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20948. private renderToTarget;
  20949. /**
  20950. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20951. * This allowed control for front to back rendering or reversly depending of the special needs.
  20952. *
  20953. * @param renderingGroupId The rendering group id corresponding to its index
  20954. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20955. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20956. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20957. */
  20958. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20959. /**
  20960. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20961. *
  20962. * @param renderingGroupId The rendering group id corresponding to its index
  20963. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20964. */
  20965. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20966. /**
  20967. * Clones the texture.
  20968. * @returns the cloned texture
  20969. */
  20970. clone(): RenderTargetTexture;
  20971. /**
  20972. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20973. * @returns The JSON representation of the texture
  20974. */
  20975. serialize(): any;
  20976. /**
  20977. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20978. */
  20979. disposeFramebufferObjects(): void;
  20980. /**
  20981. * Dispose the texture and release its associated resources.
  20982. */
  20983. dispose(): void;
  20984. /** @hidden */
  20985. _rebuild(): void;
  20986. /**
  20987. * Clear the info related to rendering groups preventing retention point in material dispose.
  20988. */
  20989. freeRenderingGroups(): void;
  20990. /**
  20991. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20992. * @returns the view count
  20993. */
  20994. getViewCount(): number;
  20995. }
  20996. }
  20997. declare module "babylonjs/Materials/material" {
  20998. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20999. import { SmartArray } from "babylonjs/Misc/smartArray";
  21000. import { Observable } from "babylonjs/Misc/observable";
  21001. import { Nullable } from "babylonjs/types";
  21002. import { Scene } from "babylonjs/scene";
  21003. import { Matrix } from "babylonjs/Maths/math.vector";
  21004. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21006. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21007. import { Effect } from "babylonjs/Materials/effect";
  21008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21009. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21010. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21011. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21012. import { Mesh } from "babylonjs/Meshes/mesh";
  21013. import { Animation } from "babylonjs/Animations/animation";
  21014. /**
  21015. * Options for compiling materials.
  21016. */
  21017. export interface IMaterialCompilationOptions {
  21018. /**
  21019. * Defines whether clip planes are enabled.
  21020. */
  21021. clipPlane: boolean;
  21022. /**
  21023. * Defines whether instances are enabled.
  21024. */
  21025. useInstances: boolean;
  21026. }
  21027. /**
  21028. * Base class for the main features of a material in Babylon.js
  21029. */
  21030. export class Material implements IAnimatable {
  21031. /**
  21032. * Returns the triangle fill mode
  21033. */
  21034. static readonly TriangleFillMode: number;
  21035. /**
  21036. * Returns the wireframe mode
  21037. */
  21038. static readonly WireFrameFillMode: number;
  21039. /**
  21040. * Returns the point fill mode
  21041. */
  21042. static readonly PointFillMode: number;
  21043. /**
  21044. * Returns the point list draw mode
  21045. */
  21046. static readonly PointListDrawMode: number;
  21047. /**
  21048. * Returns the line list draw mode
  21049. */
  21050. static readonly LineListDrawMode: number;
  21051. /**
  21052. * Returns the line loop draw mode
  21053. */
  21054. static readonly LineLoopDrawMode: number;
  21055. /**
  21056. * Returns the line strip draw mode
  21057. */
  21058. static readonly LineStripDrawMode: number;
  21059. /**
  21060. * Returns the triangle strip draw mode
  21061. */
  21062. static readonly TriangleStripDrawMode: number;
  21063. /**
  21064. * Returns the triangle fan draw mode
  21065. */
  21066. static readonly TriangleFanDrawMode: number;
  21067. /**
  21068. * Stores the clock-wise side orientation
  21069. */
  21070. static readonly ClockWiseSideOrientation: number;
  21071. /**
  21072. * Stores the counter clock-wise side orientation
  21073. */
  21074. static readonly CounterClockWiseSideOrientation: number;
  21075. /**
  21076. * The dirty texture flag value
  21077. */
  21078. static readonly TextureDirtyFlag: number;
  21079. /**
  21080. * The dirty light flag value
  21081. */
  21082. static readonly LightDirtyFlag: number;
  21083. /**
  21084. * The dirty fresnel flag value
  21085. */
  21086. static readonly FresnelDirtyFlag: number;
  21087. /**
  21088. * The dirty attribute flag value
  21089. */
  21090. static readonly AttributesDirtyFlag: number;
  21091. /**
  21092. * The dirty misc flag value
  21093. */
  21094. static readonly MiscDirtyFlag: number;
  21095. /**
  21096. * The all dirty flag value
  21097. */
  21098. static readonly AllDirtyFlag: number;
  21099. /**
  21100. * The ID of the material
  21101. */
  21102. id: string;
  21103. /**
  21104. * Gets or sets the unique id of the material
  21105. */
  21106. uniqueId: number;
  21107. /**
  21108. * The name of the material
  21109. */
  21110. name: string;
  21111. /**
  21112. * Gets or sets user defined metadata
  21113. */
  21114. metadata: any;
  21115. /**
  21116. * For internal use only. Please do not use.
  21117. */
  21118. reservedDataStore: any;
  21119. /**
  21120. * Specifies if the ready state should be checked on each call
  21121. */
  21122. checkReadyOnEveryCall: boolean;
  21123. /**
  21124. * Specifies if the ready state should be checked once
  21125. */
  21126. checkReadyOnlyOnce: boolean;
  21127. /**
  21128. * The state of the material
  21129. */
  21130. state: string;
  21131. /**
  21132. * The alpha value of the material
  21133. */
  21134. protected _alpha: number;
  21135. /**
  21136. * List of inspectable custom properties (used by the Inspector)
  21137. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21138. */
  21139. inspectableCustomProperties: IInspectable[];
  21140. /**
  21141. * Sets the alpha value of the material
  21142. */
  21143. /**
  21144. * Gets the alpha value of the material
  21145. */
  21146. alpha: number;
  21147. /**
  21148. * Specifies if back face culling is enabled
  21149. */
  21150. protected _backFaceCulling: boolean;
  21151. /**
  21152. * Sets the back-face culling state
  21153. */
  21154. /**
  21155. * Gets the back-face culling state
  21156. */
  21157. backFaceCulling: boolean;
  21158. /**
  21159. * Stores the value for side orientation
  21160. */
  21161. sideOrientation: number;
  21162. /**
  21163. * Callback triggered when the material is compiled
  21164. */
  21165. onCompiled: Nullable<(effect: Effect) => void>;
  21166. /**
  21167. * Callback triggered when an error occurs
  21168. */
  21169. onError: Nullable<(effect: Effect, errors: string) => void>;
  21170. /**
  21171. * Callback triggered to get the render target textures
  21172. */
  21173. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21174. /**
  21175. * Gets a boolean indicating that current material needs to register RTT
  21176. */
  21177. readonly hasRenderTargetTextures: boolean;
  21178. /**
  21179. * Specifies if the material should be serialized
  21180. */
  21181. doNotSerialize: boolean;
  21182. /**
  21183. * @hidden
  21184. */
  21185. _storeEffectOnSubMeshes: boolean;
  21186. /**
  21187. * Stores the animations for the material
  21188. */
  21189. animations: Nullable<Array<Animation>>;
  21190. /**
  21191. * An event triggered when the material is disposed
  21192. */
  21193. onDisposeObservable: Observable<Material>;
  21194. /**
  21195. * An observer which watches for dispose events
  21196. */
  21197. private _onDisposeObserver;
  21198. private _onUnBindObservable;
  21199. /**
  21200. * Called during a dispose event
  21201. */
  21202. onDispose: () => void;
  21203. private _onBindObservable;
  21204. /**
  21205. * An event triggered when the material is bound
  21206. */
  21207. readonly onBindObservable: Observable<AbstractMesh>;
  21208. /**
  21209. * An observer which watches for bind events
  21210. */
  21211. private _onBindObserver;
  21212. /**
  21213. * Called during a bind event
  21214. */
  21215. onBind: (Mesh: AbstractMesh) => void;
  21216. /**
  21217. * An event triggered when the material is unbound
  21218. */
  21219. readonly onUnBindObservable: Observable<Material>;
  21220. /**
  21221. * Stores the value of the alpha mode
  21222. */
  21223. private _alphaMode;
  21224. /**
  21225. * Sets the value of the alpha mode.
  21226. *
  21227. * | Value | Type | Description |
  21228. * | --- | --- | --- |
  21229. * | 0 | ALPHA_DISABLE | |
  21230. * | 1 | ALPHA_ADD | |
  21231. * | 2 | ALPHA_COMBINE | |
  21232. * | 3 | ALPHA_SUBTRACT | |
  21233. * | 4 | ALPHA_MULTIPLY | |
  21234. * | 5 | ALPHA_MAXIMIZED | |
  21235. * | 6 | ALPHA_ONEONE | |
  21236. * | 7 | ALPHA_PREMULTIPLIED | |
  21237. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21238. * | 9 | ALPHA_INTERPOLATE | |
  21239. * | 10 | ALPHA_SCREENMODE | |
  21240. *
  21241. */
  21242. /**
  21243. * Gets the value of the alpha mode
  21244. */
  21245. alphaMode: number;
  21246. /**
  21247. * Stores the state of the need depth pre-pass value
  21248. */
  21249. private _needDepthPrePass;
  21250. /**
  21251. * Sets the need depth pre-pass value
  21252. */
  21253. /**
  21254. * Gets the depth pre-pass value
  21255. */
  21256. needDepthPrePass: boolean;
  21257. /**
  21258. * Specifies if depth writing should be disabled
  21259. */
  21260. disableDepthWrite: boolean;
  21261. /**
  21262. * Specifies if depth writing should be forced
  21263. */
  21264. forceDepthWrite: boolean;
  21265. /**
  21266. * Specifies the depth function that should be used. 0 means the default engine function
  21267. */
  21268. depthFunction: number;
  21269. /**
  21270. * Specifies if there should be a separate pass for culling
  21271. */
  21272. separateCullingPass: boolean;
  21273. /**
  21274. * Stores the state specifing if fog should be enabled
  21275. */
  21276. private _fogEnabled;
  21277. /**
  21278. * Sets the state for enabling fog
  21279. */
  21280. /**
  21281. * Gets the value of the fog enabled state
  21282. */
  21283. fogEnabled: boolean;
  21284. /**
  21285. * Stores the size of points
  21286. */
  21287. pointSize: number;
  21288. /**
  21289. * Stores the z offset value
  21290. */
  21291. zOffset: number;
  21292. /**
  21293. * Gets a value specifying if wireframe mode is enabled
  21294. */
  21295. /**
  21296. * Sets the state of wireframe mode
  21297. */
  21298. wireframe: boolean;
  21299. /**
  21300. * Gets the value specifying if point clouds are enabled
  21301. */
  21302. /**
  21303. * Sets the state of point cloud mode
  21304. */
  21305. pointsCloud: boolean;
  21306. /**
  21307. * Gets the material fill mode
  21308. */
  21309. /**
  21310. * Sets the material fill mode
  21311. */
  21312. fillMode: number;
  21313. /**
  21314. * @hidden
  21315. * Stores the effects for the material
  21316. */
  21317. _effect: Nullable<Effect>;
  21318. /**
  21319. * @hidden
  21320. * Specifies if the material was previously ready
  21321. */
  21322. _wasPreviouslyReady: boolean;
  21323. /**
  21324. * Specifies if uniform buffers should be used
  21325. */
  21326. private _useUBO;
  21327. /**
  21328. * Stores a reference to the scene
  21329. */
  21330. private _scene;
  21331. /**
  21332. * Stores the fill mode state
  21333. */
  21334. private _fillMode;
  21335. /**
  21336. * Specifies if the depth write state should be cached
  21337. */
  21338. private _cachedDepthWriteState;
  21339. /**
  21340. * Specifies if the depth function state should be cached
  21341. */
  21342. private _cachedDepthFunctionState;
  21343. /**
  21344. * Stores the uniform buffer
  21345. */
  21346. protected _uniformBuffer: UniformBuffer;
  21347. /** @hidden */
  21348. _indexInSceneMaterialArray: number;
  21349. /** @hidden */
  21350. meshMap: Nullable<{
  21351. [id: string]: AbstractMesh | undefined;
  21352. }>;
  21353. /**
  21354. * Creates a material instance
  21355. * @param name defines the name of the material
  21356. * @param scene defines the scene to reference
  21357. * @param doNotAdd specifies if the material should be added to the scene
  21358. */
  21359. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21360. /**
  21361. * Returns a string representation of the current material
  21362. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21363. * @returns a string with material information
  21364. */
  21365. toString(fullDetails?: boolean): string;
  21366. /**
  21367. * Gets the class name of the material
  21368. * @returns a string with the class name of the material
  21369. */
  21370. getClassName(): string;
  21371. /**
  21372. * Specifies if updates for the material been locked
  21373. */
  21374. readonly isFrozen: boolean;
  21375. /**
  21376. * Locks updates for the material
  21377. */
  21378. freeze(): void;
  21379. /**
  21380. * Unlocks updates for the material
  21381. */
  21382. unfreeze(): void;
  21383. /**
  21384. * Specifies if the material is ready to be used
  21385. * @param mesh defines the mesh to check
  21386. * @param useInstances specifies if instances should be used
  21387. * @returns a boolean indicating if the material is ready to be used
  21388. */
  21389. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21390. /**
  21391. * Specifies that the submesh is ready to be used
  21392. * @param mesh defines the mesh to check
  21393. * @param subMesh defines which submesh to check
  21394. * @param useInstances specifies that instances should be used
  21395. * @returns a boolean indicating that the submesh is ready or not
  21396. */
  21397. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21398. /**
  21399. * Returns the material effect
  21400. * @returns the effect associated with the material
  21401. */
  21402. getEffect(): Nullable<Effect>;
  21403. /**
  21404. * Returns the current scene
  21405. * @returns a Scene
  21406. */
  21407. getScene(): Scene;
  21408. /**
  21409. * Specifies if the material will require alpha blending
  21410. * @returns a boolean specifying if alpha blending is needed
  21411. */
  21412. needAlphaBlending(): boolean;
  21413. /**
  21414. * Specifies if the mesh will require alpha blending
  21415. * @param mesh defines the mesh to check
  21416. * @returns a boolean specifying if alpha blending is needed for the mesh
  21417. */
  21418. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21419. /**
  21420. * Specifies if this material should be rendered in alpha test mode
  21421. * @returns a boolean specifying if an alpha test is needed.
  21422. */
  21423. needAlphaTesting(): boolean;
  21424. /**
  21425. * Gets the texture used for the alpha test
  21426. * @returns the texture to use for alpha testing
  21427. */
  21428. getAlphaTestTexture(): Nullable<BaseTexture>;
  21429. /**
  21430. * Marks the material to indicate that it needs to be re-calculated
  21431. */
  21432. markDirty(): void;
  21433. /** @hidden */
  21434. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21435. /**
  21436. * Binds the material to the mesh
  21437. * @param world defines the world transformation matrix
  21438. * @param mesh defines the mesh to bind the material to
  21439. */
  21440. bind(world: Matrix, mesh?: Mesh): void;
  21441. /**
  21442. * Binds the submesh to the material
  21443. * @param world defines the world transformation matrix
  21444. * @param mesh defines the mesh containing the submesh
  21445. * @param subMesh defines the submesh to bind the material to
  21446. */
  21447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21448. /**
  21449. * Binds the world matrix to the material
  21450. * @param world defines the world transformation matrix
  21451. */
  21452. bindOnlyWorldMatrix(world: Matrix): void;
  21453. /**
  21454. * Binds the scene's uniform buffer to the effect.
  21455. * @param effect defines the effect to bind to the scene uniform buffer
  21456. * @param sceneUbo defines the uniform buffer storing scene data
  21457. */
  21458. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21459. /**
  21460. * Binds the view matrix to the effect
  21461. * @param effect defines the effect to bind the view matrix to
  21462. */
  21463. bindView(effect: Effect): void;
  21464. /**
  21465. * Binds the view projection matrix to the effect
  21466. * @param effect defines the effect to bind the view projection matrix to
  21467. */
  21468. bindViewProjection(effect: Effect): void;
  21469. /**
  21470. * Specifies if material alpha testing should be turned on for the mesh
  21471. * @param mesh defines the mesh to check
  21472. */
  21473. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21474. /**
  21475. * Processes to execute after binding the material to a mesh
  21476. * @param mesh defines the rendered mesh
  21477. */
  21478. protected _afterBind(mesh?: Mesh): void;
  21479. /**
  21480. * Unbinds the material from the mesh
  21481. */
  21482. unbind(): void;
  21483. /**
  21484. * Gets the active textures from the material
  21485. * @returns an array of textures
  21486. */
  21487. getActiveTextures(): BaseTexture[];
  21488. /**
  21489. * Specifies if the material uses a texture
  21490. * @param texture defines the texture to check against the material
  21491. * @returns a boolean specifying if the material uses the texture
  21492. */
  21493. hasTexture(texture: BaseTexture): boolean;
  21494. /**
  21495. * Makes a duplicate of the material, and gives it a new name
  21496. * @param name defines the new name for the duplicated material
  21497. * @returns the cloned material
  21498. */
  21499. clone(name: string): Nullable<Material>;
  21500. /**
  21501. * Gets the meshes bound to the material
  21502. * @returns an array of meshes bound to the material
  21503. */
  21504. getBindedMeshes(): AbstractMesh[];
  21505. /**
  21506. * Force shader compilation
  21507. * @param mesh defines the mesh associated with this material
  21508. * @param onCompiled defines a function to execute once the material is compiled
  21509. * @param options defines the options to configure the compilation
  21510. * @param onError defines a function to execute if the material fails compiling
  21511. */
  21512. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21513. /**
  21514. * Force shader compilation
  21515. * @param mesh defines the mesh that will use this material
  21516. * @param options defines additional options for compiling the shaders
  21517. * @returns a promise that resolves when the compilation completes
  21518. */
  21519. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21520. private static readonly _AllDirtyCallBack;
  21521. private static readonly _ImageProcessingDirtyCallBack;
  21522. private static readonly _TextureDirtyCallBack;
  21523. private static readonly _FresnelDirtyCallBack;
  21524. private static readonly _MiscDirtyCallBack;
  21525. private static readonly _LightsDirtyCallBack;
  21526. private static readonly _AttributeDirtyCallBack;
  21527. private static _FresnelAndMiscDirtyCallBack;
  21528. private static _TextureAndMiscDirtyCallBack;
  21529. private static readonly _DirtyCallbackArray;
  21530. private static readonly _RunDirtyCallBacks;
  21531. /**
  21532. * Marks a define in the material to indicate that it needs to be re-computed
  21533. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21534. */
  21535. markAsDirty(flag: number): void;
  21536. /**
  21537. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21538. * @param func defines a function which checks material defines against the submeshes
  21539. */
  21540. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21541. /**
  21542. * Indicates that we need to re-calculated for all submeshes
  21543. */
  21544. protected _markAllSubMeshesAsAllDirty(): void;
  21545. /**
  21546. * Indicates that image processing needs to be re-calculated for all submeshes
  21547. */
  21548. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21549. /**
  21550. * Indicates that textures need to be re-calculated for all submeshes
  21551. */
  21552. protected _markAllSubMeshesAsTexturesDirty(): void;
  21553. /**
  21554. * Indicates that fresnel needs to be re-calculated for all submeshes
  21555. */
  21556. protected _markAllSubMeshesAsFresnelDirty(): void;
  21557. /**
  21558. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21559. */
  21560. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21561. /**
  21562. * Indicates that lights need to be re-calculated for all submeshes
  21563. */
  21564. protected _markAllSubMeshesAsLightsDirty(): void;
  21565. /**
  21566. * Indicates that attributes need to be re-calculated for all submeshes
  21567. */
  21568. protected _markAllSubMeshesAsAttributesDirty(): void;
  21569. /**
  21570. * Indicates that misc needs to be re-calculated for all submeshes
  21571. */
  21572. protected _markAllSubMeshesAsMiscDirty(): void;
  21573. /**
  21574. * Indicates that textures and misc need to be re-calculated for all submeshes
  21575. */
  21576. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21577. /**
  21578. * Disposes the material
  21579. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21580. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21581. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21582. */
  21583. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21584. /** @hidden */
  21585. private releaseVertexArrayObject;
  21586. /**
  21587. * Serializes this material
  21588. * @returns the serialized material object
  21589. */
  21590. serialize(): any;
  21591. /**
  21592. * Creates a material from parsed material data
  21593. * @param parsedMaterial defines parsed material data
  21594. * @param scene defines the hosting scene
  21595. * @param rootUrl defines the root URL to use to load textures
  21596. * @returns a new material
  21597. */
  21598. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21599. }
  21600. }
  21601. declare module "babylonjs/Materials/multiMaterial" {
  21602. import { Nullable } from "babylonjs/types";
  21603. import { Scene } from "babylonjs/scene";
  21604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21605. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21607. import { Material } from "babylonjs/Materials/material";
  21608. /**
  21609. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21610. * separate meshes. This can be use to improve performances.
  21611. * @see http://doc.babylonjs.com/how_to/multi_materials
  21612. */
  21613. export class MultiMaterial extends Material {
  21614. private _subMaterials;
  21615. /**
  21616. * Gets or Sets the list of Materials used within the multi material.
  21617. * They need to be ordered according to the submeshes order in the associated mesh
  21618. */
  21619. subMaterials: Nullable<Material>[];
  21620. /**
  21621. * Function used to align with Node.getChildren()
  21622. * @returns the list of Materials used within the multi material
  21623. */
  21624. getChildren(): Nullable<Material>[];
  21625. /**
  21626. * Instantiates a new Multi Material
  21627. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21628. * separate meshes. This can be use to improve performances.
  21629. * @see http://doc.babylonjs.com/how_to/multi_materials
  21630. * @param name Define the name in the scene
  21631. * @param scene Define the scene the material belongs to
  21632. */
  21633. constructor(name: string, scene: Scene);
  21634. private _hookArray;
  21635. /**
  21636. * Get one of the submaterial by its index in the submaterials array
  21637. * @param index The index to look the sub material at
  21638. * @returns The Material if the index has been defined
  21639. */
  21640. getSubMaterial(index: number): Nullable<Material>;
  21641. /**
  21642. * Get the list of active textures for the whole sub materials list.
  21643. * @returns All the textures that will be used during the rendering
  21644. */
  21645. getActiveTextures(): BaseTexture[];
  21646. /**
  21647. * Gets the current class name of the material e.g. "MultiMaterial"
  21648. * Mainly use in serialization.
  21649. * @returns the class name
  21650. */
  21651. getClassName(): string;
  21652. /**
  21653. * Checks if the material is ready to render the requested sub mesh
  21654. * @param mesh Define the mesh the submesh belongs to
  21655. * @param subMesh Define the sub mesh to look readyness for
  21656. * @param useInstances Define whether or not the material is used with instances
  21657. * @returns true if ready, otherwise false
  21658. */
  21659. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21660. /**
  21661. * Clones the current material and its related sub materials
  21662. * @param name Define the name of the newly cloned material
  21663. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21664. * @returns the cloned material
  21665. */
  21666. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21667. /**
  21668. * Serializes the materials into a JSON representation.
  21669. * @returns the JSON representation
  21670. */
  21671. serialize(): any;
  21672. /**
  21673. * Dispose the material and release its associated resources
  21674. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21675. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21676. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21677. */
  21678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21679. /**
  21680. * Creates a MultiMaterial from parsed MultiMaterial data.
  21681. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21682. * @param scene defines the hosting scene
  21683. * @returns a new MultiMaterial
  21684. */
  21685. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21686. }
  21687. }
  21688. declare module "babylonjs/Meshes/subMesh" {
  21689. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21690. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21691. import { Engine } from "babylonjs/Engines/engine";
  21692. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21693. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21694. import { Effect } from "babylonjs/Materials/effect";
  21695. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21696. import { Plane } from "babylonjs/Maths/math.plane";
  21697. import { Collider } from "babylonjs/Collisions/collider";
  21698. import { Material } from "babylonjs/Materials/material";
  21699. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21701. import { Mesh } from "babylonjs/Meshes/mesh";
  21702. import { Ray } from "babylonjs/Culling/ray";
  21703. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21704. /**
  21705. * Base class for submeshes
  21706. */
  21707. export class BaseSubMesh {
  21708. /** @hidden */
  21709. _materialDefines: Nullable<MaterialDefines>;
  21710. /** @hidden */
  21711. _materialEffect: Nullable<Effect>;
  21712. /**
  21713. * Gets material defines used by the effect associated to the sub mesh
  21714. */
  21715. /**
  21716. * Sets material defines used by the effect associated to the sub mesh
  21717. */
  21718. materialDefines: Nullable<MaterialDefines>;
  21719. /**
  21720. * Gets associated effect
  21721. */
  21722. readonly effect: Nullable<Effect>;
  21723. /**
  21724. * Sets associated effect (effect used to render this submesh)
  21725. * @param effect defines the effect to associate with
  21726. * @param defines defines the set of defines used to compile this effect
  21727. */
  21728. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21729. }
  21730. /**
  21731. * Defines a subdivision inside a mesh
  21732. */
  21733. export class SubMesh extends BaseSubMesh implements ICullable {
  21734. /** the material index to use */
  21735. materialIndex: number;
  21736. /** vertex index start */
  21737. verticesStart: number;
  21738. /** vertices count */
  21739. verticesCount: number;
  21740. /** index start */
  21741. indexStart: number;
  21742. /** indices count */
  21743. indexCount: number;
  21744. /** @hidden */
  21745. _linesIndexCount: number;
  21746. private _mesh;
  21747. private _renderingMesh;
  21748. private _boundingInfo;
  21749. private _linesIndexBuffer;
  21750. /** @hidden */
  21751. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21752. /** @hidden */
  21753. _trianglePlanes: Plane[];
  21754. /** @hidden */
  21755. _lastColliderTransformMatrix: Nullable<Matrix>;
  21756. /** @hidden */
  21757. _renderId: number;
  21758. /** @hidden */
  21759. _alphaIndex: number;
  21760. /** @hidden */
  21761. _distanceToCamera: number;
  21762. /** @hidden */
  21763. _id: number;
  21764. private _currentMaterial;
  21765. /**
  21766. * Add a new submesh to a mesh
  21767. * @param materialIndex defines the material index to use
  21768. * @param verticesStart defines vertex index start
  21769. * @param verticesCount defines vertices count
  21770. * @param indexStart defines index start
  21771. * @param indexCount defines indices count
  21772. * @param mesh defines the parent mesh
  21773. * @param renderingMesh defines an optional rendering mesh
  21774. * @param createBoundingBox defines if bounding box should be created for this submesh
  21775. * @returns the new submesh
  21776. */
  21777. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21778. /**
  21779. * Creates a new submesh
  21780. * @param materialIndex defines the material index to use
  21781. * @param verticesStart defines vertex index start
  21782. * @param verticesCount defines vertices count
  21783. * @param indexStart defines index start
  21784. * @param indexCount defines indices count
  21785. * @param mesh defines the parent mesh
  21786. * @param renderingMesh defines an optional rendering mesh
  21787. * @param createBoundingBox defines if bounding box should be created for this submesh
  21788. */
  21789. constructor(
  21790. /** the material index to use */
  21791. materialIndex: number,
  21792. /** vertex index start */
  21793. verticesStart: number,
  21794. /** vertices count */
  21795. verticesCount: number,
  21796. /** index start */
  21797. indexStart: number,
  21798. /** indices count */
  21799. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21800. /**
  21801. * Returns true if this submesh covers the entire parent mesh
  21802. * @ignorenaming
  21803. */
  21804. readonly IsGlobal: boolean;
  21805. /**
  21806. * Returns the submesh BoudingInfo object
  21807. * @returns current bounding info (or mesh's one if the submesh is global)
  21808. */
  21809. getBoundingInfo(): BoundingInfo;
  21810. /**
  21811. * Sets the submesh BoundingInfo
  21812. * @param boundingInfo defines the new bounding info to use
  21813. * @returns the SubMesh
  21814. */
  21815. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21816. /**
  21817. * Returns the mesh of the current submesh
  21818. * @return the parent mesh
  21819. */
  21820. getMesh(): AbstractMesh;
  21821. /**
  21822. * Returns the rendering mesh of the submesh
  21823. * @returns the rendering mesh (could be different from parent mesh)
  21824. */
  21825. getRenderingMesh(): Mesh;
  21826. /**
  21827. * Returns the submesh material
  21828. * @returns null or the current material
  21829. */
  21830. getMaterial(): Nullable<Material>;
  21831. /**
  21832. * Sets a new updated BoundingInfo object to the submesh
  21833. * @param data defines an optional position array to use to determine the bounding info
  21834. * @returns the SubMesh
  21835. */
  21836. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21837. /** @hidden */
  21838. _checkCollision(collider: Collider): boolean;
  21839. /**
  21840. * Updates the submesh BoundingInfo
  21841. * @param world defines the world matrix to use to update the bounding info
  21842. * @returns the submesh
  21843. */
  21844. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21845. /**
  21846. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21847. * @param frustumPlanes defines the frustum planes
  21848. * @returns true if the submesh is intersecting with the frustum
  21849. */
  21850. isInFrustum(frustumPlanes: Plane[]): boolean;
  21851. /**
  21852. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21853. * @param frustumPlanes defines the frustum planes
  21854. * @returns true if the submesh is inside the frustum
  21855. */
  21856. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21857. /**
  21858. * Renders the submesh
  21859. * @param enableAlphaMode defines if alpha needs to be used
  21860. * @returns the submesh
  21861. */
  21862. render(enableAlphaMode: boolean): SubMesh;
  21863. /**
  21864. * @hidden
  21865. */
  21866. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21867. /**
  21868. * Checks if the submesh intersects with a ray
  21869. * @param ray defines the ray to test
  21870. * @returns true is the passed ray intersects the submesh bounding box
  21871. */
  21872. canIntersects(ray: Ray): boolean;
  21873. /**
  21874. * Intersects current submesh with a ray
  21875. * @param ray defines the ray to test
  21876. * @param positions defines mesh's positions array
  21877. * @param indices defines mesh's indices array
  21878. * @param fastCheck defines if only bounding info should be used
  21879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21880. * @returns intersection info or null if no intersection
  21881. */
  21882. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21883. /** @hidden */
  21884. private _intersectLines;
  21885. /** @hidden */
  21886. private _intersectUnIndexedLines;
  21887. /** @hidden */
  21888. private _intersectTriangles;
  21889. /** @hidden */
  21890. private _intersectUnIndexedTriangles;
  21891. /** @hidden */
  21892. _rebuild(): void;
  21893. /**
  21894. * Creates a new submesh from the passed mesh
  21895. * @param newMesh defines the new hosting mesh
  21896. * @param newRenderingMesh defines an optional rendering mesh
  21897. * @returns the new submesh
  21898. */
  21899. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21900. /**
  21901. * Release associated resources
  21902. */
  21903. dispose(): void;
  21904. /**
  21905. * Gets the class name
  21906. * @returns the string "SubMesh".
  21907. */
  21908. getClassName(): string;
  21909. /**
  21910. * Creates a new submesh from indices data
  21911. * @param materialIndex the index of the main mesh material
  21912. * @param startIndex the index where to start the copy in the mesh indices array
  21913. * @param indexCount the number of indices to copy then from the startIndex
  21914. * @param mesh the main mesh to create the submesh from
  21915. * @param renderingMesh the optional rendering mesh
  21916. * @returns a new submesh
  21917. */
  21918. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21919. }
  21920. }
  21921. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21922. /**
  21923. * Class used to represent data loading progression
  21924. */
  21925. export class SceneLoaderFlags {
  21926. private static _ForceFullSceneLoadingForIncremental;
  21927. private static _ShowLoadingScreen;
  21928. private static _CleanBoneMatrixWeights;
  21929. private static _loggingLevel;
  21930. /**
  21931. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21932. */
  21933. static ForceFullSceneLoadingForIncremental: boolean;
  21934. /**
  21935. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21936. */
  21937. static ShowLoadingScreen: boolean;
  21938. /**
  21939. * Defines the current logging level (while loading the scene)
  21940. * @ignorenaming
  21941. */
  21942. static loggingLevel: number;
  21943. /**
  21944. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21945. */
  21946. static CleanBoneMatrixWeights: boolean;
  21947. }
  21948. }
  21949. declare module "babylonjs/Meshes/geometry" {
  21950. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21951. import { Scene } from "babylonjs/scene";
  21952. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21953. import { Engine } from "babylonjs/Engines/engine";
  21954. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21955. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21956. import { Effect } from "babylonjs/Materials/effect";
  21957. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21958. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21959. import { Mesh } from "babylonjs/Meshes/mesh";
  21960. /**
  21961. * Class used to store geometry data (vertex buffers + index buffer)
  21962. */
  21963. export class Geometry implements IGetSetVerticesData {
  21964. /**
  21965. * Gets or sets the ID of the geometry
  21966. */
  21967. id: string;
  21968. /**
  21969. * Gets or sets the unique ID of the geometry
  21970. */
  21971. uniqueId: number;
  21972. /**
  21973. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21974. */
  21975. delayLoadState: number;
  21976. /**
  21977. * Gets the file containing the data to load when running in delay load state
  21978. */
  21979. delayLoadingFile: Nullable<string>;
  21980. /**
  21981. * Callback called when the geometry is updated
  21982. */
  21983. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21984. private _scene;
  21985. private _engine;
  21986. private _meshes;
  21987. private _totalVertices;
  21988. /** @hidden */
  21989. _indices: IndicesArray;
  21990. /** @hidden */
  21991. _vertexBuffers: {
  21992. [key: string]: VertexBuffer;
  21993. };
  21994. private _isDisposed;
  21995. private _extend;
  21996. private _boundingBias;
  21997. /** @hidden */
  21998. _delayInfo: Array<string>;
  21999. private _indexBuffer;
  22000. private _indexBufferIsUpdatable;
  22001. /** @hidden */
  22002. _boundingInfo: Nullable<BoundingInfo>;
  22003. /** @hidden */
  22004. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22005. /** @hidden */
  22006. _softwareSkinningFrameId: number;
  22007. private _vertexArrayObjects;
  22008. private _updatable;
  22009. /** @hidden */
  22010. _positions: Nullable<Vector3[]>;
  22011. /**
  22012. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  22013. */
  22014. /**
  22015. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  22016. */
  22017. boundingBias: Vector2;
  22018. /**
  22019. * Static function used to attach a new empty geometry to a mesh
  22020. * @param mesh defines the mesh to attach the geometry to
  22021. * @returns the new Geometry
  22022. */
  22023. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22024. /**
  22025. * Creates a new geometry
  22026. * @param id defines the unique ID
  22027. * @param scene defines the hosting scene
  22028. * @param vertexData defines the VertexData used to get geometry data
  22029. * @param updatable defines if geometry must be updatable (false by default)
  22030. * @param mesh defines the mesh that will be associated with the geometry
  22031. */
  22032. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22033. /**
  22034. * Gets the current extend of the geometry
  22035. */
  22036. readonly extend: {
  22037. minimum: Vector3;
  22038. maximum: Vector3;
  22039. };
  22040. /**
  22041. * Gets the hosting scene
  22042. * @returns the hosting Scene
  22043. */
  22044. getScene(): Scene;
  22045. /**
  22046. * Gets the hosting engine
  22047. * @returns the hosting Engine
  22048. */
  22049. getEngine(): Engine;
  22050. /**
  22051. * Defines if the geometry is ready to use
  22052. * @returns true if the geometry is ready to be used
  22053. */
  22054. isReady(): boolean;
  22055. /**
  22056. * Gets a value indicating that the geometry should not be serialized
  22057. */
  22058. readonly doNotSerialize: boolean;
  22059. /** @hidden */
  22060. _rebuild(): void;
  22061. /**
  22062. * Affects all geometry data in one call
  22063. * @param vertexData defines the geometry data
  22064. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22065. */
  22066. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22067. /**
  22068. * Set specific vertex data
  22069. * @param kind defines the data kind (Position, normal, etc...)
  22070. * @param data defines the vertex data to use
  22071. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22072. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22073. */
  22074. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22075. /**
  22076. * Removes a specific vertex data
  22077. * @param kind defines the data kind (Position, normal, etc...)
  22078. */
  22079. removeVerticesData(kind: string): void;
  22080. /**
  22081. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22082. * @param buffer defines the vertex buffer to use
  22083. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22084. */
  22085. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22086. /**
  22087. * Update a specific vertex buffer
  22088. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22089. * It will do nothing if the buffer is not updatable
  22090. * @param kind defines the data kind (Position, normal, etc...)
  22091. * @param data defines the data to use
  22092. * @param offset defines the offset in the target buffer where to store the data
  22093. * @param useBytes set to true if the offset is in bytes
  22094. */
  22095. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22096. /**
  22097. * Update a specific vertex buffer
  22098. * This function will create a new buffer if the current one is not updatable
  22099. * @param kind defines the data kind (Position, normal, etc...)
  22100. * @param data defines the data to use
  22101. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22102. */
  22103. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22104. private _updateBoundingInfo;
  22105. /** @hidden */
  22106. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22107. /**
  22108. * Gets total number of vertices
  22109. * @returns the total number of vertices
  22110. */
  22111. getTotalVertices(): number;
  22112. /**
  22113. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22114. * @param kind defines the data kind (Position, normal, etc...)
  22115. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22117. * @returns a float array containing vertex data
  22118. */
  22119. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22120. /**
  22121. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22122. * @param kind defines the data kind (Position, normal, etc...)
  22123. * @returns true if the vertex buffer with the specified kind is updatable
  22124. */
  22125. isVertexBufferUpdatable(kind: string): boolean;
  22126. /**
  22127. * Gets a specific vertex buffer
  22128. * @param kind defines the data kind (Position, normal, etc...)
  22129. * @returns a VertexBuffer
  22130. */
  22131. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22132. /**
  22133. * Returns all vertex buffers
  22134. * @return an object holding all vertex buffers indexed by kind
  22135. */
  22136. getVertexBuffers(): Nullable<{
  22137. [key: string]: VertexBuffer;
  22138. }>;
  22139. /**
  22140. * Gets a boolean indicating if specific vertex buffer is present
  22141. * @param kind defines the data kind (Position, normal, etc...)
  22142. * @returns true if data is present
  22143. */
  22144. isVerticesDataPresent(kind: string): boolean;
  22145. /**
  22146. * Gets a list of all attached data kinds (Position, normal, etc...)
  22147. * @returns a list of string containing all kinds
  22148. */
  22149. getVerticesDataKinds(): string[];
  22150. /**
  22151. * Update index buffer
  22152. * @param indices defines the indices to store in the index buffer
  22153. * @param offset defines the offset in the target buffer where to store the data
  22154. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22155. */
  22156. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22157. /**
  22158. * Creates a new index buffer
  22159. * @param indices defines the indices to store in the index buffer
  22160. * @param totalVertices defines the total number of vertices (could be null)
  22161. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22162. */
  22163. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22164. /**
  22165. * Return the total number of indices
  22166. * @returns the total number of indices
  22167. */
  22168. getTotalIndices(): number;
  22169. /**
  22170. * Gets the index buffer array
  22171. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22172. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22173. * @returns the index buffer array
  22174. */
  22175. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22176. /**
  22177. * Gets the index buffer
  22178. * @return the index buffer
  22179. */
  22180. getIndexBuffer(): Nullable<DataBuffer>;
  22181. /** @hidden */
  22182. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22183. /**
  22184. * Release the associated resources for a specific mesh
  22185. * @param mesh defines the source mesh
  22186. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22187. */
  22188. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22189. /**
  22190. * Apply current geometry to a given mesh
  22191. * @param mesh defines the mesh to apply geometry to
  22192. */
  22193. applyToMesh(mesh: Mesh): void;
  22194. private _updateExtend;
  22195. private _applyToMesh;
  22196. private notifyUpdate;
  22197. /**
  22198. * Load the geometry if it was flagged as delay loaded
  22199. * @param scene defines the hosting scene
  22200. * @param onLoaded defines a callback called when the geometry is loaded
  22201. */
  22202. load(scene: Scene, onLoaded?: () => void): void;
  22203. private _queueLoad;
  22204. /**
  22205. * Invert the geometry to move from a right handed system to a left handed one.
  22206. */
  22207. toLeftHanded(): void;
  22208. /** @hidden */
  22209. _resetPointsArrayCache(): void;
  22210. /** @hidden */
  22211. _generatePointsArray(): boolean;
  22212. /**
  22213. * Gets a value indicating if the geometry is disposed
  22214. * @returns true if the geometry was disposed
  22215. */
  22216. isDisposed(): boolean;
  22217. private _disposeVertexArrayObjects;
  22218. /**
  22219. * Free all associated resources
  22220. */
  22221. dispose(): void;
  22222. /**
  22223. * Clone the current geometry into a new geometry
  22224. * @param id defines the unique ID of the new geometry
  22225. * @returns a new geometry object
  22226. */
  22227. copy(id: string): Geometry;
  22228. /**
  22229. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22230. * @return a JSON representation of the current geometry data (without the vertices data)
  22231. */
  22232. serialize(): any;
  22233. private toNumberArray;
  22234. /**
  22235. * Serialize all vertices data into a JSON oject
  22236. * @returns a JSON representation of the current geometry data
  22237. */
  22238. serializeVerticeData(): any;
  22239. /**
  22240. * Extracts a clone of a mesh geometry
  22241. * @param mesh defines the source mesh
  22242. * @param id defines the unique ID of the new geometry object
  22243. * @returns the new geometry object
  22244. */
  22245. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22246. /**
  22247. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22248. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22249. * Be aware Math.random() could cause collisions, but:
  22250. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  22251. * @returns a string containing a new GUID
  22252. */
  22253. static RandomId(): string;
  22254. /** @hidden */
  22255. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22256. private static _CleanMatricesWeights;
  22257. /**
  22258. * Create a new geometry from persisted data (Using .babylon file format)
  22259. * @param parsedVertexData defines the persisted data
  22260. * @param scene defines the hosting scene
  22261. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22262. * @returns the new geometry object
  22263. */
  22264. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22265. }
  22266. }
  22267. declare module "babylonjs/Meshes/mesh.vertexData" {
  22268. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22269. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22270. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22271. import { Geometry } from "babylonjs/Meshes/geometry";
  22272. import { Mesh } from "babylonjs/Meshes/mesh";
  22273. /**
  22274. * Define an interface for all classes that will get and set the data on vertices
  22275. */
  22276. export interface IGetSetVerticesData {
  22277. /**
  22278. * Gets a boolean indicating if specific vertex data is present
  22279. * @param kind defines the vertex data kind to use
  22280. * @returns true is data kind is present
  22281. */
  22282. isVerticesDataPresent(kind: string): boolean;
  22283. /**
  22284. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22285. * @param kind defines the data kind (Position, normal, etc...)
  22286. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22287. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22288. * @returns a float array containing vertex data
  22289. */
  22290. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22291. /**
  22292. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22293. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  22294. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22295. * @returns the indices array or an empty array if the mesh has no geometry
  22296. */
  22297. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22298. /**
  22299. * Set specific vertex data
  22300. * @param kind defines the data kind (Position, normal, etc...)
  22301. * @param data defines the vertex data to use
  22302. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22303. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22304. */
  22305. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22306. /**
  22307. * Update a specific associated vertex buffer
  22308. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22309. * - VertexBuffer.PositionKind
  22310. * - VertexBuffer.UVKind
  22311. * - VertexBuffer.UV2Kind
  22312. * - VertexBuffer.UV3Kind
  22313. * - VertexBuffer.UV4Kind
  22314. * - VertexBuffer.UV5Kind
  22315. * - VertexBuffer.UV6Kind
  22316. * - VertexBuffer.ColorKind
  22317. * - VertexBuffer.MatricesIndicesKind
  22318. * - VertexBuffer.MatricesIndicesExtraKind
  22319. * - VertexBuffer.MatricesWeightsKind
  22320. * - VertexBuffer.MatricesWeightsExtraKind
  22321. * @param data defines the data source
  22322. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22323. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  22324. */
  22325. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22326. /**
  22327. * Creates a new index buffer
  22328. * @param indices defines the indices to store in the index buffer
  22329. * @param totalVertices defines the total number of vertices (could be null)
  22330. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22331. */
  22332. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22333. }
  22334. /**
  22335. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22336. */
  22337. export class VertexData {
  22338. /**
  22339. * Mesh side orientation : usually the external or front surface
  22340. */
  22341. static readonly FRONTSIDE: number;
  22342. /**
  22343. * Mesh side orientation : usually the internal or back surface
  22344. */
  22345. static readonly BACKSIDE: number;
  22346. /**
  22347. * Mesh side orientation : both internal and external or front and back surfaces
  22348. */
  22349. static readonly DOUBLESIDE: number;
  22350. /**
  22351. * Mesh side orientation : by default, `FRONTSIDE`
  22352. */
  22353. static readonly DEFAULTSIDE: number;
  22354. /**
  22355. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22356. */
  22357. positions: Nullable<FloatArray>;
  22358. /**
  22359. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22360. */
  22361. normals: Nullable<FloatArray>;
  22362. /**
  22363. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22364. */
  22365. tangents: Nullable<FloatArray>;
  22366. /**
  22367. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22368. */
  22369. uvs: Nullable<FloatArray>;
  22370. /**
  22371. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22372. */
  22373. uvs2: Nullable<FloatArray>;
  22374. /**
  22375. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22376. */
  22377. uvs3: Nullable<FloatArray>;
  22378. /**
  22379. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22380. */
  22381. uvs4: Nullable<FloatArray>;
  22382. /**
  22383. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22384. */
  22385. uvs5: Nullable<FloatArray>;
  22386. /**
  22387. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22388. */
  22389. uvs6: Nullable<FloatArray>;
  22390. /**
  22391. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22392. */
  22393. colors: Nullable<FloatArray>;
  22394. /**
  22395. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  22396. */
  22397. matricesIndices: Nullable<FloatArray>;
  22398. /**
  22399. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22400. */
  22401. matricesWeights: Nullable<FloatArray>;
  22402. /**
  22403. * An array extending the number of possible indices
  22404. */
  22405. matricesIndicesExtra: Nullable<FloatArray>;
  22406. /**
  22407. * An array extending the number of possible weights when the number of indices is extended
  22408. */
  22409. matricesWeightsExtra: Nullable<FloatArray>;
  22410. /**
  22411. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22412. */
  22413. indices: Nullable<IndicesArray>;
  22414. /**
  22415. * Uses the passed data array to set the set the values for the specified kind of data
  22416. * @param data a linear array of floating numbers
  22417. * @param kind the type of data that is being set, eg positions, colors etc
  22418. */
  22419. set(data: FloatArray, kind: string): void;
  22420. /**
  22421. * Associates the vertexData to the passed Mesh.
  22422. * Sets it as updatable or not (default `false`)
  22423. * @param mesh the mesh the vertexData is applied to
  22424. * @param updatable when used and having the value true allows new data to update the vertexData
  22425. * @returns the VertexData
  22426. */
  22427. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22428. /**
  22429. * Associates the vertexData to the passed Geometry.
  22430. * Sets it as updatable or not (default `false`)
  22431. * @param geometry the geometry the vertexData is applied to
  22432. * @param updatable when used and having the value true allows new data to update the vertexData
  22433. * @returns VertexData
  22434. */
  22435. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22436. /**
  22437. * Updates the associated mesh
  22438. * @param mesh the mesh to be updated
  22439. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22440. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22441. * @returns VertexData
  22442. */
  22443. updateMesh(mesh: Mesh): VertexData;
  22444. /**
  22445. * Updates the associated geometry
  22446. * @param geometry the geometry to be updated
  22447. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22448. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22449. * @returns VertexData.
  22450. */
  22451. updateGeometry(geometry: Geometry): VertexData;
  22452. private _applyTo;
  22453. private _update;
  22454. /**
  22455. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22456. * @param matrix the transforming matrix
  22457. * @returns the VertexData
  22458. */
  22459. transform(matrix: Matrix): VertexData;
  22460. /**
  22461. * Merges the passed VertexData into the current one
  22462. * @param other the VertexData to be merged into the current one
  22463. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22464. * @returns the modified VertexData
  22465. */
  22466. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22467. private _mergeElement;
  22468. private _validate;
  22469. /**
  22470. * Serializes the VertexData
  22471. * @returns a serialized object
  22472. */
  22473. serialize(): any;
  22474. /**
  22475. * Extracts the vertexData from a mesh
  22476. * @param mesh the mesh from which to extract the VertexData
  22477. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22478. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22479. * @returns the object VertexData associated to the passed mesh
  22480. */
  22481. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22482. /**
  22483. * Extracts the vertexData from the geometry
  22484. * @param geometry the geometry from which to extract the VertexData
  22485. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22486. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22487. * @returns the object VertexData associated to the passed mesh
  22488. */
  22489. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22490. private static _ExtractFrom;
  22491. /**
  22492. * Creates the VertexData for a Ribbon
  22493. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22494. * * pathArray array of paths, each of which an array of successive Vector3
  22495. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22496. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22497. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  22498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22499. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22500. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22501. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22502. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22503. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22504. * @returns the VertexData of the ribbon
  22505. */
  22506. static CreateRibbon(options: {
  22507. pathArray: Vector3[][];
  22508. closeArray?: boolean;
  22509. closePath?: boolean;
  22510. offset?: number;
  22511. sideOrientation?: number;
  22512. frontUVs?: Vector4;
  22513. backUVs?: Vector4;
  22514. invertUV?: boolean;
  22515. uvs?: Vector2[];
  22516. colors?: Color4[];
  22517. }): VertexData;
  22518. /**
  22519. * Creates the VertexData for a box
  22520. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22521. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22522. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22523. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22524. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22525. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22526. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22528. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22529. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22530. * @returns the VertexData of the box
  22531. */
  22532. static CreateBox(options: {
  22533. size?: number;
  22534. width?: number;
  22535. height?: number;
  22536. depth?: number;
  22537. faceUV?: Vector4[];
  22538. faceColors?: Color4[];
  22539. sideOrientation?: number;
  22540. frontUVs?: Vector4;
  22541. backUVs?: Vector4;
  22542. }): VertexData;
  22543. /**
  22544. * Creates the VertexData for a tiled box
  22545. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22546. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22547. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22548. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22550. * @returns the VertexData of the box
  22551. */
  22552. static CreateTiledBox(options: {
  22553. pattern?: number;
  22554. width?: number;
  22555. height?: number;
  22556. depth?: number;
  22557. tileSize?: number;
  22558. tileWidth?: number;
  22559. tileHeight?: number;
  22560. alignHorizontal?: number;
  22561. alignVertical?: number;
  22562. faceUV?: Vector4[];
  22563. faceColors?: Color4[];
  22564. sideOrientation?: number;
  22565. }): VertexData;
  22566. /**
  22567. * Creates the VertexData for a tiled plane
  22568. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22569. * * pattern a limited pattern arrangement depending on the number
  22570. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22571. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22572. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22574. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22575. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22576. * @returns the VertexData of the tiled plane
  22577. */
  22578. static CreateTiledPlane(options: {
  22579. pattern?: number;
  22580. tileSize?: number;
  22581. tileWidth?: number;
  22582. tileHeight?: number;
  22583. size?: number;
  22584. width?: number;
  22585. height?: number;
  22586. alignHorizontal?: number;
  22587. alignVertical?: number;
  22588. sideOrientation?: number;
  22589. frontUVs?: Vector4;
  22590. backUVs?: Vector4;
  22591. }): VertexData;
  22592. /**
  22593. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22594. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22595. * * segments sets the number of horizontal strips optional, default 32
  22596. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22597. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22598. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22599. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22600. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  22601. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22603. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22604. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22605. * @returns the VertexData of the ellipsoid
  22606. */
  22607. static CreateSphere(options: {
  22608. segments?: number;
  22609. diameter?: number;
  22610. diameterX?: number;
  22611. diameterY?: number;
  22612. diameterZ?: number;
  22613. arc?: number;
  22614. slice?: number;
  22615. sideOrientation?: number;
  22616. frontUVs?: Vector4;
  22617. backUVs?: Vector4;
  22618. }): VertexData;
  22619. /**
  22620. * Creates the VertexData for a cylinder, cone or prism
  22621. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22622. * * height sets the height (y direction) of the cylinder, optional, default 2
  22623. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22624. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22625. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22626. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22627. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22628. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  22629. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22630. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22631. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22632. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22634. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22635. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22636. * @returns the VertexData of the cylinder, cone or prism
  22637. */
  22638. static CreateCylinder(options: {
  22639. height?: number;
  22640. diameterTop?: number;
  22641. diameterBottom?: number;
  22642. diameter?: number;
  22643. tessellation?: number;
  22644. subdivisions?: number;
  22645. arc?: number;
  22646. faceColors?: Color4[];
  22647. faceUV?: Vector4[];
  22648. hasRings?: boolean;
  22649. enclose?: boolean;
  22650. sideOrientation?: number;
  22651. frontUVs?: Vector4;
  22652. backUVs?: Vector4;
  22653. }): VertexData;
  22654. /**
  22655. * Creates the VertexData for a torus
  22656. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22657. * * diameter the diameter of the torus, optional default 1
  22658. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22659. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22660. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22661. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22662. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22663. * @returns the VertexData of the torus
  22664. */
  22665. static CreateTorus(options: {
  22666. diameter?: number;
  22667. thickness?: number;
  22668. tessellation?: number;
  22669. sideOrientation?: number;
  22670. frontUVs?: Vector4;
  22671. backUVs?: Vector4;
  22672. }): VertexData;
  22673. /**
  22674. * Creates the VertexData of the LineSystem
  22675. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22676. * - lines an array of lines, each line being an array of successive Vector3
  22677. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22678. * @returns the VertexData of the LineSystem
  22679. */
  22680. static CreateLineSystem(options: {
  22681. lines: Vector3[][];
  22682. colors?: Nullable<Color4[][]>;
  22683. }): VertexData;
  22684. /**
  22685. * Create the VertexData for a DashedLines
  22686. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22687. * - points an array successive Vector3
  22688. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22689. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22690. * - dashNb the intended total number of dashes, optional, default 200
  22691. * @returns the VertexData for the DashedLines
  22692. */
  22693. static CreateDashedLines(options: {
  22694. points: Vector3[];
  22695. dashSize?: number;
  22696. gapSize?: number;
  22697. dashNb?: number;
  22698. }): VertexData;
  22699. /**
  22700. * Creates the VertexData for a Ground
  22701. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22702. * - width the width (x direction) of the ground, optional, default 1
  22703. * - height the height (z direction) of the ground, optional, default 1
  22704. * - subdivisions the number of subdivisions per side, optional, default 1
  22705. * @returns the VertexData of the Ground
  22706. */
  22707. static CreateGround(options: {
  22708. width?: number;
  22709. height?: number;
  22710. subdivisions?: number;
  22711. subdivisionsX?: number;
  22712. subdivisionsY?: number;
  22713. }): VertexData;
  22714. /**
  22715. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22716. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22717. * * xmin the ground minimum X coordinate, optional, default -1
  22718. * * zmin the ground minimum Z coordinate, optional, default -1
  22719. * * xmax the ground maximum X coordinate, optional, default 1
  22720. * * zmax the ground maximum Z coordinate, optional, default 1
  22721. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  22722. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  22723. * @returns the VertexData of the TiledGround
  22724. */
  22725. static CreateTiledGround(options: {
  22726. xmin: number;
  22727. zmin: number;
  22728. xmax: number;
  22729. zmax: number;
  22730. subdivisions?: {
  22731. w: number;
  22732. h: number;
  22733. };
  22734. precision?: {
  22735. w: number;
  22736. h: number;
  22737. };
  22738. }): VertexData;
  22739. /**
  22740. * Creates the VertexData of the Ground designed from a heightmap
  22741. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22742. * * width the width (x direction) of the ground
  22743. * * height the height (z direction) of the ground
  22744. * * subdivisions the number of subdivisions per side
  22745. * * minHeight the minimum altitude on the ground, optional, default 0
  22746. * * maxHeight the maximum altitude on the ground, optional default 1
  22747. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22748. * * buffer the array holding the image color data
  22749. * * bufferWidth the width of image
  22750. * * bufferHeight the height of image
  22751. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22752. * @returns the VertexData of the Ground designed from a heightmap
  22753. */
  22754. static CreateGroundFromHeightMap(options: {
  22755. width: number;
  22756. height: number;
  22757. subdivisions: number;
  22758. minHeight: number;
  22759. maxHeight: number;
  22760. colorFilter: Color3;
  22761. buffer: Uint8Array;
  22762. bufferWidth: number;
  22763. bufferHeight: number;
  22764. alphaFilter: number;
  22765. }): VertexData;
  22766. /**
  22767. * Creates the VertexData for a Plane
  22768. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22769. * * size sets the width and height of the plane to the value of size, optional default 1
  22770. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22771. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22773. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22774. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22775. * @returns the VertexData of the box
  22776. */
  22777. static CreatePlane(options: {
  22778. size?: number;
  22779. width?: number;
  22780. height?: number;
  22781. sideOrientation?: number;
  22782. frontUVs?: Vector4;
  22783. backUVs?: Vector4;
  22784. }): VertexData;
  22785. /**
  22786. * Creates the VertexData of the Disc or regular Polygon
  22787. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22788. * * radius the radius of the disc, optional default 0.5
  22789. * * tessellation the number of polygon sides, optional, default 64
  22790. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  22791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22792. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22793. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22794. * @returns the VertexData of the box
  22795. */
  22796. static CreateDisc(options: {
  22797. radius?: number;
  22798. tessellation?: number;
  22799. arc?: number;
  22800. sideOrientation?: number;
  22801. frontUVs?: Vector4;
  22802. backUVs?: Vector4;
  22803. }): VertexData;
  22804. /**
  22805. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22806. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22807. * @param polygon a mesh built from polygonTriangulation.build()
  22808. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22809. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22810. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22811. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22812. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22813. * @returns the VertexData of the Polygon
  22814. */
  22815. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22816. /**
  22817. * Creates the VertexData of the IcoSphere
  22818. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22819. * * radius the radius of the IcoSphere, optional default 1
  22820. * * radiusX allows stretching in the x direction, optional, default radius
  22821. * * radiusY allows stretching in the y direction, optional, default radius
  22822. * * radiusZ allows stretching in the z direction, optional, default radius
  22823. * * flat when true creates a flat shaded mesh, optional, default true
  22824. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22826. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22827. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22828. * @returns the VertexData of the IcoSphere
  22829. */
  22830. static CreateIcoSphere(options: {
  22831. radius?: number;
  22832. radiusX?: number;
  22833. radiusY?: number;
  22834. radiusZ?: number;
  22835. flat?: boolean;
  22836. subdivisions?: number;
  22837. sideOrientation?: number;
  22838. frontUVs?: Vector4;
  22839. backUVs?: Vector4;
  22840. }): VertexData;
  22841. /**
  22842. * Creates the VertexData for a Polyhedron
  22843. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22844. * * type provided types are:
  22845. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22846. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  22847. * * size the size of the IcoSphere, optional default 1
  22848. * * sizeX allows stretching in the x direction, optional, default size
  22849. * * sizeY allows stretching in the y direction, optional, default size
  22850. * * sizeZ allows stretching in the z direction, optional, default size
  22851. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  22852. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22853. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22854. * * flat when true creates a flat shaded mesh, optional, default true
  22855. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22856. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22857. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22858. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22859. * @returns the VertexData of the Polyhedron
  22860. */
  22861. static CreatePolyhedron(options: {
  22862. type?: number;
  22863. size?: number;
  22864. sizeX?: number;
  22865. sizeY?: number;
  22866. sizeZ?: number;
  22867. custom?: any;
  22868. faceUV?: Vector4[];
  22869. faceColors?: Color4[];
  22870. flat?: boolean;
  22871. sideOrientation?: number;
  22872. frontUVs?: Vector4;
  22873. backUVs?: Vector4;
  22874. }): VertexData;
  22875. /**
  22876. * Creates the VertexData for a TorusKnot
  22877. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22878. * * radius the radius of the torus knot, optional, default 2
  22879. * * tube the thickness of the tube, optional, default 0.5
  22880. * * radialSegments the number of sides on each tube segments, optional, default 32
  22881. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22882. * * p the number of windings around the z axis, optional, default 2
  22883. * * q the number of windings around the x axis, optional, default 3
  22884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22885. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22886. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22887. * @returns the VertexData of the Torus Knot
  22888. */
  22889. static CreateTorusKnot(options: {
  22890. radius?: number;
  22891. tube?: number;
  22892. radialSegments?: number;
  22893. tubularSegments?: number;
  22894. p?: number;
  22895. q?: number;
  22896. sideOrientation?: number;
  22897. frontUVs?: Vector4;
  22898. backUVs?: Vector4;
  22899. }): VertexData;
  22900. /**
  22901. * Compute normals for given positions and indices
  22902. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22903. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22904. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22905. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22906. * * facetNormals : optional array of facet normals (vector3)
  22907. * * facetPositions : optional array of facet positions (vector3)
  22908. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22909. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22910. * * bInfo : optional bounding info, required for facetPartitioning computation
  22911. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22912. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22913. * * useRightHandedSystem: optional boolean to for right handed system computation
  22914. * * depthSort : optional boolean to enable the facet depth sort computation
  22915. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22916. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22917. */
  22918. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22919. facetNormals?: any;
  22920. facetPositions?: any;
  22921. facetPartitioning?: any;
  22922. ratio?: number;
  22923. bInfo?: any;
  22924. bbSize?: Vector3;
  22925. subDiv?: any;
  22926. useRightHandedSystem?: boolean;
  22927. depthSort?: boolean;
  22928. distanceTo?: Vector3;
  22929. depthSortedFacets?: any;
  22930. }): void;
  22931. /** @hidden */
  22932. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22933. /**
  22934. * Applies VertexData created from the imported parameters to the geometry
  22935. * @param parsedVertexData the parsed data from an imported file
  22936. * @param geometry the geometry to apply the VertexData to
  22937. */
  22938. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22939. }
  22940. }
  22941. declare module "babylonjs/Morph/morphTarget" {
  22942. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22943. import { Observable } from "babylonjs/Misc/observable";
  22944. import { Nullable, FloatArray } from "babylonjs/types";
  22945. import { Scene } from "babylonjs/scene";
  22946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22947. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22948. /**
  22949. * Defines a target to use with MorphTargetManager
  22950. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22951. */
  22952. export class MorphTarget implements IAnimatable {
  22953. /** defines the name of the target */
  22954. name: string;
  22955. /**
  22956. * Gets or sets the list of animations
  22957. */
  22958. animations: import("babylonjs/Animations/animation").Animation[];
  22959. private _scene;
  22960. private _positions;
  22961. private _normals;
  22962. private _tangents;
  22963. private _uvs;
  22964. private _influence;
  22965. private _uniqueId;
  22966. /**
  22967. * Observable raised when the influence changes
  22968. */
  22969. onInfluenceChanged: Observable<boolean>;
  22970. /** @hidden */
  22971. _onDataLayoutChanged: Observable<void>;
  22972. /**
  22973. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22974. */
  22975. influence: number;
  22976. /**
  22977. * Gets or sets the id of the morph Target
  22978. */
  22979. id: string;
  22980. private _animationPropertiesOverride;
  22981. /**
  22982. * Gets or sets the animation properties override
  22983. */
  22984. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22985. /**
  22986. * Creates a new MorphTarget
  22987. * @param name defines the name of the target
  22988. * @param influence defines the influence to use
  22989. * @param scene defines the scene the morphtarget belongs to
  22990. */
  22991. constructor(
  22992. /** defines the name of the target */
  22993. name: string, influence?: number, scene?: Nullable<Scene>);
  22994. /**
  22995. * Gets the unique ID of this manager
  22996. */
  22997. readonly uniqueId: number;
  22998. /**
  22999. * Gets a boolean defining if the target contains position data
  23000. */
  23001. readonly hasPositions: boolean;
  23002. /**
  23003. * Gets a boolean defining if the target contains normal data
  23004. */
  23005. readonly hasNormals: boolean;
  23006. /**
  23007. * Gets a boolean defining if the target contains tangent data
  23008. */
  23009. readonly hasTangents: boolean;
  23010. /**
  23011. * Gets a boolean defining if the target contains texture coordinates data
  23012. */
  23013. readonly hasUVs: boolean;
  23014. /**
  23015. * Affects position data to this target
  23016. * @param data defines the position data to use
  23017. */
  23018. setPositions(data: Nullable<FloatArray>): void;
  23019. /**
  23020. * Gets the position data stored in this target
  23021. * @returns a FloatArray containing the position data (or null if not present)
  23022. */
  23023. getPositions(): Nullable<FloatArray>;
  23024. /**
  23025. * Affects normal data to this target
  23026. * @param data defines the normal data to use
  23027. */
  23028. setNormals(data: Nullable<FloatArray>): void;
  23029. /**
  23030. * Gets the normal data stored in this target
  23031. * @returns a FloatArray containing the normal data (or null if not present)
  23032. */
  23033. getNormals(): Nullable<FloatArray>;
  23034. /**
  23035. * Affects tangent data to this target
  23036. * @param data defines the tangent data to use
  23037. */
  23038. setTangents(data: Nullable<FloatArray>): void;
  23039. /**
  23040. * Gets the tangent data stored in this target
  23041. * @returns a FloatArray containing the tangent data (or null if not present)
  23042. */
  23043. getTangents(): Nullable<FloatArray>;
  23044. /**
  23045. * Affects texture coordinates data to this target
  23046. * @param data defines the texture coordinates data to use
  23047. */
  23048. setUVs(data: Nullable<FloatArray>): void;
  23049. /**
  23050. * Gets the texture coordinates data stored in this target
  23051. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23052. */
  23053. getUVs(): Nullable<FloatArray>;
  23054. /**
  23055. * Clone the current target
  23056. * @returns a new MorphTarget
  23057. */
  23058. clone(): MorphTarget;
  23059. /**
  23060. * Serializes the current target into a Serialization object
  23061. * @returns the serialized object
  23062. */
  23063. serialize(): any;
  23064. /**
  23065. * Returns the string "MorphTarget"
  23066. * @returns "MorphTarget"
  23067. */
  23068. getClassName(): string;
  23069. /**
  23070. * Creates a new target from serialized data
  23071. * @param serializationObject defines the serialized data to use
  23072. * @returns a new MorphTarget
  23073. */
  23074. static Parse(serializationObject: any): MorphTarget;
  23075. /**
  23076. * Creates a MorphTarget from mesh data
  23077. * @param mesh defines the source mesh
  23078. * @param name defines the name to use for the new target
  23079. * @param influence defines the influence to attach to the target
  23080. * @returns a new MorphTarget
  23081. */
  23082. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23083. }
  23084. }
  23085. declare module "babylonjs/Morph/morphTargetManager" {
  23086. import { Nullable } from "babylonjs/types";
  23087. import { Scene } from "babylonjs/scene";
  23088. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23089. /**
  23090. * This class is used to deform meshes using morphing between different targets
  23091. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23092. */
  23093. export class MorphTargetManager {
  23094. private _targets;
  23095. private _targetInfluenceChangedObservers;
  23096. private _targetDataLayoutChangedObservers;
  23097. private _activeTargets;
  23098. private _scene;
  23099. private _influences;
  23100. private _supportsNormals;
  23101. private _supportsTangents;
  23102. private _supportsUVs;
  23103. private _vertexCount;
  23104. private _uniqueId;
  23105. private _tempInfluences;
  23106. /**
  23107. * Gets or sets a boolean indicating if normals must be morphed
  23108. */
  23109. enableNormalMorphing: boolean;
  23110. /**
  23111. * Gets or sets a boolean indicating if tangents must be morphed
  23112. */
  23113. enableTangentMorphing: boolean;
  23114. /**
  23115. * Gets or sets a boolean indicating if UV must be morphed
  23116. */
  23117. enableUVMorphing: boolean;
  23118. /**
  23119. * Creates a new MorphTargetManager
  23120. * @param scene defines the current scene
  23121. */
  23122. constructor(scene?: Nullable<Scene>);
  23123. /**
  23124. * Gets the unique ID of this manager
  23125. */
  23126. readonly uniqueId: number;
  23127. /**
  23128. * Gets the number of vertices handled by this manager
  23129. */
  23130. readonly vertexCount: number;
  23131. /**
  23132. * Gets a boolean indicating if this manager supports morphing of normals
  23133. */
  23134. readonly supportsNormals: boolean;
  23135. /**
  23136. * Gets a boolean indicating if this manager supports morphing of tangents
  23137. */
  23138. readonly supportsTangents: boolean;
  23139. /**
  23140. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23141. */
  23142. readonly supportsUVs: boolean;
  23143. /**
  23144. * Gets the number of targets stored in this manager
  23145. */
  23146. readonly numTargets: number;
  23147. /**
  23148. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23149. */
  23150. readonly numInfluencers: number;
  23151. /**
  23152. * Gets the list of influences (one per target)
  23153. */
  23154. readonly influences: Float32Array;
  23155. /**
  23156. * Gets the active target at specified index. An active target is a target with an influence > 0
  23157. * @param index defines the index to check
  23158. * @returns the requested target
  23159. */
  23160. getActiveTarget(index: number): MorphTarget;
  23161. /**
  23162. * Gets the target at specified index
  23163. * @param index defines the index to check
  23164. * @returns the requested target
  23165. */
  23166. getTarget(index: number): MorphTarget;
  23167. /**
  23168. * Add a new target to this manager
  23169. * @param target defines the target to add
  23170. */
  23171. addTarget(target: MorphTarget): void;
  23172. /**
  23173. * Removes a target from the manager
  23174. * @param target defines the target to remove
  23175. */
  23176. removeTarget(target: MorphTarget): void;
  23177. /**
  23178. * Clone the current manager
  23179. * @returns a new MorphTargetManager
  23180. */
  23181. clone(): MorphTargetManager;
  23182. /**
  23183. * Serializes the current manager into a Serialization object
  23184. * @returns the serialized object
  23185. */
  23186. serialize(): any;
  23187. private _syncActiveTargets;
  23188. /**
  23189. * Syncrhonize the targets with all the meshes using this morph target manager
  23190. */
  23191. synchronize(): void;
  23192. /**
  23193. * Creates a new MorphTargetManager from serialized data
  23194. * @param serializationObject defines the serialized data
  23195. * @param scene defines the hosting scene
  23196. * @returns the new MorphTargetManager
  23197. */
  23198. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23199. }
  23200. }
  23201. declare module "babylonjs/Meshes/meshLODLevel" {
  23202. import { Mesh } from "babylonjs/Meshes/mesh";
  23203. import { Nullable } from "babylonjs/types";
  23204. /**
  23205. * Class used to represent a specific level of detail of a mesh
  23206. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23207. */
  23208. export class MeshLODLevel {
  23209. /** Defines the distance where this level should start being displayed */
  23210. distance: number;
  23211. /** Defines the mesh to use to render this level */
  23212. mesh: Nullable<Mesh>;
  23213. /**
  23214. * Creates a new LOD level
  23215. * @param distance defines the distance where this level should star being displayed
  23216. * @param mesh defines the mesh to use to render this level
  23217. */
  23218. constructor(
  23219. /** Defines the distance where this level should start being displayed */
  23220. distance: number,
  23221. /** Defines the mesh to use to render this level */
  23222. mesh: Nullable<Mesh>);
  23223. }
  23224. }
  23225. declare module "babylonjs/Meshes/groundMesh" {
  23226. import { Scene } from "babylonjs/scene";
  23227. import { Vector3 } from "babylonjs/Maths/math.vector";
  23228. import { Mesh } from "babylonjs/Meshes/mesh";
  23229. /**
  23230. * Mesh representing the gorund
  23231. */
  23232. export class GroundMesh extends Mesh {
  23233. /** If octree should be generated */
  23234. generateOctree: boolean;
  23235. private _heightQuads;
  23236. /** @hidden */
  23237. _subdivisionsX: number;
  23238. /** @hidden */
  23239. _subdivisionsY: number;
  23240. /** @hidden */
  23241. _width: number;
  23242. /** @hidden */
  23243. _height: number;
  23244. /** @hidden */
  23245. _minX: number;
  23246. /** @hidden */
  23247. _maxX: number;
  23248. /** @hidden */
  23249. _minZ: number;
  23250. /** @hidden */
  23251. _maxZ: number;
  23252. constructor(name: string, scene: Scene);
  23253. /**
  23254. * "GroundMesh"
  23255. * @returns "GroundMesh"
  23256. */
  23257. getClassName(): string;
  23258. /**
  23259. * The minimum of x and y subdivisions
  23260. */
  23261. readonly subdivisions: number;
  23262. /**
  23263. * X subdivisions
  23264. */
  23265. readonly subdivisionsX: number;
  23266. /**
  23267. * Y subdivisions
  23268. */
  23269. readonly subdivisionsY: number;
  23270. /**
  23271. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23272. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23273. * @param chunksCount the number of subdivisions for x and y
  23274. * @param octreeBlocksSize (Default: 32)
  23275. */
  23276. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23277. /**
  23278. * Returns a height (y) value in the Worl system :
  23279. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23280. * @param x x coordinate
  23281. * @param z z coordinate
  23282. * @returns the ground y position if (x, z) are outside the ground surface.
  23283. */
  23284. getHeightAtCoordinates(x: number, z: number): number;
  23285. /**
  23286. * Returns a normalized vector (Vector3) orthogonal to the ground
  23287. * at the ground coordinates (x, z) expressed in the World system.
  23288. * @param x x coordinate
  23289. * @param z z coordinate
  23290. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23291. */
  23292. getNormalAtCoordinates(x: number, z: number): Vector3;
  23293. /**
  23294. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23295. * at the ground coordinates (x, z) expressed in the World system.
  23296. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23297. * @param x x coordinate
  23298. * @param z z coordinate
  23299. * @param ref vector to store the result
  23300. * @returns the GroundMesh.
  23301. */
  23302. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23303. /**
  23304. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23305. * if the ground has been updated.
  23306. * This can be used in the render loop.
  23307. * @returns the GroundMesh.
  23308. */
  23309. updateCoordinateHeights(): GroundMesh;
  23310. private _getFacetAt;
  23311. private _initHeightQuads;
  23312. private _computeHeightQuads;
  23313. /**
  23314. * Serializes this ground mesh
  23315. * @param serializationObject object to write serialization to
  23316. */
  23317. serialize(serializationObject: any): void;
  23318. /**
  23319. * Parses a serialized ground mesh
  23320. * @param parsedMesh the serialized mesh
  23321. * @param scene the scene to create the ground mesh in
  23322. * @returns the created ground mesh
  23323. */
  23324. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23325. }
  23326. }
  23327. declare module "babylonjs/Physics/physicsJoint" {
  23328. import { Vector3 } from "babylonjs/Maths/math.vector";
  23329. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23330. /**
  23331. * Interface for Physics-Joint data
  23332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23333. */
  23334. export interface PhysicsJointData {
  23335. /**
  23336. * The main pivot of the joint
  23337. */
  23338. mainPivot?: Vector3;
  23339. /**
  23340. * The connected pivot of the joint
  23341. */
  23342. connectedPivot?: Vector3;
  23343. /**
  23344. * The main axis of the joint
  23345. */
  23346. mainAxis?: Vector3;
  23347. /**
  23348. * The connected axis of the joint
  23349. */
  23350. connectedAxis?: Vector3;
  23351. /**
  23352. * The collision of the joint
  23353. */
  23354. collision?: boolean;
  23355. /**
  23356. * Native Oimo/Cannon/Energy data
  23357. */
  23358. nativeParams?: any;
  23359. }
  23360. /**
  23361. * This is a holder class for the physics joint created by the physics plugin
  23362. * It holds a set of functions to control the underlying joint
  23363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23364. */
  23365. export class PhysicsJoint {
  23366. /**
  23367. * The type of the physics joint
  23368. */
  23369. type: number;
  23370. /**
  23371. * The data for the physics joint
  23372. */
  23373. jointData: PhysicsJointData;
  23374. private _physicsJoint;
  23375. protected _physicsPlugin: IPhysicsEnginePlugin;
  23376. /**
  23377. * Initializes the physics joint
  23378. * @param type The type of the physics joint
  23379. * @param jointData The data for the physics joint
  23380. */
  23381. constructor(
  23382. /**
  23383. * The type of the physics joint
  23384. */
  23385. type: number,
  23386. /**
  23387. * The data for the physics joint
  23388. */
  23389. jointData: PhysicsJointData);
  23390. /**
  23391. * Gets the physics joint
  23392. */
  23393. /**
  23394. * Sets the physics joint
  23395. */
  23396. physicsJoint: any;
  23397. /**
  23398. * Sets the physics plugin
  23399. */
  23400. physicsPlugin: IPhysicsEnginePlugin;
  23401. /**
  23402. * Execute a function that is physics-plugin specific.
  23403. * @param {Function} func the function that will be executed.
  23404. * It accepts two parameters: the physics world and the physics joint
  23405. */
  23406. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23407. /**
  23408. * Distance-Joint type
  23409. */
  23410. static DistanceJoint: number;
  23411. /**
  23412. * Hinge-Joint type
  23413. */
  23414. static HingeJoint: number;
  23415. /**
  23416. * Ball-and-Socket joint type
  23417. */
  23418. static BallAndSocketJoint: number;
  23419. /**
  23420. * Wheel-Joint type
  23421. */
  23422. static WheelJoint: number;
  23423. /**
  23424. * Slider-Joint type
  23425. */
  23426. static SliderJoint: number;
  23427. /**
  23428. * Prismatic-Joint type
  23429. */
  23430. static PrismaticJoint: number;
  23431. /**
  23432. * Universal-Joint type
  23433. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23434. */
  23435. static UniversalJoint: number;
  23436. /**
  23437. * Hinge-Joint 2 type
  23438. */
  23439. static Hinge2Joint: number;
  23440. /**
  23441. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23442. */
  23443. static PointToPointJoint: number;
  23444. /**
  23445. * Spring-Joint type
  23446. */
  23447. static SpringJoint: number;
  23448. /**
  23449. * Lock-Joint type
  23450. */
  23451. static LockJoint: number;
  23452. }
  23453. /**
  23454. * A class representing a physics distance joint
  23455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23456. */
  23457. export class DistanceJoint extends PhysicsJoint {
  23458. /**
  23459. *
  23460. * @param jointData The data for the Distance-Joint
  23461. */
  23462. constructor(jointData: DistanceJointData);
  23463. /**
  23464. * Update the predefined distance.
  23465. * @param maxDistance The maximum preferred distance
  23466. * @param minDistance The minimum preferred distance
  23467. */
  23468. updateDistance(maxDistance: number, minDistance?: number): void;
  23469. }
  23470. /**
  23471. * Represents a Motor-Enabled Joint
  23472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23473. */
  23474. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23475. /**
  23476. * Initializes the Motor-Enabled Joint
  23477. * @param type The type of the joint
  23478. * @param jointData The physica joint data for the joint
  23479. */
  23480. constructor(type: number, jointData: PhysicsJointData);
  23481. /**
  23482. * Set the motor values.
  23483. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23484. * @param force the force to apply
  23485. * @param maxForce max force for this motor.
  23486. */
  23487. setMotor(force?: number, maxForce?: number): void;
  23488. /**
  23489. * Set the motor's limits.
  23490. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23491. * @param upperLimit The upper limit of the motor
  23492. * @param lowerLimit The lower limit of the motor
  23493. */
  23494. setLimit(upperLimit: number, lowerLimit?: number): void;
  23495. }
  23496. /**
  23497. * This class represents a single physics Hinge-Joint
  23498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23499. */
  23500. export class HingeJoint extends MotorEnabledJoint {
  23501. /**
  23502. * Initializes the Hinge-Joint
  23503. * @param jointData The joint data for the Hinge-Joint
  23504. */
  23505. constructor(jointData: PhysicsJointData);
  23506. /**
  23507. * Set the motor values.
  23508. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23509. * @param {number} force the force to apply
  23510. * @param {number} maxForce max force for this motor.
  23511. */
  23512. setMotor(force?: number, maxForce?: number): void;
  23513. /**
  23514. * Set the motor's limits.
  23515. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23516. * @param upperLimit The upper limit of the motor
  23517. * @param lowerLimit The lower limit of the motor
  23518. */
  23519. setLimit(upperLimit: number, lowerLimit?: number): void;
  23520. }
  23521. /**
  23522. * This class represents a dual hinge physics joint (same as wheel joint)
  23523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23524. */
  23525. export class Hinge2Joint extends MotorEnabledJoint {
  23526. /**
  23527. * Initializes the Hinge2-Joint
  23528. * @param jointData The joint data for the Hinge2-Joint
  23529. */
  23530. constructor(jointData: PhysicsJointData);
  23531. /**
  23532. * Set the motor values.
  23533. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23534. * @param {number} targetSpeed the speed the motor is to reach
  23535. * @param {number} maxForce max force for this motor.
  23536. * @param {motorIndex} the motor's index, 0 or 1.
  23537. */
  23538. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23539. /**
  23540. * Set the motor limits.
  23541. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23542. * @param {number} upperLimit the upper limit
  23543. * @param {number} lowerLimit lower limit
  23544. * @param {motorIndex} the motor's index, 0 or 1.
  23545. */
  23546. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23547. }
  23548. /**
  23549. * Interface for a motor enabled joint
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface IMotorEnabledJoint {
  23553. /**
  23554. * Physics joint
  23555. */
  23556. physicsJoint: any;
  23557. /**
  23558. * Sets the motor of the motor-enabled joint
  23559. * @param force The force of the motor
  23560. * @param maxForce The maximum force of the motor
  23561. * @param motorIndex The index of the motor
  23562. */
  23563. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23564. /**
  23565. * Sets the limit of the motor
  23566. * @param upperLimit The upper limit of the motor
  23567. * @param lowerLimit The lower limit of the motor
  23568. * @param motorIndex The index of the motor
  23569. */
  23570. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23571. }
  23572. /**
  23573. * Joint data for a Distance-Joint
  23574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23575. */
  23576. export interface DistanceJointData extends PhysicsJointData {
  23577. /**
  23578. * Max distance the 2 joint objects can be apart
  23579. */
  23580. maxDistance: number;
  23581. }
  23582. /**
  23583. * Joint data from a spring joint
  23584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23585. */
  23586. export interface SpringJointData extends PhysicsJointData {
  23587. /**
  23588. * Length of the spring
  23589. */
  23590. length: number;
  23591. /**
  23592. * Stiffness of the spring
  23593. */
  23594. stiffness: number;
  23595. /**
  23596. * Damping of the spring
  23597. */
  23598. damping: number;
  23599. /** this callback will be called when applying the force to the impostors. */
  23600. forceApplicationCallback: () => void;
  23601. }
  23602. }
  23603. declare module "babylonjs/Physics/physicsRaycastResult" {
  23604. import { Vector3 } from "babylonjs/Maths/math.vector";
  23605. /**
  23606. * Holds the data for the raycast result
  23607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23608. */
  23609. export class PhysicsRaycastResult {
  23610. private _hasHit;
  23611. private _hitDistance;
  23612. private _hitNormalWorld;
  23613. private _hitPointWorld;
  23614. private _rayFromWorld;
  23615. private _rayToWorld;
  23616. /**
  23617. * Gets if there was a hit
  23618. */
  23619. readonly hasHit: boolean;
  23620. /**
  23621. * Gets the distance from the hit
  23622. */
  23623. readonly hitDistance: number;
  23624. /**
  23625. * Gets the hit normal/direction in the world
  23626. */
  23627. readonly hitNormalWorld: Vector3;
  23628. /**
  23629. * Gets the hit point in the world
  23630. */
  23631. readonly hitPointWorld: Vector3;
  23632. /**
  23633. * Gets the ray "start point" of the ray in the world
  23634. */
  23635. readonly rayFromWorld: Vector3;
  23636. /**
  23637. * Gets the ray "end point" of the ray in the world
  23638. */
  23639. readonly rayToWorld: Vector3;
  23640. /**
  23641. * Sets the hit data (normal & point in world space)
  23642. * @param hitNormalWorld defines the normal in world space
  23643. * @param hitPointWorld defines the point in world space
  23644. */
  23645. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23646. /**
  23647. * Sets the distance from the start point to the hit point
  23648. * @param distance
  23649. */
  23650. setHitDistance(distance: number): void;
  23651. /**
  23652. * Calculates the distance manually
  23653. */
  23654. calculateHitDistance(): void;
  23655. /**
  23656. * Resets all the values to default
  23657. * @param from The from point on world space
  23658. * @param to The to point on world space
  23659. */
  23660. reset(from?: Vector3, to?: Vector3): void;
  23661. }
  23662. /**
  23663. * Interface for the size containing width and height
  23664. */
  23665. interface IXYZ {
  23666. /**
  23667. * X
  23668. */
  23669. x: number;
  23670. /**
  23671. * Y
  23672. */
  23673. y: number;
  23674. /**
  23675. * Z
  23676. */
  23677. z: number;
  23678. }
  23679. }
  23680. declare module "babylonjs/Physics/IPhysicsEngine" {
  23681. import { Nullable } from "babylonjs/types";
  23682. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23684. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23685. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23686. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23687. /**
  23688. * Interface used to describe a physics joint
  23689. */
  23690. export interface PhysicsImpostorJoint {
  23691. /** Defines the main impostor to which the joint is linked */
  23692. mainImpostor: PhysicsImpostor;
  23693. /** Defines the impostor that is connected to the main impostor using this joint */
  23694. connectedImpostor: PhysicsImpostor;
  23695. /** Defines the joint itself */
  23696. joint: PhysicsJoint;
  23697. }
  23698. /** @hidden */
  23699. export interface IPhysicsEnginePlugin {
  23700. world: any;
  23701. name: string;
  23702. setGravity(gravity: Vector3): void;
  23703. setTimeStep(timeStep: number): void;
  23704. getTimeStep(): number;
  23705. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23706. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23707. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23708. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23709. removePhysicsBody(impostor: PhysicsImpostor): void;
  23710. generateJoint(joint: PhysicsImpostorJoint): void;
  23711. removeJoint(joint: PhysicsImpostorJoint): void;
  23712. isSupported(): boolean;
  23713. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23714. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23715. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23716. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23717. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23718. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23719. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23720. getBodyMass(impostor: PhysicsImpostor): number;
  23721. getBodyFriction(impostor: PhysicsImpostor): number;
  23722. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23723. getBodyRestitution(impostor: PhysicsImpostor): number;
  23724. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23725. getBodyPressure?(impostor: PhysicsImpostor): number;
  23726. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23727. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23728. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23729. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23730. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23731. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23732. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23733. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23734. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23735. sleepBody(impostor: PhysicsImpostor): void;
  23736. wakeUpBody(impostor: PhysicsImpostor): void;
  23737. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23738. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23739. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23740. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23741. getRadius(impostor: PhysicsImpostor): number;
  23742. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23743. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23744. dispose(): void;
  23745. }
  23746. /**
  23747. * Interface used to define a physics engine
  23748. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23749. */
  23750. export interface IPhysicsEngine {
  23751. /**
  23752. * Gets the gravity vector used by the simulation
  23753. */
  23754. gravity: Vector3;
  23755. /**
  23756. * Sets the gravity vector used by the simulation
  23757. * @param gravity defines the gravity vector to use
  23758. */
  23759. setGravity(gravity: Vector3): void;
  23760. /**
  23761. * Set the time step of the physics engine.
  23762. * Default is 1/60.
  23763. * To slow it down, enter 1/600 for example.
  23764. * To speed it up, 1/30
  23765. * @param newTimeStep the new timestep to apply to this world.
  23766. */
  23767. setTimeStep(newTimeStep: number): void;
  23768. /**
  23769. * Get the time step of the physics engine.
  23770. * @returns the current time step
  23771. */
  23772. getTimeStep(): number;
  23773. /**
  23774. * Set the sub time step of the physics engine.
  23775. * Default is 0 meaning there is no sub steps
  23776. * To increase physics resolution precision, set a small value (like 1 ms)
  23777. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23778. */
  23779. setSubTimeStep(subTimeStep: number): void;
  23780. /**
  23781. * Get the sub time step of the physics engine.
  23782. * @returns the current sub time step
  23783. */
  23784. getSubTimeStep(): number;
  23785. /**
  23786. * Release all resources
  23787. */
  23788. dispose(): void;
  23789. /**
  23790. * Gets the name of the current physics plugin
  23791. * @returns the name of the plugin
  23792. */
  23793. getPhysicsPluginName(): string;
  23794. /**
  23795. * Adding a new impostor for the impostor tracking.
  23796. * This will be done by the impostor itself.
  23797. * @param impostor the impostor to add
  23798. */
  23799. addImpostor(impostor: PhysicsImpostor): void;
  23800. /**
  23801. * Remove an impostor from the engine.
  23802. * This impostor and its mesh will not longer be updated by the physics engine.
  23803. * @param impostor the impostor to remove
  23804. */
  23805. removeImpostor(impostor: PhysicsImpostor): void;
  23806. /**
  23807. * Add a joint to the physics engine
  23808. * @param mainImpostor defines the main impostor to which the joint is added.
  23809. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23810. * @param joint defines the joint that will connect both impostors.
  23811. */
  23812. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23813. /**
  23814. * Removes a joint from the simulation
  23815. * @param mainImpostor defines the impostor used with the joint
  23816. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23817. * @param joint defines the joint to remove
  23818. */
  23819. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23820. /**
  23821. * Gets the current plugin used to run the simulation
  23822. * @returns current plugin
  23823. */
  23824. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23825. /**
  23826. * Gets the list of physic impostors
  23827. * @returns an array of PhysicsImpostor
  23828. */
  23829. getImpostors(): Array<PhysicsImpostor>;
  23830. /**
  23831. * Gets the impostor for a physics enabled object
  23832. * @param object defines the object impersonated by the impostor
  23833. * @returns the PhysicsImpostor or null if not found
  23834. */
  23835. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23836. /**
  23837. * Gets the impostor for a physics body object
  23838. * @param body defines physics body used by the impostor
  23839. * @returns the PhysicsImpostor or null if not found
  23840. */
  23841. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23842. /**
  23843. * Does a raycast in the physics world
  23844. * @param from when should the ray start?
  23845. * @param to when should the ray end?
  23846. * @returns PhysicsRaycastResult
  23847. */
  23848. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23849. /**
  23850. * Called by the scene. No need to call it.
  23851. * @param delta defines the timespam between frames
  23852. */
  23853. _step(delta: number): void;
  23854. }
  23855. }
  23856. declare module "babylonjs/Physics/physicsImpostor" {
  23857. import { Nullable, IndicesArray } from "babylonjs/types";
  23858. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23859. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23861. import { Scene } from "babylonjs/scene";
  23862. import { Bone } from "babylonjs/Bones/bone";
  23863. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23864. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23865. import { Space } from "babylonjs/Maths/math.axis";
  23866. /**
  23867. * The interface for the physics imposter parameters
  23868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23869. */
  23870. export interface PhysicsImpostorParameters {
  23871. /**
  23872. * The mass of the physics imposter
  23873. */
  23874. mass: number;
  23875. /**
  23876. * The friction of the physics imposter
  23877. */
  23878. friction?: number;
  23879. /**
  23880. * The coefficient of restitution of the physics imposter
  23881. */
  23882. restitution?: number;
  23883. /**
  23884. * The native options of the physics imposter
  23885. */
  23886. nativeOptions?: any;
  23887. /**
  23888. * Specifies if the parent should be ignored
  23889. */
  23890. ignoreParent?: boolean;
  23891. /**
  23892. * Specifies if bi-directional transformations should be disabled
  23893. */
  23894. disableBidirectionalTransformation?: boolean;
  23895. /**
  23896. * The pressure inside the physics imposter, soft object only
  23897. */
  23898. pressure?: number;
  23899. /**
  23900. * The stiffness the physics imposter, soft object only
  23901. */
  23902. stiffness?: number;
  23903. /**
  23904. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23905. */
  23906. velocityIterations?: number;
  23907. /**
  23908. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23909. */
  23910. positionIterations?: number;
  23911. /**
  23912. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23913. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23914. * Add to fix multiple points
  23915. */
  23916. fixedPoints?: number;
  23917. /**
  23918. * The collision margin around a soft object
  23919. */
  23920. margin?: number;
  23921. /**
  23922. * The collision margin around a soft object
  23923. */
  23924. damping?: number;
  23925. /**
  23926. * The path for a rope based on an extrusion
  23927. */
  23928. path?: any;
  23929. /**
  23930. * The shape of an extrusion used for a rope based on an extrusion
  23931. */
  23932. shape?: any;
  23933. }
  23934. /**
  23935. * Interface for a physics-enabled object
  23936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23937. */
  23938. export interface IPhysicsEnabledObject {
  23939. /**
  23940. * The position of the physics-enabled object
  23941. */
  23942. position: Vector3;
  23943. /**
  23944. * The rotation of the physics-enabled object
  23945. */
  23946. rotationQuaternion: Nullable<Quaternion>;
  23947. /**
  23948. * The scale of the physics-enabled object
  23949. */
  23950. scaling: Vector3;
  23951. /**
  23952. * The rotation of the physics-enabled object
  23953. */
  23954. rotation?: Vector3;
  23955. /**
  23956. * The parent of the physics-enabled object
  23957. */
  23958. parent?: any;
  23959. /**
  23960. * The bounding info of the physics-enabled object
  23961. * @returns The bounding info of the physics-enabled object
  23962. */
  23963. getBoundingInfo(): BoundingInfo;
  23964. /**
  23965. * Computes the world matrix
  23966. * @param force Specifies if the world matrix should be computed by force
  23967. * @returns A world matrix
  23968. */
  23969. computeWorldMatrix(force: boolean): Matrix;
  23970. /**
  23971. * Gets the world matrix
  23972. * @returns A world matrix
  23973. */
  23974. getWorldMatrix?(): Matrix;
  23975. /**
  23976. * Gets the child meshes
  23977. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23978. * @returns An array of abstract meshes
  23979. */
  23980. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23981. /**
  23982. * Gets the vertex data
  23983. * @param kind The type of vertex data
  23984. * @returns A nullable array of numbers, or a float32 array
  23985. */
  23986. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23987. /**
  23988. * Gets the indices from the mesh
  23989. * @returns A nullable array of index arrays
  23990. */
  23991. getIndices?(): Nullable<IndicesArray>;
  23992. /**
  23993. * Gets the scene from the mesh
  23994. * @returns the indices array or null
  23995. */
  23996. getScene?(): Scene;
  23997. /**
  23998. * Gets the absolute position from the mesh
  23999. * @returns the absolute position
  24000. */
  24001. getAbsolutePosition(): Vector3;
  24002. /**
  24003. * Gets the absolute pivot point from the mesh
  24004. * @returns the absolute pivot point
  24005. */
  24006. getAbsolutePivotPoint(): Vector3;
  24007. /**
  24008. * Rotates the mesh
  24009. * @param axis The axis of rotation
  24010. * @param amount The amount of rotation
  24011. * @param space The space of the rotation
  24012. * @returns The rotation transform node
  24013. */
  24014. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24015. /**
  24016. * Translates the mesh
  24017. * @param axis The axis of translation
  24018. * @param distance The distance of translation
  24019. * @param space The space of the translation
  24020. * @returns The transform node
  24021. */
  24022. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24023. /**
  24024. * Sets the absolute position of the mesh
  24025. * @param absolutePosition The absolute position of the mesh
  24026. * @returns The transform node
  24027. */
  24028. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24029. /**
  24030. * Gets the class name of the mesh
  24031. * @returns The class name
  24032. */
  24033. getClassName(): string;
  24034. }
  24035. /**
  24036. * Represents a physics imposter
  24037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24038. */
  24039. export class PhysicsImpostor {
  24040. /**
  24041. * The physics-enabled object used as the physics imposter
  24042. */
  24043. object: IPhysicsEnabledObject;
  24044. /**
  24045. * The type of the physics imposter
  24046. */
  24047. type: number;
  24048. private _options;
  24049. private _scene?;
  24050. /**
  24051. * The default object size of the imposter
  24052. */
  24053. static DEFAULT_OBJECT_SIZE: Vector3;
  24054. /**
  24055. * The identity quaternion of the imposter
  24056. */
  24057. static IDENTITY_QUATERNION: Quaternion;
  24058. /** @hidden */
  24059. _pluginData: any;
  24060. private _physicsEngine;
  24061. private _physicsBody;
  24062. private _bodyUpdateRequired;
  24063. private _onBeforePhysicsStepCallbacks;
  24064. private _onAfterPhysicsStepCallbacks;
  24065. /** @hidden */
  24066. _onPhysicsCollideCallbacks: Array<{
  24067. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24068. otherImpostors: Array<PhysicsImpostor>;
  24069. }>;
  24070. private _deltaPosition;
  24071. private _deltaRotation;
  24072. private _deltaRotationConjugated;
  24073. /** @hidden */
  24074. _isFromLine: boolean;
  24075. private _parent;
  24076. private _isDisposed;
  24077. private static _tmpVecs;
  24078. private static _tmpQuat;
  24079. /**
  24080. * Specifies if the physics imposter is disposed
  24081. */
  24082. readonly isDisposed: boolean;
  24083. /**
  24084. * Gets the mass of the physics imposter
  24085. */
  24086. mass: number;
  24087. /**
  24088. * Gets the coefficient of friction
  24089. */
  24090. /**
  24091. * Sets the coefficient of friction
  24092. */
  24093. friction: number;
  24094. /**
  24095. * Gets the coefficient of restitution
  24096. */
  24097. /**
  24098. * Sets the coefficient of restitution
  24099. */
  24100. restitution: number;
  24101. /**
  24102. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24103. */
  24104. /**
  24105. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24106. */
  24107. pressure: number;
  24108. /**
  24109. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24110. */
  24111. /**
  24112. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24113. */
  24114. stiffness: number;
  24115. /**
  24116. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24117. */
  24118. /**
  24119. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24120. */
  24121. velocityIterations: number;
  24122. /**
  24123. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24124. */
  24125. /**
  24126. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24127. */
  24128. positionIterations: number;
  24129. /**
  24130. * The unique id of the physics imposter
  24131. * set by the physics engine when adding this impostor to the array
  24132. */
  24133. uniqueId: number;
  24134. /**
  24135. * @hidden
  24136. */
  24137. soft: boolean;
  24138. /**
  24139. * @hidden
  24140. */
  24141. segments: number;
  24142. private _joints;
  24143. /**
  24144. * Initializes the physics imposter
  24145. * @param object The physics-enabled object used as the physics imposter
  24146. * @param type The type of the physics imposter
  24147. * @param _options The options for the physics imposter
  24148. * @param _scene The Babylon scene
  24149. */
  24150. constructor(
  24151. /**
  24152. * The physics-enabled object used as the physics imposter
  24153. */
  24154. object: IPhysicsEnabledObject,
  24155. /**
  24156. * The type of the physics imposter
  24157. */
  24158. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24159. /**
  24160. * This function will completly initialize this impostor.
  24161. * It will create a new body - but only if this mesh has no parent.
  24162. * If it has, this impostor will not be used other than to define the impostor
  24163. * of the child mesh.
  24164. * @hidden
  24165. */
  24166. _init(): void;
  24167. private _getPhysicsParent;
  24168. /**
  24169. * Should a new body be generated.
  24170. * @returns boolean specifying if body initialization is required
  24171. */
  24172. isBodyInitRequired(): boolean;
  24173. /**
  24174. * Sets the updated scaling
  24175. * @param updated Specifies if the scaling is updated
  24176. */
  24177. setScalingUpdated(): void;
  24178. /**
  24179. * Force a regeneration of this or the parent's impostor's body.
  24180. * Use under cautious - This will remove all joints already implemented.
  24181. */
  24182. forceUpdate(): void;
  24183. /**
  24184. * Gets the body that holds this impostor. Either its own, or its parent.
  24185. */
  24186. /**
  24187. * Set the physics body. Used mainly by the physics engine/plugin
  24188. */
  24189. physicsBody: any;
  24190. /**
  24191. * Get the parent of the physics imposter
  24192. * @returns Physics imposter or null
  24193. */
  24194. /**
  24195. * Sets the parent of the physics imposter
  24196. */
  24197. parent: Nullable<PhysicsImpostor>;
  24198. /**
  24199. * Resets the update flags
  24200. */
  24201. resetUpdateFlags(): void;
  24202. /**
  24203. * Gets the object extend size
  24204. * @returns the object extend size
  24205. */
  24206. getObjectExtendSize(): Vector3;
  24207. /**
  24208. * Gets the object center
  24209. * @returns The object center
  24210. */
  24211. getObjectCenter(): Vector3;
  24212. /**
  24213. * Get a specific parametes from the options parameter
  24214. * @param paramName The object parameter name
  24215. * @returns The object parameter
  24216. */
  24217. getParam(paramName: string): any;
  24218. /**
  24219. * Sets a specific parameter in the options given to the physics plugin
  24220. * @param paramName The parameter name
  24221. * @param value The value of the parameter
  24222. */
  24223. setParam(paramName: string, value: number): void;
  24224. /**
  24225. * Specifically change the body's mass option. Won't recreate the physics body object
  24226. * @param mass The mass of the physics imposter
  24227. */
  24228. setMass(mass: number): void;
  24229. /**
  24230. * Gets the linear velocity
  24231. * @returns linear velocity or null
  24232. */
  24233. getLinearVelocity(): Nullable<Vector3>;
  24234. /**
  24235. * Sets the linear velocity
  24236. * @param velocity linear velocity or null
  24237. */
  24238. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24239. /**
  24240. * Gets the angular velocity
  24241. * @returns angular velocity or null
  24242. */
  24243. getAngularVelocity(): Nullable<Vector3>;
  24244. /**
  24245. * Sets the angular velocity
  24246. * @param velocity The velocity or null
  24247. */
  24248. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24249. /**
  24250. * Execute a function with the physics plugin native code
  24251. * Provide a function the will have two variables - the world object and the physics body object
  24252. * @param func The function to execute with the physics plugin native code
  24253. */
  24254. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24255. /**
  24256. * Register a function that will be executed before the physics world is stepping forward
  24257. * @param func The function to execute before the physics world is stepped forward
  24258. */
  24259. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24260. /**
  24261. * Unregister a function that will be executed before the physics world is stepping forward
  24262. * @param func The function to execute before the physics world is stepped forward
  24263. */
  24264. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24265. /**
  24266. * Register a function that will be executed after the physics step
  24267. * @param func The function to execute after physics step
  24268. */
  24269. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24270. /**
  24271. * Unregisters a function that will be executed after the physics step
  24272. * @param func The function to execute after physics step
  24273. */
  24274. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24275. /**
  24276. * register a function that will be executed when this impostor collides against a different body
  24277. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24278. * @param func Callback that is executed on collision
  24279. */
  24280. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24281. /**
  24282. * Unregisters the physics imposter on contact
  24283. * @param collideAgainst The physics object to collide against
  24284. * @param func Callback to execute on collision
  24285. */
  24286. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24287. private _tmpQuat;
  24288. private _tmpQuat2;
  24289. /**
  24290. * Get the parent rotation
  24291. * @returns The parent rotation
  24292. */
  24293. getParentsRotation(): Quaternion;
  24294. /**
  24295. * this function is executed by the physics engine.
  24296. */
  24297. beforeStep: () => void;
  24298. /**
  24299. * this function is executed by the physics engine
  24300. */
  24301. afterStep: () => void;
  24302. /**
  24303. * Legacy collision detection event support
  24304. */
  24305. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24306. /**
  24307. * event and body object due to cannon's event-based architecture.
  24308. */
  24309. onCollide: (e: {
  24310. body: any;
  24311. }) => void;
  24312. /**
  24313. * Apply a force
  24314. * @param force The force to apply
  24315. * @param contactPoint The contact point for the force
  24316. * @returns The physics imposter
  24317. */
  24318. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24319. /**
  24320. * Apply an impulse
  24321. * @param force The impulse force
  24322. * @param contactPoint The contact point for the impulse force
  24323. * @returns The physics imposter
  24324. */
  24325. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24326. /**
  24327. * A help function to create a joint
  24328. * @param otherImpostor A physics imposter used to create a joint
  24329. * @param jointType The type of joint
  24330. * @param jointData The data for the joint
  24331. * @returns The physics imposter
  24332. */
  24333. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24334. /**
  24335. * Add a joint to this impostor with a different impostor
  24336. * @param otherImpostor A physics imposter used to add a joint
  24337. * @param joint The joint to add
  24338. * @returns The physics imposter
  24339. */
  24340. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24341. /**
  24342. * Add an anchor to a cloth impostor
  24343. * @param otherImpostor rigid impostor to anchor to
  24344. * @param width ratio across width from 0 to 1
  24345. * @param height ratio up height from 0 to 1
  24346. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24347. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24348. * @returns impostor the soft imposter
  24349. */
  24350. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24351. /**
  24352. * Add a hook to a rope impostor
  24353. * @param otherImpostor rigid impostor to anchor to
  24354. * @param length ratio across rope from 0 to 1
  24355. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24356. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24357. * @returns impostor the rope imposter
  24358. */
  24359. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24360. /**
  24361. * Will keep this body still, in a sleep mode.
  24362. * @returns the physics imposter
  24363. */
  24364. sleep(): PhysicsImpostor;
  24365. /**
  24366. * Wake the body up.
  24367. * @returns The physics imposter
  24368. */
  24369. wakeUp(): PhysicsImpostor;
  24370. /**
  24371. * Clones the physics imposter
  24372. * @param newObject The physics imposter clones to this physics-enabled object
  24373. * @returns A nullable physics imposter
  24374. */
  24375. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24376. /**
  24377. * Disposes the physics imposter
  24378. */
  24379. dispose(): void;
  24380. /**
  24381. * Sets the delta position
  24382. * @param position The delta position amount
  24383. */
  24384. setDeltaPosition(position: Vector3): void;
  24385. /**
  24386. * Sets the delta rotation
  24387. * @param rotation The delta rotation amount
  24388. */
  24389. setDeltaRotation(rotation: Quaternion): void;
  24390. /**
  24391. * Gets the box size of the physics imposter and stores the result in the input parameter
  24392. * @param result Stores the box size
  24393. * @returns The physics imposter
  24394. */
  24395. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24396. /**
  24397. * Gets the radius of the physics imposter
  24398. * @returns Radius of the physics imposter
  24399. */
  24400. getRadius(): number;
  24401. /**
  24402. * Sync a bone with this impostor
  24403. * @param bone The bone to sync to the impostor.
  24404. * @param boneMesh The mesh that the bone is influencing.
  24405. * @param jointPivot The pivot of the joint / bone in local space.
  24406. * @param distToJoint Optional distance from the impostor to the joint.
  24407. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24408. */
  24409. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24410. /**
  24411. * Sync impostor to a bone
  24412. * @param bone The bone that the impostor will be synced to.
  24413. * @param boneMesh The mesh that the bone is influencing.
  24414. * @param jointPivot The pivot of the joint / bone in local space.
  24415. * @param distToJoint Optional distance from the impostor to the joint.
  24416. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24417. * @param boneAxis Optional vector3 axis the bone is aligned with
  24418. */
  24419. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24420. /**
  24421. * No-Imposter type
  24422. */
  24423. static NoImpostor: number;
  24424. /**
  24425. * Sphere-Imposter type
  24426. */
  24427. static SphereImpostor: number;
  24428. /**
  24429. * Box-Imposter type
  24430. */
  24431. static BoxImpostor: number;
  24432. /**
  24433. * Plane-Imposter type
  24434. */
  24435. static PlaneImpostor: number;
  24436. /**
  24437. * Mesh-imposter type
  24438. */
  24439. static MeshImpostor: number;
  24440. /**
  24441. * Capsule-Impostor type (Ammo.js plugin only)
  24442. */
  24443. static CapsuleImpostor: number;
  24444. /**
  24445. * Cylinder-Imposter type
  24446. */
  24447. static CylinderImpostor: number;
  24448. /**
  24449. * Particle-Imposter type
  24450. */
  24451. static ParticleImpostor: number;
  24452. /**
  24453. * Heightmap-Imposter type
  24454. */
  24455. static HeightmapImpostor: number;
  24456. /**
  24457. * ConvexHull-Impostor type (Ammo.js plugin only)
  24458. */
  24459. static ConvexHullImpostor: number;
  24460. /**
  24461. * Custom-Imposter type (Ammo.js plugin only)
  24462. */
  24463. static CustomImpostor: number;
  24464. /**
  24465. * Rope-Imposter type
  24466. */
  24467. static RopeImpostor: number;
  24468. /**
  24469. * Cloth-Imposter type
  24470. */
  24471. static ClothImpostor: number;
  24472. /**
  24473. * Softbody-Imposter type
  24474. */
  24475. static SoftbodyImpostor: number;
  24476. }
  24477. }
  24478. declare module "babylonjs/Meshes/mesh" {
  24479. import { Observable } from "babylonjs/Misc/observable";
  24480. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24481. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24482. import { Camera } from "babylonjs/Cameras/camera";
  24483. import { Scene } from "babylonjs/scene";
  24484. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24485. import { Color4 } from "babylonjs/Maths/math.color";
  24486. import { Engine } from "babylonjs/Engines/engine";
  24487. import { Node } from "babylonjs/node";
  24488. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24489. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24490. import { Buffer } from "babylonjs/Meshes/buffer";
  24491. import { Geometry } from "babylonjs/Meshes/geometry";
  24492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24493. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24494. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24495. import { Effect } from "babylonjs/Materials/effect";
  24496. import { Material } from "babylonjs/Materials/material";
  24497. import { Skeleton } from "babylonjs/Bones/skeleton";
  24498. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24499. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24500. import { Path3D } from "babylonjs/Maths/math.path";
  24501. import { Plane } from "babylonjs/Maths/math.plane";
  24502. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24503. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24504. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24505. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24506. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24507. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24508. /**
  24509. * @hidden
  24510. **/
  24511. export class _CreationDataStorage {
  24512. closePath?: boolean;
  24513. closeArray?: boolean;
  24514. idx: number[];
  24515. dashSize: number;
  24516. gapSize: number;
  24517. path3D: Path3D;
  24518. pathArray: Vector3[][];
  24519. arc: number;
  24520. radius: number;
  24521. cap: number;
  24522. tessellation: number;
  24523. }
  24524. /**
  24525. * @hidden
  24526. **/
  24527. class _InstanceDataStorage {
  24528. visibleInstances: any;
  24529. batchCache: _InstancesBatch;
  24530. instancesBufferSize: number;
  24531. instancesBuffer: Nullable<Buffer>;
  24532. instancesData: Float32Array;
  24533. overridenInstanceCount: number;
  24534. isFrozen: boolean;
  24535. previousBatch: Nullable<_InstancesBatch>;
  24536. hardwareInstancedRendering: boolean;
  24537. sideOrientation: number;
  24538. manualUpdate: boolean;
  24539. }
  24540. /**
  24541. * @hidden
  24542. **/
  24543. export class _InstancesBatch {
  24544. mustReturn: boolean;
  24545. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24546. renderSelf: boolean[];
  24547. hardwareInstancedRendering: boolean[];
  24548. }
  24549. /**
  24550. * Class used to represent renderable models
  24551. */
  24552. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24553. /**
  24554. * Mesh side orientation : usually the external or front surface
  24555. */
  24556. static readonly FRONTSIDE: number;
  24557. /**
  24558. * Mesh side orientation : usually the internal or back surface
  24559. */
  24560. static readonly BACKSIDE: number;
  24561. /**
  24562. * Mesh side orientation : both internal and external or front and back surfaces
  24563. */
  24564. static readonly DOUBLESIDE: number;
  24565. /**
  24566. * Mesh side orientation : by default, `FRONTSIDE`
  24567. */
  24568. static readonly DEFAULTSIDE: number;
  24569. /**
  24570. * Mesh cap setting : no cap
  24571. */
  24572. static readonly NO_CAP: number;
  24573. /**
  24574. * Mesh cap setting : one cap at the beginning of the mesh
  24575. */
  24576. static readonly CAP_START: number;
  24577. /**
  24578. * Mesh cap setting : one cap at the end of the mesh
  24579. */
  24580. static readonly CAP_END: number;
  24581. /**
  24582. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24583. */
  24584. static readonly CAP_ALL: number;
  24585. /**
  24586. * Mesh pattern setting : no flip or rotate
  24587. */
  24588. static readonly NO_FLIP: number;
  24589. /**
  24590. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24591. */
  24592. static readonly FLIP_TILE: number;
  24593. /**
  24594. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24595. */
  24596. static readonly ROTATE_TILE: number;
  24597. /**
  24598. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24599. */
  24600. static readonly FLIP_ROW: number;
  24601. /**
  24602. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24603. */
  24604. static readonly ROTATE_ROW: number;
  24605. /**
  24606. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24607. */
  24608. static readonly FLIP_N_ROTATE_TILE: number;
  24609. /**
  24610. * Mesh pattern setting : rotate pattern and rotate
  24611. */
  24612. static readonly FLIP_N_ROTATE_ROW: number;
  24613. /**
  24614. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24615. */
  24616. static readonly CENTER: number;
  24617. /**
  24618. * Mesh tile positioning : part tiles on left
  24619. */
  24620. static readonly LEFT: number;
  24621. /**
  24622. * Mesh tile positioning : part tiles on right
  24623. */
  24624. static readonly RIGHT: number;
  24625. /**
  24626. * Mesh tile positioning : part tiles on top
  24627. */
  24628. static readonly TOP: number;
  24629. /**
  24630. * Mesh tile positioning : part tiles on bottom
  24631. */
  24632. static readonly BOTTOM: number;
  24633. /**
  24634. * Gets the default side orientation.
  24635. * @param orientation the orientation to value to attempt to get
  24636. * @returns the default orientation
  24637. * @hidden
  24638. */
  24639. static _GetDefaultSideOrientation(orientation?: number): number;
  24640. private _internalMeshDataInfo;
  24641. /**
  24642. * An event triggered before rendering the mesh
  24643. */
  24644. readonly onBeforeRenderObservable: Observable<Mesh>;
  24645. /**
  24646. * An event triggered before binding the mesh
  24647. */
  24648. readonly onBeforeBindObservable: Observable<Mesh>;
  24649. /**
  24650. * An event triggered after rendering the mesh
  24651. */
  24652. readonly onAfterRenderObservable: Observable<Mesh>;
  24653. /**
  24654. * An event triggered before drawing the mesh
  24655. */
  24656. readonly onBeforeDrawObservable: Observable<Mesh>;
  24657. private _onBeforeDrawObserver;
  24658. /**
  24659. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24660. */
  24661. onBeforeDraw: () => void;
  24662. readonly hasInstances: boolean;
  24663. /**
  24664. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24665. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24666. */
  24667. delayLoadState: number;
  24668. /**
  24669. * Gets the list of instances created from this mesh
  24670. * it is not supposed to be modified manually.
  24671. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24672. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24673. */
  24674. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24675. /**
  24676. * Gets the file containing delay loading data for this mesh
  24677. */
  24678. delayLoadingFile: string;
  24679. /** @hidden */
  24680. _binaryInfo: any;
  24681. /**
  24682. * User defined function used to change how LOD level selection is done
  24683. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24684. */
  24685. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24686. /**
  24687. * Gets or sets the morph target manager
  24688. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24689. */
  24690. morphTargetManager: Nullable<MorphTargetManager>;
  24691. /** @hidden */
  24692. _creationDataStorage: Nullable<_CreationDataStorage>;
  24693. /** @hidden */
  24694. _geometry: Nullable<Geometry>;
  24695. /** @hidden */
  24696. _delayInfo: Array<string>;
  24697. /** @hidden */
  24698. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24699. /** @hidden */
  24700. _instanceDataStorage: _InstanceDataStorage;
  24701. private _effectiveMaterial;
  24702. /** @hidden */
  24703. _shouldGenerateFlatShading: boolean;
  24704. /** @hidden */
  24705. _originalBuilderSideOrientation: number;
  24706. /**
  24707. * Use this property to change the original side orientation defined at construction time
  24708. */
  24709. overrideMaterialSideOrientation: Nullable<number>;
  24710. /**
  24711. * Gets the source mesh (the one used to clone this one from)
  24712. */
  24713. readonly source: Nullable<Mesh>;
  24714. /**
  24715. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24716. */
  24717. isUnIndexed: boolean;
  24718. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24719. readonly worldMatrixInstancedBuffer: Float32Array;
  24720. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24721. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24722. /**
  24723. * @constructor
  24724. * @param name The value used by scene.getMeshByName() to do a lookup.
  24725. * @param scene The scene to add this mesh to.
  24726. * @param parent The parent of this mesh, if it has one
  24727. * @param source An optional Mesh from which geometry is shared, cloned.
  24728. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24729. * When false, achieved by calling a clone(), also passing False.
  24730. * This will make creation of children, recursive.
  24731. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24732. */
  24733. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24734. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24735. doNotInstantiate: boolean;
  24736. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24737. /**
  24738. * Gets the class name
  24739. * @returns the string "Mesh".
  24740. */
  24741. getClassName(): string;
  24742. /** @hidden */
  24743. readonly _isMesh: boolean;
  24744. /**
  24745. * Returns a description of this mesh
  24746. * @param fullDetails define if full details about this mesh must be used
  24747. * @returns a descriptive string representing this mesh
  24748. */
  24749. toString(fullDetails?: boolean): string;
  24750. /** @hidden */
  24751. _unBindEffect(): void;
  24752. /**
  24753. * Gets a boolean indicating if this mesh has LOD
  24754. */
  24755. readonly hasLODLevels: boolean;
  24756. /**
  24757. * Gets the list of MeshLODLevel associated with the current mesh
  24758. * @returns an array of MeshLODLevel
  24759. */
  24760. getLODLevels(): MeshLODLevel[];
  24761. private _sortLODLevels;
  24762. /**
  24763. * Add a mesh as LOD level triggered at the given distance.
  24764. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24765. * @param distance The distance from the center of the object to show this level
  24766. * @param mesh The mesh to be added as LOD level (can be null)
  24767. * @return This mesh (for chaining)
  24768. */
  24769. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24770. /**
  24771. * Returns the LOD level mesh at the passed distance or null if not found.
  24772. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24773. * @param distance The distance from the center of the object to show this level
  24774. * @returns a Mesh or `null`
  24775. */
  24776. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24777. /**
  24778. * Remove a mesh from the LOD array
  24779. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24780. * @param mesh defines the mesh to be removed
  24781. * @return This mesh (for chaining)
  24782. */
  24783. removeLODLevel(mesh: Mesh): Mesh;
  24784. /**
  24785. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24786. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24787. * @param camera defines the camera to use to compute distance
  24788. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24789. * @return This mesh (for chaining)
  24790. */
  24791. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24792. /**
  24793. * Gets the mesh internal Geometry object
  24794. */
  24795. readonly geometry: Nullable<Geometry>;
  24796. /**
  24797. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24798. * @returns the total number of vertices
  24799. */
  24800. getTotalVertices(): number;
  24801. /**
  24802. * Returns the content of an associated vertex buffer
  24803. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24804. * - VertexBuffer.PositionKind
  24805. * - VertexBuffer.UVKind
  24806. * - VertexBuffer.UV2Kind
  24807. * - VertexBuffer.UV3Kind
  24808. * - VertexBuffer.UV4Kind
  24809. * - VertexBuffer.UV5Kind
  24810. * - VertexBuffer.UV6Kind
  24811. * - VertexBuffer.ColorKind
  24812. * - VertexBuffer.MatricesIndicesKind
  24813. * - VertexBuffer.MatricesIndicesExtraKind
  24814. * - VertexBuffer.MatricesWeightsKind
  24815. * - VertexBuffer.MatricesWeightsExtraKind
  24816. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  24817. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24818. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24819. */
  24820. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24821. /**
  24822. * Returns the mesh VertexBuffer object from the requested `kind`
  24823. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24824. * - VertexBuffer.PositionKind
  24825. * - VertexBuffer.NormalKind
  24826. * - VertexBuffer.UVKind
  24827. * - VertexBuffer.UV2Kind
  24828. * - VertexBuffer.UV3Kind
  24829. * - VertexBuffer.UV4Kind
  24830. * - VertexBuffer.UV5Kind
  24831. * - VertexBuffer.UV6Kind
  24832. * - VertexBuffer.ColorKind
  24833. * - VertexBuffer.MatricesIndicesKind
  24834. * - VertexBuffer.MatricesIndicesExtraKind
  24835. * - VertexBuffer.MatricesWeightsKind
  24836. * - VertexBuffer.MatricesWeightsExtraKind
  24837. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24838. */
  24839. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24840. /**
  24841. * Tests if a specific vertex buffer is associated with this mesh
  24842. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24843. * - VertexBuffer.PositionKind
  24844. * - VertexBuffer.NormalKind
  24845. * - VertexBuffer.UVKind
  24846. * - VertexBuffer.UV2Kind
  24847. * - VertexBuffer.UV3Kind
  24848. * - VertexBuffer.UV4Kind
  24849. * - VertexBuffer.UV5Kind
  24850. * - VertexBuffer.UV6Kind
  24851. * - VertexBuffer.ColorKind
  24852. * - VertexBuffer.MatricesIndicesKind
  24853. * - VertexBuffer.MatricesIndicesExtraKind
  24854. * - VertexBuffer.MatricesWeightsKind
  24855. * - VertexBuffer.MatricesWeightsExtraKind
  24856. * @returns a boolean
  24857. */
  24858. isVerticesDataPresent(kind: string): boolean;
  24859. /**
  24860. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24861. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24862. * - VertexBuffer.PositionKind
  24863. * - VertexBuffer.UVKind
  24864. * - VertexBuffer.UV2Kind
  24865. * - VertexBuffer.UV3Kind
  24866. * - VertexBuffer.UV4Kind
  24867. * - VertexBuffer.UV5Kind
  24868. * - VertexBuffer.UV6Kind
  24869. * - VertexBuffer.ColorKind
  24870. * - VertexBuffer.MatricesIndicesKind
  24871. * - VertexBuffer.MatricesIndicesExtraKind
  24872. * - VertexBuffer.MatricesWeightsKind
  24873. * - VertexBuffer.MatricesWeightsExtraKind
  24874. * @returns a boolean
  24875. */
  24876. isVertexBufferUpdatable(kind: string): boolean;
  24877. /**
  24878. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24879. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24880. * - VertexBuffer.PositionKind
  24881. * - VertexBuffer.NormalKind
  24882. * - VertexBuffer.UVKind
  24883. * - VertexBuffer.UV2Kind
  24884. * - VertexBuffer.UV3Kind
  24885. * - VertexBuffer.UV4Kind
  24886. * - VertexBuffer.UV5Kind
  24887. * - VertexBuffer.UV6Kind
  24888. * - VertexBuffer.ColorKind
  24889. * - VertexBuffer.MatricesIndicesKind
  24890. * - VertexBuffer.MatricesIndicesExtraKind
  24891. * - VertexBuffer.MatricesWeightsKind
  24892. * - VertexBuffer.MatricesWeightsExtraKind
  24893. * @returns an array of strings
  24894. */
  24895. getVerticesDataKinds(): string[];
  24896. /**
  24897. * Returns a positive integer : the total number of indices in this mesh geometry.
  24898. * @returns the numner of indices or zero if the mesh has no geometry.
  24899. */
  24900. getTotalIndices(): number;
  24901. /**
  24902. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24903. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24904. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24905. * @returns the indices array or an empty array if the mesh has no geometry
  24906. */
  24907. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24908. readonly isBlocked: boolean;
  24909. /**
  24910. * Determine if the current mesh is ready to be rendered
  24911. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24912. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24913. * @returns true if all associated assets are ready (material, textures, shaders)
  24914. */
  24915. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24916. /**
  24917. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  24918. */
  24919. readonly areNormalsFrozen: boolean;
  24920. /**
  24921. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24922. * @returns the current mesh
  24923. */
  24924. freezeNormals(): Mesh;
  24925. /**
  24926. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  24927. * @returns the current mesh
  24928. */
  24929. unfreezeNormals(): Mesh;
  24930. /**
  24931. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24932. */
  24933. overridenInstanceCount: number;
  24934. /** @hidden */
  24935. _preActivate(): Mesh;
  24936. /** @hidden */
  24937. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24938. /** @hidden */
  24939. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24940. /**
  24941. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24942. * This means the mesh underlying bounding box and sphere are recomputed.
  24943. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24944. * @returns the current mesh
  24945. */
  24946. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24947. /** @hidden */
  24948. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24949. /**
  24950. * This function will subdivide the mesh into multiple submeshes
  24951. * @param count defines the expected number of submeshes
  24952. */
  24953. subdivide(count: number): void;
  24954. /**
  24955. * Copy a FloatArray into a specific associated vertex buffer
  24956. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24957. * - VertexBuffer.PositionKind
  24958. * - VertexBuffer.UVKind
  24959. * - VertexBuffer.UV2Kind
  24960. * - VertexBuffer.UV3Kind
  24961. * - VertexBuffer.UV4Kind
  24962. * - VertexBuffer.UV5Kind
  24963. * - VertexBuffer.UV6Kind
  24964. * - VertexBuffer.ColorKind
  24965. * - VertexBuffer.MatricesIndicesKind
  24966. * - VertexBuffer.MatricesIndicesExtraKind
  24967. * - VertexBuffer.MatricesWeightsKind
  24968. * - VertexBuffer.MatricesWeightsExtraKind
  24969. * @param data defines the data source
  24970. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24971. * @param stride defines the data stride size (can be null)
  24972. * @returns the current mesh
  24973. */
  24974. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24975. /**
  24976. * Delete a vertex buffer associated with this mesh
  24977. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24978. * - VertexBuffer.PositionKind
  24979. * - VertexBuffer.UVKind
  24980. * - VertexBuffer.UV2Kind
  24981. * - VertexBuffer.UV3Kind
  24982. * - VertexBuffer.UV4Kind
  24983. * - VertexBuffer.UV5Kind
  24984. * - VertexBuffer.UV6Kind
  24985. * - VertexBuffer.ColorKind
  24986. * - VertexBuffer.MatricesIndicesKind
  24987. * - VertexBuffer.MatricesIndicesExtraKind
  24988. * - VertexBuffer.MatricesWeightsKind
  24989. * - VertexBuffer.MatricesWeightsExtraKind
  24990. */
  24991. removeVerticesData(kind: string): void;
  24992. /**
  24993. * Flags an associated vertex buffer as updatable
  24994. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24995. * - VertexBuffer.PositionKind
  24996. * - VertexBuffer.UVKind
  24997. * - VertexBuffer.UV2Kind
  24998. * - VertexBuffer.UV3Kind
  24999. * - VertexBuffer.UV4Kind
  25000. * - VertexBuffer.UV5Kind
  25001. * - VertexBuffer.UV6Kind
  25002. * - VertexBuffer.ColorKind
  25003. * - VertexBuffer.MatricesIndicesKind
  25004. * - VertexBuffer.MatricesIndicesExtraKind
  25005. * - VertexBuffer.MatricesWeightsKind
  25006. * - VertexBuffer.MatricesWeightsExtraKind
  25007. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25008. */
  25009. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25010. /**
  25011. * Sets the mesh global Vertex Buffer
  25012. * @param buffer defines the buffer to use
  25013. * @returns the current mesh
  25014. */
  25015. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25016. /**
  25017. * Update a specific associated vertex buffer
  25018. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25019. * - VertexBuffer.PositionKind
  25020. * - VertexBuffer.UVKind
  25021. * - VertexBuffer.UV2Kind
  25022. * - VertexBuffer.UV3Kind
  25023. * - VertexBuffer.UV4Kind
  25024. * - VertexBuffer.UV5Kind
  25025. * - VertexBuffer.UV6Kind
  25026. * - VertexBuffer.ColorKind
  25027. * - VertexBuffer.MatricesIndicesKind
  25028. * - VertexBuffer.MatricesIndicesExtraKind
  25029. * - VertexBuffer.MatricesWeightsKind
  25030. * - VertexBuffer.MatricesWeightsExtraKind
  25031. * @param data defines the data source
  25032. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25033. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  25034. * @returns the current mesh
  25035. */
  25036. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25037. /**
  25038. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25039. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25040. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25041. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25042. * @returns the current mesh
  25043. */
  25044. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25045. /**
  25046. * Creates a un-shared specific occurence of the geometry for the mesh.
  25047. * @returns the current mesh
  25048. */
  25049. makeGeometryUnique(): Mesh;
  25050. /**
  25051. * Set the index buffer of this mesh
  25052. * @param indices defines the source data
  25053. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25054. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25055. * @returns the current mesh
  25056. */
  25057. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25058. /**
  25059. * Update the current index buffer
  25060. * @param indices defines the source data
  25061. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25062. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25063. * @returns the current mesh
  25064. */
  25065. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25066. /**
  25067. * Invert the geometry to move from a right handed system to a left handed one.
  25068. * @returns the current mesh
  25069. */
  25070. toLeftHanded(): Mesh;
  25071. /** @hidden */
  25072. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25073. /** @hidden */
  25074. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25075. /**
  25076. * Registers for this mesh a javascript function called just before the rendering process
  25077. * @param func defines the function to call before rendering this mesh
  25078. * @returns the current mesh
  25079. */
  25080. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25081. /**
  25082. * Disposes a previously registered javascript function called before the rendering
  25083. * @param func defines the function to remove
  25084. * @returns the current mesh
  25085. */
  25086. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25087. /**
  25088. * Registers for this mesh a javascript function called just after the rendering is complete
  25089. * @param func defines the function to call after rendering this mesh
  25090. * @returns the current mesh
  25091. */
  25092. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25093. /**
  25094. * Disposes a previously registered javascript function called after the rendering.
  25095. * @param func defines the function to remove
  25096. * @returns the current mesh
  25097. */
  25098. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25099. /** @hidden */
  25100. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25101. /** @hidden */
  25102. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25103. /** @hidden */
  25104. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25105. /** @hidden */
  25106. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25107. /** @hidden */
  25108. _rebuild(): void;
  25109. /** @hidden */
  25110. _freeze(): void;
  25111. /** @hidden */
  25112. _unFreeze(): void;
  25113. /**
  25114. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  25115. * @param subMesh defines the subMesh to render
  25116. * @param enableAlphaMode defines if alpha mode can be changed
  25117. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25118. * @returns the current mesh
  25119. */
  25120. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25121. private _onBeforeDraw;
  25122. /**
  25123. * Renormalize the mesh and patch it up if there are no weights
  25124. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25125. * However in the case of zero weights then we set just a single influence to 1.
  25126. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25127. */
  25128. cleanMatrixWeights(): void;
  25129. private normalizeSkinFourWeights;
  25130. private normalizeSkinWeightsAndExtra;
  25131. /**
  25132. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25133. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25134. * the user know there was an issue with importing the mesh
  25135. * @returns a validation object with skinned, valid and report string
  25136. */
  25137. validateSkinning(): {
  25138. skinned: boolean;
  25139. valid: boolean;
  25140. report: string;
  25141. };
  25142. /** @hidden */
  25143. _checkDelayState(): Mesh;
  25144. private _queueLoad;
  25145. /**
  25146. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25147. * A mesh is in the frustum if its bounding box intersects the frustum
  25148. * @param frustumPlanes defines the frustum to test
  25149. * @returns true if the mesh is in the frustum planes
  25150. */
  25151. isInFrustum(frustumPlanes: Plane[]): boolean;
  25152. /**
  25153. * Sets the mesh material by the material or multiMaterial `id` property
  25154. * @param id is a string identifying the material or the multiMaterial
  25155. * @returns the current mesh
  25156. */
  25157. setMaterialByID(id: string): Mesh;
  25158. /**
  25159. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25160. * @returns an array of IAnimatable
  25161. */
  25162. getAnimatables(): IAnimatable[];
  25163. /**
  25164. * Modifies the mesh geometry according to the passed transformation matrix.
  25165. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25166. * The mesh normals are modified using the same transformation.
  25167. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25168. * @param transform defines the transform matrix to use
  25169. * @see http://doc.babylonjs.com/resources/baking_transformations
  25170. * @returns the current mesh
  25171. */
  25172. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25173. /**
  25174. * Modifies the mesh geometry according to its own current World Matrix.
  25175. * The mesh World Matrix is then reset.
  25176. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25177. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25178. * @see http://doc.babylonjs.com/resources/baking_transformations
  25179. * @returns the current mesh
  25180. */
  25181. bakeCurrentTransformIntoVertices(): Mesh;
  25182. /** @hidden */
  25183. readonly _positions: Nullable<Vector3[]>;
  25184. /** @hidden */
  25185. _resetPointsArrayCache(): Mesh;
  25186. /** @hidden */
  25187. _generatePointsArray(): boolean;
  25188. /**
  25189. * Returns a new Mesh object generated from the current mesh properties.
  25190. * This method must not get confused with createInstance()
  25191. * @param name is a string, the name given to the new mesh
  25192. * @param newParent can be any Node object (default `null`)
  25193. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25194. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25195. * @returns a new mesh
  25196. */
  25197. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25198. /**
  25199. * Releases resources associated with this mesh.
  25200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25202. */
  25203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25204. /** @hidden */
  25205. _disposeInstanceSpecificData(): void;
  25206. /**
  25207. * Modifies the mesh geometry according to a displacement map.
  25208. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25209. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25210. * @param url is a string, the URL from the image file is to be downloaded.
  25211. * @param minHeight is the lower limit of the displacement.
  25212. * @param maxHeight is the upper limit of the displacement.
  25213. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25214. * @param uvOffset is an optional vector2 used to offset UV.
  25215. * @param uvScale is an optional vector2 used to scale UV.
  25216. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25217. * @returns the Mesh.
  25218. */
  25219. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25220. /**
  25221. * Modifies the mesh geometry according to a displacementMap buffer.
  25222. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25223. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25224. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25225. * @param heightMapWidth is the width of the buffer image.
  25226. * @param heightMapHeight is the height of the buffer image.
  25227. * @param minHeight is the lower limit of the displacement.
  25228. * @param maxHeight is the upper limit of the displacement.
  25229. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25230. * @param uvOffset is an optional vector2 used to offset UV.
  25231. * @param uvScale is an optional vector2 used to scale UV.
  25232. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25233. * @returns the Mesh.
  25234. */
  25235. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25236. /**
  25237. * Modify the mesh to get a flat shading rendering.
  25238. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25239. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25240. * @returns current mesh
  25241. */
  25242. convertToFlatShadedMesh(): Mesh;
  25243. /**
  25244. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25245. * In other words, more vertices, no more indices and a single bigger VBO.
  25246. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25247. * @returns current mesh
  25248. */
  25249. convertToUnIndexedMesh(): Mesh;
  25250. /**
  25251. * Inverses facet orientations.
  25252. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25253. * @param flipNormals will also inverts the normals
  25254. * @returns current mesh
  25255. */
  25256. flipFaces(flipNormals?: boolean): Mesh;
  25257. /**
  25258. * Increase the number of facets and hence vertices in a mesh
  25259. * Vertex normals are interpolated from existing vertex normals
  25260. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25261. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25262. */
  25263. increaseVertices(numberPerEdge: number): void;
  25264. /**
  25265. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25266. * This will undo any application of covertToFlatShadedMesh
  25267. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25268. */
  25269. forceSharedVertices(): void;
  25270. /** @hidden */
  25271. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25272. /** @hidden */
  25273. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25274. /**
  25275. * Creates a new InstancedMesh object from the mesh model.
  25276. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25277. * @param name defines the name of the new instance
  25278. * @returns a new InstancedMesh
  25279. */
  25280. createInstance(name: string): InstancedMesh;
  25281. /**
  25282. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25283. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25284. * @returns the current mesh
  25285. */
  25286. synchronizeInstances(): Mesh;
  25287. /**
  25288. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25289. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25290. * This should be used together with the simplification to avoid disappearing triangles.
  25291. * @param successCallback an optional success callback to be called after the optimization finished.
  25292. * @returns the current mesh
  25293. */
  25294. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25295. /**
  25296. * Serialize current mesh
  25297. * @param serializationObject defines the object which will receive the serialization data
  25298. */
  25299. serialize(serializationObject: any): void;
  25300. /** @hidden */
  25301. _syncGeometryWithMorphTargetManager(): void;
  25302. /** @hidden */
  25303. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25304. /**
  25305. * Returns a new Mesh object parsed from the source provided.
  25306. * @param parsedMesh is the source
  25307. * @param scene defines the hosting scene
  25308. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25309. * @returns a new Mesh
  25310. */
  25311. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25312. /**
  25313. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25314. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25315. * @param name defines the name of the mesh to create
  25316. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25317. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25318. * @param closePath creates a seam between the first and the last points of each path of the path array
  25319. * @param offset is taken in account only if the `pathArray` is containing a single path
  25320. * @param scene defines the hosting scene
  25321. * @param updatable defines if the mesh must be flagged as updatable
  25322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25323. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  25324. * @returns a new Mesh
  25325. */
  25326. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25327. /**
  25328. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25329. * @param name defines the name of the mesh to create
  25330. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25331. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25332. * @param scene defines the hosting scene
  25333. * @param updatable defines if the mesh must be flagged as updatable
  25334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25335. * @returns a new Mesh
  25336. */
  25337. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25338. /**
  25339. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25340. * @param name defines the name of the mesh to create
  25341. * @param size sets the size (float) of each box side (default 1)
  25342. * @param scene defines the hosting scene
  25343. * @param updatable defines if the mesh must be flagged as updatable
  25344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25345. * @returns a new Mesh
  25346. */
  25347. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25348. /**
  25349. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25350. * @param name defines the name of the mesh to create
  25351. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25352. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25353. * @param scene defines the hosting scene
  25354. * @param updatable defines if the mesh must be flagged as updatable
  25355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25356. * @returns a new Mesh
  25357. */
  25358. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25359. /**
  25360. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25361. * @param name defines the name of the mesh to create
  25362. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25363. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25364. * @param scene defines the hosting scene
  25365. * @returns a new Mesh
  25366. */
  25367. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25368. /**
  25369. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25370. * @param name defines the name of the mesh to create
  25371. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25372. * @param diameterTop set the top cap diameter (floats, default 1)
  25373. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25374. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25375. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25376. * @param scene defines the hosting scene
  25377. * @param updatable defines if the mesh must be flagged as updatable
  25378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25379. * @returns a new Mesh
  25380. */
  25381. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25382. /**
  25383. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25384. * @param name defines the name of the mesh to create
  25385. * @param diameter sets the diameter size (float) of the torus (default 1)
  25386. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25387. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25388. * @param scene defines the hosting scene
  25389. * @param updatable defines if the mesh must be flagged as updatable
  25390. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25391. * @returns a new Mesh
  25392. */
  25393. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25394. /**
  25395. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25396. * @param name defines the name of the mesh to create
  25397. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25398. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25399. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25400. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25401. * @param p the number of windings on X axis (positive integers, default 2)
  25402. * @param q the number of windings on Y axis (positive integers, default 3)
  25403. * @param scene defines the hosting scene
  25404. * @param updatable defines if the mesh must be flagged as updatable
  25405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25406. * @returns a new Mesh
  25407. */
  25408. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25409. /**
  25410. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25411. * @param name defines the name of the mesh to create
  25412. * @param points is an array successive Vector3
  25413. * @param scene defines the hosting scene
  25414. * @param updatable defines if the mesh must be flagged as updatable
  25415. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  25416. * @returns a new Mesh
  25417. */
  25418. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25419. /**
  25420. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25421. * @param name defines the name of the mesh to create
  25422. * @param points is an array successive Vector3
  25423. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25424. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25425. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25426. * @param scene defines the hosting scene
  25427. * @param updatable defines if the mesh must be flagged as updatable
  25428. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  25429. * @returns a new Mesh
  25430. */
  25431. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25432. /**
  25433. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25434. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25435. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  25436. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25437. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25438. * Remember you can only change the shape positions, not their number when updating a polygon.
  25439. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25440. * @param name defines the name of the mesh to create
  25441. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25442. * @param scene defines the hosting scene
  25443. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25444. * @param updatable defines if the mesh must be flagged as updatable
  25445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25446. * @param earcutInjection can be used to inject your own earcut reference
  25447. * @returns a new Mesh
  25448. */
  25449. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25450. /**
  25451. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25452. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25453. * @param name defines the name of the mesh to create
  25454. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25455. * @param depth defines the height of extrusion
  25456. * @param scene defines the hosting scene
  25457. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25458. * @param updatable defines if the mesh must be flagged as updatable
  25459. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25460. * @param earcutInjection can be used to inject your own earcut reference
  25461. * @returns a new Mesh
  25462. */
  25463. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25464. /**
  25465. * Creates an extruded shape mesh.
  25466. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  25467. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25468. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25469. * @param name defines the name of the mesh to create
  25470. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25471. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25472. * @param scale is the value to scale the shape
  25473. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  25474. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25475. * @param scene defines the hosting scene
  25476. * @param updatable defines if the mesh must be flagged as updatable
  25477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25478. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  25479. * @returns a new Mesh
  25480. */
  25481. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25482. /**
  25483. * Creates an custom extruded shape mesh.
  25484. * The custom extrusion is a parametric shape.
  25485. * It has no predefined shape. Its final shape will depend on the input parameters.
  25486. * Please consider using the same method from the MeshBuilder class instead
  25487. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25488. * @param name defines the name of the mesh to create
  25489. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25490. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25491. * @param scaleFunction is a custom Javascript function called on each path point
  25492. * @param rotationFunction is a custom Javascript function called on each path point
  25493. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25494. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25495. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25496. * @param scene defines the hosting scene
  25497. * @param updatable defines if the mesh must be flagged as updatable
  25498. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25499. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  25500. * @returns a new Mesh
  25501. */
  25502. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25503. /**
  25504. * Creates lathe mesh.
  25505. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25506. * Please consider using the same method from the MeshBuilder class instead
  25507. * @param name defines the name of the mesh to create
  25508. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  25509. * @param radius is the radius value of the lathe
  25510. * @param tessellation is the side number of the lathe.
  25511. * @param scene defines the hosting scene
  25512. * @param updatable defines if the mesh must be flagged as updatable
  25513. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25514. * @returns a new Mesh
  25515. */
  25516. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25517. /**
  25518. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25519. * @param name defines the name of the mesh to create
  25520. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25521. * @param scene defines the hosting scene
  25522. * @param updatable defines if the mesh must be flagged as updatable
  25523. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25524. * @returns a new Mesh
  25525. */
  25526. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25527. /**
  25528. * Creates a ground mesh.
  25529. * Please consider using the same method from the MeshBuilder class instead
  25530. * @param name defines the name of the mesh to create
  25531. * @param width set the width of the ground
  25532. * @param height set the height of the ground
  25533. * @param subdivisions sets the number of subdivisions per side
  25534. * @param scene defines the hosting scene
  25535. * @param updatable defines if the mesh must be flagged as updatable
  25536. * @returns a new Mesh
  25537. */
  25538. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25539. /**
  25540. * Creates a tiled ground mesh.
  25541. * Please consider using the same method from the MeshBuilder class instead
  25542. * @param name defines the name of the mesh to create
  25543. * @param xmin set the ground minimum X coordinate
  25544. * @param zmin set the ground minimum Y coordinate
  25545. * @param xmax set the ground maximum X coordinate
  25546. * @param zmax set the ground maximum Z coordinate
  25547. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  25548. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  25549. * @param scene defines the hosting scene
  25550. * @param updatable defines if the mesh must be flagged as updatable
  25551. * @returns a new Mesh
  25552. */
  25553. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25554. w: number;
  25555. h: number;
  25556. }, precision: {
  25557. w: number;
  25558. h: number;
  25559. }, scene: Scene, updatable?: boolean): Mesh;
  25560. /**
  25561. * Creates a ground mesh from a height map.
  25562. * Please consider using the same method from the MeshBuilder class instead
  25563. * @see http://doc.babylonjs.com/babylon101/height_map
  25564. * @param name defines the name of the mesh to create
  25565. * @param url sets the URL of the height map image resource
  25566. * @param width set the ground width size
  25567. * @param height set the ground height size
  25568. * @param subdivisions sets the number of subdivision per side
  25569. * @param minHeight is the minimum altitude on the ground
  25570. * @param maxHeight is the maximum altitude on the ground
  25571. * @param scene defines the hosting scene
  25572. * @param updatable defines if the mesh must be flagged as updatable
  25573. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25574. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25575. * @returns a new Mesh
  25576. */
  25577. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  25578. /**
  25579. * Creates a tube mesh.
  25580. * The tube is a parametric shape.
  25581. * It has no predefined shape. Its final shape will depend on the input parameters.
  25582. * Please consider using the same method from the MeshBuilder class instead
  25583. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25584. * @param name defines the name of the mesh to create
  25585. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25586. * @param radius sets the tube radius size
  25587. * @param tessellation is the number of sides on the tubular surface
  25588. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  25589. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25590. * @param scene defines the hosting scene
  25591. * @param updatable defines if the mesh must be flagged as updatable
  25592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25593. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  25594. * @returns a new Mesh
  25595. */
  25596. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25597. (i: number, distance: number): number;
  25598. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25599. /**
  25600. * Creates a polyhedron mesh.
  25601. * Please consider using the same method from the MeshBuilder class instead.
  25602. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  25603. * * The parameter `size` (positive float, default 1) sets the polygon size
  25604. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25605. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  25606. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  25607. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  25608. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  25609. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  25610. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25613. * @param name defines the name of the mesh to create
  25614. * @param options defines the options used to create the mesh
  25615. * @param scene defines the hosting scene
  25616. * @returns a new Mesh
  25617. */
  25618. static CreatePolyhedron(name: string, options: {
  25619. type?: number;
  25620. size?: number;
  25621. sizeX?: number;
  25622. sizeY?: number;
  25623. sizeZ?: number;
  25624. custom?: any;
  25625. faceUV?: Vector4[];
  25626. faceColors?: Color4[];
  25627. updatable?: boolean;
  25628. sideOrientation?: number;
  25629. }, scene: Scene): Mesh;
  25630. /**
  25631. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25632. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25633. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  25634. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25635. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  25636. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25639. * @param name defines the name of the mesh
  25640. * @param options defines the options used to create the mesh
  25641. * @param scene defines the hosting scene
  25642. * @returns a new Mesh
  25643. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25644. */
  25645. static CreateIcoSphere(name: string, options: {
  25646. radius?: number;
  25647. flat?: boolean;
  25648. subdivisions?: number;
  25649. sideOrientation?: number;
  25650. updatable?: boolean;
  25651. }, scene: Scene): Mesh;
  25652. /**
  25653. * Creates a decal mesh.
  25654. * Please consider using the same method from the MeshBuilder class instead.
  25655. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25656. * @param name defines the name of the mesh
  25657. * @param sourceMesh defines the mesh receiving the decal
  25658. * @param position sets the position of the decal in world coordinates
  25659. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25660. * @param size sets the decal scaling
  25661. * @param angle sets the angle to rotate the decal
  25662. * @returns a new Mesh
  25663. */
  25664. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25665. /**
  25666. * Prepare internal position array for software CPU skinning
  25667. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25668. */
  25669. setPositionsForCPUSkinning(): Float32Array;
  25670. /**
  25671. * Prepare internal normal array for software CPU skinning
  25672. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25673. */
  25674. setNormalsForCPUSkinning(): Float32Array;
  25675. /**
  25676. * Updates the vertex buffer by applying transformation from the bones
  25677. * @param skeleton defines the skeleton to apply to current mesh
  25678. * @returns the current mesh
  25679. */
  25680. applySkeleton(skeleton: Skeleton): Mesh;
  25681. /**
  25682. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  25683. * @param meshes defines the list of meshes to scan
  25684. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25685. */
  25686. static MinMax(meshes: AbstractMesh[]): {
  25687. min: Vector3;
  25688. max: Vector3;
  25689. };
  25690. /**
  25691. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25692. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25693. * @returns a vector3
  25694. */
  25695. static Center(meshesOrMinMaxVector: {
  25696. min: Vector3;
  25697. max: Vector3;
  25698. } | AbstractMesh[]): Vector3;
  25699. /**
  25700. * Merge the array of meshes into a single mesh for performance reasons.
  25701. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25702. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25703. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25704. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25705. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25706. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25707. * @returns a new mesh
  25708. */
  25709. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25710. /** @hidden */
  25711. addInstance(instance: InstancedMesh): void;
  25712. /** @hidden */
  25713. removeInstance(instance: InstancedMesh): void;
  25714. }
  25715. }
  25716. declare module "babylonjs/Cameras/camera" {
  25717. import { SmartArray } from "babylonjs/Misc/smartArray";
  25718. import { Observable } from "babylonjs/Misc/observable";
  25719. import { Nullable } from "babylonjs/types";
  25720. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25721. import { Scene } from "babylonjs/scene";
  25722. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25723. import { Node } from "babylonjs/node";
  25724. import { Mesh } from "babylonjs/Meshes/mesh";
  25725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25726. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25727. import { Viewport } from "babylonjs/Maths/math.viewport";
  25728. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25729. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25730. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25731. import { Ray } from "babylonjs/Culling/ray";
  25732. /**
  25733. * This is the base class of all the camera used in the application.
  25734. * @see http://doc.babylonjs.com/features/cameras
  25735. */
  25736. export class Camera extends Node {
  25737. /** @hidden */
  25738. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25739. /**
  25740. * This is the default projection mode used by the cameras.
  25741. * It helps recreating a feeling of perspective and better appreciate depth.
  25742. * This is the best way to simulate real life cameras.
  25743. */
  25744. static readonly PERSPECTIVE_CAMERA: number;
  25745. /**
  25746. * This helps creating camera with an orthographic mode.
  25747. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  25748. */
  25749. static readonly ORTHOGRAPHIC_CAMERA: number;
  25750. /**
  25751. * This is the default FOV mode for perspective cameras.
  25752. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25753. */
  25754. static readonly FOVMODE_VERTICAL_FIXED: number;
  25755. /**
  25756. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25757. */
  25758. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25759. /**
  25760. * This specifies ther is no need for a camera rig.
  25761. * Basically only one eye is rendered corresponding to the camera.
  25762. */
  25763. static readonly RIG_MODE_NONE: number;
  25764. /**
  25765. * Simulates a camera Rig with one blue eye and one red eye.
  25766. * This can be use with 3d blue and red glasses.
  25767. */
  25768. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25769. /**
  25770. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25771. */
  25772. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25773. /**
  25774. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25775. */
  25776. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25777. /**
  25778. * Defines that both eyes of the camera will be rendered over under each other.
  25779. */
  25780. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25781. /**
  25782. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25783. */
  25784. static readonly RIG_MODE_VR: number;
  25785. /**
  25786. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25787. */
  25788. static readonly RIG_MODE_WEBVR: number;
  25789. /**
  25790. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25791. */
  25792. static readonly RIG_MODE_CUSTOM: number;
  25793. /**
  25794. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25795. */
  25796. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25797. /**
  25798. * Define the input manager associated with the camera.
  25799. */
  25800. inputs: CameraInputsManager<Camera>;
  25801. /** @hidden */
  25802. _position: Vector3;
  25803. /**
  25804. * Define the current local position of the camera in the scene
  25805. */
  25806. position: Vector3;
  25807. /**
  25808. * The vector the camera should consider as up.
  25809. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25810. */
  25811. upVector: Vector3;
  25812. /**
  25813. * Define the current limit on the left side for an orthographic camera
  25814. * In scene unit
  25815. */
  25816. orthoLeft: Nullable<number>;
  25817. /**
  25818. * Define the current limit on the right side for an orthographic camera
  25819. * In scene unit
  25820. */
  25821. orthoRight: Nullable<number>;
  25822. /**
  25823. * Define the current limit on the bottom side for an orthographic camera
  25824. * In scene unit
  25825. */
  25826. orthoBottom: Nullable<number>;
  25827. /**
  25828. * Define the current limit on the top side for an orthographic camera
  25829. * In scene unit
  25830. */
  25831. orthoTop: Nullable<number>;
  25832. /**
  25833. * Field Of View is set in Radians. (default is 0.8)
  25834. */
  25835. fov: number;
  25836. /**
  25837. * Define the minimum distance the camera can see from.
  25838. * This is important to note that the depth buffer are not infinite and the closer it starts
  25839. * the more your scene might encounter depth fighting issue.
  25840. */
  25841. minZ: number;
  25842. /**
  25843. * Define the maximum distance the camera can see to.
  25844. * This is important to note that the depth buffer are not infinite and the further it end
  25845. * the more your scene might encounter depth fighting issue.
  25846. */
  25847. maxZ: number;
  25848. /**
  25849. * Define the default inertia of the camera.
  25850. * This helps giving a smooth feeling to the camera movement.
  25851. */
  25852. inertia: number;
  25853. /**
  25854. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25855. */
  25856. mode: number;
  25857. /**
  25858. * Define wether the camera is intermediate.
  25859. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25860. */
  25861. isIntermediate: boolean;
  25862. /**
  25863. * Define the viewport of the camera.
  25864. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25865. */
  25866. viewport: Viewport;
  25867. /**
  25868. * Restricts the camera to viewing objects with the same layerMask.
  25869. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25870. */
  25871. layerMask: number;
  25872. /**
  25873. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25874. */
  25875. fovMode: number;
  25876. /**
  25877. * Rig mode of the camera.
  25878. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25879. * This is normally controlled byt the camera themselves as internal use.
  25880. */
  25881. cameraRigMode: number;
  25882. /**
  25883. * Defines the distance between both "eyes" in case of a RIG
  25884. */
  25885. interaxialDistance: number;
  25886. /**
  25887. * Defines if stereoscopic rendering is done side by side or over under.
  25888. */
  25889. isStereoscopicSideBySide: boolean;
  25890. /**
  25891. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  25892. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25893. * else in the scene. (Eg. security camera)
  25894. *
  25895. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25896. */
  25897. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25898. /**
  25899. * When set, the camera will render to this render target instead of the default canvas
  25900. *
  25901. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25902. */
  25903. outputRenderTarget: Nullable<RenderTargetTexture>;
  25904. /**
  25905. * Observable triggered when the camera view matrix has changed.
  25906. */
  25907. onViewMatrixChangedObservable: Observable<Camera>;
  25908. /**
  25909. * Observable triggered when the camera Projection matrix has changed.
  25910. */
  25911. onProjectionMatrixChangedObservable: Observable<Camera>;
  25912. /**
  25913. * Observable triggered when the inputs have been processed.
  25914. */
  25915. onAfterCheckInputsObservable: Observable<Camera>;
  25916. /**
  25917. * Observable triggered when reset has been called and applied to the camera.
  25918. */
  25919. onRestoreStateObservable: Observable<Camera>;
  25920. /** @hidden */
  25921. _cameraRigParams: any;
  25922. /** @hidden */
  25923. _rigCameras: Camera[];
  25924. /** @hidden */
  25925. _rigPostProcess: Nullable<PostProcess>;
  25926. protected _webvrViewMatrix: Matrix;
  25927. /** @hidden */
  25928. _skipRendering: boolean;
  25929. /** @hidden */
  25930. _projectionMatrix: Matrix;
  25931. /** @hidden */
  25932. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25933. /** @hidden */
  25934. _activeMeshes: SmartArray<AbstractMesh>;
  25935. protected _globalPosition: Vector3;
  25936. /** @hidden */
  25937. _computedViewMatrix: Matrix;
  25938. private _doNotComputeProjectionMatrix;
  25939. private _transformMatrix;
  25940. private _frustumPlanes;
  25941. private _refreshFrustumPlanes;
  25942. private _storedFov;
  25943. private _stateStored;
  25944. /**
  25945. * Instantiates a new camera object.
  25946. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25947. * @see http://doc.babylonjs.com/features/cameras
  25948. * @param name Defines the name of the camera in the scene
  25949. * @param position Defines the position of the camera
  25950. * @param scene Defines the scene the camera belongs too
  25951. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25952. */
  25953. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25954. /**
  25955. * Store current camera state (fov, position, etc..)
  25956. * @returns the camera
  25957. */
  25958. storeState(): Camera;
  25959. /**
  25960. * Restores the camera state values if it has been stored. You must call storeState() first
  25961. */
  25962. protected _restoreStateValues(): boolean;
  25963. /**
  25964. * Restored camera state. You must call storeState() first.
  25965. * @returns true if restored and false otherwise
  25966. */
  25967. restoreState(): boolean;
  25968. /**
  25969. * Gets the class name of the camera.
  25970. * @returns the class name
  25971. */
  25972. getClassName(): string;
  25973. /** @hidden */
  25974. readonly _isCamera: boolean;
  25975. /**
  25976. * Gets a string representation of the camera useful for debug purpose.
  25977. * @param fullDetails Defines that a more verboe level of logging is required
  25978. * @returns the string representation
  25979. */
  25980. toString(fullDetails?: boolean): string;
  25981. /**
  25982. * Gets the current world space position of the camera.
  25983. */
  25984. readonly globalPosition: Vector3;
  25985. /**
  25986. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25987. * @returns the active meshe list
  25988. */
  25989. getActiveMeshes(): SmartArray<AbstractMesh>;
  25990. /**
  25991. * Check wether a mesh is part of the current active mesh list of the camera
  25992. * @param mesh Defines the mesh to check
  25993. * @returns true if active, false otherwise
  25994. */
  25995. isActiveMesh(mesh: Mesh): boolean;
  25996. /**
  25997. * Is this camera ready to be used/rendered
  25998. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25999. * @return true if the camera is ready
  26000. */
  26001. isReady(completeCheck?: boolean): boolean;
  26002. /** @hidden */
  26003. _initCache(): void;
  26004. /** @hidden */
  26005. _updateCache(ignoreParentClass?: boolean): void;
  26006. /** @hidden */
  26007. _isSynchronized(): boolean;
  26008. /** @hidden */
  26009. _isSynchronizedViewMatrix(): boolean;
  26010. /** @hidden */
  26011. _isSynchronizedProjectionMatrix(): boolean;
  26012. /**
  26013. * Attach the input controls to a specific dom element to get the input from.
  26014. * @param element Defines the element the controls should be listened from
  26015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26016. */
  26017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26018. /**
  26019. * Detach the current controls from the specified dom element.
  26020. * @param element Defines the element to stop listening the inputs from
  26021. */
  26022. detachControl(element: HTMLElement): void;
  26023. /**
  26024. * Update the camera state according to the different inputs gathered during the frame.
  26025. */
  26026. update(): void;
  26027. /** @hidden */
  26028. _checkInputs(): void;
  26029. /** @hidden */
  26030. readonly rigCameras: Camera[];
  26031. /**
  26032. * Gets the post process used by the rig cameras
  26033. */
  26034. readonly rigPostProcess: Nullable<PostProcess>;
  26035. /**
  26036. * Internal, gets the first post proces.
  26037. * @returns the first post process to be run on this camera.
  26038. */
  26039. _getFirstPostProcess(): Nullable<PostProcess>;
  26040. private _cascadePostProcessesToRigCams;
  26041. /**
  26042. * Attach a post process to the camera.
  26043. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26044. * @param postProcess The post process to attach to the camera
  26045. * @param insertAt The position of the post process in case several of them are in use in the scene
  26046. * @returns the position the post process has been inserted at
  26047. */
  26048. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26049. /**
  26050. * Detach a post process to the camera.
  26051. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26052. * @param postProcess The post process to detach from the camera
  26053. */
  26054. detachPostProcess(postProcess: PostProcess): void;
  26055. /**
  26056. * Gets the current world matrix of the camera
  26057. */
  26058. getWorldMatrix(): Matrix;
  26059. /** @hidden */
  26060. _getViewMatrix(): Matrix;
  26061. /**
  26062. * Gets the current view matrix of the camera.
  26063. * @param force forces the camera to recompute the matrix without looking at the cached state
  26064. * @returns the view matrix
  26065. */
  26066. getViewMatrix(force?: boolean): Matrix;
  26067. /**
  26068. * Freeze the projection matrix.
  26069. * It will prevent the cache check of the camera projection compute and can speed up perf
  26070. * if no parameter of the camera are meant to change
  26071. * @param projection Defines manually a projection if necessary
  26072. */
  26073. freezeProjectionMatrix(projection?: Matrix): void;
  26074. /**
  26075. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26076. */
  26077. unfreezeProjectionMatrix(): void;
  26078. /**
  26079. * Gets the current projection matrix of the camera.
  26080. * @param force forces the camera to recompute the matrix without looking at the cached state
  26081. * @returns the projection matrix
  26082. */
  26083. getProjectionMatrix(force?: boolean): Matrix;
  26084. /**
  26085. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26086. * @returns a Matrix
  26087. */
  26088. getTransformationMatrix(): Matrix;
  26089. private _updateFrustumPlanes;
  26090. /**
  26091. * Checks if a cullable object (mesh...) is in the camera frustum
  26092. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26093. * @param target The object to check
  26094. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26095. * @returns true if the object is in frustum otherwise false
  26096. */
  26097. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26098. /**
  26099. * Checks if a cullable object (mesh...) is in the camera frustum
  26100. * Unlike isInFrustum this cheks the full bounding box
  26101. * @param target The object to check
  26102. * @returns true if the object is in frustum otherwise false
  26103. */
  26104. isCompletelyInFrustum(target: ICullable): boolean;
  26105. /**
  26106. * Gets a ray in the forward direction from the camera.
  26107. * @param length Defines the length of the ray to create
  26108. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26109. * @param origin Defines the start point of the ray which defaults to the camera position
  26110. * @returns the forward ray
  26111. */
  26112. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26113. /**
  26114. * Releases resources associated with this node.
  26115. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26116. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26117. */
  26118. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26119. /** @hidden */
  26120. _isLeftCamera: boolean;
  26121. /**
  26122. * Gets the left camera of a rig setup in case of Rigged Camera
  26123. */
  26124. readonly isLeftCamera: boolean;
  26125. /** @hidden */
  26126. _isRightCamera: boolean;
  26127. /**
  26128. * Gets the right camera of a rig setup in case of Rigged Camera
  26129. */
  26130. readonly isRightCamera: boolean;
  26131. /**
  26132. * Gets the left camera of a rig setup in case of Rigged Camera
  26133. */
  26134. readonly leftCamera: Nullable<FreeCamera>;
  26135. /**
  26136. * Gets the right camera of a rig setup in case of Rigged Camera
  26137. */
  26138. readonly rightCamera: Nullable<FreeCamera>;
  26139. /**
  26140. * Gets the left camera target of a rig setup in case of Rigged Camera
  26141. * @returns the target position
  26142. */
  26143. getLeftTarget(): Nullable<Vector3>;
  26144. /**
  26145. * Gets the right camera target of a rig setup in case of Rigged Camera
  26146. * @returns the target position
  26147. */
  26148. getRightTarget(): Nullable<Vector3>;
  26149. /**
  26150. * @hidden
  26151. */
  26152. setCameraRigMode(mode: number, rigParams: any): void;
  26153. /** @hidden */
  26154. static _setStereoscopicRigMode(camera: Camera): void;
  26155. /** @hidden */
  26156. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26157. /** @hidden */
  26158. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26159. /** @hidden */
  26160. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26161. /** @hidden */
  26162. _getVRProjectionMatrix(): Matrix;
  26163. protected _updateCameraRotationMatrix(): void;
  26164. protected _updateWebVRCameraRotationMatrix(): void;
  26165. /**
  26166. * This function MUST be overwritten by the different WebVR cameras available.
  26167. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26168. * @hidden
  26169. */
  26170. _getWebVRProjectionMatrix(): Matrix;
  26171. /**
  26172. * This function MUST be overwritten by the different WebVR cameras available.
  26173. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26174. * @hidden
  26175. */
  26176. _getWebVRViewMatrix(): Matrix;
  26177. /** @hidden */
  26178. setCameraRigParameter(name: string, value: any): void;
  26179. /**
  26180. * needs to be overridden by children so sub has required properties to be copied
  26181. * @hidden
  26182. */
  26183. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26184. /**
  26185. * May need to be overridden by children
  26186. * @hidden
  26187. */
  26188. _updateRigCameras(): void;
  26189. /** @hidden */
  26190. _setupInputs(): void;
  26191. /**
  26192. * Serialiaze the camera setup to a json represention
  26193. * @returns the JSON representation
  26194. */
  26195. serialize(): any;
  26196. /**
  26197. * Clones the current camera.
  26198. * @param name The cloned camera name
  26199. * @returns the cloned camera
  26200. */
  26201. clone(name: string): Camera;
  26202. /**
  26203. * Gets the direction of the camera relative to a given local axis.
  26204. * @param localAxis Defines the reference axis to provide a relative direction.
  26205. * @return the direction
  26206. */
  26207. getDirection(localAxis: Vector3): Vector3;
  26208. /**
  26209. * Returns the current camera absolute rotation
  26210. */
  26211. readonly absoluteRotation: Quaternion;
  26212. /**
  26213. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26214. * @param localAxis Defines the reference axis to provide a relative direction.
  26215. * @param result Defines the vector to store the result in
  26216. */
  26217. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26218. /**
  26219. * Gets a camera constructor for a given camera type
  26220. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26221. * @param name The name of the camera the result will be able to instantiate
  26222. * @param scene The scene the result will construct the camera in
  26223. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26224. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26225. * @returns a factory method to construc the camera
  26226. */
  26227. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26228. /**
  26229. * Compute the world matrix of the camera.
  26230. * @returns the camera world matrix
  26231. */
  26232. computeWorldMatrix(): Matrix;
  26233. /**
  26234. * Parse a JSON and creates the camera from the parsed information
  26235. * @param parsedCamera The JSON to parse
  26236. * @param scene The scene to instantiate the camera in
  26237. * @returns the newly constructed camera
  26238. */
  26239. static Parse(parsedCamera: any, scene: Scene): Camera;
  26240. }
  26241. }
  26242. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26243. import { Nullable } from "babylonjs/types";
  26244. import { Scene } from "babylonjs/scene";
  26245. import { Vector4 } from "babylonjs/Maths/math.vector";
  26246. import { Mesh } from "babylonjs/Meshes/mesh";
  26247. /**
  26248. * Class containing static functions to help procedurally build meshes
  26249. */
  26250. export class DiscBuilder {
  26251. /**
  26252. * Creates a plane polygonal mesh. By default, this is a disc
  26253. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26254. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  26255. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  26256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26259. * @param name defines the name of the mesh
  26260. * @param options defines the options used to create the mesh
  26261. * @param scene defines the hosting scene
  26262. * @returns the plane polygonal mesh
  26263. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26264. */
  26265. static CreateDisc(name: string, options: {
  26266. radius?: number;
  26267. tessellation?: number;
  26268. arc?: number;
  26269. updatable?: boolean;
  26270. sideOrientation?: number;
  26271. frontUVs?: Vector4;
  26272. backUVs?: Vector4;
  26273. }, scene?: Nullable<Scene>): Mesh;
  26274. }
  26275. }
  26276. declare module "babylonjs/Materials/fresnelParameters" {
  26277. import { Color3 } from "babylonjs/Maths/math.color";
  26278. /**
  26279. * This represents all the required information to add a fresnel effect on a material:
  26280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26281. */
  26282. export class FresnelParameters {
  26283. private _isEnabled;
  26284. /**
  26285. * Define if the fresnel effect is enable or not.
  26286. */
  26287. isEnabled: boolean;
  26288. /**
  26289. * Define the color used on edges (grazing angle)
  26290. */
  26291. leftColor: Color3;
  26292. /**
  26293. * Define the color used on center
  26294. */
  26295. rightColor: Color3;
  26296. /**
  26297. * Define bias applied to computed fresnel term
  26298. */
  26299. bias: number;
  26300. /**
  26301. * Defined the power exponent applied to fresnel term
  26302. */
  26303. power: number;
  26304. /**
  26305. * Clones the current fresnel and its valuues
  26306. * @returns a clone fresnel configuration
  26307. */
  26308. clone(): FresnelParameters;
  26309. /**
  26310. * Serializes the current fresnel parameters to a JSON representation.
  26311. * @return the JSON serialization
  26312. */
  26313. serialize(): any;
  26314. /**
  26315. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26316. * @param parsedFresnelParameters Define the JSON representation
  26317. * @returns the parsed parameters
  26318. */
  26319. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26320. }
  26321. }
  26322. declare module "babylonjs/Materials/pushMaterial" {
  26323. import { Nullable } from "babylonjs/types";
  26324. import { Scene } from "babylonjs/scene";
  26325. import { Matrix } from "babylonjs/Maths/math.vector";
  26326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26327. import { Mesh } from "babylonjs/Meshes/mesh";
  26328. import { Material } from "babylonjs/Materials/material";
  26329. import { Effect } from "babylonjs/Materials/effect";
  26330. /**
  26331. * Base class of materials working in push mode in babylon JS
  26332. * @hidden
  26333. */
  26334. export class PushMaterial extends Material {
  26335. protected _activeEffect: Effect;
  26336. protected _normalMatrix: Matrix;
  26337. /**
  26338. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26339. * This means that the material can keep using a previous shader while a new one is being compiled.
  26340. * This is mostly used when shader parallel compilation is supported (true by default)
  26341. */
  26342. allowShaderHotSwapping: boolean;
  26343. constructor(name: string, scene: Scene);
  26344. getEffect(): Effect;
  26345. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26346. /**
  26347. * Binds the given world matrix to the active effect
  26348. *
  26349. * @param world the matrix to bind
  26350. */
  26351. bindOnlyWorldMatrix(world: Matrix): void;
  26352. /**
  26353. * Binds the given normal matrix to the active effect
  26354. *
  26355. * @param normalMatrix the matrix to bind
  26356. */
  26357. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26358. bind(world: Matrix, mesh?: Mesh): void;
  26359. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26360. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26361. }
  26362. }
  26363. declare module "babylonjs/Materials/materialFlags" {
  26364. /**
  26365. * This groups all the flags used to control the materials channel.
  26366. */
  26367. export class MaterialFlags {
  26368. private static _DiffuseTextureEnabled;
  26369. /**
  26370. * Are diffuse textures enabled in the application.
  26371. */
  26372. static DiffuseTextureEnabled: boolean;
  26373. private static _AmbientTextureEnabled;
  26374. /**
  26375. * Are ambient textures enabled in the application.
  26376. */
  26377. static AmbientTextureEnabled: boolean;
  26378. private static _OpacityTextureEnabled;
  26379. /**
  26380. * Are opacity textures enabled in the application.
  26381. */
  26382. static OpacityTextureEnabled: boolean;
  26383. private static _ReflectionTextureEnabled;
  26384. /**
  26385. * Are reflection textures enabled in the application.
  26386. */
  26387. static ReflectionTextureEnabled: boolean;
  26388. private static _EmissiveTextureEnabled;
  26389. /**
  26390. * Are emissive textures enabled in the application.
  26391. */
  26392. static EmissiveTextureEnabled: boolean;
  26393. private static _SpecularTextureEnabled;
  26394. /**
  26395. * Are specular textures enabled in the application.
  26396. */
  26397. static SpecularTextureEnabled: boolean;
  26398. private static _BumpTextureEnabled;
  26399. /**
  26400. * Are bump textures enabled in the application.
  26401. */
  26402. static BumpTextureEnabled: boolean;
  26403. private static _LightmapTextureEnabled;
  26404. /**
  26405. * Are lightmap textures enabled in the application.
  26406. */
  26407. static LightmapTextureEnabled: boolean;
  26408. private static _RefractionTextureEnabled;
  26409. /**
  26410. * Are refraction textures enabled in the application.
  26411. */
  26412. static RefractionTextureEnabled: boolean;
  26413. private static _ColorGradingTextureEnabled;
  26414. /**
  26415. * Are color grading textures enabled in the application.
  26416. */
  26417. static ColorGradingTextureEnabled: boolean;
  26418. private static _FresnelEnabled;
  26419. /**
  26420. * Are fresnels enabled in the application.
  26421. */
  26422. static FresnelEnabled: boolean;
  26423. private static _ClearCoatTextureEnabled;
  26424. /**
  26425. * Are clear coat textures enabled in the application.
  26426. */
  26427. static ClearCoatTextureEnabled: boolean;
  26428. private static _ClearCoatBumpTextureEnabled;
  26429. /**
  26430. * Are clear coat bump textures enabled in the application.
  26431. */
  26432. static ClearCoatBumpTextureEnabled: boolean;
  26433. private static _ClearCoatTintTextureEnabled;
  26434. /**
  26435. * Are clear coat tint textures enabled in the application.
  26436. */
  26437. static ClearCoatTintTextureEnabled: boolean;
  26438. private static _SheenTextureEnabled;
  26439. /**
  26440. * Are sheen textures enabled in the application.
  26441. */
  26442. static SheenTextureEnabled: boolean;
  26443. private static _AnisotropicTextureEnabled;
  26444. /**
  26445. * Are anisotropic textures enabled in the application.
  26446. */
  26447. static AnisotropicTextureEnabled: boolean;
  26448. private static _ThicknessTextureEnabled;
  26449. /**
  26450. * Are thickness textures enabled in the application.
  26451. */
  26452. static ThicknessTextureEnabled: boolean;
  26453. }
  26454. }
  26455. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26456. /** @hidden */
  26457. export var defaultFragmentDeclaration: {
  26458. name: string;
  26459. shader: string;
  26460. };
  26461. }
  26462. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26463. /** @hidden */
  26464. export var defaultUboDeclaration: {
  26465. name: string;
  26466. shader: string;
  26467. };
  26468. }
  26469. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26470. /** @hidden */
  26471. export var lightFragmentDeclaration: {
  26472. name: string;
  26473. shader: string;
  26474. };
  26475. }
  26476. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26477. /** @hidden */
  26478. export var lightUboDeclaration: {
  26479. name: string;
  26480. shader: string;
  26481. };
  26482. }
  26483. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26484. /** @hidden */
  26485. export var lightsFragmentFunctions: {
  26486. name: string;
  26487. shader: string;
  26488. };
  26489. }
  26490. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26491. /** @hidden */
  26492. export var shadowsFragmentFunctions: {
  26493. name: string;
  26494. shader: string;
  26495. };
  26496. }
  26497. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26498. /** @hidden */
  26499. export var fresnelFunction: {
  26500. name: string;
  26501. shader: string;
  26502. };
  26503. }
  26504. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26505. /** @hidden */
  26506. export var reflectionFunction: {
  26507. name: string;
  26508. shader: string;
  26509. };
  26510. }
  26511. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26512. /** @hidden */
  26513. export var bumpFragmentFunctions: {
  26514. name: string;
  26515. shader: string;
  26516. };
  26517. }
  26518. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26519. /** @hidden */
  26520. export var logDepthDeclaration: {
  26521. name: string;
  26522. shader: string;
  26523. };
  26524. }
  26525. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26526. /** @hidden */
  26527. export var bumpFragment: {
  26528. name: string;
  26529. shader: string;
  26530. };
  26531. }
  26532. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26533. /** @hidden */
  26534. export var depthPrePass: {
  26535. name: string;
  26536. shader: string;
  26537. };
  26538. }
  26539. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26540. /** @hidden */
  26541. export var lightFragment: {
  26542. name: string;
  26543. shader: string;
  26544. };
  26545. }
  26546. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26547. /** @hidden */
  26548. export var logDepthFragment: {
  26549. name: string;
  26550. shader: string;
  26551. };
  26552. }
  26553. declare module "babylonjs/Shaders/default.fragment" {
  26554. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26555. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26556. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26557. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26558. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26559. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26560. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26561. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26562. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26563. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26564. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26565. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26566. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26567. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26568. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26569. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26570. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26571. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26572. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26573. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26574. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26575. /** @hidden */
  26576. export var defaultPixelShader: {
  26577. name: string;
  26578. shader: string;
  26579. };
  26580. }
  26581. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26582. /** @hidden */
  26583. export var defaultVertexDeclaration: {
  26584. name: string;
  26585. shader: string;
  26586. };
  26587. }
  26588. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26589. /** @hidden */
  26590. export var bumpVertexDeclaration: {
  26591. name: string;
  26592. shader: string;
  26593. };
  26594. }
  26595. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26596. /** @hidden */
  26597. export var bumpVertex: {
  26598. name: string;
  26599. shader: string;
  26600. };
  26601. }
  26602. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26603. /** @hidden */
  26604. export var fogVertex: {
  26605. name: string;
  26606. shader: string;
  26607. };
  26608. }
  26609. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26610. /** @hidden */
  26611. export var shadowsVertex: {
  26612. name: string;
  26613. shader: string;
  26614. };
  26615. }
  26616. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26617. /** @hidden */
  26618. export var pointCloudVertex: {
  26619. name: string;
  26620. shader: string;
  26621. };
  26622. }
  26623. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26624. /** @hidden */
  26625. export var logDepthVertex: {
  26626. name: string;
  26627. shader: string;
  26628. };
  26629. }
  26630. declare module "babylonjs/Shaders/default.vertex" {
  26631. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26632. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26633. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26634. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26635. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26636. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26638. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26639. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26640. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26641. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26642. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26643. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26644. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26645. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26646. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26647. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26648. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26649. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26650. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26651. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26652. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26653. /** @hidden */
  26654. export var defaultVertexShader: {
  26655. name: string;
  26656. shader: string;
  26657. };
  26658. }
  26659. declare module "babylonjs/Materials/standardMaterial" {
  26660. import { SmartArray } from "babylonjs/Misc/smartArray";
  26661. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26662. import { Nullable } from "babylonjs/types";
  26663. import { Scene } from "babylonjs/scene";
  26664. import { Matrix } from "babylonjs/Maths/math.vector";
  26665. import { Color3 } from "babylonjs/Maths/math.color";
  26666. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26668. import { Mesh } from "babylonjs/Meshes/mesh";
  26669. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26670. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26671. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26672. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26673. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26675. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26676. import "babylonjs/Shaders/default.fragment";
  26677. import "babylonjs/Shaders/default.vertex";
  26678. /** @hidden */
  26679. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26680. MAINUV1: boolean;
  26681. MAINUV2: boolean;
  26682. DIFFUSE: boolean;
  26683. DIFFUSEDIRECTUV: number;
  26684. AMBIENT: boolean;
  26685. AMBIENTDIRECTUV: number;
  26686. OPACITY: boolean;
  26687. OPACITYDIRECTUV: number;
  26688. OPACITYRGB: boolean;
  26689. REFLECTION: boolean;
  26690. EMISSIVE: boolean;
  26691. EMISSIVEDIRECTUV: number;
  26692. SPECULAR: boolean;
  26693. SPECULARDIRECTUV: number;
  26694. BUMP: boolean;
  26695. BUMPDIRECTUV: number;
  26696. PARALLAX: boolean;
  26697. PARALLAXOCCLUSION: boolean;
  26698. SPECULAROVERALPHA: boolean;
  26699. CLIPPLANE: boolean;
  26700. CLIPPLANE2: boolean;
  26701. CLIPPLANE3: boolean;
  26702. CLIPPLANE4: boolean;
  26703. ALPHATEST: boolean;
  26704. DEPTHPREPASS: boolean;
  26705. ALPHAFROMDIFFUSE: boolean;
  26706. POINTSIZE: boolean;
  26707. FOG: boolean;
  26708. SPECULARTERM: boolean;
  26709. DIFFUSEFRESNEL: boolean;
  26710. OPACITYFRESNEL: boolean;
  26711. REFLECTIONFRESNEL: boolean;
  26712. REFRACTIONFRESNEL: boolean;
  26713. EMISSIVEFRESNEL: boolean;
  26714. FRESNEL: boolean;
  26715. NORMAL: boolean;
  26716. UV1: boolean;
  26717. UV2: boolean;
  26718. VERTEXCOLOR: boolean;
  26719. VERTEXALPHA: boolean;
  26720. NUM_BONE_INFLUENCERS: number;
  26721. BonesPerMesh: number;
  26722. BONETEXTURE: boolean;
  26723. INSTANCES: boolean;
  26724. GLOSSINESS: boolean;
  26725. ROUGHNESS: boolean;
  26726. EMISSIVEASILLUMINATION: boolean;
  26727. LINKEMISSIVEWITHDIFFUSE: boolean;
  26728. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26729. LIGHTMAP: boolean;
  26730. LIGHTMAPDIRECTUV: number;
  26731. OBJECTSPACE_NORMALMAP: boolean;
  26732. USELIGHTMAPASSHADOWMAP: boolean;
  26733. REFLECTIONMAP_3D: boolean;
  26734. REFLECTIONMAP_SPHERICAL: boolean;
  26735. REFLECTIONMAP_PLANAR: boolean;
  26736. REFLECTIONMAP_CUBIC: boolean;
  26737. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26738. REFLECTIONMAP_PROJECTION: boolean;
  26739. REFLECTIONMAP_SKYBOX: boolean;
  26740. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26741. REFLECTIONMAP_EXPLICIT: boolean;
  26742. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26743. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26744. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26745. INVERTCUBICMAP: boolean;
  26746. LOGARITHMICDEPTH: boolean;
  26747. REFRACTION: boolean;
  26748. REFRACTIONMAP_3D: boolean;
  26749. REFLECTIONOVERALPHA: boolean;
  26750. TWOSIDEDLIGHTING: boolean;
  26751. SHADOWFLOAT: boolean;
  26752. MORPHTARGETS: boolean;
  26753. MORPHTARGETS_NORMAL: boolean;
  26754. MORPHTARGETS_TANGENT: boolean;
  26755. MORPHTARGETS_UV: boolean;
  26756. NUM_MORPH_INFLUENCERS: number;
  26757. NONUNIFORMSCALING: boolean;
  26758. PREMULTIPLYALPHA: boolean;
  26759. IMAGEPROCESSING: boolean;
  26760. VIGNETTE: boolean;
  26761. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26762. VIGNETTEBLENDMODEOPAQUE: boolean;
  26763. TONEMAPPING: boolean;
  26764. TONEMAPPING_ACES: boolean;
  26765. CONTRAST: boolean;
  26766. COLORCURVES: boolean;
  26767. COLORGRADING: boolean;
  26768. COLORGRADING3D: boolean;
  26769. SAMPLER3DGREENDEPTH: boolean;
  26770. SAMPLER3DBGRMAP: boolean;
  26771. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26772. MULTIVIEW: boolean;
  26773. /**
  26774. * If the reflection texture on this material is in linear color space
  26775. * @hidden
  26776. */
  26777. IS_REFLECTION_LINEAR: boolean;
  26778. /**
  26779. * If the refraction texture on this material is in linear color space
  26780. * @hidden
  26781. */
  26782. IS_REFRACTION_LINEAR: boolean;
  26783. EXPOSURE: boolean;
  26784. constructor();
  26785. setReflectionMode(modeToEnable: string): void;
  26786. }
  26787. /**
  26788. * This is the default material used in Babylon. It is the best trade off between quality
  26789. * and performances.
  26790. * @see http://doc.babylonjs.com/babylon101/materials
  26791. */
  26792. export class StandardMaterial extends PushMaterial {
  26793. private _diffuseTexture;
  26794. /**
  26795. * The basic texture of the material as viewed under a light.
  26796. */
  26797. diffuseTexture: Nullable<BaseTexture>;
  26798. private _ambientTexture;
  26799. /**
  26800. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26801. */
  26802. ambientTexture: Nullable<BaseTexture>;
  26803. private _opacityTexture;
  26804. /**
  26805. * Define the transparency of the material from a texture.
  26806. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26807. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26808. */
  26809. opacityTexture: Nullable<BaseTexture>;
  26810. private _reflectionTexture;
  26811. /**
  26812. * Define the texture used to display the reflection.
  26813. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26814. */
  26815. reflectionTexture: Nullable<BaseTexture>;
  26816. private _emissiveTexture;
  26817. /**
  26818. * Define texture of the material as if self lit.
  26819. * This will be mixed in the final result even in the absence of light.
  26820. */
  26821. emissiveTexture: Nullable<BaseTexture>;
  26822. private _specularTexture;
  26823. /**
  26824. * Define how the color and intensity of the highlight given by the light in the material.
  26825. */
  26826. specularTexture: Nullable<BaseTexture>;
  26827. private _bumpTexture;
  26828. /**
  26829. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26830. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  26831. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26832. */
  26833. bumpTexture: Nullable<BaseTexture>;
  26834. private _lightmapTexture;
  26835. /**
  26836. * Complex lighting can be computationally expensive to compute at runtime.
  26837. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26838. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26839. */
  26840. lightmapTexture: Nullable<BaseTexture>;
  26841. private _refractionTexture;
  26842. /**
  26843. * Define the texture used to display the refraction.
  26844. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26845. */
  26846. refractionTexture: Nullable<BaseTexture>;
  26847. /**
  26848. * The color of the material lit by the environmental background lighting.
  26849. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26850. */
  26851. ambientColor: Color3;
  26852. /**
  26853. * The basic color of the material as viewed under a light.
  26854. */
  26855. diffuseColor: Color3;
  26856. /**
  26857. * Define how the color and intensity of the highlight given by the light in the material.
  26858. */
  26859. specularColor: Color3;
  26860. /**
  26861. * Define the color of the material as if self lit.
  26862. * This will be mixed in the final result even in the absence of light.
  26863. */
  26864. emissiveColor: Color3;
  26865. /**
  26866. * Defines how sharp are the highlights in the material.
  26867. * The bigger the value the sharper giving a more glossy feeling to the result.
  26868. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26869. */
  26870. specularPower: number;
  26871. private _useAlphaFromDiffuseTexture;
  26872. /**
  26873. * Does the transparency come from the diffuse texture alpha channel.
  26874. */
  26875. useAlphaFromDiffuseTexture: boolean;
  26876. private _useEmissiveAsIllumination;
  26877. /**
  26878. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26879. */
  26880. useEmissiveAsIllumination: boolean;
  26881. private _linkEmissiveWithDiffuse;
  26882. /**
  26883. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26884. * the emissive level when the final color is close to one.
  26885. */
  26886. linkEmissiveWithDiffuse: boolean;
  26887. private _useSpecularOverAlpha;
  26888. /**
  26889. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26890. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26891. */
  26892. useSpecularOverAlpha: boolean;
  26893. private _useReflectionOverAlpha;
  26894. /**
  26895. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26896. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26897. */
  26898. useReflectionOverAlpha: boolean;
  26899. private _disableLighting;
  26900. /**
  26901. * Does lights from the scene impacts this material.
  26902. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26903. */
  26904. disableLighting: boolean;
  26905. private _useObjectSpaceNormalMap;
  26906. /**
  26907. * Allows using an object space normal map (instead of tangent space).
  26908. */
  26909. useObjectSpaceNormalMap: boolean;
  26910. private _useParallax;
  26911. /**
  26912. * Is parallax enabled or not.
  26913. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26914. */
  26915. useParallax: boolean;
  26916. private _useParallaxOcclusion;
  26917. /**
  26918. * Is parallax occlusion enabled or not.
  26919. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26920. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26921. */
  26922. useParallaxOcclusion: boolean;
  26923. /**
  26924. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  26925. */
  26926. parallaxScaleBias: number;
  26927. private _roughness;
  26928. /**
  26929. * Helps to define how blurry the reflections should appears in the material.
  26930. */
  26931. roughness: number;
  26932. /**
  26933. * In case of refraction, define the value of the index of refraction.
  26934. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26935. */
  26936. indexOfRefraction: number;
  26937. /**
  26938. * Invert the refraction texture alongside the y axis.
  26939. * It can be useful with procedural textures or probe for instance.
  26940. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26941. */
  26942. invertRefractionY: boolean;
  26943. /**
  26944. * Defines the alpha limits in alpha test mode.
  26945. */
  26946. alphaCutOff: number;
  26947. private _useLightmapAsShadowmap;
  26948. /**
  26949. * In case of light mapping, define whether the map contains light or shadow informations.
  26950. */
  26951. useLightmapAsShadowmap: boolean;
  26952. private _diffuseFresnelParameters;
  26953. /**
  26954. * Define the diffuse fresnel parameters of the material.
  26955. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26956. */
  26957. diffuseFresnelParameters: FresnelParameters;
  26958. private _opacityFresnelParameters;
  26959. /**
  26960. * Define the opacity fresnel parameters of the material.
  26961. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26962. */
  26963. opacityFresnelParameters: FresnelParameters;
  26964. private _reflectionFresnelParameters;
  26965. /**
  26966. * Define the reflection fresnel parameters of the material.
  26967. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26968. */
  26969. reflectionFresnelParameters: FresnelParameters;
  26970. private _refractionFresnelParameters;
  26971. /**
  26972. * Define the refraction fresnel parameters of the material.
  26973. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26974. */
  26975. refractionFresnelParameters: FresnelParameters;
  26976. private _emissiveFresnelParameters;
  26977. /**
  26978. * Define the emissive fresnel parameters of the material.
  26979. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26980. */
  26981. emissiveFresnelParameters: FresnelParameters;
  26982. private _useReflectionFresnelFromSpecular;
  26983. /**
  26984. * If true automatically deducts the fresnels values from the material specularity.
  26985. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26986. */
  26987. useReflectionFresnelFromSpecular: boolean;
  26988. private _useGlossinessFromSpecularMapAlpha;
  26989. /**
  26990. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26991. */
  26992. useGlossinessFromSpecularMapAlpha: boolean;
  26993. private _maxSimultaneousLights;
  26994. /**
  26995. * Defines the maximum number of lights that can be used in the material
  26996. */
  26997. maxSimultaneousLights: number;
  26998. private _invertNormalMapX;
  26999. /**
  27000. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27001. */
  27002. invertNormalMapX: boolean;
  27003. private _invertNormalMapY;
  27004. /**
  27005. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27006. */
  27007. invertNormalMapY: boolean;
  27008. private _twoSidedLighting;
  27009. /**
  27010. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27011. */
  27012. twoSidedLighting: boolean;
  27013. /**
  27014. * Default configuration related to image processing available in the standard Material.
  27015. */
  27016. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27017. /**
  27018. * Gets the image processing configuration used either in this material.
  27019. */
  27020. /**
  27021. * Sets the Default image processing configuration used either in the this material.
  27022. *
  27023. * If sets to null, the scene one is in use.
  27024. */
  27025. imageProcessingConfiguration: ImageProcessingConfiguration;
  27026. /**
  27027. * Keep track of the image processing observer to allow dispose and replace.
  27028. */
  27029. private _imageProcessingObserver;
  27030. /**
  27031. * Attaches a new image processing configuration to the Standard Material.
  27032. * @param configuration
  27033. */
  27034. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27035. /**
  27036. * Gets wether the color curves effect is enabled.
  27037. */
  27038. /**
  27039. * Sets wether the color curves effect is enabled.
  27040. */
  27041. cameraColorCurvesEnabled: boolean;
  27042. /**
  27043. * Gets wether the color grading effect is enabled.
  27044. */
  27045. /**
  27046. * Gets wether the color grading effect is enabled.
  27047. */
  27048. cameraColorGradingEnabled: boolean;
  27049. /**
  27050. * Gets wether tonemapping is enabled or not.
  27051. */
  27052. /**
  27053. * Sets wether tonemapping is enabled or not
  27054. */
  27055. cameraToneMappingEnabled: boolean;
  27056. /**
  27057. * The camera exposure used on this material.
  27058. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27059. * This corresponds to a photographic exposure.
  27060. */
  27061. /**
  27062. * The camera exposure used on this material.
  27063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27064. * This corresponds to a photographic exposure.
  27065. */
  27066. cameraExposure: number;
  27067. /**
  27068. * Gets The camera contrast used on this material.
  27069. */
  27070. /**
  27071. * Sets The camera contrast used on this material.
  27072. */
  27073. cameraContrast: number;
  27074. /**
  27075. * Gets the Color Grading 2D Lookup Texture.
  27076. */
  27077. /**
  27078. * Sets the Color Grading 2D Lookup Texture.
  27079. */
  27080. cameraColorGradingTexture: Nullable<BaseTexture>;
  27081. /**
  27082. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27083. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27084. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27085. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27086. */
  27087. /**
  27088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27090. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27092. */
  27093. cameraColorCurves: Nullable<ColorCurves>;
  27094. /**
  27095. * Custom callback helping to override the default shader used in the material.
  27096. */
  27097. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27098. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27099. protected _worldViewProjectionMatrix: Matrix;
  27100. protected _globalAmbientColor: Color3;
  27101. protected _useLogarithmicDepth: boolean;
  27102. protected _rebuildInParallel: boolean;
  27103. /**
  27104. * Instantiates a new standard material.
  27105. * This is the default material used in Babylon. It is the best trade off between quality
  27106. * and performances.
  27107. * @see http://doc.babylonjs.com/babylon101/materials
  27108. * @param name Define the name of the material in the scene
  27109. * @param scene Define the scene the material belong to
  27110. */
  27111. constructor(name: string, scene: Scene);
  27112. /**
  27113. * Gets a boolean indicating that current material needs to register RTT
  27114. */
  27115. readonly hasRenderTargetTextures: boolean;
  27116. /**
  27117. * Gets the current class name of the material e.g. "StandardMaterial"
  27118. * Mainly use in serialization.
  27119. * @returns the class name
  27120. */
  27121. getClassName(): string;
  27122. /**
  27123. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27124. * You can try switching to logarithmic depth.
  27125. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27126. */
  27127. useLogarithmicDepth: boolean;
  27128. /**
  27129. * Specifies if the material will require alpha blending
  27130. * @returns a boolean specifying if alpha blending is needed
  27131. */
  27132. needAlphaBlending(): boolean;
  27133. /**
  27134. * Specifies if this material should be rendered in alpha test mode
  27135. * @returns a boolean specifying if an alpha test is needed.
  27136. */
  27137. needAlphaTesting(): boolean;
  27138. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27139. /**
  27140. * Get the texture used for alpha test purpose.
  27141. * @returns the diffuse texture in case of the standard material.
  27142. */
  27143. getAlphaTestTexture(): Nullable<BaseTexture>;
  27144. /**
  27145. * Get if the submesh is ready to be used and all its information available.
  27146. * Child classes can use it to update shaders
  27147. * @param mesh defines the mesh to check
  27148. * @param subMesh defines which submesh to check
  27149. * @param useInstances specifies that instances should be used
  27150. * @returns a boolean indicating that the submesh is ready or not
  27151. */
  27152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27153. /**
  27154. * Builds the material UBO layouts.
  27155. * Used internally during the effect preparation.
  27156. */
  27157. buildUniformLayout(): void;
  27158. /**
  27159. * Unbinds the material from the mesh
  27160. */
  27161. unbind(): void;
  27162. /**
  27163. * Binds the submesh to this material by preparing the effect and shader to draw
  27164. * @param world defines the world transformation matrix
  27165. * @param mesh defines the mesh containing the submesh
  27166. * @param subMesh defines the submesh to bind the material to
  27167. */
  27168. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27169. /**
  27170. * Get the list of animatables in the material.
  27171. * @returns the list of animatables object used in the material
  27172. */
  27173. getAnimatables(): IAnimatable[];
  27174. /**
  27175. * Gets the active textures from the material
  27176. * @returns an array of textures
  27177. */
  27178. getActiveTextures(): BaseTexture[];
  27179. /**
  27180. * Specifies if the material uses a texture
  27181. * @param texture defines the texture to check against the material
  27182. * @returns a boolean specifying if the material uses the texture
  27183. */
  27184. hasTexture(texture: BaseTexture): boolean;
  27185. /**
  27186. * Disposes the material
  27187. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27188. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27189. */
  27190. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27191. /**
  27192. * Makes a duplicate of the material, and gives it a new name
  27193. * @param name defines the new name for the duplicated material
  27194. * @returns the cloned material
  27195. */
  27196. clone(name: string): StandardMaterial;
  27197. /**
  27198. * Serializes this material in a JSON representation
  27199. * @returns the serialized material object
  27200. */
  27201. serialize(): any;
  27202. /**
  27203. * Creates a standard material from parsed material data
  27204. * @param source defines the JSON representation of the material
  27205. * @param scene defines the hosting scene
  27206. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27207. * @returns a new standard material
  27208. */
  27209. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27210. /**
  27211. * Are diffuse textures enabled in the application.
  27212. */
  27213. static DiffuseTextureEnabled: boolean;
  27214. /**
  27215. * Are ambient textures enabled in the application.
  27216. */
  27217. static AmbientTextureEnabled: boolean;
  27218. /**
  27219. * Are opacity textures enabled in the application.
  27220. */
  27221. static OpacityTextureEnabled: boolean;
  27222. /**
  27223. * Are reflection textures enabled in the application.
  27224. */
  27225. static ReflectionTextureEnabled: boolean;
  27226. /**
  27227. * Are emissive textures enabled in the application.
  27228. */
  27229. static EmissiveTextureEnabled: boolean;
  27230. /**
  27231. * Are specular textures enabled in the application.
  27232. */
  27233. static SpecularTextureEnabled: boolean;
  27234. /**
  27235. * Are bump textures enabled in the application.
  27236. */
  27237. static BumpTextureEnabled: boolean;
  27238. /**
  27239. * Are lightmap textures enabled in the application.
  27240. */
  27241. static LightmapTextureEnabled: boolean;
  27242. /**
  27243. * Are refraction textures enabled in the application.
  27244. */
  27245. static RefractionTextureEnabled: boolean;
  27246. /**
  27247. * Are color grading textures enabled in the application.
  27248. */
  27249. static ColorGradingTextureEnabled: boolean;
  27250. /**
  27251. * Are fresnels enabled in the application.
  27252. */
  27253. static FresnelEnabled: boolean;
  27254. }
  27255. }
  27256. declare module "babylonjs/Particles/solidParticleSystem" {
  27257. import { Nullable } from "babylonjs/types";
  27258. import { Vector3 } from "babylonjs/Maths/math.vector";
  27259. import { Mesh } from "babylonjs/Meshes/mesh";
  27260. import { Scene, IDisposable } from "babylonjs/scene";
  27261. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27262. import { Material } from "babylonjs/Materials/material";
  27263. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27264. /**
  27265. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27266. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  27267. * The SPS is also a particle system. It provides some methods to manage the particles.
  27268. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27269. *
  27270. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27271. */
  27272. export class SolidParticleSystem implements IDisposable {
  27273. /**
  27274. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27275. * Example : var p = SPS.particles[i];
  27276. */
  27277. particles: SolidParticle[];
  27278. /**
  27279. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27280. */
  27281. nbParticles: number;
  27282. /**
  27283. * If the particles must ever face the camera (default false). Useful for planar particles.
  27284. */
  27285. billboard: boolean;
  27286. /**
  27287. * Recompute normals when adding a shape
  27288. */
  27289. recomputeNormals: boolean;
  27290. /**
  27291. * This a counter ofr your own usage. It's not set by any SPS functions.
  27292. */
  27293. counter: number;
  27294. /**
  27295. * The SPS name. This name is also given to the underlying mesh.
  27296. */
  27297. name: string;
  27298. /**
  27299. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27300. */
  27301. mesh: Mesh;
  27302. /**
  27303. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27304. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27305. */
  27306. vars: any;
  27307. /**
  27308. * This array is populated when the SPS is set as 'pickable'.
  27309. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27310. * Each element of this array is an object `{idx: int, faceId: int}`.
  27311. * `idx` is the picked particle index in the `SPS.particles` array
  27312. * `faceId` is the picked face index counted within this particle.
  27313. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27314. */
  27315. pickedParticles: {
  27316. idx: number;
  27317. faceId: number;
  27318. }[];
  27319. /**
  27320. * This array is populated when `enableDepthSort` is set to true.
  27321. * Each element of this array is an instance of the class DepthSortedParticle.
  27322. */
  27323. depthSortedParticles: DepthSortedParticle[];
  27324. /**
  27325. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27326. * @hidden
  27327. */
  27328. _bSphereOnly: boolean;
  27329. /**
  27330. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27331. * @hidden
  27332. */
  27333. _bSphereRadiusFactor: number;
  27334. private _scene;
  27335. private _positions;
  27336. private _indices;
  27337. private _normals;
  27338. private _colors;
  27339. private _uvs;
  27340. private _indices32;
  27341. private _positions32;
  27342. private _normals32;
  27343. private _fixedNormal32;
  27344. private _colors32;
  27345. private _uvs32;
  27346. private _index;
  27347. private _updatable;
  27348. private _pickable;
  27349. private _isVisibilityBoxLocked;
  27350. private _alwaysVisible;
  27351. private _depthSort;
  27352. private _expandable;
  27353. private _shapeCounter;
  27354. private _copy;
  27355. private _color;
  27356. private _computeParticleColor;
  27357. private _computeParticleTexture;
  27358. private _computeParticleRotation;
  27359. private _computeParticleVertex;
  27360. private _computeBoundingBox;
  27361. private _depthSortParticles;
  27362. private _camera;
  27363. private _mustUnrotateFixedNormals;
  27364. private _particlesIntersect;
  27365. private _needs32Bits;
  27366. private _isNotBuilt;
  27367. private _lastParticleId;
  27368. private _idxOfId;
  27369. private _multimaterialEnabled;
  27370. private _useModelMaterial;
  27371. private _indicesByMaterial;
  27372. private _materialIndexes;
  27373. private _depthSortFunction;
  27374. private _materialSortFunction;
  27375. private _materials;
  27376. private _multimaterial;
  27377. private _materialIndexesById;
  27378. private _defaultMaterial;
  27379. private _autoUpdateSubMeshes;
  27380. /**
  27381. * Creates a SPS (Solid Particle System) object.
  27382. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27383. * @param scene (Scene) is the scene in which the SPS is added.
  27384. * @param options defines the options of the sps e.g.
  27385. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27386. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27387. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27388. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27389. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27390. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27391. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27392. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27393. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27394. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27395. */
  27396. constructor(name: string, scene: Scene, options?: {
  27397. updatable?: boolean;
  27398. isPickable?: boolean;
  27399. enableDepthSort?: boolean;
  27400. particleIntersection?: boolean;
  27401. boundingSphereOnly?: boolean;
  27402. bSphereRadiusFactor?: number;
  27403. expandable?: boolean;
  27404. useModelMaterial?: boolean;
  27405. enableMultiMaterial?: boolean;
  27406. });
  27407. /**
  27408. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27409. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27410. * @returns the created mesh
  27411. */
  27412. buildMesh(): Mesh;
  27413. /**
  27414. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27415. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27416. * Thus the particles generated from `digest()` have their property `position` set yet.
  27417. * @param mesh ( Mesh ) is the mesh to be digested
  27418. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  27419. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27420. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27421. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27422. * @returns the current SPS
  27423. */
  27424. digest(mesh: Mesh, options?: {
  27425. facetNb?: number;
  27426. number?: number;
  27427. delta?: number;
  27428. storage?: [];
  27429. }): SolidParticleSystem;
  27430. /**
  27431. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27432. * @hidden
  27433. */
  27434. private _unrotateFixedNormals;
  27435. /**
  27436. * Resets the temporary working copy particle
  27437. * @hidden
  27438. */
  27439. private _resetCopy;
  27440. /**
  27441. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27442. * @param p the current index in the positions array to be updated
  27443. * @param ind the current index in the indices array
  27444. * @param shape a Vector3 array, the shape geometry
  27445. * @param positions the positions array to be updated
  27446. * @param meshInd the shape indices array
  27447. * @param indices the indices array to be updated
  27448. * @param meshUV the shape uv array
  27449. * @param uvs the uv array to be updated
  27450. * @param meshCol the shape color array
  27451. * @param colors the color array to be updated
  27452. * @param meshNor the shape normals array
  27453. * @param normals the normals array to be updated
  27454. * @param idx the particle index
  27455. * @param idxInShape the particle index in its shape
  27456. * @param options the addShape() method passed options
  27457. * @model the particle model
  27458. * @hidden
  27459. */
  27460. private _meshBuilder;
  27461. /**
  27462. * Returns a shape Vector3 array from positions float array
  27463. * @param positions float array
  27464. * @returns a vector3 array
  27465. * @hidden
  27466. */
  27467. private _posToShape;
  27468. /**
  27469. * Returns a shapeUV array from a float uvs (array deep copy)
  27470. * @param uvs as a float array
  27471. * @returns a shapeUV array
  27472. * @hidden
  27473. */
  27474. private _uvsToShapeUV;
  27475. /**
  27476. * Adds a new particle object in the particles array
  27477. * @param idx particle index in particles array
  27478. * @param id particle id
  27479. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27480. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27481. * @param model particle ModelShape object
  27482. * @param shapeId model shape identifier
  27483. * @param idxInShape index of the particle in the current model
  27484. * @param bInfo model bounding info object
  27485. * @param storage target storage array, if any
  27486. * @hidden
  27487. */
  27488. private _addParticle;
  27489. /**
  27490. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27491. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27492. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27493. * @param nb (positive integer) the number of particles to be created from this model
  27494. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27495. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27496. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27497. * @returns the number of shapes in the system
  27498. */
  27499. addShape(mesh: Mesh, nb: number, options?: {
  27500. positionFunction?: any;
  27501. vertexFunction?: any;
  27502. storage?: [];
  27503. }): number;
  27504. /**
  27505. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27506. * @hidden
  27507. */
  27508. private _rebuildParticle;
  27509. /**
  27510. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27511. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27512. * @returns the SPS.
  27513. */
  27514. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27515. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27516. * Returns an array with the removed particles.
  27517. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27518. * The SPS can't be empty so at least one particle needs to remain in place.
  27519. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27520. * @param start index of the first particle to remove
  27521. * @param end index of the last particle to remove (included)
  27522. * @returns an array populated with the removed particles
  27523. */
  27524. removeParticles(start: number, end: number): SolidParticle[];
  27525. /**
  27526. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27527. * @param solidParticleArray an array populated with Solid Particles objects
  27528. * @returns the SPS
  27529. */
  27530. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27531. /**
  27532. * Creates a new particle and modifies the SPS mesh geometry :
  27533. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27534. * - calls _addParticle() to populate the particle array
  27535. * factorized code from addShape() and insertParticlesFromArray()
  27536. * @param idx particle index in the particles array
  27537. * @param i particle index in its shape
  27538. * @param modelShape particle ModelShape object
  27539. * @param shape shape vertex array
  27540. * @param meshInd shape indices array
  27541. * @param meshUV shape uv array
  27542. * @param meshCol shape color array
  27543. * @param meshNor shape normals array
  27544. * @param bbInfo shape bounding info
  27545. * @param storage target particle storage
  27546. * @options addShape() passed options
  27547. * @hidden
  27548. */
  27549. private _insertNewParticle;
  27550. /**
  27551. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27552. * This method calls `updateParticle()` for each particle of the SPS.
  27553. * For an animated SPS, it is usually called within the render loop.
  27554. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27555. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27556. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27557. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27558. * @returns the SPS.
  27559. */
  27560. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27561. /**
  27562. * Disposes the SPS.
  27563. */
  27564. dispose(): void;
  27565. /**
  27566. * Returns a SolidParticle object from its identifier : particle.id
  27567. * @param id (integer) the particle Id
  27568. * @returns the searched particle or null if not found in the SPS.
  27569. */
  27570. getParticleById(id: number): Nullable<SolidParticle>;
  27571. /**
  27572. * Returns a new array populated with the particles having the passed shapeId.
  27573. * @param shapeId (integer) the shape identifier
  27574. * @returns a new solid particle array
  27575. */
  27576. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27577. /**
  27578. * Populates the passed array "ref" with the particles having the passed shapeId.
  27579. * @param shapeId the shape identifier
  27580. * @returns the SPS
  27581. * @param ref
  27582. */
  27583. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27584. /**
  27585. * Computes the required SubMeshes according the materials assigned to the particles.
  27586. * @returns the solid particle system.
  27587. * Does nothing if called before the SPS mesh is built.
  27588. */
  27589. computeSubMeshes(): SolidParticleSystem;
  27590. /**
  27591. * Sorts the solid particles by material when MultiMaterial is enabled.
  27592. * Updates the indices32 array.
  27593. * Updates the indicesByMaterial array.
  27594. * Updates the mesh indices array.
  27595. * @returns the SPS
  27596. * @hidden
  27597. */
  27598. private _sortParticlesByMaterial;
  27599. /**
  27600. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27601. * @hidden
  27602. */
  27603. private _setMaterialIndexesById;
  27604. /**
  27605. * Returns an array with unique values of Materials from the passed array
  27606. * @param array the material array to be checked and filtered
  27607. * @hidden
  27608. */
  27609. private _filterUniqueMaterialId;
  27610. /**
  27611. * Sets a new Standard Material as _defaultMaterial if not already set.
  27612. * @hidden
  27613. */
  27614. private _setDefaultMaterial;
  27615. /**
  27616. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27617. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27618. * @returns the SPS.
  27619. */
  27620. refreshVisibleSize(): SolidParticleSystem;
  27621. /**
  27622. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27623. * @param size the size (float) of the visibility box
  27624. * note : this doesn't lock the SPS mesh bounding box.
  27625. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27626. */
  27627. setVisibilityBox(size: number): void;
  27628. /**
  27629. * Gets whether the SPS as always visible or not
  27630. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27631. */
  27632. /**
  27633. * Sets the SPS as always visible or not
  27634. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27635. */
  27636. isAlwaysVisible: boolean;
  27637. /**
  27638. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27639. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27640. */
  27641. /**
  27642. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27643. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27644. */
  27645. isVisibilityBoxLocked: boolean;
  27646. /**
  27647. * Tells to `setParticles()` to compute the particle rotations or not.
  27648. * Default value : true. The SPS is faster when it's set to false.
  27649. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27650. */
  27651. /**
  27652. * Gets if `setParticles()` computes the particle rotations or not.
  27653. * Default value : true. The SPS is faster when it's set to false.
  27654. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27655. */
  27656. computeParticleRotation: boolean;
  27657. /**
  27658. * Tells to `setParticles()` to compute the particle colors or not.
  27659. * Default value : true. The SPS is faster when it's set to false.
  27660. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27661. */
  27662. /**
  27663. * Gets if `setParticles()` computes the particle colors or not.
  27664. * Default value : true. The SPS is faster when it's set to false.
  27665. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27666. */
  27667. computeParticleColor: boolean;
  27668. /**
  27669. * Gets if `setParticles()` computes the particle textures or not.
  27670. * Default value : true. The SPS is faster when it's set to false.
  27671. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27672. */
  27673. computeParticleTexture: boolean;
  27674. /**
  27675. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27676. * Default value : false. The SPS is faster when it's set to false.
  27677. * Note : the particle custom vertex positions aren't stored values.
  27678. */
  27679. /**
  27680. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27681. * Default value : false. The SPS is faster when it's set to false.
  27682. * Note : the particle custom vertex positions aren't stored values.
  27683. */
  27684. computeParticleVertex: boolean;
  27685. /**
  27686. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27687. */
  27688. /**
  27689. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27690. */
  27691. computeBoundingBox: boolean;
  27692. /**
  27693. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27694. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27695. * Default : `true`
  27696. */
  27697. /**
  27698. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27699. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27700. * Default : `true`
  27701. */
  27702. depthSortParticles: boolean;
  27703. /**
  27704. * Gets if the SPS is created as expandable at construction time.
  27705. * Default : `false`
  27706. */
  27707. readonly expandable: boolean;
  27708. /**
  27709. * Gets if the SPS supports the Multi Materials
  27710. */
  27711. readonly multimaterialEnabled: boolean;
  27712. /**
  27713. * Gets if the SPS uses the model materials for its own multimaterial.
  27714. */
  27715. readonly useModelMaterial: boolean;
  27716. /**
  27717. * The SPS used material array.
  27718. */
  27719. readonly materials: Material[];
  27720. /**
  27721. * Sets the SPS MultiMaterial from the passed materials.
  27722. * Note : the passed array is internally copied and not used then by reference.
  27723. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27724. */
  27725. setMultiMaterial(materials: Material[]): void;
  27726. /**
  27727. * The SPS computed multimaterial object
  27728. */
  27729. multimaterial: MultiMaterial;
  27730. /**
  27731. * If the subMeshes must be updated on the next call to setParticles()
  27732. */
  27733. autoUpdateSubMeshes: boolean;
  27734. /**
  27735. * This function does nothing. It may be overwritten to set all the particle first values.
  27736. * The SPS doesn't call this function, you may have to call it by your own.
  27737. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27738. */
  27739. initParticles(): void;
  27740. /**
  27741. * This function does nothing. It may be overwritten to recycle a particle.
  27742. * The SPS doesn't call this function, you may have to call it by your own.
  27743. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27744. * @param particle The particle to recycle
  27745. * @returns the recycled particle
  27746. */
  27747. recycleParticle(particle: SolidParticle): SolidParticle;
  27748. /**
  27749. * Updates a particle : this function should be overwritten by the user.
  27750. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27751. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27752. * @example : just set a particle position or velocity and recycle conditions
  27753. * @param particle The particle to update
  27754. * @returns the updated particle
  27755. */
  27756. updateParticle(particle: SolidParticle): SolidParticle;
  27757. /**
  27758. * Updates a vertex of a particle : it can be overwritten by the user.
  27759. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27760. * @param particle the current particle
  27761. * @param vertex the current index of the current particle
  27762. * @param pt the index of the current vertex in the particle shape
  27763. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27764. * @example : just set a vertex particle position
  27765. * @returns the updated vertex
  27766. */
  27767. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27768. /**
  27769. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27770. * This does nothing and may be overwritten by the user.
  27771. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27772. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27773. * @param update the boolean update value actually passed to setParticles()
  27774. */
  27775. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27776. /**
  27777. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27778. * This will be passed three parameters.
  27779. * This does nothing and may be overwritten by the user.
  27780. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27782. * @param update the boolean update value actually passed to setParticles()
  27783. */
  27784. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27785. }
  27786. }
  27787. declare module "babylonjs/Particles/solidParticle" {
  27788. import { Nullable } from "babylonjs/types";
  27789. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  27790. import { Color4 } from "babylonjs/Maths/math.color";
  27791. import { Mesh } from "babylonjs/Meshes/mesh";
  27792. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27793. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  27794. import { Plane } from "babylonjs/Maths/math.plane";
  27795. import { Material } from "babylonjs/Materials/material";
  27796. /**
  27797. * Represents one particle of a solid particle system.
  27798. */
  27799. export class SolidParticle {
  27800. /**
  27801. * particle global index
  27802. */
  27803. idx: number;
  27804. /**
  27805. * particle identifier
  27806. */
  27807. id: number;
  27808. /**
  27809. * The color of the particle
  27810. */
  27811. color: Nullable<Color4>;
  27812. /**
  27813. * The world space position of the particle.
  27814. */
  27815. position: Vector3;
  27816. /**
  27817. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27818. */
  27819. rotation: Vector3;
  27820. /**
  27821. * The world space rotation quaternion of the particle.
  27822. */
  27823. rotationQuaternion: Nullable<Quaternion>;
  27824. /**
  27825. * The scaling of the particle.
  27826. */
  27827. scaling: Vector3;
  27828. /**
  27829. * The uvs of the particle.
  27830. */
  27831. uvs: Vector4;
  27832. /**
  27833. * The current speed of the particle.
  27834. */
  27835. velocity: Vector3;
  27836. /**
  27837. * The pivot point in the particle local space.
  27838. */
  27839. pivot: Vector3;
  27840. /**
  27841. * Must the particle be translated from its pivot point in its local space ?
  27842. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27843. * Default : false
  27844. */
  27845. translateFromPivot: boolean;
  27846. /**
  27847. * Is the particle active or not ?
  27848. */
  27849. alive: boolean;
  27850. /**
  27851. * Is the particle visible or not ?
  27852. */
  27853. isVisible: boolean;
  27854. /**
  27855. * Index of this particle in the global "positions" array (Internal use)
  27856. * @hidden
  27857. */
  27858. _pos: number;
  27859. /**
  27860. * @hidden Index of this particle in the global "indices" array (Internal use)
  27861. */
  27862. _ind: number;
  27863. /**
  27864. * @hidden ModelShape of this particle (Internal use)
  27865. */
  27866. _model: ModelShape;
  27867. /**
  27868. * ModelShape id of this particle
  27869. */
  27870. shapeId: number;
  27871. /**
  27872. * Index of the particle in its shape id
  27873. */
  27874. idxInShape: number;
  27875. /**
  27876. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27877. */
  27878. _modelBoundingInfo: BoundingInfo;
  27879. /**
  27880. * @hidden Particle BoundingInfo object (Internal use)
  27881. */
  27882. _boundingInfo: BoundingInfo;
  27883. /**
  27884. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27885. */
  27886. _sps: SolidParticleSystem;
  27887. /**
  27888. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27889. */
  27890. _stillInvisible: boolean;
  27891. /**
  27892. * @hidden Last computed particle rotation matrix
  27893. */
  27894. _rotationMatrix: number[];
  27895. /**
  27896. * Parent particle Id, if any.
  27897. * Default null.
  27898. */
  27899. parentId: Nullable<number>;
  27900. /**
  27901. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27902. */
  27903. materialIndex: Nullable<number>;
  27904. /**
  27905. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27906. * The possible values are :
  27907. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27908. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27909. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27910. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27911. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27912. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27913. * */
  27914. cullingStrategy: number;
  27915. /**
  27916. * @hidden Internal global position in the SPS.
  27917. */
  27918. _globalPosition: Vector3;
  27919. /**
  27920. * Creates a Solid Particle object.
  27921. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27922. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27923. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27924. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27925. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27926. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27927. * @param shapeId (integer) is the model shape identifier in the SPS.
  27928. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27929. * @param sps defines the sps it is associated to
  27930. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27931. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27932. */
  27933. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27934. /**
  27935. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27936. * @param target the particle target
  27937. * @returns the current particle
  27938. */
  27939. copyToRef(target: SolidParticle): SolidParticle;
  27940. /**
  27941. * Legacy support, changed scale to scaling
  27942. */
  27943. /**
  27944. * Legacy support, changed scale to scaling
  27945. */
  27946. scale: Vector3;
  27947. /**
  27948. * Legacy support, changed quaternion to rotationQuaternion
  27949. */
  27950. /**
  27951. * Legacy support, changed quaternion to rotationQuaternion
  27952. */
  27953. quaternion: Nullable<Quaternion>;
  27954. /**
  27955. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27956. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27957. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27958. * @returns true if it intersects
  27959. */
  27960. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27961. /**
  27962. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27963. * A particle is in the frustum if its bounding box intersects the frustum
  27964. * @param frustumPlanes defines the frustum to test
  27965. * @returns true if the particle is in the frustum planes
  27966. */
  27967. isInFrustum(frustumPlanes: Plane[]): boolean;
  27968. /**
  27969. * get the rotation matrix of the particle
  27970. * @hidden
  27971. */
  27972. getRotationMatrix(m: Matrix): void;
  27973. }
  27974. /**
  27975. * Represents the shape of the model used by one particle of a solid particle system.
  27976. * SPS internal tool, don't use it manually.
  27977. */
  27978. export class ModelShape {
  27979. /**
  27980. * The shape id
  27981. * @hidden
  27982. */
  27983. shapeID: number;
  27984. /**
  27985. * flat array of model positions (internal use)
  27986. * @hidden
  27987. */
  27988. _shape: Vector3[];
  27989. /**
  27990. * flat array of model UVs (internal use)
  27991. * @hidden
  27992. */
  27993. _shapeUV: number[];
  27994. /**
  27995. * color array of the model
  27996. * @hidden
  27997. */
  27998. _shapeColors: number[];
  27999. /**
  28000. * indices array of the model
  28001. * @hidden
  28002. */
  28003. _indices: number[];
  28004. /**
  28005. * normals array of the model
  28006. * @hidden
  28007. */
  28008. _normals: number[];
  28009. /**
  28010. * length of the shape in the model indices array (internal use)
  28011. * @hidden
  28012. */
  28013. _indicesLength: number;
  28014. /**
  28015. * Custom position function (internal use)
  28016. * @hidden
  28017. */
  28018. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28019. /**
  28020. * Custom vertex function (internal use)
  28021. * @hidden
  28022. */
  28023. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28024. /**
  28025. * Model material (internal use)
  28026. * @hidden
  28027. */
  28028. _material: Nullable<Material>;
  28029. /**
  28030. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  28031. * SPS internal tool, don't use it manually.
  28032. * @hidden
  28033. */
  28034. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28035. }
  28036. /**
  28037. * Represents a Depth Sorted Particle in the solid particle system.
  28038. * @hidden
  28039. */
  28040. export class DepthSortedParticle {
  28041. /**
  28042. * Index of the particle in the "indices" array
  28043. */
  28044. ind: number;
  28045. /**
  28046. * Length of the particle shape in the "indices" array
  28047. */
  28048. indicesLength: number;
  28049. /**
  28050. * Squared distance from the particle to the camera
  28051. */
  28052. sqDistance: number;
  28053. /**
  28054. * Material index when used with MultiMaterials
  28055. */
  28056. materialIndex: number;
  28057. /**
  28058. * Creates a new sorted particle
  28059. * @param materialIndex
  28060. */
  28061. constructor(ind: number, indLength: number, materialIndex: number);
  28062. }
  28063. }
  28064. declare module "babylonjs/Collisions/meshCollisionData" {
  28065. import { Collider } from "babylonjs/Collisions/collider";
  28066. import { Vector3 } from "babylonjs/Maths/math.vector";
  28067. import { Nullable } from "babylonjs/types";
  28068. import { Observer } from "babylonjs/Misc/observable";
  28069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28070. /**
  28071. * @hidden
  28072. */
  28073. export class _MeshCollisionData {
  28074. _checkCollisions: boolean;
  28075. _collisionMask: number;
  28076. _collisionGroup: number;
  28077. _collider: Nullable<Collider>;
  28078. _oldPositionForCollisions: Vector3;
  28079. _diffPositionForCollisions: Vector3;
  28080. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28081. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28082. }
  28083. }
  28084. declare module "babylonjs/Meshes/abstractMesh" {
  28085. import { Observable } from "babylonjs/Misc/observable";
  28086. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28087. import { Camera } from "babylonjs/Cameras/camera";
  28088. import { Scene, IDisposable } from "babylonjs/scene";
  28089. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28090. import { Node } from "babylonjs/node";
  28091. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28092. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28094. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28095. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28096. import { Material } from "babylonjs/Materials/material";
  28097. import { Light } from "babylonjs/Lights/light";
  28098. import { Skeleton } from "babylonjs/Bones/skeleton";
  28099. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28100. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28101. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28102. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28103. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28104. import { Plane } from "babylonjs/Maths/math.plane";
  28105. import { Ray } from "babylonjs/Culling/ray";
  28106. import { Collider } from "babylonjs/Collisions/collider";
  28107. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28108. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28109. /** @hidden */
  28110. class _FacetDataStorage {
  28111. facetPositions: Vector3[];
  28112. facetNormals: Vector3[];
  28113. facetPartitioning: number[][];
  28114. facetNb: number;
  28115. partitioningSubdivisions: number;
  28116. partitioningBBoxRatio: number;
  28117. facetDataEnabled: boolean;
  28118. facetParameters: any;
  28119. bbSize: Vector3;
  28120. subDiv: {
  28121. max: number;
  28122. X: number;
  28123. Y: number;
  28124. Z: number;
  28125. };
  28126. facetDepthSort: boolean;
  28127. facetDepthSortEnabled: boolean;
  28128. depthSortedIndices: IndicesArray;
  28129. depthSortedFacets: {
  28130. ind: number;
  28131. sqDistance: number;
  28132. }[];
  28133. facetDepthSortFunction: (f1: {
  28134. ind: number;
  28135. sqDistance: number;
  28136. }, f2: {
  28137. ind: number;
  28138. sqDistance: number;
  28139. }) => number;
  28140. facetDepthSortFrom: Vector3;
  28141. facetDepthSortOrigin: Vector3;
  28142. invertedMatrix: Matrix;
  28143. }
  28144. /**
  28145. * @hidden
  28146. **/
  28147. class _InternalAbstractMeshDataInfo {
  28148. _hasVertexAlpha: boolean;
  28149. _useVertexColors: boolean;
  28150. _numBoneInfluencers: number;
  28151. _applyFog: boolean;
  28152. _receiveShadows: boolean;
  28153. _facetData: _FacetDataStorage;
  28154. _visibility: number;
  28155. _skeleton: Nullable<Skeleton>;
  28156. _layerMask: number;
  28157. _computeBonesUsingShaders: boolean;
  28158. _isActive: boolean;
  28159. _onlyForInstances: boolean;
  28160. _isActiveIntermediate: boolean;
  28161. _onlyForInstancesIntermediate: boolean;
  28162. _actAsRegularMesh: boolean;
  28163. }
  28164. /**
  28165. * Class used to store all common mesh properties
  28166. */
  28167. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28168. /** No occlusion */
  28169. static OCCLUSION_TYPE_NONE: number;
  28170. /** Occlusion set to optimisitic */
  28171. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28172. /** Occlusion set to strict */
  28173. static OCCLUSION_TYPE_STRICT: number;
  28174. /** Use an accurante occlusion algorithm */
  28175. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28176. /** Use a conservative occlusion algorithm */
  28177. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28178. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28179. * Test order :
  28180. * Is the bounding sphere outside the frustum ?
  28181. * If not, are the bounding box vertices outside the frustum ?
  28182. * It not, then the cullable object is in the frustum.
  28183. */
  28184. static readonly CULLINGSTRATEGY_STANDARD: number;
  28185. /** Culling strategy : Bounding Sphere Only.
  28186. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28187. * It's also less accurate than the standard because some not visible objects can still be selected.
  28188. * Test : is the bounding sphere outside the frustum ?
  28189. * If not, then the cullable object is in the frustum.
  28190. */
  28191. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28192. /** Culling strategy : Optimistic Inclusion.
  28193. * This in an inclusion test first, then the standard exclusion test.
  28194. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28195. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  28196. * Anyway, it's as accurate as the standard strategy.
  28197. * Test :
  28198. * Is the cullable object bounding sphere center in the frustum ?
  28199. * If not, apply the default culling strategy.
  28200. */
  28201. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28202. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28203. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28204. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28205. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  28206. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28207. * Test :
  28208. * Is the cullable object bounding sphere center in the frustum ?
  28209. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28210. */
  28211. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28212. /**
  28213. * No billboard
  28214. */
  28215. static readonly BILLBOARDMODE_NONE: number;
  28216. /** Billboard on X axis */
  28217. static readonly BILLBOARDMODE_X: number;
  28218. /** Billboard on Y axis */
  28219. static readonly BILLBOARDMODE_Y: number;
  28220. /** Billboard on Z axis */
  28221. static readonly BILLBOARDMODE_Z: number;
  28222. /** Billboard on all axes */
  28223. static readonly BILLBOARDMODE_ALL: number;
  28224. /** Billboard on using position instead of orientation */
  28225. static readonly BILLBOARDMODE_USE_POSITION: number;
  28226. /** @hidden */
  28227. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28228. /**
  28229. * The culling strategy to use to check whether the mesh must be rendered or not.
  28230. * This value can be changed at any time and will be used on the next render mesh selection.
  28231. * The possible values are :
  28232. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28233. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28234. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28235. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28236. * Please read each static variable documentation to get details about the culling process.
  28237. * */
  28238. cullingStrategy: number;
  28239. /**
  28240. * Gets the number of facets in the mesh
  28241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28242. */
  28243. readonly facetNb: number;
  28244. /**
  28245. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28247. */
  28248. partitioningSubdivisions: number;
  28249. /**
  28250. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28251. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28252. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28253. */
  28254. partitioningBBoxRatio: number;
  28255. /**
  28256. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28257. * Works only for updatable meshes.
  28258. * Doesn't work with multi-materials
  28259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28260. */
  28261. mustDepthSortFacets: boolean;
  28262. /**
  28263. * The location (Vector3) where the facet depth sort must be computed from.
  28264. * By default, the active camera position.
  28265. * Used only when facet depth sort is enabled
  28266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28267. */
  28268. facetDepthSortFrom: Vector3;
  28269. /**
  28270. * gets a boolean indicating if facetData is enabled
  28271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28272. */
  28273. readonly isFacetDataEnabled: boolean;
  28274. /** @hidden */
  28275. _updateNonUniformScalingState(value: boolean): boolean;
  28276. /**
  28277. * An event triggered when this mesh collides with another one
  28278. */
  28279. onCollideObservable: Observable<AbstractMesh>;
  28280. /** Set a function to call when this mesh collides with another one */
  28281. onCollide: () => void;
  28282. /**
  28283. * An event triggered when the collision's position changes
  28284. */
  28285. onCollisionPositionChangeObservable: Observable<Vector3>;
  28286. /** Set a function to call when the collision's position changes */
  28287. onCollisionPositionChange: () => void;
  28288. /**
  28289. * An event triggered when material is changed
  28290. */
  28291. onMaterialChangedObservable: Observable<AbstractMesh>;
  28292. /**
  28293. * Gets or sets the orientation for POV movement & rotation
  28294. */
  28295. definedFacingForward: boolean;
  28296. /** @hidden */
  28297. _occlusionQuery: Nullable<WebGLQuery>;
  28298. /** @hidden */
  28299. _renderingGroup: Nullable<RenderingGroup>;
  28300. /**
  28301. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28302. */
  28303. /**
  28304. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28305. */
  28306. visibility: number;
  28307. /** Gets or sets the alpha index used to sort transparent meshes
  28308. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28309. */
  28310. alphaIndex: number;
  28311. /**
  28312. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28313. */
  28314. isVisible: boolean;
  28315. /**
  28316. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28317. */
  28318. isPickable: boolean;
  28319. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28320. showSubMeshesBoundingBox: boolean;
  28321. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28322. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28323. */
  28324. isBlocker: boolean;
  28325. /**
  28326. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28327. */
  28328. enablePointerMoveEvents: boolean;
  28329. /**
  28330. * Specifies the rendering group id for this mesh (0 by default)
  28331. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28332. */
  28333. renderingGroupId: number;
  28334. private _material;
  28335. /** Gets or sets current material */
  28336. material: Nullable<Material>;
  28337. /**
  28338. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28339. * @see http://doc.babylonjs.com/babylon101/shadows
  28340. */
  28341. receiveShadows: boolean;
  28342. /** Defines color to use when rendering outline */
  28343. outlineColor: Color3;
  28344. /** Define width to use when rendering outline */
  28345. outlineWidth: number;
  28346. /** Defines color to use when rendering overlay */
  28347. overlayColor: Color3;
  28348. /** Defines alpha to use when rendering overlay */
  28349. overlayAlpha: number;
  28350. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28351. hasVertexAlpha: boolean;
  28352. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  28353. useVertexColors: boolean;
  28354. /**
  28355. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28356. */
  28357. computeBonesUsingShaders: boolean;
  28358. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28359. numBoneInfluencers: number;
  28360. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28361. applyFog: boolean;
  28362. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28363. useOctreeForRenderingSelection: boolean;
  28364. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28365. useOctreeForPicking: boolean;
  28366. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28367. useOctreeForCollisions: boolean;
  28368. /**
  28369. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28370. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28371. */
  28372. layerMask: number;
  28373. /**
  28374. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28375. */
  28376. alwaysSelectAsActiveMesh: boolean;
  28377. /**
  28378. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28379. */
  28380. doNotSyncBoundingInfo: boolean;
  28381. /**
  28382. * Gets or sets the current action manager
  28383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28384. */
  28385. actionManager: Nullable<AbstractActionManager>;
  28386. private _meshCollisionData;
  28387. /**
  28388. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28390. */
  28391. ellipsoid: Vector3;
  28392. /**
  28393. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28395. */
  28396. ellipsoidOffset: Vector3;
  28397. /**
  28398. * Gets or sets a collision mask used to mask collisions (default is -1).
  28399. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28400. */
  28401. collisionMask: number;
  28402. /**
  28403. * Gets or sets the current collision group mask (-1 by default).
  28404. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28405. */
  28406. collisionGroup: number;
  28407. /**
  28408. * Defines edge width used when edgesRenderer is enabled
  28409. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28410. */
  28411. edgesWidth: number;
  28412. /**
  28413. * Defines edge color used when edgesRenderer is enabled
  28414. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28415. */
  28416. edgesColor: Color4;
  28417. /** @hidden */
  28418. _edgesRenderer: Nullable<IEdgesRenderer>;
  28419. /** @hidden */
  28420. _masterMesh: Nullable<AbstractMesh>;
  28421. /** @hidden */
  28422. _boundingInfo: Nullable<BoundingInfo>;
  28423. /** @hidden */
  28424. _renderId: number;
  28425. /**
  28426. * Gets or sets the list of subMeshes
  28427. * @see http://doc.babylonjs.com/how_to/multi_materials
  28428. */
  28429. subMeshes: SubMesh[];
  28430. /** @hidden */
  28431. _intersectionsInProgress: AbstractMesh[];
  28432. /** @hidden */
  28433. _unIndexed: boolean;
  28434. /** @hidden */
  28435. _lightSources: Light[];
  28436. /** Gets the list of lights affecting that mesh */
  28437. readonly lightSources: Light[];
  28438. /** @hidden */
  28439. readonly _positions: Nullable<Vector3[]>;
  28440. /** @hidden */
  28441. _waitingData: {
  28442. lods: Nullable<any>;
  28443. actions: Nullable<any>;
  28444. freezeWorldMatrix: Nullable<boolean>;
  28445. };
  28446. /** @hidden */
  28447. _bonesTransformMatrices: Nullable<Float32Array>;
  28448. /** @hidden */
  28449. _transformMatrixTexture: Nullable<RawTexture>;
  28450. /**
  28451. * Gets or sets a skeleton to apply skining transformations
  28452. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28453. */
  28454. skeleton: Nullable<Skeleton>;
  28455. /**
  28456. * An event triggered when the mesh is rebuilt.
  28457. */
  28458. onRebuildObservable: Observable<AbstractMesh>;
  28459. /**
  28460. * Creates a new AbstractMesh
  28461. * @param name defines the name of the mesh
  28462. * @param scene defines the hosting scene
  28463. */
  28464. constructor(name: string, scene?: Nullable<Scene>);
  28465. /**
  28466. * Returns the string "AbstractMesh"
  28467. * @returns "AbstractMesh"
  28468. */
  28469. getClassName(): string;
  28470. /**
  28471. * Gets a string representation of the current mesh
  28472. * @param fullDetails defines a boolean indicating if full details must be included
  28473. * @returns a string representation of the current mesh
  28474. */
  28475. toString(fullDetails?: boolean): string;
  28476. /**
  28477. * @hidden
  28478. */
  28479. protected _getEffectiveParent(): Nullable<Node>;
  28480. /** @hidden */
  28481. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28482. /** @hidden */
  28483. _rebuild(): void;
  28484. /** @hidden */
  28485. _resyncLightSources(): void;
  28486. /** @hidden */
  28487. _resyncLightSource(light: Light): void;
  28488. /** @hidden */
  28489. _unBindEffect(): void;
  28490. /** @hidden */
  28491. _removeLightSource(light: Light, dispose: boolean): void;
  28492. private _markSubMeshesAsDirty;
  28493. /** @hidden */
  28494. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28495. /** @hidden */
  28496. _markSubMeshesAsAttributesDirty(): void;
  28497. /** @hidden */
  28498. _markSubMeshesAsMiscDirty(): void;
  28499. /**
  28500. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28501. */
  28502. scaling: Vector3;
  28503. /**
  28504. * Returns true if the mesh is blocked. Implemented by child classes
  28505. */
  28506. readonly isBlocked: boolean;
  28507. /**
  28508. * Returns the mesh itself by default. Implemented by child classes
  28509. * @param camera defines the camera to use to pick the right LOD level
  28510. * @returns the currentAbstractMesh
  28511. */
  28512. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28513. /**
  28514. * Returns 0 by default. Implemented by child classes
  28515. * @returns an integer
  28516. */
  28517. getTotalVertices(): number;
  28518. /**
  28519. * Returns a positive integer : the total number of indices in this mesh geometry.
  28520. * @returns the numner of indices or zero if the mesh has no geometry.
  28521. */
  28522. getTotalIndices(): number;
  28523. /**
  28524. * Returns null by default. Implemented by child classes
  28525. * @returns null
  28526. */
  28527. getIndices(): Nullable<IndicesArray>;
  28528. /**
  28529. * Returns the array of the requested vertex data kind. Implemented by child classes
  28530. * @param kind defines the vertex data kind to use
  28531. * @returns null
  28532. */
  28533. getVerticesData(kind: string): Nullable<FloatArray>;
  28534. /**
  28535. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28536. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28537. * Note that a new underlying VertexBuffer object is created each call.
  28538. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28539. * @param kind defines vertex data kind:
  28540. * * VertexBuffer.PositionKind
  28541. * * VertexBuffer.UVKind
  28542. * * VertexBuffer.UV2Kind
  28543. * * VertexBuffer.UV3Kind
  28544. * * VertexBuffer.UV4Kind
  28545. * * VertexBuffer.UV5Kind
  28546. * * VertexBuffer.UV6Kind
  28547. * * VertexBuffer.ColorKind
  28548. * * VertexBuffer.MatricesIndicesKind
  28549. * * VertexBuffer.MatricesIndicesExtraKind
  28550. * * VertexBuffer.MatricesWeightsKind
  28551. * * VertexBuffer.MatricesWeightsExtraKind
  28552. * @param data defines the data source
  28553. * @param updatable defines if the data must be flagged as updatable (or static)
  28554. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  28555. * @returns the current mesh
  28556. */
  28557. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28558. /**
  28559. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28560. * If the mesh has no geometry, it is simply returned as it is.
  28561. * @param kind defines vertex data kind:
  28562. * * VertexBuffer.PositionKind
  28563. * * VertexBuffer.UVKind
  28564. * * VertexBuffer.UV2Kind
  28565. * * VertexBuffer.UV3Kind
  28566. * * VertexBuffer.UV4Kind
  28567. * * VertexBuffer.UV5Kind
  28568. * * VertexBuffer.UV6Kind
  28569. * * VertexBuffer.ColorKind
  28570. * * VertexBuffer.MatricesIndicesKind
  28571. * * VertexBuffer.MatricesIndicesExtraKind
  28572. * * VertexBuffer.MatricesWeightsKind
  28573. * * VertexBuffer.MatricesWeightsExtraKind
  28574. * @param data defines the data source
  28575. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  28576. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28577. * @returns the current mesh
  28578. */
  28579. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28580. /**
  28581. * Sets the mesh indices,
  28582. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28583. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28584. * @param totalVertices Defines the total number of vertices
  28585. * @returns the current mesh
  28586. */
  28587. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28588. /**
  28589. * Gets a boolean indicating if specific vertex data is present
  28590. * @param kind defines the vertex data kind to use
  28591. * @returns true is data kind is present
  28592. */
  28593. isVerticesDataPresent(kind: string): boolean;
  28594. /**
  28595. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28596. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28597. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28598. * @returns a BoundingInfo
  28599. */
  28600. getBoundingInfo(): BoundingInfo;
  28601. /**
  28602. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28603. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28604. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28605. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28606. * @returns the current mesh
  28607. */
  28608. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28609. /**
  28610. * Overwrite the current bounding info
  28611. * @param boundingInfo defines the new bounding info
  28612. * @returns the current mesh
  28613. */
  28614. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28615. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28616. readonly useBones: boolean;
  28617. /** @hidden */
  28618. _preActivate(): void;
  28619. /** @hidden */
  28620. _preActivateForIntermediateRendering(renderId: number): void;
  28621. /** @hidden */
  28622. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28623. /** @hidden */
  28624. _postActivate(): void;
  28625. /** @hidden */
  28626. _freeze(): void;
  28627. /** @hidden */
  28628. _unFreeze(): void;
  28629. /**
  28630. * Gets the current world matrix
  28631. * @returns a Matrix
  28632. */
  28633. getWorldMatrix(): Matrix;
  28634. /** @hidden */
  28635. _getWorldMatrixDeterminant(): number;
  28636. /**
  28637. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28638. */
  28639. readonly isAnInstance: boolean;
  28640. /**
  28641. * Gets a boolean indicating if this mesh has instances
  28642. */
  28643. readonly hasInstances: boolean;
  28644. /**
  28645. * Perform relative position change from the point of view of behind the front of the mesh.
  28646. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28647. * Supports definition of mesh facing forward or backward
  28648. * @param amountRight defines the distance on the right axis
  28649. * @param amountUp defines the distance on the up axis
  28650. * @param amountForward defines the distance on the forward axis
  28651. * @returns the current mesh
  28652. */
  28653. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28654. /**
  28655. * Calculate relative position change from the point of view of behind the front of the mesh.
  28656. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28657. * Supports definition of mesh facing forward or backward
  28658. * @param amountRight defines the distance on the right axis
  28659. * @param amountUp defines the distance on the up axis
  28660. * @param amountForward defines the distance on the forward axis
  28661. * @returns the new displacement vector
  28662. */
  28663. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28664. /**
  28665. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28666. * Supports definition of mesh facing forward or backward
  28667. * @param flipBack defines the flip
  28668. * @param twirlClockwise defines the twirl
  28669. * @param tiltRight defines the tilt
  28670. * @returns the current mesh
  28671. */
  28672. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28673. /**
  28674. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28675. * Supports definition of mesh facing forward or backward.
  28676. * @param flipBack defines the flip
  28677. * @param twirlClockwise defines the twirl
  28678. * @param tiltRight defines the tilt
  28679. * @returns the new rotation vector
  28680. */
  28681. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28682. /**
  28683. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28684. * This means the mesh underlying bounding box and sphere are recomputed.
  28685. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28686. * @returns the current mesh
  28687. */
  28688. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28689. /** @hidden */
  28690. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28691. /** @hidden */
  28692. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28693. /** @hidden */
  28694. _updateBoundingInfo(): AbstractMesh;
  28695. /** @hidden */
  28696. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28697. /** @hidden */
  28698. protected _afterComputeWorldMatrix(): void;
  28699. /** @hidden */
  28700. readonly _effectiveMesh: AbstractMesh;
  28701. /**
  28702. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28703. * A mesh is in the frustum if its bounding box intersects the frustum
  28704. * @param frustumPlanes defines the frustum to test
  28705. * @returns true if the mesh is in the frustum planes
  28706. */
  28707. isInFrustum(frustumPlanes: Plane[]): boolean;
  28708. /**
  28709. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28710. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28711. * @param frustumPlanes defines the frustum to test
  28712. * @returns true if the mesh is completely in the frustum planes
  28713. */
  28714. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28715. /**
  28716. * True if the mesh intersects another mesh or a SolidParticle object
  28717. * @param mesh defines a target mesh or SolidParticle to test
  28718. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  28719. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28720. * @returns true if there is an intersection
  28721. */
  28722. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28723. /**
  28724. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28725. * @param point defines the point to test
  28726. * @returns true if there is an intersection
  28727. */
  28728. intersectsPoint(point: Vector3): boolean;
  28729. /**
  28730. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28731. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28732. */
  28733. checkCollisions: boolean;
  28734. /**
  28735. * Gets Collider object used to compute collisions (not physics)
  28736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28737. */
  28738. readonly collider: Nullable<Collider>;
  28739. /**
  28740. * Move the mesh using collision engine
  28741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28742. * @param displacement defines the requested displacement vector
  28743. * @returns the current mesh
  28744. */
  28745. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28746. private _onCollisionPositionChange;
  28747. /** @hidden */
  28748. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28749. /** @hidden */
  28750. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28751. /** @hidden */
  28752. _checkCollision(collider: Collider): AbstractMesh;
  28753. /** @hidden */
  28754. _generatePointsArray(): boolean;
  28755. /**
  28756. * Checks if the passed Ray intersects with the mesh
  28757. * @param ray defines the ray to use
  28758. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28759. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28760. * @returns the picking info
  28761. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28762. */
  28763. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28764. /**
  28765. * Clones the current mesh
  28766. * @param name defines the mesh name
  28767. * @param newParent defines the new mesh parent
  28768. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28769. * @returns the new mesh
  28770. */
  28771. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28772. /**
  28773. * Disposes all the submeshes of the current meshnp
  28774. * @returns the current mesh
  28775. */
  28776. releaseSubMeshes(): AbstractMesh;
  28777. /**
  28778. * Releases resources associated with this abstract mesh.
  28779. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28780. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28781. */
  28782. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28783. /**
  28784. * Adds the passed mesh as a child to the current mesh
  28785. * @param mesh defines the child mesh
  28786. * @returns the current mesh
  28787. */
  28788. addChild(mesh: AbstractMesh): AbstractMesh;
  28789. /**
  28790. * Removes the passed mesh from the current mesh children list
  28791. * @param mesh defines the child mesh
  28792. * @returns the current mesh
  28793. */
  28794. removeChild(mesh: AbstractMesh): AbstractMesh;
  28795. /** @hidden */
  28796. private _initFacetData;
  28797. /**
  28798. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28799. * This method can be called within the render loop.
  28800. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  28801. * @returns the current mesh
  28802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28803. */
  28804. updateFacetData(): AbstractMesh;
  28805. /**
  28806. * Returns the facetLocalNormals array.
  28807. * The normals are expressed in the mesh local spac
  28808. * @returns an array of Vector3
  28809. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28810. */
  28811. getFacetLocalNormals(): Vector3[];
  28812. /**
  28813. * Returns the facetLocalPositions array.
  28814. * The facet positions are expressed in the mesh local space
  28815. * @returns an array of Vector3
  28816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28817. */
  28818. getFacetLocalPositions(): Vector3[];
  28819. /**
  28820. * Returns the facetLocalPartioning array
  28821. * @returns an array of array of numbers
  28822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28823. */
  28824. getFacetLocalPartitioning(): number[][];
  28825. /**
  28826. * Returns the i-th facet position in the world system.
  28827. * This method allocates a new Vector3 per call
  28828. * @param i defines the facet index
  28829. * @returns a new Vector3
  28830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28831. */
  28832. getFacetPosition(i: number): Vector3;
  28833. /**
  28834. * Sets the reference Vector3 with the i-th facet position in the world system
  28835. * @param i defines the facet index
  28836. * @param ref defines the target vector
  28837. * @returns the current mesh
  28838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28839. */
  28840. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28841. /**
  28842. * Returns the i-th facet normal in the world system.
  28843. * This method allocates a new Vector3 per call
  28844. * @param i defines the facet index
  28845. * @returns a new Vector3
  28846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28847. */
  28848. getFacetNormal(i: number): Vector3;
  28849. /**
  28850. * Sets the reference Vector3 with the i-th facet normal in the world system
  28851. * @param i defines the facet index
  28852. * @param ref defines the target vector
  28853. * @returns the current mesh
  28854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28855. */
  28856. getFacetNormalToRef(i: number, ref: Vector3): this;
  28857. /**
  28858. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  28859. * @param x defines x coordinate
  28860. * @param y defines y coordinate
  28861. * @param z defines z coordinate
  28862. * @returns the array of facet indexes
  28863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28864. */
  28865. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28866. /**
  28867. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28868. * @param projected sets as the (x,y,z) world projection on the facet
  28869. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  28870. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  28871. * @param x defines x coordinate
  28872. * @param y defines y coordinate
  28873. * @param z defines z coordinate
  28874. * @returns the face index if found (or null instead)
  28875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28876. */
  28877. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28878. /**
  28879. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28880. * @param projected sets as the (x,y,z) local projection on the facet
  28881. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  28882. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  28883. * @param x defines x coordinate
  28884. * @param y defines y coordinate
  28885. * @param z defines z coordinate
  28886. * @returns the face index if found (or null instead)
  28887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28888. */
  28889. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28890. /**
  28891. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28892. * @returns the parameters
  28893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28894. */
  28895. getFacetDataParameters(): any;
  28896. /**
  28897. * Disables the feature FacetData and frees the related memory
  28898. * @returns the current mesh
  28899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28900. */
  28901. disableFacetData(): AbstractMesh;
  28902. /**
  28903. * Updates the AbstractMesh indices array
  28904. * @param indices defines the data source
  28905. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28906. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  28907. * @returns the current mesh
  28908. */
  28909. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28910. /**
  28911. * Creates new normals data for the mesh
  28912. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28913. * @returns the current mesh
  28914. */
  28915. createNormals(updatable: boolean): AbstractMesh;
  28916. /**
  28917. * Align the mesh with a normal
  28918. * @param normal defines the normal to use
  28919. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28920. * @returns the current mesh
  28921. */
  28922. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28923. /** @hidden */
  28924. _checkOcclusionQuery(): boolean;
  28925. /**
  28926. * Disables the mesh edge rendering mode
  28927. * @returns the currentAbstractMesh
  28928. */
  28929. disableEdgesRendering(): AbstractMesh;
  28930. /**
  28931. * Enables the edge rendering mode on the mesh.
  28932. * This mode makes the mesh edges visible
  28933. * @param epsilon defines the maximal distance between two angles to detect a face
  28934. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28935. * @returns the currentAbstractMesh
  28936. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28937. */
  28938. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28939. }
  28940. }
  28941. declare module "babylonjs/Actions/actionEvent" {
  28942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28943. import { Nullable } from "babylonjs/types";
  28944. import { Sprite } from "babylonjs/Sprites/sprite";
  28945. import { Scene } from "babylonjs/scene";
  28946. import { Vector2 } from "babylonjs/Maths/math.vector";
  28947. /**
  28948. * Interface used to define ActionEvent
  28949. */
  28950. export interface IActionEvent {
  28951. /** The mesh or sprite that triggered the action */
  28952. source: any;
  28953. /** The X mouse cursor position at the time of the event */
  28954. pointerX: number;
  28955. /** The Y mouse cursor position at the time of the event */
  28956. pointerY: number;
  28957. /** The mesh that is currently pointed at (can be null) */
  28958. meshUnderPointer: Nullable<AbstractMesh>;
  28959. /** the original (browser) event that triggered the ActionEvent */
  28960. sourceEvent?: any;
  28961. /** additional data for the event */
  28962. additionalData?: any;
  28963. }
  28964. /**
  28965. * ActionEvent is the event being sent when an action is triggered.
  28966. */
  28967. export class ActionEvent implements IActionEvent {
  28968. /** The mesh or sprite that triggered the action */
  28969. source: any;
  28970. /** The X mouse cursor position at the time of the event */
  28971. pointerX: number;
  28972. /** The Y mouse cursor position at the time of the event */
  28973. pointerY: number;
  28974. /** The mesh that is currently pointed at (can be null) */
  28975. meshUnderPointer: Nullable<AbstractMesh>;
  28976. /** the original (browser) event that triggered the ActionEvent */
  28977. sourceEvent?: any;
  28978. /** additional data for the event */
  28979. additionalData?: any;
  28980. /**
  28981. * Creates a new ActionEvent
  28982. * @param source The mesh or sprite that triggered the action
  28983. * @param pointerX The X mouse cursor position at the time of the event
  28984. * @param pointerY The Y mouse cursor position at the time of the event
  28985. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28986. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28987. * @param additionalData additional data for the event
  28988. */
  28989. constructor(
  28990. /** The mesh or sprite that triggered the action */
  28991. source: any,
  28992. /** The X mouse cursor position at the time of the event */
  28993. pointerX: number,
  28994. /** The Y mouse cursor position at the time of the event */
  28995. pointerY: number,
  28996. /** The mesh that is currently pointed at (can be null) */
  28997. meshUnderPointer: Nullable<AbstractMesh>,
  28998. /** the original (browser) event that triggered the ActionEvent */
  28999. sourceEvent?: any,
  29000. /** additional data for the event */
  29001. additionalData?: any);
  29002. /**
  29003. * Helper function to auto-create an ActionEvent from a source mesh.
  29004. * @param source The source mesh that triggered the event
  29005. * @param evt The original (browser) event
  29006. * @param additionalData additional data for the event
  29007. * @returns the new ActionEvent
  29008. */
  29009. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29010. /**
  29011. * Helper function to auto-create an ActionEvent from a source sprite
  29012. * @param source The source sprite that triggered the event
  29013. * @param scene Scene associated with the sprite
  29014. * @param evt The original (browser) event
  29015. * @param additionalData additional data for the event
  29016. * @returns the new ActionEvent
  29017. */
  29018. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29019. /**
  29020. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29021. * @param scene the scene where the event occurred
  29022. * @param evt The original (browser) event
  29023. * @returns the new ActionEvent
  29024. */
  29025. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29026. /**
  29027. * Helper function to auto-create an ActionEvent from a primitive
  29028. * @param prim defines the target primitive
  29029. * @param pointerPos defines the pointer position
  29030. * @param evt The original (browser) event
  29031. * @param additionalData additional data for the event
  29032. * @returns the new ActionEvent
  29033. */
  29034. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29035. }
  29036. }
  29037. declare module "babylonjs/Actions/abstractActionManager" {
  29038. import { IDisposable } from "babylonjs/scene";
  29039. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29040. import { IAction } from "babylonjs/Actions/action";
  29041. import { Nullable } from "babylonjs/types";
  29042. /**
  29043. * Abstract class used to decouple action Manager from scene and meshes.
  29044. * Do not instantiate.
  29045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29046. */
  29047. export abstract class AbstractActionManager implements IDisposable {
  29048. /** Gets the list of active triggers */
  29049. static Triggers: {
  29050. [key: string]: number;
  29051. };
  29052. /** Gets the cursor to use when hovering items */
  29053. hoverCursor: string;
  29054. /** Gets the list of actions */
  29055. actions: IAction[];
  29056. /**
  29057. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29058. */
  29059. isRecursive: boolean;
  29060. /**
  29061. * Releases all associated resources
  29062. */
  29063. abstract dispose(): void;
  29064. /**
  29065. * Does this action manager has pointer triggers
  29066. */
  29067. abstract readonly hasPointerTriggers: boolean;
  29068. /**
  29069. * Does this action manager has pick triggers
  29070. */
  29071. abstract readonly hasPickTriggers: boolean;
  29072. /**
  29073. * Process a specific trigger
  29074. * @param trigger defines the trigger to process
  29075. * @param evt defines the event details to be processed
  29076. */
  29077. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29078. /**
  29079. * Does this action manager handles actions of any of the given triggers
  29080. * @param triggers defines the triggers to be tested
  29081. * @return a boolean indicating whether one (or more) of the triggers is handled
  29082. */
  29083. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29084. /**
  29085. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29086. * speed.
  29087. * @param triggerA defines the trigger to be tested
  29088. * @param triggerB defines the trigger to be tested
  29089. * @return a boolean indicating whether one (or more) of the triggers is handled
  29090. */
  29091. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29092. /**
  29093. * Does this action manager handles actions of a given trigger
  29094. * @param trigger defines the trigger to be tested
  29095. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29096. * @return whether the trigger is handled
  29097. */
  29098. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29099. /**
  29100. * Serialize this manager to a JSON object
  29101. * @param name defines the property name to store this manager
  29102. * @returns a JSON representation of this manager
  29103. */
  29104. abstract serialize(name: string): any;
  29105. /**
  29106. * Registers an action to this action manager
  29107. * @param action defines the action to be registered
  29108. * @return the action amended (prepared) after registration
  29109. */
  29110. abstract registerAction(action: IAction): Nullable<IAction>;
  29111. /**
  29112. * Unregisters an action to this action manager
  29113. * @param action defines the action to be unregistered
  29114. * @return a boolean indicating whether the action has been unregistered
  29115. */
  29116. abstract unregisterAction(action: IAction): Boolean;
  29117. /**
  29118. * Does exist one action manager with at least one trigger
  29119. **/
  29120. static readonly HasTriggers: boolean;
  29121. /**
  29122. * Does exist one action manager with at least one pick trigger
  29123. **/
  29124. static readonly HasPickTriggers: boolean;
  29125. /**
  29126. * Does exist one action manager that handles actions of a given trigger
  29127. * @param trigger defines the trigger to be tested
  29128. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29129. **/
  29130. static HasSpecificTrigger(trigger: number): boolean;
  29131. }
  29132. }
  29133. declare module "babylonjs/node" {
  29134. import { Scene } from "babylonjs/scene";
  29135. import { Nullable } from "babylonjs/types";
  29136. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29137. import { Engine } from "babylonjs/Engines/engine";
  29138. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29139. import { Observable } from "babylonjs/Misc/observable";
  29140. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29141. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29142. import { Animatable } from "babylonjs/Animations/animatable";
  29143. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29144. import { Animation } from "babylonjs/Animations/animation";
  29145. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29147. /**
  29148. * Defines how a node can be built from a string name.
  29149. */
  29150. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29151. /**
  29152. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29153. */
  29154. export class Node implements IBehaviorAware<Node> {
  29155. /** @hidden */
  29156. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29157. private static _NodeConstructors;
  29158. /**
  29159. * Add a new node constructor
  29160. * @param type defines the type name of the node to construct
  29161. * @param constructorFunc defines the constructor function
  29162. */
  29163. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29164. /**
  29165. * Returns a node constructor based on type name
  29166. * @param type defines the type name
  29167. * @param name defines the new node name
  29168. * @param scene defines the hosting scene
  29169. * @param options defines optional options to transmit to constructors
  29170. * @returns the new constructor or null
  29171. */
  29172. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29173. /**
  29174. * Gets or sets the name of the node
  29175. */
  29176. name: string;
  29177. /**
  29178. * Gets or sets the id of the node
  29179. */
  29180. id: string;
  29181. /**
  29182. * Gets or sets the unique id of the node
  29183. */
  29184. uniqueId: number;
  29185. /**
  29186. * Gets or sets a string used to store user defined state for the node
  29187. */
  29188. state: string;
  29189. /**
  29190. * Gets or sets an object used to store user defined information for the node
  29191. */
  29192. metadata: any;
  29193. /**
  29194. * For internal use only. Please do not use.
  29195. */
  29196. reservedDataStore: any;
  29197. /**
  29198. * List of inspectable custom properties (used by the Inspector)
  29199. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29200. */
  29201. inspectableCustomProperties: IInspectable[];
  29202. private _doNotSerialize;
  29203. /**
  29204. * Gets or sets a boolean used to define if the node must be serialized
  29205. */
  29206. doNotSerialize: boolean;
  29207. /** @hidden */
  29208. _isDisposed: boolean;
  29209. /**
  29210. * Gets a list of Animations associated with the node
  29211. */
  29212. animations: import("babylonjs/Animations/animation").Animation[];
  29213. protected _ranges: {
  29214. [name: string]: Nullable<AnimationRange>;
  29215. };
  29216. /**
  29217. * Callback raised when the node is ready to be used
  29218. */
  29219. onReady: Nullable<(node: Node) => void>;
  29220. private _isEnabled;
  29221. private _isParentEnabled;
  29222. private _isReady;
  29223. /** @hidden */
  29224. _currentRenderId: number;
  29225. private _parentUpdateId;
  29226. /** @hidden */
  29227. _childUpdateId: number;
  29228. /** @hidden */
  29229. _waitingParentId: Nullable<string>;
  29230. /** @hidden */
  29231. _scene: Scene;
  29232. /** @hidden */
  29233. _cache: any;
  29234. private _parentNode;
  29235. private _children;
  29236. /** @hidden */
  29237. _worldMatrix: Matrix;
  29238. /** @hidden */
  29239. _worldMatrixDeterminant: number;
  29240. /** @hidden */
  29241. _worldMatrixDeterminantIsDirty: boolean;
  29242. /** @hidden */
  29243. private _sceneRootNodesIndex;
  29244. /**
  29245. * Gets a boolean indicating if the node has been disposed
  29246. * @returns true if the node was disposed
  29247. */
  29248. isDisposed(): boolean;
  29249. /**
  29250. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29251. * @see https://doc.babylonjs.com/how_to/parenting
  29252. */
  29253. parent: Nullable<Node>;
  29254. /** @hidden */
  29255. _addToSceneRootNodes(): void;
  29256. /** @hidden */
  29257. _removeFromSceneRootNodes(): void;
  29258. private _animationPropertiesOverride;
  29259. /**
  29260. * Gets or sets the animation properties override
  29261. */
  29262. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29263. /**
  29264. * Gets a string idenfifying the name of the class
  29265. * @returns "Node" string
  29266. */
  29267. getClassName(): string;
  29268. /** @hidden */
  29269. readonly _isNode: boolean;
  29270. /**
  29271. * An event triggered when the mesh is disposed
  29272. */
  29273. onDisposeObservable: Observable<Node>;
  29274. private _onDisposeObserver;
  29275. /**
  29276. * Sets a callback that will be raised when the node will be disposed
  29277. */
  29278. onDispose: () => void;
  29279. /**
  29280. * Creates a new Node
  29281. * @param name the name and id to be given to this node
  29282. * @param scene the scene this node will be added to
  29283. */
  29284. constructor(name: string, scene?: Nullable<Scene>);
  29285. /**
  29286. * Gets the scene of the node
  29287. * @returns a scene
  29288. */
  29289. getScene(): Scene;
  29290. /**
  29291. * Gets the engine of the node
  29292. * @returns a Engine
  29293. */
  29294. getEngine(): Engine;
  29295. private _behaviors;
  29296. /**
  29297. * Attach a behavior to the node
  29298. * @see http://doc.babylonjs.com/features/behaviour
  29299. * @param behavior defines the behavior to attach
  29300. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29301. * @returns the current Node
  29302. */
  29303. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29304. /**
  29305. * Remove an attached behavior
  29306. * @see http://doc.babylonjs.com/features/behaviour
  29307. * @param behavior defines the behavior to attach
  29308. * @returns the current Node
  29309. */
  29310. removeBehavior(behavior: Behavior<Node>): Node;
  29311. /**
  29312. * Gets the list of attached behaviors
  29313. * @see http://doc.babylonjs.com/features/behaviour
  29314. */
  29315. readonly behaviors: Behavior<Node>[];
  29316. /**
  29317. * Gets an attached behavior by name
  29318. * @param name defines the name of the behavior to look for
  29319. * @see http://doc.babylonjs.com/features/behaviour
  29320. * @returns null if behavior was not found else the requested behavior
  29321. */
  29322. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29323. /**
  29324. * Returns the latest update of the World matrix
  29325. * @returns a Matrix
  29326. */
  29327. getWorldMatrix(): Matrix;
  29328. /** @hidden */
  29329. _getWorldMatrixDeterminant(): number;
  29330. /**
  29331. * Returns directly the latest state of the mesh World matrix.
  29332. * A Matrix is returned.
  29333. */
  29334. readonly worldMatrixFromCache: Matrix;
  29335. /** @hidden */
  29336. _initCache(): void;
  29337. /** @hidden */
  29338. updateCache(force?: boolean): void;
  29339. /** @hidden */
  29340. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29341. /** @hidden */
  29342. _updateCache(ignoreParentClass?: boolean): void;
  29343. /** @hidden */
  29344. _isSynchronized(): boolean;
  29345. /** @hidden */
  29346. _markSyncedWithParent(): void;
  29347. /** @hidden */
  29348. isSynchronizedWithParent(): boolean;
  29349. /** @hidden */
  29350. isSynchronized(): boolean;
  29351. /**
  29352. * Is this node ready to be used/rendered
  29353. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29354. * @return true if the node is ready
  29355. */
  29356. isReady(completeCheck?: boolean): boolean;
  29357. /**
  29358. * Is this node enabled?
  29359. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  29360. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  29361. * @return whether this node (and its parent) is enabled
  29362. */
  29363. isEnabled(checkAncestors?: boolean): boolean;
  29364. /** @hidden */
  29365. protected _syncParentEnabledState(): void;
  29366. /**
  29367. * Set the enabled state of this node
  29368. * @param value defines the new enabled state
  29369. */
  29370. setEnabled(value: boolean): void;
  29371. /**
  29372. * Is this node a descendant of the given node?
  29373. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29374. * @param ancestor defines the parent node to inspect
  29375. * @returns a boolean indicating if this node is a descendant of the given node
  29376. */
  29377. isDescendantOf(ancestor: Node): boolean;
  29378. /** @hidden */
  29379. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29380. /**
  29381. * Will return all nodes that have this node as ascendant
  29382. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  29383. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  29384. * @return all children nodes of all types
  29385. */
  29386. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29387. /**
  29388. * Get all child-meshes of this node
  29389. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  29390. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  29391. * @returns an array of AbstractMesh
  29392. */
  29393. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29394. /**
  29395. * Get all direct children of this node
  29396. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  29397. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  29398. * @returns an array of Node
  29399. */
  29400. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29401. /** @hidden */
  29402. _setReady(state: boolean): void;
  29403. /**
  29404. * Get an animation by name
  29405. * @param name defines the name of the animation to look for
  29406. * @returns null if not found else the requested animation
  29407. */
  29408. getAnimationByName(name: string): Nullable<Animation>;
  29409. /**
  29410. * Creates an animation range for this node
  29411. * @param name defines the name of the range
  29412. * @param from defines the starting key
  29413. * @param to defines the end key
  29414. */
  29415. createAnimationRange(name: string, from: number, to: number): void;
  29416. /**
  29417. * Delete a specific animation range
  29418. * @param name defines the name of the range to delete
  29419. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29420. */
  29421. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29422. /**
  29423. * Get an animation range by name
  29424. * @param name defines the name of the animation range to look for
  29425. * @returns null if not found else the requested animation range
  29426. */
  29427. getAnimationRange(name: string): Nullable<AnimationRange>;
  29428. /**
  29429. * Gets the list of all animation ranges defined on this node
  29430. * @returns an array
  29431. */
  29432. getAnimationRanges(): Nullable<AnimationRange>[];
  29433. /**
  29434. * Will start the animation sequence
  29435. * @param name defines the range frames for animation sequence
  29436. * @param loop defines if the animation should loop (false by default)
  29437. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29438. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29439. * @returns the object created for this animation. If range does not exist, it will return null
  29440. */
  29441. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29442. /**
  29443. * Serialize animation ranges into a JSON compatible object
  29444. * @returns serialization object
  29445. */
  29446. serializeAnimationRanges(): any;
  29447. /**
  29448. * Computes the world matrix of the node
  29449. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29450. * @returns the world matrix
  29451. */
  29452. computeWorldMatrix(force?: boolean): Matrix;
  29453. /**
  29454. * Releases resources associated with this node.
  29455. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29456. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29457. */
  29458. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29459. /**
  29460. * Parse animation range data from a serialization object and store them into a given node
  29461. * @param node defines where to store the animation ranges
  29462. * @param parsedNode defines the serialization object to read data from
  29463. * @param scene defines the hosting scene
  29464. */
  29465. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29466. /**
  29467. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29468. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29469. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  29470. * @returns the new bounding vectors
  29471. */
  29472. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29473. min: Vector3;
  29474. max: Vector3;
  29475. };
  29476. }
  29477. }
  29478. declare module "babylonjs/Animations/animation" {
  29479. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29480. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29481. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29482. import { Nullable } from "babylonjs/types";
  29483. import { Scene } from "babylonjs/scene";
  29484. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29485. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29486. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29487. import { Node } from "babylonjs/node";
  29488. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29489. import { Size } from "babylonjs/Maths/math.size";
  29490. import { Animatable } from "babylonjs/Animations/animatable";
  29491. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29492. /**
  29493. * @hidden
  29494. */
  29495. export class _IAnimationState {
  29496. key: number;
  29497. repeatCount: number;
  29498. workValue?: any;
  29499. loopMode?: number;
  29500. offsetValue?: any;
  29501. highLimitValue?: any;
  29502. }
  29503. /**
  29504. * Class used to store any kind of animation
  29505. */
  29506. export class Animation {
  29507. /**Name of the animation */
  29508. name: string;
  29509. /**Property to animate */
  29510. targetProperty: string;
  29511. /**The frames per second of the animation */
  29512. framePerSecond: number;
  29513. /**The data type of the animation */
  29514. dataType: number;
  29515. /**The loop mode of the animation */
  29516. loopMode?: number | undefined;
  29517. /**Specifies if blending should be enabled */
  29518. enableBlending?: boolean | undefined;
  29519. /**
  29520. * Use matrix interpolation instead of using direct key value when animating matrices
  29521. */
  29522. static AllowMatricesInterpolation: boolean;
  29523. /**
  29524. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29525. */
  29526. static AllowMatrixDecomposeForInterpolation: boolean;
  29527. /**
  29528. * Stores the key frames of the animation
  29529. */
  29530. private _keys;
  29531. /**
  29532. * Stores the easing function of the animation
  29533. */
  29534. private _easingFunction;
  29535. /**
  29536. * @hidden Internal use only
  29537. */
  29538. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29539. /**
  29540. * The set of event that will be linked to this animation
  29541. */
  29542. private _events;
  29543. /**
  29544. * Stores an array of target property paths
  29545. */
  29546. targetPropertyPath: string[];
  29547. /**
  29548. * Stores the blending speed of the animation
  29549. */
  29550. blendingSpeed: number;
  29551. /**
  29552. * Stores the animation ranges for the animation
  29553. */
  29554. private _ranges;
  29555. /**
  29556. * @hidden Internal use
  29557. */
  29558. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29559. /**
  29560. * Sets up an animation
  29561. * @param property The property to animate
  29562. * @param animationType The animation type to apply
  29563. * @param framePerSecond The frames per second of the animation
  29564. * @param easingFunction The easing function used in the animation
  29565. * @returns The created animation
  29566. */
  29567. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29568. /**
  29569. * Create and start an animation on a node
  29570. * @param name defines the name of the global animation that will be run on all nodes
  29571. * @param node defines the root node where the animation will take place
  29572. * @param targetProperty defines property to animate
  29573. * @param framePerSecond defines the number of frame per second yo use
  29574. * @param totalFrame defines the number of frames in total
  29575. * @param from defines the initial value
  29576. * @param to defines the final value
  29577. * @param loopMode defines which loop mode you want to use (off by default)
  29578. * @param easingFunction defines the easing function to use (linear by default)
  29579. * @param onAnimationEnd defines the callback to call when animation end
  29580. * @returns the animatable created for this animation
  29581. */
  29582. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29583. /**
  29584. * Create and start an animation on a node and its descendants
  29585. * @param name defines the name of the global animation that will be run on all nodes
  29586. * @param node defines the root node where the animation will take place
  29587. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  29588. * @param targetProperty defines property to animate
  29589. * @param framePerSecond defines the number of frame per second to use
  29590. * @param totalFrame defines the number of frames in total
  29591. * @param from defines the initial value
  29592. * @param to defines the final value
  29593. * @param loopMode defines which loop mode you want to use (off by default)
  29594. * @param easingFunction defines the easing function to use (linear by default)
  29595. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29596. * @returns the list of animatables created for all nodes
  29597. * @example https://www.babylonjs-playground.com/#MH0VLI
  29598. */
  29599. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  29600. /**
  29601. * Creates a new animation, merges it with the existing animations and starts it
  29602. * @param name Name of the animation
  29603. * @param node Node which contains the scene that begins the animations
  29604. * @param targetProperty Specifies which property to animate
  29605. * @param framePerSecond The frames per second of the animation
  29606. * @param totalFrame The total number of frames
  29607. * @param from The frame at the beginning of the animation
  29608. * @param to The frame at the end of the animation
  29609. * @param loopMode Specifies the loop mode of the animation
  29610. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29611. * @param onAnimationEnd Callback to run once the animation is complete
  29612. * @returns Nullable animation
  29613. */
  29614. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29615. /**
  29616. * Transition property of an host to the target Value
  29617. * @param property The property to transition
  29618. * @param targetValue The target Value of the property
  29619. * @param host The object where the property to animate belongs
  29620. * @param scene Scene used to run the animation
  29621. * @param frameRate Framerate (in frame/s) to use
  29622. * @param transition The transition type we want to use
  29623. * @param duration The duration of the animation, in milliseconds
  29624. * @param onAnimationEnd Callback trigger at the end of the animation
  29625. * @returns Nullable animation
  29626. */
  29627. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29628. /**
  29629. * Return the array of runtime animations currently using this animation
  29630. */
  29631. readonly runtimeAnimations: RuntimeAnimation[];
  29632. /**
  29633. * Specifies if any of the runtime animations are currently running
  29634. */
  29635. readonly hasRunningRuntimeAnimations: boolean;
  29636. /**
  29637. * Initializes the animation
  29638. * @param name Name of the animation
  29639. * @param targetProperty Property to animate
  29640. * @param framePerSecond The frames per second of the animation
  29641. * @param dataType The data type of the animation
  29642. * @param loopMode The loop mode of the animation
  29643. * @param enableBlending Specifies if blending should be enabled
  29644. */
  29645. constructor(
  29646. /**Name of the animation */
  29647. name: string,
  29648. /**Property to animate */
  29649. targetProperty: string,
  29650. /**The frames per second of the animation */
  29651. framePerSecond: number,
  29652. /**The data type of the animation */
  29653. dataType: number,
  29654. /**The loop mode of the animation */
  29655. loopMode?: number | undefined,
  29656. /**Specifies if blending should be enabled */
  29657. enableBlending?: boolean | undefined);
  29658. /**
  29659. * Converts the animation to a string
  29660. * @param fullDetails support for multiple levels of logging within scene loading
  29661. * @returns String form of the animation
  29662. */
  29663. toString(fullDetails?: boolean): string;
  29664. /**
  29665. * Add an event to this animation
  29666. * @param event Event to add
  29667. */
  29668. addEvent(event: AnimationEvent): void;
  29669. /**
  29670. * Remove all events found at the given frame
  29671. * @param frame The frame to remove events from
  29672. */
  29673. removeEvents(frame: number): void;
  29674. /**
  29675. * Retrieves all the events from the animation
  29676. * @returns Events from the animation
  29677. */
  29678. getEvents(): AnimationEvent[];
  29679. /**
  29680. * Creates an animation range
  29681. * @param name Name of the animation range
  29682. * @param from Starting frame of the animation range
  29683. * @param to Ending frame of the animation
  29684. */
  29685. createRange(name: string, from: number, to: number): void;
  29686. /**
  29687. * Deletes an animation range by name
  29688. * @param name Name of the animation range to delete
  29689. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29690. */
  29691. deleteRange(name: string, deleteFrames?: boolean): void;
  29692. /**
  29693. * Gets the animation range by name, or null if not defined
  29694. * @param name Name of the animation range
  29695. * @returns Nullable animation range
  29696. */
  29697. getRange(name: string): Nullable<AnimationRange>;
  29698. /**
  29699. * Gets the key frames from the animation
  29700. * @returns The key frames of the animation
  29701. */
  29702. getKeys(): Array<IAnimationKey>;
  29703. /**
  29704. * Gets the highest frame rate of the animation
  29705. * @returns Highest frame rate of the animation
  29706. */
  29707. getHighestFrame(): number;
  29708. /**
  29709. * Gets the easing function of the animation
  29710. * @returns Easing function of the animation
  29711. */
  29712. getEasingFunction(): IEasingFunction;
  29713. /**
  29714. * Sets the easing function of the animation
  29715. * @param easingFunction A custom mathematical formula for animation
  29716. */
  29717. setEasingFunction(easingFunction: EasingFunction): void;
  29718. /**
  29719. * Interpolates a scalar linearly
  29720. * @param startValue Start value of the animation curve
  29721. * @param endValue End value of the animation curve
  29722. * @param gradient Scalar amount to interpolate
  29723. * @returns Interpolated scalar value
  29724. */
  29725. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29726. /**
  29727. * Interpolates a scalar cubically
  29728. * @param startValue Start value of the animation curve
  29729. * @param outTangent End tangent of the animation
  29730. * @param endValue End value of the animation curve
  29731. * @param inTangent Start tangent of the animation curve
  29732. * @param gradient Scalar amount to interpolate
  29733. * @returns Interpolated scalar value
  29734. */
  29735. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29736. /**
  29737. * Interpolates a quaternion using a spherical linear interpolation
  29738. * @param startValue Start value of the animation curve
  29739. * @param endValue End value of the animation curve
  29740. * @param gradient Scalar amount to interpolate
  29741. * @returns Interpolated quaternion value
  29742. */
  29743. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29744. /**
  29745. * Interpolates a quaternion cubically
  29746. * @param startValue Start value of the animation curve
  29747. * @param outTangent End tangent of the animation curve
  29748. * @param endValue End value of the animation curve
  29749. * @param inTangent Start tangent of the animation curve
  29750. * @param gradient Scalar amount to interpolate
  29751. * @returns Interpolated quaternion value
  29752. */
  29753. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29754. /**
  29755. * Interpolates a Vector3 linearl
  29756. * @param startValue Start value of the animation curve
  29757. * @param endValue End value of the animation curve
  29758. * @param gradient Scalar amount to interpolate
  29759. * @returns Interpolated scalar value
  29760. */
  29761. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29762. /**
  29763. * Interpolates a Vector3 cubically
  29764. * @param startValue Start value of the animation curve
  29765. * @param outTangent End tangent of the animation
  29766. * @param endValue End value of the animation curve
  29767. * @param inTangent Start tangent of the animation curve
  29768. * @param gradient Scalar amount to interpolate
  29769. * @returns InterpolatedVector3 value
  29770. */
  29771. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29772. /**
  29773. * Interpolates a Vector2 linearly
  29774. * @param startValue Start value of the animation curve
  29775. * @param endValue End value of the animation curve
  29776. * @param gradient Scalar amount to interpolate
  29777. * @returns Interpolated Vector2 value
  29778. */
  29779. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29780. /**
  29781. * Interpolates a Vector2 cubically
  29782. * @param startValue Start value of the animation curve
  29783. * @param outTangent End tangent of the animation
  29784. * @param endValue End value of the animation curve
  29785. * @param inTangent Start tangent of the animation curve
  29786. * @param gradient Scalar amount to interpolate
  29787. * @returns Interpolated Vector2 value
  29788. */
  29789. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29790. /**
  29791. * Interpolates a size linearly
  29792. * @param startValue Start value of the animation curve
  29793. * @param endValue End value of the animation curve
  29794. * @param gradient Scalar amount to interpolate
  29795. * @returns Interpolated Size value
  29796. */
  29797. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29798. /**
  29799. * Interpolates a Color3 linearly
  29800. * @param startValue Start value of the animation curve
  29801. * @param endValue End value of the animation curve
  29802. * @param gradient Scalar amount to interpolate
  29803. * @returns Interpolated Color3 value
  29804. */
  29805. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29806. /**
  29807. * Interpolates a Color4 linearly
  29808. * @param startValue Start value of the animation curve
  29809. * @param endValue End value of the animation curve
  29810. * @param gradient Scalar amount to interpolate
  29811. * @returns Interpolated Color3 value
  29812. */
  29813. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29814. /**
  29815. * @hidden Internal use only
  29816. */
  29817. _getKeyValue(value: any): any;
  29818. /**
  29819. * @hidden Internal use only
  29820. */
  29821. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29822. /**
  29823. * Defines the function to use to interpolate matrices
  29824. * @param startValue defines the start matrix
  29825. * @param endValue defines the end matrix
  29826. * @param gradient defines the gradient between both matrices
  29827. * @param result defines an optional target matrix where to store the interpolation
  29828. * @returns the interpolated matrix
  29829. */
  29830. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29831. /**
  29832. * Makes a copy of the animation
  29833. * @returns Cloned animation
  29834. */
  29835. clone(): Animation;
  29836. /**
  29837. * Sets the key frames of the animation
  29838. * @param values The animation key frames to set
  29839. */
  29840. setKeys(values: Array<IAnimationKey>): void;
  29841. /**
  29842. * Serializes the animation to an object
  29843. * @returns Serialized object
  29844. */
  29845. serialize(): any;
  29846. /**
  29847. * Float animation type
  29848. */
  29849. static readonly ANIMATIONTYPE_FLOAT: number;
  29850. /**
  29851. * Vector3 animation type
  29852. */
  29853. static readonly ANIMATIONTYPE_VECTOR3: number;
  29854. /**
  29855. * Quaternion animation type
  29856. */
  29857. static readonly ANIMATIONTYPE_QUATERNION: number;
  29858. /**
  29859. * Matrix animation type
  29860. */
  29861. static readonly ANIMATIONTYPE_MATRIX: number;
  29862. /**
  29863. * Color3 animation type
  29864. */
  29865. static readonly ANIMATIONTYPE_COLOR3: number;
  29866. /**
  29867. * Color3 animation type
  29868. */
  29869. static readonly ANIMATIONTYPE_COLOR4: number;
  29870. /**
  29871. * Vector2 animation type
  29872. */
  29873. static readonly ANIMATIONTYPE_VECTOR2: number;
  29874. /**
  29875. * Size animation type
  29876. */
  29877. static readonly ANIMATIONTYPE_SIZE: number;
  29878. /**
  29879. * Relative Loop Mode
  29880. */
  29881. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29882. /**
  29883. * Cycle Loop Mode
  29884. */
  29885. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29886. /**
  29887. * Constant Loop Mode
  29888. */
  29889. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29890. /** @hidden */
  29891. static _UniversalLerp(left: any, right: any, amount: number): any;
  29892. /**
  29893. * Parses an animation object and creates an animation
  29894. * @param parsedAnimation Parsed animation object
  29895. * @returns Animation object
  29896. */
  29897. static Parse(parsedAnimation: any): Animation;
  29898. /**
  29899. * Appends the serialized animations from the source animations
  29900. * @param source Source containing the animations
  29901. * @param destination Target to store the animations
  29902. */
  29903. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29904. }
  29905. }
  29906. declare module "babylonjs/Animations/animatable.interface" {
  29907. import { Nullable } from "babylonjs/types";
  29908. import { Animation } from "babylonjs/Animations/animation";
  29909. /**
  29910. * Interface containing an array of animations
  29911. */
  29912. export interface IAnimatable {
  29913. /**
  29914. * Array of animations
  29915. */
  29916. animations: Nullable<Array<Animation>>;
  29917. }
  29918. }
  29919. declare module "babylonjs/Misc/decorators" {
  29920. import { Nullable } from "babylonjs/types";
  29921. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29922. import { Scene } from "babylonjs/scene";
  29923. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29924. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29925. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29926. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29927. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29928. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29929. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29930. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29931. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29932. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29933. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29934. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29935. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29936. /**
  29937. * Decorator used to define property that can be serialized as reference to a camera
  29938. * @param sourceName defines the name of the property to decorate
  29939. */
  29940. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29941. /**
  29942. * Class used to help serialization objects
  29943. */
  29944. export class SerializationHelper {
  29945. /** @hidden */
  29946. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29947. /** @hidden */
  29948. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29949. /** @hidden */
  29950. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29951. /** @hidden */
  29952. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29953. /**
  29954. * Appends the serialized animations from the source animations
  29955. * @param source Source containing the animations
  29956. * @param destination Target to store the animations
  29957. */
  29958. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29959. /**
  29960. * Static function used to serialized a specific entity
  29961. * @param entity defines the entity to serialize
  29962. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29963. * @returns a JSON compatible object representing the serialization of the entity
  29964. */
  29965. static Serialize<T>(entity: T, serializationObject?: any): any;
  29966. /**
  29967. * Creates a new entity from a serialization data object
  29968. * @param creationFunction defines a function used to instanciated the new entity
  29969. * @param source defines the source serialization data
  29970. * @param scene defines the hosting scene
  29971. * @param rootUrl defines the root url for resources
  29972. * @returns a new entity
  29973. */
  29974. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29975. /**
  29976. * Clones an object
  29977. * @param creationFunction defines the function used to instanciate the new object
  29978. * @param source defines the source object
  29979. * @returns the cloned object
  29980. */
  29981. static Clone<T>(creationFunction: () => T, source: T): T;
  29982. /**
  29983. * Instanciates a new object based on a source one (some data will be shared between both object)
  29984. * @param creationFunction defines the function used to instanciate the new object
  29985. * @param source defines the source object
  29986. * @returns the new object
  29987. */
  29988. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29989. }
  29990. }
  29991. declare module "babylonjs/Misc/guid" {
  29992. /**
  29993. * Class used to manipulate GUIDs
  29994. */
  29995. export class GUID {
  29996. /**
  29997. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29998. * Be aware Math.random() could cause collisions, but:
  29999. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  30000. * @returns a pseudo random id
  30001. */
  30002. static RandomId(): string;
  30003. }
  30004. }
  30005. declare module "babylonjs/Materials/Textures/baseTexture" {
  30006. import { Observable } from "babylonjs/Misc/observable";
  30007. import { Nullable } from "babylonjs/types";
  30008. import { Scene } from "babylonjs/scene";
  30009. import { Matrix } from "babylonjs/Maths/math.vector";
  30010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30011. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30012. import { ISize } from "babylonjs/Maths/math.size";
  30013. /**
  30014. * Base class of all the textures in babylon.
  30015. * It groups all the common properties the materials, post process, lights... might need
  30016. * in order to make a correct use of the texture.
  30017. */
  30018. export class BaseTexture implements IAnimatable {
  30019. /**
  30020. * Default anisotropic filtering level for the application.
  30021. * It is set to 4 as a good tradeoff between perf and quality.
  30022. */
  30023. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30024. /**
  30025. * Gets or sets the unique id of the texture
  30026. */
  30027. uniqueId: number;
  30028. /**
  30029. * Define the name of the texture.
  30030. */
  30031. name: string;
  30032. /**
  30033. * Gets or sets an object used to store user defined information.
  30034. */
  30035. metadata: any;
  30036. /**
  30037. * For internal use only. Please do not use.
  30038. */
  30039. reservedDataStore: any;
  30040. private _hasAlpha;
  30041. /**
  30042. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30043. */
  30044. hasAlpha: boolean;
  30045. /**
  30046. * Defines if the alpha value should be determined via the rgb values.
  30047. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30048. */
  30049. getAlphaFromRGB: boolean;
  30050. /**
  30051. * Intensity or strength of the texture.
  30052. * It is commonly used by materials to fine tune the intensity of the texture
  30053. */
  30054. level: number;
  30055. /**
  30056. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30057. * This is part of the texture as textures usually maps to one uv set.
  30058. */
  30059. coordinatesIndex: number;
  30060. private _coordinatesMode;
  30061. /**
  30062. * How a texture is mapped.
  30063. *
  30064. * | Value | Type | Description |
  30065. * | ----- | ----------------------------------- | ----------- |
  30066. * | 0 | EXPLICIT_MODE | |
  30067. * | 1 | SPHERICAL_MODE | |
  30068. * | 2 | PLANAR_MODE | |
  30069. * | 3 | CUBIC_MODE | |
  30070. * | 4 | PROJECTION_MODE | |
  30071. * | 5 | SKYBOX_MODE | |
  30072. * | 6 | INVCUBIC_MODE | |
  30073. * | 7 | EQUIRECTANGULAR_MODE | |
  30074. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30075. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30076. */
  30077. coordinatesMode: number;
  30078. /**
  30079. * | Value | Type | Description |
  30080. * | ----- | ------------------ | ----------- |
  30081. * | 0 | CLAMP_ADDRESSMODE | |
  30082. * | 1 | WRAP_ADDRESSMODE | |
  30083. * | 2 | MIRROR_ADDRESSMODE | |
  30084. */
  30085. wrapU: number;
  30086. /**
  30087. * | Value | Type | Description |
  30088. * | ----- | ------------------ | ----------- |
  30089. * | 0 | CLAMP_ADDRESSMODE | |
  30090. * | 1 | WRAP_ADDRESSMODE | |
  30091. * | 2 | MIRROR_ADDRESSMODE | |
  30092. */
  30093. wrapV: number;
  30094. /**
  30095. * | Value | Type | Description |
  30096. * | ----- | ------------------ | ----------- |
  30097. * | 0 | CLAMP_ADDRESSMODE | |
  30098. * | 1 | WRAP_ADDRESSMODE | |
  30099. * | 2 | MIRROR_ADDRESSMODE | |
  30100. */
  30101. wrapR: number;
  30102. /**
  30103. * With compliant hardware and browser (supporting anisotropic filtering)
  30104. * this defines the level of anisotropic filtering in the texture.
  30105. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30106. */
  30107. anisotropicFilteringLevel: number;
  30108. /**
  30109. * Define if the texture is a cube texture or if false a 2d texture.
  30110. */
  30111. isCube: boolean;
  30112. /**
  30113. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30114. */
  30115. is3D: boolean;
  30116. /**
  30117. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30118. */
  30119. is2DArray: boolean;
  30120. /**
  30121. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30122. * HDR texture are usually stored in linear space.
  30123. * This only impacts the PBR and Background materials
  30124. */
  30125. gammaSpace: boolean;
  30126. /**
  30127. * Gets or sets whether or not the texture contains RGBD data.
  30128. */
  30129. isRGBD: boolean;
  30130. /**
  30131. * Is Z inverted in the texture (useful in a cube texture).
  30132. */
  30133. invertZ: boolean;
  30134. /**
  30135. * Are mip maps generated for this texture or not.
  30136. */
  30137. readonly noMipmap: boolean;
  30138. /**
  30139. * @hidden
  30140. */
  30141. lodLevelInAlpha: boolean;
  30142. /**
  30143. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30144. */
  30145. lodGenerationOffset: number;
  30146. /**
  30147. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30148. */
  30149. lodGenerationScale: number;
  30150. /**
  30151. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30152. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30153. * average roughness values.
  30154. */
  30155. linearSpecularLOD: boolean;
  30156. /**
  30157. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30158. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30159. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30160. */
  30161. irradianceTexture: Nullable<BaseTexture>;
  30162. /**
  30163. * Define if the texture is a render target.
  30164. */
  30165. isRenderTarget: boolean;
  30166. /**
  30167. * Define the unique id of the texture in the scene.
  30168. */
  30169. readonly uid: string;
  30170. /**
  30171. * Return a string representation of the texture.
  30172. * @returns the texture as a string
  30173. */
  30174. toString(): string;
  30175. /**
  30176. * Get the class name of the texture.
  30177. * @returns "BaseTexture"
  30178. */
  30179. getClassName(): string;
  30180. /**
  30181. * Define the list of animation attached to the texture.
  30182. */
  30183. animations: import("babylonjs/Animations/animation").Animation[];
  30184. /**
  30185. * An event triggered when the texture is disposed.
  30186. */
  30187. onDisposeObservable: Observable<BaseTexture>;
  30188. private _onDisposeObserver;
  30189. /**
  30190. * Callback triggered when the texture has been disposed.
  30191. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30192. */
  30193. onDispose: () => void;
  30194. /**
  30195. * Define the current state of the loading sequence when in delayed load mode.
  30196. */
  30197. delayLoadState: number;
  30198. private _scene;
  30199. /** @hidden */
  30200. _texture: Nullable<InternalTexture>;
  30201. private _uid;
  30202. /**
  30203. * Define if the texture is preventinga material to render or not.
  30204. * If not and the texture is not ready, the engine will use a default black texture instead.
  30205. */
  30206. readonly isBlocking: boolean;
  30207. /**
  30208. * Instantiates a new BaseTexture.
  30209. * Base class of all the textures in babylon.
  30210. * It groups all the common properties the materials, post process, lights... might need
  30211. * in order to make a correct use of the texture.
  30212. * @param scene Define the scene the texture blongs to
  30213. */
  30214. constructor(scene: Nullable<Scene>);
  30215. /**
  30216. * Get the scene the texture belongs to.
  30217. * @returns the scene or null if undefined
  30218. */
  30219. getScene(): Nullable<Scene>;
  30220. /**
  30221. * Get the texture transform matrix used to offset tile the texture for istance.
  30222. * @returns the transformation matrix
  30223. */
  30224. getTextureMatrix(): Matrix;
  30225. /**
  30226. * Get the texture reflection matrix used to rotate/transform the reflection.
  30227. * @returns the reflection matrix
  30228. */
  30229. getReflectionTextureMatrix(): Matrix;
  30230. /**
  30231. * Get the underlying lower level texture from Babylon.
  30232. * @returns the insternal texture
  30233. */
  30234. getInternalTexture(): Nullable<InternalTexture>;
  30235. /**
  30236. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30237. * @returns true if ready or not blocking
  30238. */
  30239. isReadyOrNotBlocking(): boolean;
  30240. /**
  30241. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30242. * @returns true if fully ready
  30243. */
  30244. isReady(): boolean;
  30245. private _cachedSize;
  30246. /**
  30247. * Get the size of the texture.
  30248. * @returns the texture size.
  30249. */
  30250. getSize(): ISize;
  30251. /**
  30252. * Get the base size of the texture.
  30253. * It can be different from the size if the texture has been resized for POT for instance
  30254. * @returns the base size
  30255. */
  30256. getBaseSize(): ISize;
  30257. /**
  30258. * Update the sampling mode of the texture.
  30259. * Default is Trilinear mode.
  30260. *
  30261. * | Value | Type | Description |
  30262. * | ----- | ------------------ | ----------- |
  30263. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30264. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30265. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30266. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30267. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30268. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30269. * | 7 | NEAREST_LINEAR | |
  30270. * | 8 | NEAREST_NEAREST | |
  30271. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30272. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30273. * | 11 | LINEAR_LINEAR | |
  30274. * | 12 | LINEAR_NEAREST | |
  30275. *
  30276. * > _mag_: magnification filter (close to the viewer)
  30277. * > _min_: minification filter (far from the viewer)
  30278. * > _mip_: filter used between mip map levels
  30279. *@param samplingMode Define the new sampling mode of the texture
  30280. */
  30281. updateSamplingMode(samplingMode: number): void;
  30282. /**
  30283. * Scales the texture if is `canRescale()`
  30284. * @param ratio the resize factor we want to use to rescale
  30285. */
  30286. scale(ratio: number): void;
  30287. /**
  30288. * Get if the texture can rescale.
  30289. */
  30290. readonly canRescale: boolean;
  30291. /** @hidden */
  30292. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30293. /** @hidden */
  30294. _rebuild(): void;
  30295. /**
  30296. * Triggers the load sequence in delayed load mode.
  30297. */
  30298. delayLoad(): void;
  30299. /**
  30300. * Clones the texture.
  30301. * @returns the cloned texture
  30302. */
  30303. clone(): Nullable<BaseTexture>;
  30304. /**
  30305. * Get the texture underlying type (INT, FLOAT...)
  30306. */
  30307. readonly textureType: number;
  30308. /**
  30309. * Get the texture underlying format (RGB, RGBA...)
  30310. */
  30311. readonly textureFormat: number;
  30312. /**
  30313. * Indicates that textures need to be re-calculated for all materials
  30314. */
  30315. protected _markAllSubMeshesAsTexturesDirty(): void;
  30316. /**
  30317. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30318. * This will returns an RGBA array buffer containing either in values (0-255) or
  30319. * float values (0-1) depending of the underlying buffer type.
  30320. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30321. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30322. * @param buffer defines a user defined buffer to fill with data (can be null)
  30323. * @returns The Array buffer containing the pixels data.
  30324. */
  30325. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30326. /**
  30327. * Release and destroy the underlying lower level texture aka internalTexture.
  30328. */
  30329. releaseInternalTexture(): void;
  30330. /** @hidden */
  30331. readonly _lodTextureHigh: Nullable<BaseTexture>;
  30332. /** @hidden */
  30333. readonly _lodTextureMid: Nullable<BaseTexture>;
  30334. /** @hidden */
  30335. readonly _lodTextureLow: Nullable<BaseTexture>;
  30336. /**
  30337. * Dispose the texture and release its associated resources.
  30338. */
  30339. dispose(): void;
  30340. /**
  30341. * Serialize the texture into a JSON representation that can be parsed later on.
  30342. * @returns the JSON representation of the texture
  30343. */
  30344. serialize(): any;
  30345. /**
  30346. * Helper function to be called back once a list of texture contains only ready textures.
  30347. * @param textures Define the list of textures to wait for
  30348. * @param callback Define the callback triggered once the entire list will be ready
  30349. */
  30350. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30351. }
  30352. }
  30353. declare module "babylonjs/Materials/effect" {
  30354. import { Observable } from "babylonjs/Misc/observable";
  30355. import { Nullable } from "babylonjs/types";
  30356. import { IDisposable } from "babylonjs/scene";
  30357. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30358. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30359. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30360. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30361. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30362. import { Engine } from "babylonjs/Engines/engine";
  30363. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30365. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30366. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30367. /**
  30368. * Options to be used when creating an effect.
  30369. */
  30370. export interface IEffectCreationOptions {
  30371. /**
  30372. * Atrributes that will be used in the shader.
  30373. */
  30374. attributes: string[];
  30375. /**
  30376. * Uniform varible names that will be set in the shader.
  30377. */
  30378. uniformsNames: string[];
  30379. /**
  30380. * Uniform buffer variable names that will be set in the shader.
  30381. */
  30382. uniformBuffersNames: string[];
  30383. /**
  30384. * Sampler texture variable names that will be set in the shader.
  30385. */
  30386. samplers: string[];
  30387. /**
  30388. * Define statements that will be set in the shader.
  30389. */
  30390. defines: any;
  30391. /**
  30392. * Possible fallbacks for this effect to improve performance when needed.
  30393. */
  30394. fallbacks: Nullable<IEffectFallbacks>;
  30395. /**
  30396. * Callback that will be called when the shader is compiled.
  30397. */
  30398. onCompiled: Nullable<(effect: Effect) => void>;
  30399. /**
  30400. * Callback that will be called if an error occurs during shader compilation.
  30401. */
  30402. onError: Nullable<(effect: Effect, errors: string) => void>;
  30403. /**
  30404. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30405. */
  30406. indexParameters?: any;
  30407. /**
  30408. * Max number of lights that can be used in the shader.
  30409. */
  30410. maxSimultaneousLights?: number;
  30411. /**
  30412. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30413. */
  30414. transformFeedbackVaryings?: Nullable<string[]>;
  30415. }
  30416. /**
  30417. * Effect containing vertex and fragment shader that can be executed on an object.
  30418. */
  30419. export class Effect implements IDisposable {
  30420. /**
  30421. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30422. */
  30423. static ShadersRepository: string;
  30424. /**
  30425. * Name of the effect.
  30426. */
  30427. name: any;
  30428. /**
  30429. * String container all the define statements that should be set on the shader.
  30430. */
  30431. defines: string;
  30432. /**
  30433. * Callback that will be called when the shader is compiled.
  30434. */
  30435. onCompiled: Nullable<(effect: Effect) => void>;
  30436. /**
  30437. * Callback that will be called if an error occurs during shader compilation.
  30438. */
  30439. onError: Nullable<(effect: Effect, errors: string) => void>;
  30440. /**
  30441. * Callback that will be called when effect is bound.
  30442. */
  30443. onBind: Nullable<(effect: Effect) => void>;
  30444. /**
  30445. * Unique ID of the effect.
  30446. */
  30447. uniqueId: number;
  30448. /**
  30449. * Observable that will be called when the shader is compiled.
  30450. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30451. */
  30452. onCompileObservable: Observable<Effect>;
  30453. /**
  30454. * Observable that will be called if an error occurs during shader compilation.
  30455. */
  30456. onErrorObservable: Observable<Effect>;
  30457. /** @hidden */
  30458. _onBindObservable: Nullable<Observable<Effect>>;
  30459. /**
  30460. * Observable that will be called when effect is bound.
  30461. */
  30462. readonly onBindObservable: Observable<Effect>;
  30463. /** @hidden */
  30464. _bonesComputationForcedToCPU: boolean;
  30465. private static _uniqueIdSeed;
  30466. private _engine;
  30467. private _uniformBuffersNames;
  30468. private _uniformsNames;
  30469. private _samplerList;
  30470. private _samplers;
  30471. private _isReady;
  30472. private _compilationError;
  30473. private _allFallbacksProcessed;
  30474. private _attributesNames;
  30475. private _attributes;
  30476. private _uniforms;
  30477. /**
  30478. * Key for the effect.
  30479. * @hidden
  30480. */
  30481. _key: string;
  30482. private _indexParameters;
  30483. private _fallbacks;
  30484. private _vertexSourceCode;
  30485. private _fragmentSourceCode;
  30486. private _vertexSourceCodeOverride;
  30487. private _fragmentSourceCodeOverride;
  30488. private _transformFeedbackVaryings;
  30489. /**
  30490. * Compiled shader to webGL program.
  30491. * @hidden
  30492. */
  30493. _pipelineContext: Nullable<IPipelineContext>;
  30494. private _valueCache;
  30495. private static _baseCache;
  30496. /**
  30497. * Instantiates an effect.
  30498. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30499. * @param baseName Name of the effect.
  30500. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30501. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30502. * @param samplers List of sampler variables that will be passed to the shader.
  30503. * @param engine Engine to be used to render the effect
  30504. * @param defines Define statements to be added to the shader.
  30505. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30506. * @param onCompiled Callback that will be called when the shader is compiled.
  30507. * @param onError Callback that will be called if an error occurs during shader compilation.
  30508. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30509. */
  30510. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30511. private _useFinalCode;
  30512. /**
  30513. * Unique key for this effect
  30514. */
  30515. readonly key: string;
  30516. /**
  30517. * If the effect has been compiled and prepared.
  30518. * @returns if the effect is compiled and prepared.
  30519. */
  30520. isReady(): boolean;
  30521. private _isReadyInternal;
  30522. /**
  30523. * The engine the effect was initialized with.
  30524. * @returns the engine.
  30525. */
  30526. getEngine(): Engine;
  30527. /**
  30528. * The pipeline context for this effect
  30529. * @returns the associated pipeline context
  30530. */
  30531. getPipelineContext(): Nullable<IPipelineContext>;
  30532. /**
  30533. * The set of names of attribute variables for the shader.
  30534. * @returns An array of attribute names.
  30535. */
  30536. getAttributesNames(): string[];
  30537. /**
  30538. * Returns the attribute at the given index.
  30539. * @param index The index of the attribute.
  30540. * @returns The location of the attribute.
  30541. */
  30542. getAttributeLocation(index: number): number;
  30543. /**
  30544. * Returns the attribute based on the name of the variable.
  30545. * @param name of the attribute to look up.
  30546. * @returns the attribute location.
  30547. */
  30548. getAttributeLocationByName(name: string): number;
  30549. /**
  30550. * The number of attributes.
  30551. * @returns the numnber of attributes.
  30552. */
  30553. getAttributesCount(): number;
  30554. /**
  30555. * Gets the index of a uniform variable.
  30556. * @param uniformName of the uniform to look up.
  30557. * @returns the index.
  30558. */
  30559. getUniformIndex(uniformName: string): number;
  30560. /**
  30561. * Returns the attribute based on the name of the variable.
  30562. * @param uniformName of the uniform to look up.
  30563. * @returns the location of the uniform.
  30564. */
  30565. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30566. /**
  30567. * Returns an array of sampler variable names
  30568. * @returns The array of sampler variable neames.
  30569. */
  30570. getSamplers(): string[];
  30571. /**
  30572. * The error from the last compilation.
  30573. * @returns the error string.
  30574. */
  30575. getCompilationError(): string;
  30576. /**
  30577. * Gets a boolean indicating that all fallbacks were used during compilation
  30578. * @returns true if all fallbacks were used
  30579. */
  30580. allFallbacksProcessed(): boolean;
  30581. /**
  30582. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30583. * @param func The callback to be used.
  30584. */
  30585. executeWhenCompiled(func: (effect: Effect) => void): void;
  30586. private _checkIsReady;
  30587. private _loadShader;
  30588. /**
  30589. * Recompiles the webGL program
  30590. * @param vertexSourceCode The source code for the vertex shader.
  30591. * @param fragmentSourceCode The source code for the fragment shader.
  30592. * @param onCompiled Callback called when completed.
  30593. * @param onError Callback called on error.
  30594. * @hidden
  30595. */
  30596. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30597. /**
  30598. * Prepares the effect
  30599. * @hidden
  30600. */
  30601. _prepareEffect(): void;
  30602. private _processCompilationErrors;
  30603. /**
  30604. * Checks if the effect is supported. (Must be called after compilation)
  30605. */
  30606. readonly isSupported: boolean;
  30607. /**
  30608. * Binds a texture to the engine to be used as output of the shader.
  30609. * @param channel Name of the output variable.
  30610. * @param texture Texture to bind.
  30611. * @hidden
  30612. */
  30613. _bindTexture(channel: string, texture: InternalTexture): void;
  30614. /**
  30615. * Sets a texture on the engine to be used in the shader.
  30616. * @param channel Name of the sampler variable.
  30617. * @param texture Texture to set.
  30618. */
  30619. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30620. /**
  30621. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30622. * @param channel Name of the sampler variable.
  30623. * @param texture Texture to set.
  30624. */
  30625. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30626. /**
  30627. * Sets an array of textures on the engine to be used in the shader.
  30628. * @param channel Name of the variable.
  30629. * @param textures Textures to set.
  30630. */
  30631. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30632. /**
  30633. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  30634. * @param channel Name of the sampler variable.
  30635. * @param postProcess Post process to get the input texture from.
  30636. */
  30637. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30638. /**
  30639. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30640. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  30641. * @param channel Name of the sampler variable.
  30642. * @param postProcess Post process to get the output texture from.
  30643. */
  30644. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30645. /** @hidden */
  30646. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30647. /** @hidden */
  30648. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30649. /** @hidden */
  30650. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30651. /** @hidden */
  30652. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30653. /**
  30654. * Binds a buffer to a uniform.
  30655. * @param buffer Buffer to bind.
  30656. * @param name Name of the uniform variable to bind to.
  30657. */
  30658. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30659. /**
  30660. * Binds block to a uniform.
  30661. * @param blockName Name of the block to bind.
  30662. * @param index Index to bind.
  30663. */
  30664. bindUniformBlock(blockName: string, index: number): void;
  30665. /**
  30666. * Sets an interger value on a uniform variable.
  30667. * @param uniformName Name of the variable.
  30668. * @param value Value to be set.
  30669. * @returns this effect.
  30670. */
  30671. setInt(uniformName: string, value: number): Effect;
  30672. /**
  30673. * Sets an int array on a uniform variable.
  30674. * @param uniformName Name of the variable.
  30675. * @param array array to be set.
  30676. * @returns this effect.
  30677. */
  30678. setIntArray(uniformName: string, array: Int32Array): Effect;
  30679. /**
  30680. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  30681. * @param uniformName Name of the variable.
  30682. * @param array array to be set.
  30683. * @returns this effect.
  30684. */
  30685. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30686. /**
  30687. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  30688. * @param uniformName Name of the variable.
  30689. * @param array array to be set.
  30690. * @returns this effect.
  30691. */
  30692. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30693. /**
  30694. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  30695. * @param uniformName Name of the variable.
  30696. * @param array array to be set.
  30697. * @returns this effect.
  30698. */
  30699. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30700. /**
  30701. * Sets an float array on a uniform variable.
  30702. * @param uniformName Name of the variable.
  30703. * @param array array to be set.
  30704. * @returns this effect.
  30705. */
  30706. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30707. /**
  30708. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  30709. * @param uniformName Name of the variable.
  30710. * @param array array to be set.
  30711. * @returns this effect.
  30712. */
  30713. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30714. /**
  30715. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  30716. * @param uniformName Name of the variable.
  30717. * @param array array to be set.
  30718. * @returns this effect.
  30719. */
  30720. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30721. /**
  30722. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  30723. * @param uniformName Name of the variable.
  30724. * @param array array to be set.
  30725. * @returns this effect.
  30726. */
  30727. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30728. /**
  30729. * Sets an array on a uniform variable.
  30730. * @param uniformName Name of the variable.
  30731. * @param array array to be set.
  30732. * @returns this effect.
  30733. */
  30734. setArray(uniformName: string, array: number[]): Effect;
  30735. /**
  30736. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  30737. * @param uniformName Name of the variable.
  30738. * @param array array to be set.
  30739. * @returns this effect.
  30740. */
  30741. setArray2(uniformName: string, array: number[]): Effect;
  30742. /**
  30743. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  30744. * @param uniformName Name of the variable.
  30745. * @param array array to be set.
  30746. * @returns this effect.
  30747. */
  30748. setArray3(uniformName: string, array: number[]): Effect;
  30749. /**
  30750. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  30751. * @param uniformName Name of the variable.
  30752. * @param array array to be set.
  30753. * @returns this effect.
  30754. */
  30755. setArray4(uniformName: string, array: number[]): Effect;
  30756. /**
  30757. * Sets matrices on a uniform variable.
  30758. * @param uniformName Name of the variable.
  30759. * @param matrices matrices to be set.
  30760. * @returns this effect.
  30761. */
  30762. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30763. /**
  30764. * Sets matrix on a uniform variable.
  30765. * @param uniformName Name of the variable.
  30766. * @param matrix matrix to be set.
  30767. * @returns this effect.
  30768. */
  30769. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30770. /**
  30771. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  30772. * @param uniformName Name of the variable.
  30773. * @param matrix matrix to be set.
  30774. * @returns this effect.
  30775. */
  30776. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30777. /**
  30778. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30779. * @param uniformName Name of the variable.
  30780. * @param matrix matrix to be set.
  30781. * @returns this effect.
  30782. */
  30783. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30784. /**
  30785. * Sets a float on a uniform variable.
  30786. * @param uniformName Name of the variable.
  30787. * @param value value to be set.
  30788. * @returns this effect.
  30789. */
  30790. setFloat(uniformName: string, value: number): Effect;
  30791. /**
  30792. * Sets a boolean on a uniform variable.
  30793. * @param uniformName Name of the variable.
  30794. * @param bool value to be set.
  30795. * @returns this effect.
  30796. */
  30797. setBool(uniformName: string, bool: boolean): Effect;
  30798. /**
  30799. * Sets a Vector2 on a uniform variable.
  30800. * @param uniformName Name of the variable.
  30801. * @param vector2 vector2 to be set.
  30802. * @returns this effect.
  30803. */
  30804. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30805. /**
  30806. * Sets a float2 on a uniform variable.
  30807. * @param uniformName Name of the variable.
  30808. * @param x First float in float2.
  30809. * @param y Second float in float2.
  30810. * @returns this effect.
  30811. */
  30812. setFloat2(uniformName: string, x: number, y: number): Effect;
  30813. /**
  30814. * Sets a Vector3 on a uniform variable.
  30815. * @param uniformName Name of the variable.
  30816. * @param vector3 Value to be set.
  30817. * @returns this effect.
  30818. */
  30819. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30820. /**
  30821. * Sets a float3 on a uniform variable.
  30822. * @param uniformName Name of the variable.
  30823. * @param x First float in float3.
  30824. * @param y Second float in float3.
  30825. * @param z Third float in float3.
  30826. * @returns this effect.
  30827. */
  30828. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30829. /**
  30830. * Sets a Vector4 on a uniform variable.
  30831. * @param uniformName Name of the variable.
  30832. * @param vector4 Value to be set.
  30833. * @returns this effect.
  30834. */
  30835. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30836. /**
  30837. * Sets a float4 on a uniform variable.
  30838. * @param uniformName Name of the variable.
  30839. * @param x First float in float4.
  30840. * @param y Second float in float4.
  30841. * @param z Third float in float4.
  30842. * @param w Fourth float in float4.
  30843. * @returns this effect.
  30844. */
  30845. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30846. /**
  30847. * Sets a Color3 on a uniform variable.
  30848. * @param uniformName Name of the variable.
  30849. * @param color3 Value to be set.
  30850. * @returns this effect.
  30851. */
  30852. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30853. /**
  30854. * Sets a Color4 on a uniform variable.
  30855. * @param uniformName Name of the variable.
  30856. * @param color3 Value to be set.
  30857. * @param alpha Alpha value to be set.
  30858. * @returns this effect.
  30859. */
  30860. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30861. /**
  30862. * Sets a Color4 on a uniform variable
  30863. * @param uniformName defines the name of the variable
  30864. * @param color4 defines the value to be set
  30865. * @returns this effect.
  30866. */
  30867. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30868. /** Release all associated resources */
  30869. dispose(): void;
  30870. /**
  30871. * This function will add a new shader to the shader store
  30872. * @param name the name of the shader
  30873. * @param pixelShader optional pixel shader content
  30874. * @param vertexShader optional vertex shader content
  30875. */
  30876. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30877. /**
  30878. * Store of each shader (The can be looked up using effect.key)
  30879. */
  30880. static ShadersStore: {
  30881. [key: string]: string;
  30882. };
  30883. /**
  30884. * Store of each included file for a shader (The can be looked up using effect.key)
  30885. */
  30886. static IncludesShadersStore: {
  30887. [key: string]: string;
  30888. };
  30889. /**
  30890. * Resets the cache of effects.
  30891. */
  30892. static ResetCache(): void;
  30893. }
  30894. }
  30895. declare module "babylonjs/Engines/engineCapabilities" {
  30896. /**
  30897. * Interface used to describe the capabilities of the engine relatively to the current browser
  30898. */
  30899. export interface EngineCapabilities {
  30900. /** Maximum textures units per fragment shader */
  30901. maxTexturesImageUnits: number;
  30902. /** Maximum texture units per vertex shader */
  30903. maxVertexTextureImageUnits: number;
  30904. /** Maximum textures units in the entire pipeline */
  30905. maxCombinedTexturesImageUnits: number;
  30906. /** Maximum texture size */
  30907. maxTextureSize: number;
  30908. /** Maximum texture samples */
  30909. maxSamples?: number;
  30910. /** Maximum cube texture size */
  30911. maxCubemapTextureSize: number;
  30912. /** Maximum render texture size */
  30913. maxRenderTextureSize: number;
  30914. /** Maximum number of vertex attributes */
  30915. maxVertexAttribs: number;
  30916. /** Maximum number of varyings */
  30917. maxVaryingVectors: number;
  30918. /** Maximum number of uniforms per vertex shader */
  30919. maxVertexUniformVectors: number;
  30920. /** Maximum number of uniforms per fragment shader */
  30921. maxFragmentUniformVectors: number;
  30922. /** Defines if standard derivates (dx/dy) are supported */
  30923. standardDerivatives: boolean;
  30924. /** Defines if s3tc texture compression is supported */
  30925. s3tc?: WEBGL_compressed_texture_s3tc;
  30926. /** Defines if pvrtc texture compression is supported */
  30927. pvrtc: any;
  30928. /** Defines if etc1 texture compression is supported */
  30929. etc1: any;
  30930. /** Defines if etc2 texture compression is supported */
  30931. etc2: any;
  30932. /** Defines if astc texture compression is supported */
  30933. astc: any;
  30934. /** Defines if float textures are supported */
  30935. textureFloat: boolean;
  30936. /** Defines if vertex array objects are supported */
  30937. vertexArrayObject: boolean;
  30938. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30939. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30940. /** Gets the maximum level of anisotropy supported */
  30941. maxAnisotropy: number;
  30942. /** Defines if instancing is supported */
  30943. instancedArrays: boolean;
  30944. /** Defines if 32 bits indices are supported */
  30945. uintIndices: boolean;
  30946. /** Defines if high precision shaders are supported */
  30947. highPrecisionShaderSupported: boolean;
  30948. /** Defines if depth reading in the fragment shader is supported */
  30949. fragmentDepthSupported: boolean;
  30950. /** Defines if float texture linear filtering is supported*/
  30951. textureFloatLinearFiltering: boolean;
  30952. /** Defines if rendering to float textures is supported */
  30953. textureFloatRender: boolean;
  30954. /** Defines if half float textures are supported*/
  30955. textureHalfFloat: boolean;
  30956. /** Defines if half float texture linear filtering is supported*/
  30957. textureHalfFloatLinearFiltering: boolean;
  30958. /** Defines if rendering to half float textures is supported */
  30959. textureHalfFloatRender: boolean;
  30960. /** Defines if textureLOD shader command is supported */
  30961. textureLOD: boolean;
  30962. /** Defines if draw buffers extension is supported */
  30963. drawBuffersExtension: boolean;
  30964. /** Defines if depth textures are supported */
  30965. depthTextureExtension: boolean;
  30966. /** Defines if float color buffer are supported */
  30967. colorBufferFloat: boolean;
  30968. /** Gets disjoint timer query extension (null if not supported) */
  30969. timerQuery?: EXT_disjoint_timer_query;
  30970. /** Defines if timestamp can be used with timer query */
  30971. canUseTimestampForTimerQuery: boolean;
  30972. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30973. multiview?: any;
  30974. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30975. oculusMultiview?: any;
  30976. /** Function used to let the system compiles shaders in background */
  30977. parallelShaderCompile?: {
  30978. COMPLETION_STATUS_KHR: number;
  30979. };
  30980. /** Max number of texture samples for MSAA */
  30981. maxMSAASamples: number;
  30982. /** Defines if the blend min max extension is supported */
  30983. blendMinMax: boolean;
  30984. }
  30985. }
  30986. declare module "babylonjs/States/depthCullingState" {
  30987. import { Nullable } from "babylonjs/types";
  30988. /**
  30989. * @hidden
  30990. **/
  30991. export class DepthCullingState {
  30992. private _isDepthTestDirty;
  30993. private _isDepthMaskDirty;
  30994. private _isDepthFuncDirty;
  30995. private _isCullFaceDirty;
  30996. private _isCullDirty;
  30997. private _isZOffsetDirty;
  30998. private _isFrontFaceDirty;
  30999. private _depthTest;
  31000. private _depthMask;
  31001. private _depthFunc;
  31002. private _cull;
  31003. private _cullFace;
  31004. private _zOffset;
  31005. private _frontFace;
  31006. /**
  31007. * Initializes the state.
  31008. */
  31009. constructor();
  31010. readonly isDirty: boolean;
  31011. zOffset: number;
  31012. cullFace: Nullable<number>;
  31013. cull: Nullable<boolean>;
  31014. depthFunc: Nullable<number>;
  31015. depthMask: boolean;
  31016. depthTest: boolean;
  31017. frontFace: Nullable<number>;
  31018. reset(): void;
  31019. apply(gl: WebGLRenderingContext): void;
  31020. }
  31021. }
  31022. declare module "babylonjs/States/stencilState" {
  31023. /**
  31024. * @hidden
  31025. **/
  31026. export class StencilState {
  31027. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  31028. static readonly ALWAYS: number;
  31029. /** Passed to stencilOperation to specify that stencil value must be kept */
  31030. static readonly KEEP: number;
  31031. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31032. static readonly REPLACE: number;
  31033. private _isStencilTestDirty;
  31034. private _isStencilMaskDirty;
  31035. private _isStencilFuncDirty;
  31036. private _isStencilOpDirty;
  31037. private _stencilTest;
  31038. private _stencilMask;
  31039. private _stencilFunc;
  31040. private _stencilFuncRef;
  31041. private _stencilFuncMask;
  31042. private _stencilOpStencilFail;
  31043. private _stencilOpDepthFail;
  31044. private _stencilOpStencilDepthPass;
  31045. readonly isDirty: boolean;
  31046. stencilFunc: number;
  31047. stencilFuncRef: number;
  31048. stencilFuncMask: number;
  31049. stencilOpStencilFail: number;
  31050. stencilOpDepthFail: number;
  31051. stencilOpStencilDepthPass: number;
  31052. stencilMask: number;
  31053. stencilTest: boolean;
  31054. constructor();
  31055. reset(): void;
  31056. apply(gl: WebGLRenderingContext): void;
  31057. }
  31058. }
  31059. declare module "babylonjs/States/alphaCullingState" {
  31060. /**
  31061. * @hidden
  31062. **/
  31063. export class AlphaState {
  31064. private _isAlphaBlendDirty;
  31065. private _isBlendFunctionParametersDirty;
  31066. private _isBlendEquationParametersDirty;
  31067. private _isBlendConstantsDirty;
  31068. private _alphaBlend;
  31069. private _blendFunctionParameters;
  31070. private _blendEquationParameters;
  31071. private _blendConstants;
  31072. /**
  31073. * Initializes the state.
  31074. */
  31075. constructor();
  31076. readonly isDirty: boolean;
  31077. alphaBlend: boolean;
  31078. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31079. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31080. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31081. reset(): void;
  31082. apply(gl: WebGLRenderingContext): void;
  31083. }
  31084. }
  31085. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31086. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31087. /** @hidden */
  31088. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31089. attributeProcessor(attribute: string): string;
  31090. varyingProcessor(varying: string, isFragment: boolean): string;
  31091. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31092. }
  31093. }
  31094. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31095. /**
  31096. * Interface for attribute information associated with buffer instanciation
  31097. */
  31098. export interface InstancingAttributeInfo {
  31099. /**
  31100. * Index/offset of the attribute in the vertex shader
  31101. */
  31102. index: number;
  31103. /**
  31104. * size of the attribute, 1, 2, 3 or 4
  31105. */
  31106. attributeSize: number;
  31107. /**
  31108. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31109. * default is FLOAT
  31110. */
  31111. attributeType: number;
  31112. /**
  31113. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31114. */
  31115. normalized: boolean;
  31116. /**
  31117. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31118. */
  31119. offset: number;
  31120. /**
  31121. * Name of the GLSL attribute, for debugging purpose only
  31122. */
  31123. attributeName: string;
  31124. }
  31125. }
  31126. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31127. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31128. import { Nullable } from "babylonjs/types";
  31129. module "babylonjs/Engines/thinEngine" {
  31130. interface ThinEngine {
  31131. /**
  31132. * Update a video texture
  31133. * @param texture defines the texture to update
  31134. * @param video defines the video element to use
  31135. * @param invertY defines if data must be stored with Y axis inverted
  31136. */
  31137. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31138. }
  31139. }
  31140. }
  31141. declare module "babylonjs/Materials/Textures/videoTexture" {
  31142. import { Observable } from "babylonjs/Misc/observable";
  31143. import { Nullable } from "babylonjs/types";
  31144. import { Scene } from "babylonjs/scene";
  31145. import { Texture } from "babylonjs/Materials/Textures/texture";
  31146. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31147. /**
  31148. * Settings for finer control over video usage
  31149. */
  31150. export interface VideoTextureSettings {
  31151. /**
  31152. * Applies `autoplay` to video, if specified
  31153. */
  31154. autoPlay?: boolean;
  31155. /**
  31156. * Applies `loop` to video, if specified
  31157. */
  31158. loop?: boolean;
  31159. /**
  31160. * Automatically updates internal texture from video at every frame in the render loop
  31161. */
  31162. autoUpdateTexture: boolean;
  31163. /**
  31164. * Image src displayed during the video loading or until the user interacts with the video.
  31165. */
  31166. poster?: string;
  31167. }
  31168. /**
  31169. * If you want to display a video in your scene, this is the special texture for that.
  31170. * This special texture works similar to other textures, with the exception of a few parameters.
  31171. * @see https://doc.babylonjs.com/how_to/video_texture
  31172. */
  31173. export class VideoTexture extends Texture {
  31174. /**
  31175. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31176. */
  31177. readonly autoUpdateTexture: boolean;
  31178. /**
  31179. * The video instance used by the texture internally
  31180. */
  31181. readonly video: HTMLVideoElement;
  31182. private _onUserActionRequestedObservable;
  31183. /**
  31184. * Event triggerd when a dom action is required by the user to play the video.
  31185. * This happens due to recent changes in browser policies preventing video to auto start.
  31186. */
  31187. readonly onUserActionRequestedObservable: Observable<Texture>;
  31188. private _generateMipMaps;
  31189. private _engine;
  31190. private _stillImageCaptured;
  31191. private _displayingPosterTexture;
  31192. private _settings;
  31193. private _createInternalTextureOnEvent;
  31194. private _frameId;
  31195. /**
  31196. * Creates a video texture.
  31197. * If you want to display a video in your scene, this is the special texture for that.
  31198. * This special texture works similar to other textures, with the exception of a few parameters.
  31199. * @see https://doc.babylonjs.com/how_to/video_texture
  31200. * @param name optional name, will detect from video source, if not defined
  31201. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31202. * @param scene is obviously the current scene.
  31203. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31204. * @param invertY is false by default but can be used to invert video on Y axis
  31205. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31206. * @param settings allows finer control over video usage
  31207. */
  31208. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31209. private _getName;
  31210. private _getVideo;
  31211. private _createInternalTexture;
  31212. private reset;
  31213. /**
  31214. * @hidden Internal method to initiate `update`.
  31215. */
  31216. _rebuild(): void;
  31217. /**
  31218. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31219. */
  31220. update(): void;
  31221. /**
  31222. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31223. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31224. */
  31225. updateTexture(isVisible: boolean): void;
  31226. protected _updateInternalTexture: () => void;
  31227. /**
  31228. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31229. * @param url New url.
  31230. */
  31231. updateURL(url: string): void;
  31232. /**
  31233. * Dispose the texture and release its associated resources.
  31234. */
  31235. dispose(): void;
  31236. /**
  31237. * Creates a video texture straight from a stream.
  31238. * @param scene Define the scene the texture should be created in
  31239. * @param stream Define the stream the texture should be created from
  31240. * @returns The created video texture as a promise
  31241. */
  31242. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31243. /**
  31244. * Creates a video texture straight from your WebCam video feed.
  31245. * @param scene Define the scene the texture should be created in
  31246. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31247. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31248. * @returns The created video texture as a promise
  31249. */
  31250. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31251. minWidth: number;
  31252. maxWidth: number;
  31253. minHeight: number;
  31254. maxHeight: number;
  31255. deviceId: string;
  31256. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31257. /**
  31258. * Creates a video texture straight from your WebCam video feed.
  31259. * @param scene Define the scene the texture should be created in
  31260. * @param onReady Define a callback to triggered once the texture will be ready
  31261. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31262. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31263. */
  31264. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31265. minWidth: number;
  31266. maxWidth: number;
  31267. minHeight: number;
  31268. maxHeight: number;
  31269. deviceId: string;
  31270. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31271. }
  31272. }
  31273. declare module "babylonjs/Engines/thinEngine" {
  31274. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31275. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31276. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31277. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31278. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31279. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31280. import { Observable } from "babylonjs/Misc/observable";
  31281. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31282. import { StencilState } from "babylonjs/States/stencilState";
  31283. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31284. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31285. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31286. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31287. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31288. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31289. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31290. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31291. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31292. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31293. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31294. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31295. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31296. /**
  31297. * Defines the interface used by objects working like Scene
  31298. * @hidden
  31299. */
  31300. interface ISceneLike {
  31301. _addPendingData(data: any): void;
  31302. _removePendingData(data: any): void;
  31303. offlineProvider: IOfflineProvider;
  31304. }
  31305. /** Interface defining initialization parameters for Engine class */
  31306. export interface EngineOptions extends WebGLContextAttributes {
  31307. /**
  31308. * Defines if the engine should no exceed a specified device ratio
  31309. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31310. */
  31311. limitDeviceRatio?: number;
  31312. /**
  31313. * Defines if webvr should be enabled automatically
  31314. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31315. */
  31316. autoEnableWebVR?: boolean;
  31317. /**
  31318. * Defines if webgl2 should be turned off even if supported
  31319. * @see http://doc.babylonjs.com/features/webgl2
  31320. */
  31321. disableWebGL2Support?: boolean;
  31322. /**
  31323. * Defines if webaudio should be initialized as well
  31324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31325. */
  31326. audioEngine?: boolean;
  31327. /**
  31328. * Defines if animations should run using a deterministic lock step
  31329. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31330. */
  31331. deterministicLockstep?: boolean;
  31332. /** Defines the maximum steps to use with deterministic lock step mode */
  31333. lockstepMaxSteps?: number;
  31334. /** Defines the seconds between each deterministic lock step */
  31335. timeStep?: number;
  31336. /**
  31337. * Defines that engine should ignore context lost events
  31338. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31339. */
  31340. doNotHandleContextLost?: boolean;
  31341. /**
  31342. * Defines that engine should ignore modifying touch action attribute and style
  31343. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31344. */
  31345. doNotHandleTouchAction?: boolean;
  31346. /**
  31347. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31348. */
  31349. useHighPrecisionFloats?: boolean;
  31350. }
  31351. /**
  31352. * The base engine class (root of all engines)
  31353. */
  31354. export class ThinEngine {
  31355. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31356. static ExceptionList: ({
  31357. key: string;
  31358. capture: string;
  31359. captureConstraint: number;
  31360. targets: string[];
  31361. } | {
  31362. key: string;
  31363. capture: null;
  31364. captureConstraint: null;
  31365. targets: string[];
  31366. })[];
  31367. /** @hidden */
  31368. static _TextureLoaders: IInternalTextureLoader[];
  31369. /**
  31370. * Returns the current npm package of the sdk
  31371. */
  31372. static readonly NpmPackage: string;
  31373. /**
  31374. * Returns the current version of the framework
  31375. */
  31376. static readonly Version: string;
  31377. /**
  31378. * Returns a string describing the current engine
  31379. */
  31380. readonly description: string;
  31381. /**
  31382. * Gets or sets the epsilon value used by collision engine
  31383. */
  31384. static CollisionsEpsilon: number;
  31385. /**
  31386. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31387. */
  31388. static ShadersRepository: string;
  31389. /**
  31390. * Gets or sets the textures that the engine should not attempt to load as compressed
  31391. */
  31392. protected _excludedCompressedTextures: string[];
  31393. /**
  31394. * Filters the compressed texture formats to only include
  31395. * files that are not included in the skippable list
  31396. *
  31397. * @param url the current extension
  31398. * @param textureFormatInUse the current compressed texture format
  31399. * @returns "format" string
  31400. */
  31401. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31402. /** @hidden */
  31403. _shaderProcessor: IShaderProcessor;
  31404. /**
  31405. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31406. */
  31407. forcePOTTextures: boolean;
  31408. /**
  31409. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31410. */
  31411. isFullscreen: boolean;
  31412. /**
  31413. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31414. */
  31415. cullBackFaces: boolean;
  31416. /**
  31417. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31418. */
  31419. renderEvenInBackground: boolean;
  31420. /**
  31421. * Gets or sets a boolean indicating that cache can be kept between frames
  31422. */
  31423. preventCacheWipeBetweenFrames: boolean;
  31424. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31425. validateShaderPrograms: boolean;
  31426. /**
  31427. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31428. * This can provide greater z depth for distant objects.
  31429. */
  31430. useReverseDepthBuffer: boolean;
  31431. /**
  31432. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31433. */
  31434. disableUniformBuffers: boolean;
  31435. /** @hidden */
  31436. _uniformBuffers: UniformBuffer[];
  31437. /**
  31438. * Gets a boolean indicating that the engine supports uniform buffers
  31439. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31440. */
  31441. readonly supportsUniformBuffers: boolean;
  31442. /** @hidden */
  31443. _gl: WebGLRenderingContext;
  31444. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31445. protected _windowIsBackground: boolean;
  31446. protected _webGLVersion: number;
  31447. protected _creationOptions: EngineOptions;
  31448. protected _highPrecisionShadersAllowed: boolean;
  31449. /** @hidden */
  31450. readonly _shouldUseHighPrecisionShader: boolean;
  31451. /**
  31452. * Gets a boolean indicating that only power of 2 textures are supported
  31453. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31454. */
  31455. readonly needPOTTextures: boolean;
  31456. /** @hidden */
  31457. _badOS: boolean;
  31458. /** @hidden */
  31459. _badDesktopOS: boolean;
  31460. private _hardwareScalingLevel;
  31461. /** @hidden */
  31462. _caps: EngineCapabilities;
  31463. private _isStencilEnable;
  31464. protected _colorWrite: boolean;
  31465. private _glVersion;
  31466. private _glRenderer;
  31467. private _glVendor;
  31468. /** @hidden */
  31469. _videoTextureSupported: boolean;
  31470. protected _renderingQueueLaunched: boolean;
  31471. protected _activeRenderLoops: (() => void)[];
  31472. /**
  31473. * Observable signaled when a context lost event is raised
  31474. */
  31475. onContextLostObservable: Observable<ThinEngine>;
  31476. /**
  31477. * Observable signaled when a context restored event is raised
  31478. */
  31479. onContextRestoredObservable: Observable<ThinEngine>;
  31480. private _onContextLost;
  31481. private _onContextRestored;
  31482. protected _contextWasLost: boolean;
  31483. /** @hidden */
  31484. _doNotHandleContextLost: boolean;
  31485. /**
  31486. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31488. */
  31489. doNotHandleContextLost: boolean;
  31490. /**
  31491. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31492. */
  31493. disableVertexArrayObjects: boolean;
  31494. /** @hidden */
  31495. protected _depthCullingState: DepthCullingState;
  31496. /** @hidden */
  31497. protected _stencilState: StencilState;
  31498. /** @hidden */
  31499. protected _alphaState: AlphaState;
  31500. /** @hidden */
  31501. _internalTexturesCache: InternalTexture[];
  31502. /** @hidden */
  31503. protected _activeChannel: number;
  31504. private _currentTextureChannel;
  31505. /** @hidden */
  31506. protected _boundTexturesCache: {
  31507. [key: string]: Nullable<InternalTexture>;
  31508. };
  31509. /** @hidden */
  31510. protected _currentEffect: Nullable<Effect>;
  31511. /** @hidden */
  31512. protected _currentProgram: Nullable<WebGLProgram>;
  31513. private _compiledEffects;
  31514. private _vertexAttribArraysEnabled;
  31515. /** @hidden */
  31516. protected _cachedViewport: Nullable<IViewportLike>;
  31517. private _cachedVertexArrayObject;
  31518. /** @hidden */
  31519. protected _cachedVertexBuffers: any;
  31520. /** @hidden */
  31521. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31522. /** @hidden */
  31523. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31524. /** @hidden */
  31525. _currentRenderTarget: Nullable<InternalTexture>;
  31526. private _uintIndicesCurrentlySet;
  31527. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31528. /** @hidden */
  31529. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31530. private _currentBufferPointers;
  31531. private _currentInstanceLocations;
  31532. private _currentInstanceBuffers;
  31533. private _textureUnits;
  31534. /** @hidden */
  31535. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31536. /** @hidden */
  31537. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31538. /** @hidden */
  31539. _boundRenderFunction: any;
  31540. private _vaoRecordInProgress;
  31541. private _mustWipeVertexAttributes;
  31542. private _emptyTexture;
  31543. private _emptyCubeTexture;
  31544. private _emptyTexture3D;
  31545. private _emptyTexture2DArray;
  31546. /** @hidden */
  31547. _frameHandler: number;
  31548. private _nextFreeTextureSlots;
  31549. private _maxSimultaneousTextures;
  31550. private _activeRequests;
  31551. protected _texturesSupported: string[];
  31552. /** @hidden */
  31553. _textureFormatInUse: Nullable<string>;
  31554. protected readonly _supportsHardwareTextureRescaling: boolean;
  31555. /**
  31556. * Gets the list of texture formats supported
  31557. */
  31558. readonly texturesSupported: Array<string>;
  31559. /**
  31560. * Gets the list of texture formats in use
  31561. */
  31562. readonly textureFormatInUse: Nullable<string>;
  31563. /**
  31564. * Gets the current viewport
  31565. */
  31566. readonly currentViewport: Nullable<IViewportLike>;
  31567. /**
  31568. * Gets the default empty texture
  31569. */
  31570. readonly emptyTexture: InternalTexture;
  31571. /**
  31572. * Gets the default empty 3D texture
  31573. */
  31574. readonly emptyTexture3D: InternalTexture;
  31575. /**
  31576. * Gets the default empty 2D array texture
  31577. */
  31578. readonly emptyTexture2DArray: InternalTexture;
  31579. /**
  31580. * Gets the default empty cube texture
  31581. */
  31582. readonly emptyCubeTexture: InternalTexture;
  31583. /**
  31584. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31585. */
  31586. readonly premultipliedAlpha: boolean;
  31587. /**
  31588. * Observable event triggered before each texture is initialized
  31589. */
  31590. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31591. /**
  31592. * Creates a new engine
  31593. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  31594. * @param antialias defines enable antialiasing (default: false)
  31595. * @param options defines further options to be sent to the getContext() function
  31596. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31597. */
  31598. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31599. private _rebuildInternalTextures;
  31600. private _rebuildEffects;
  31601. /**
  31602. * Gets a boolean indicating if all created effects are ready
  31603. * @returns true if all effects are ready
  31604. */
  31605. areAllEffectsReady(): boolean;
  31606. protected _rebuildBuffers(): void;
  31607. private _initGLContext;
  31608. /**
  31609. * Gets version of the current webGL context
  31610. */
  31611. readonly webGLVersion: number;
  31612. /**
  31613. * Gets a string idenfifying the name of the class
  31614. * @returns "Engine" string
  31615. */
  31616. getClassName(): string;
  31617. /**
  31618. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31619. */
  31620. readonly isStencilEnable: boolean;
  31621. /** @hidden */
  31622. _prepareWorkingCanvas(): void;
  31623. /**
  31624. * Reset the texture cache to empty state
  31625. */
  31626. resetTextureCache(): void;
  31627. /**
  31628. * Gets an object containing information about the current webGL context
  31629. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31630. */
  31631. getGlInfo(): {
  31632. vendor: string;
  31633. renderer: string;
  31634. version: string;
  31635. };
  31636. /**
  31637. * Defines the hardware scaling level.
  31638. * By default the hardware scaling level is computed from the window device ratio.
  31639. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  31640. * @param level defines the level to use
  31641. */
  31642. setHardwareScalingLevel(level: number): void;
  31643. /**
  31644. * Gets the current hardware scaling level.
  31645. * By default the hardware scaling level is computed from the window device ratio.
  31646. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  31647. * @returns a number indicating the current hardware scaling level
  31648. */
  31649. getHardwareScalingLevel(): number;
  31650. /**
  31651. * Gets the list of loaded textures
  31652. * @returns an array containing all loaded textures
  31653. */
  31654. getLoadedTexturesCache(): InternalTexture[];
  31655. /**
  31656. * Gets the object containing all engine capabilities
  31657. * @returns the EngineCapabilities object
  31658. */
  31659. getCaps(): EngineCapabilities;
  31660. /**
  31661. * stop executing a render loop function and remove it from the execution array
  31662. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31663. */
  31664. stopRenderLoop(renderFunction?: () => void): void;
  31665. /** @hidden */
  31666. _renderLoop(): void;
  31667. /**
  31668. * Gets the HTML canvas attached with the current webGL context
  31669. * @returns a HTML canvas
  31670. */
  31671. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31672. /**
  31673. * Gets host window
  31674. * @returns the host window object
  31675. */
  31676. getHostWindow(): Nullable<Window>;
  31677. /**
  31678. * Gets the current render width
  31679. * @param useScreen defines if screen size must be used (or the current render target if any)
  31680. * @returns a number defining the current render width
  31681. */
  31682. getRenderWidth(useScreen?: boolean): number;
  31683. /**
  31684. * Gets the current render height
  31685. * @param useScreen defines if screen size must be used (or the current render target if any)
  31686. * @returns a number defining the current render height
  31687. */
  31688. getRenderHeight(useScreen?: boolean): number;
  31689. /**
  31690. * Can be used to override the current requestAnimationFrame requester.
  31691. * @hidden
  31692. */
  31693. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31694. /**
  31695. * Register and execute a render loop. The engine can have more than one render function
  31696. * @param renderFunction defines the function to continuously execute
  31697. */
  31698. runRenderLoop(renderFunction: () => void): void;
  31699. /**
  31700. * Clear the current render buffer or the current render target (if any is set up)
  31701. * @param color defines the color to use
  31702. * @param backBuffer defines if the back buffer must be cleared
  31703. * @param depth defines if the depth buffer must be cleared
  31704. * @param stencil defines if the stencil buffer must be cleared
  31705. */
  31706. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31707. private _viewportCached;
  31708. /** @hidden */
  31709. _viewport(x: number, y: number, width: number, height: number): void;
  31710. /**
  31711. * Set the WebGL's viewport
  31712. * @param viewport defines the viewport element to be used
  31713. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31714. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31715. */
  31716. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31717. /**
  31718. * Begin a new frame
  31719. */
  31720. beginFrame(): void;
  31721. /**
  31722. * Enf the current frame
  31723. */
  31724. endFrame(): void;
  31725. /**
  31726. * Resize the view according to the canvas' size
  31727. */
  31728. resize(): void;
  31729. /**
  31730. * Force a specific size of the canvas
  31731. * @param width defines the new canvas' width
  31732. * @param height defines the new canvas' height
  31733. */
  31734. setSize(width: number, height: number): void;
  31735. /**
  31736. * Binds the frame buffer to the specified texture.
  31737. * @param texture The texture to render to or null for the default canvas
  31738. * @param faceIndex The face of the texture to render to in case of cube texture
  31739. * @param requiredWidth The width of the target to render to
  31740. * @param requiredHeight The height of the target to render to
  31741. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31742. * @param depthStencilTexture The depth stencil texture to use to render
  31743. * @param lodLevel defines le lod level to bind to the frame buffer
  31744. */
  31745. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31746. /** @hidden */
  31747. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31748. /**
  31749. * Unbind the current render target texture from the webGL context
  31750. * @param texture defines the render target texture to unbind
  31751. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31752. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31753. */
  31754. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31755. /**
  31756. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31757. */
  31758. flushFramebuffer(): void;
  31759. /**
  31760. * Unbind the current render target and bind the default framebuffer
  31761. */
  31762. restoreDefaultFramebuffer(): void;
  31763. /** @hidden */
  31764. protected _resetVertexBufferBinding(): void;
  31765. /**
  31766. * Creates a vertex buffer
  31767. * @param data the data for the vertex buffer
  31768. * @returns the new WebGL static buffer
  31769. */
  31770. createVertexBuffer(data: DataArray): DataBuffer;
  31771. private _createVertexBuffer;
  31772. /**
  31773. * Creates a dynamic vertex buffer
  31774. * @param data the data for the dynamic vertex buffer
  31775. * @returns the new WebGL dynamic buffer
  31776. */
  31777. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31778. protected _resetIndexBufferBinding(): void;
  31779. /**
  31780. * Creates a new index buffer
  31781. * @param indices defines the content of the index buffer
  31782. * @param updatable defines if the index buffer must be updatable
  31783. * @returns a new webGL buffer
  31784. */
  31785. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31786. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31787. /**
  31788. * Bind a webGL buffer to the webGL context
  31789. * @param buffer defines the buffer to bind
  31790. */
  31791. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31792. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31793. private bindBuffer;
  31794. /**
  31795. * update the bound buffer with the given data
  31796. * @param data defines the data to update
  31797. */
  31798. updateArrayBuffer(data: Float32Array): void;
  31799. private _vertexAttribPointer;
  31800. private _bindIndexBufferWithCache;
  31801. private _bindVertexBuffersAttributes;
  31802. /**
  31803. * Records a vertex array object
  31804. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31805. * @param vertexBuffers defines the list of vertex buffers to store
  31806. * @param indexBuffer defines the index buffer to store
  31807. * @param effect defines the effect to store
  31808. * @returns the new vertex array object
  31809. */
  31810. recordVertexArrayObject(vertexBuffers: {
  31811. [key: string]: VertexBuffer;
  31812. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31813. /**
  31814. * Bind a specific vertex array object
  31815. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31816. * @param vertexArrayObject defines the vertex array object to bind
  31817. * @param indexBuffer defines the index buffer to bind
  31818. */
  31819. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31820. /**
  31821. * Bind webGl buffers directly to the webGL context
  31822. * @param vertexBuffer defines the vertex buffer to bind
  31823. * @param indexBuffer defines the index buffer to bind
  31824. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31825. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31826. * @param effect defines the effect associated with the vertex buffer
  31827. */
  31828. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31829. private _unbindVertexArrayObject;
  31830. /**
  31831. * Bind a list of vertex buffers to the webGL context
  31832. * @param vertexBuffers defines the list of vertex buffers to bind
  31833. * @param indexBuffer defines the index buffer to bind
  31834. * @param effect defines the effect associated with the vertex buffers
  31835. */
  31836. bindBuffers(vertexBuffers: {
  31837. [key: string]: Nullable<VertexBuffer>;
  31838. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31839. /**
  31840. * Unbind all instance attributes
  31841. */
  31842. unbindInstanceAttributes(): void;
  31843. /**
  31844. * Release and free the memory of a vertex array object
  31845. * @param vao defines the vertex array object to delete
  31846. */
  31847. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31848. /** @hidden */
  31849. _releaseBuffer(buffer: DataBuffer): boolean;
  31850. protected _deleteBuffer(buffer: DataBuffer): void;
  31851. /**
  31852. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31853. * @param instancesBuffer defines the webGL buffer to update and bind
  31854. * @param data defines the data to store in the buffer
  31855. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31856. */
  31857. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31858. /**
  31859. * Apply all cached states (depth, culling, stencil and alpha)
  31860. */
  31861. applyStates(): void;
  31862. /**
  31863. * Send a draw order
  31864. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31865. * @param indexStart defines the starting index
  31866. * @param indexCount defines the number of index to draw
  31867. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31868. */
  31869. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31870. /**
  31871. * Draw a list of points
  31872. * @param verticesStart defines the index of first vertex to draw
  31873. * @param verticesCount defines the count of vertices to draw
  31874. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31875. */
  31876. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31877. /**
  31878. * Draw a list of unindexed primitives
  31879. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31880. * @param verticesStart defines the index of first vertex to draw
  31881. * @param verticesCount defines the count of vertices to draw
  31882. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31883. */
  31884. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31885. /**
  31886. * Draw a list of indexed primitives
  31887. * @param fillMode defines the primitive to use
  31888. * @param indexStart defines the starting index
  31889. * @param indexCount defines the number of index to draw
  31890. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31891. */
  31892. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31893. /**
  31894. * Draw a list of unindexed primitives
  31895. * @param fillMode defines the primitive to use
  31896. * @param verticesStart defines the index of first vertex to draw
  31897. * @param verticesCount defines the count of vertices to draw
  31898. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31899. */
  31900. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31901. private _drawMode;
  31902. /** @hidden */
  31903. protected _reportDrawCall(): void;
  31904. /** @hidden */
  31905. _releaseEffect(effect: Effect): void;
  31906. /** @hidden */
  31907. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31908. /**
  31909. * Create a new effect (used to store vertex/fragment shaders)
  31910. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31911. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31912. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31913. * @param samplers defines an array of string used to represent textures
  31914. * @param defines defines the string containing the defines to use to compile the shaders
  31915. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31916. * @param onCompiled defines a function to call when the effect creation is successful
  31917. * @param onError defines a function to call when the effect creation has failed
  31918. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31919. * @returns the new Effect
  31920. */
  31921. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31922. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31923. private _compileShader;
  31924. private _compileRawShader;
  31925. /**
  31926. * Directly creates a webGL program
  31927. * @param pipelineContext defines the pipeline context to attach to
  31928. * @param vertexCode defines the vertex shader code to use
  31929. * @param fragmentCode defines the fragment shader code to use
  31930. * @param context defines the webGL context to use (if not set, the current one will be used)
  31931. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31932. * @returns the new webGL program
  31933. */
  31934. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31935. /**
  31936. * Creates a webGL program
  31937. * @param pipelineContext defines the pipeline context to attach to
  31938. * @param vertexCode defines the vertex shader code to use
  31939. * @param fragmentCode defines the fragment shader code to use
  31940. * @param defines defines the string containing the defines to use to compile the shaders
  31941. * @param context defines the webGL context to use (if not set, the current one will be used)
  31942. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31943. * @returns the new webGL program
  31944. */
  31945. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31946. /**
  31947. * Creates a new pipeline context
  31948. * @returns the new pipeline
  31949. */
  31950. createPipelineContext(): IPipelineContext;
  31951. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31952. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31953. /** @hidden */
  31954. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31955. /** @hidden */
  31956. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31957. /** @hidden */
  31958. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31959. /**
  31960. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31961. * @param pipelineContext defines the pipeline context to use
  31962. * @param uniformsNames defines the list of uniform names
  31963. * @returns an array of webGL uniform locations
  31964. */
  31965. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31966. /**
  31967. * Gets the lsit of active attributes for a given webGL program
  31968. * @param pipelineContext defines the pipeline context to use
  31969. * @param attributesNames defines the list of attribute names to get
  31970. * @returns an array of indices indicating the offset of each attribute
  31971. */
  31972. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31973. /**
  31974. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31975. * @param effect defines the effect to activate
  31976. */
  31977. enableEffect(effect: Nullable<Effect>): void;
  31978. /**
  31979. * Set the value of an uniform to a number (int)
  31980. * @param uniform defines the webGL uniform location where to store the value
  31981. * @param value defines the int number to store
  31982. */
  31983. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31984. /**
  31985. * Set the value of an uniform to an array of int32
  31986. * @param uniform defines the webGL uniform location where to store the value
  31987. * @param array defines the array of int32 to store
  31988. */
  31989. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31990. /**
  31991. * Set the value of an uniform to an array of int32 (stored as vec2)
  31992. * @param uniform defines the webGL uniform location where to store the value
  31993. * @param array defines the array of int32 to store
  31994. */
  31995. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31996. /**
  31997. * Set the value of an uniform to an array of int32 (stored as vec3)
  31998. * @param uniform defines the webGL uniform location where to store the value
  31999. * @param array defines the array of int32 to store
  32000. */
  32001. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32002. /**
  32003. * Set the value of an uniform to an array of int32 (stored as vec4)
  32004. * @param uniform defines the webGL uniform location where to store the value
  32005. * @param array defines the array of int32 to store
  32006. */
  32007. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32008. /**
  32009. * Set the value of an uniform to an array of number
  32010. * @param uniform defines the webGL uniform location where to store the value
  32011. * @param array defines the array of number to store
  32012. */
  32013. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32014. /**
  32015. * Set the value of an uniform to an array of number (stored as vec2)
  32016. * @param uniform defines the webGL uniform location where to store the value
  32017. * @param array defines the array of number to store
  32018. */
  32019. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32020. /**
  32021. * Set the value of an uniform to an array of number (stored as vec3)
  32022. * @param uniform defines the webGL uniform location where to store the value
  32023. * @param array defines the array of number to store
  32024. */
  32025. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32026. /**
  32027. * Set the value of an uniform to an array of number (stored as vec4)
  32028. * @param uniform defines the webGL uniform location where to store the value
  32029. * @param array defines the array of number to store
  32030. */
  32031. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32032. /**
  32033. * Set the value of an uniform to an array of float32 (stored as matrices)
  32034. * @param uniform defines the webGL uniform location where to store the value
  32035. * @param matrices defines the array of float32 to store
  32036. */
  32037. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32038. /**
  32039. * Set the value of an uniform to a matrix (3x3)
  32040. * @param uniform defines the webGL uniform location where to store the value
  32041. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32042. */
  32043. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32044. /**
  32045. * Set the value of an uniform to a matrix (2x2)
  32046. * @param uniform defines the webGL uniform location where to store the value
  32047. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32048. */
  32049. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32050. /**
  32051. * Set the value of an uniform to a number (float)
  32052. * @param uniform defines the webGL uniform location where to store the value
  32053. * @param value defines the float number to store
  32054. */
  32055. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32056. /**
  32057. * Set the value of an uniform to a vec2
  32058. * @param uniform defines the webGL uniform location where to store the value
  32059. * @param x defines the 1st component of the value
  32060. * @param y defines the 2nd component of the value
  32061. */
  32062. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32063. /**
  32064. * Set the value of an uniform to a vec3
  32065. * @param uniform defines the webGL uniform location where to store the value
  32066. * @param x defines the 1st component of the value
  32067. * @param y defines the 2nd component of the value
  32068. * @param z defines the 3rd component of the value
  32069. */
  32070. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32071. /**
  32072. * Set the value of an uniform to a vec4
  32073. * @param uniform defines the webGL uniform location where to store the value
  32074. * @param x defines the 1st component of the value
  32075. * @param y defines the 2nd component of the value
  32076. * @param z defines the 3rd component of the value
  32077. * @param w defines the 4th component of the value
  32078. */
  32079. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32080. /**
  32081. * Gets the depth culling state manager
  32082. */
  32083. readonly depthCullingState: DepthCullingState;
  32084. /**
  32085. * Gets the alpha state manager
  32086. */
  32087. readonly alphaState: AlphaState;
  32088. /**
  32089. * Gets the stencil state manager
  32090. */
  32091. readonly stencilState: StencilState;
  32092. /**
  32093. * Clears the list of texture accessible through engine.
  32094. * This can help preventing texture load conflict due to name collision.
  32095. */
  32096. clearInternalTexturesCache(): void;
  32097. /**
  32098. * Force the entire cache to be cleared
  32099. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32100. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32101. */
  32102. wipeCaches(bruteForce?: boolean): void;
  32103. /** @hidden */
  32104. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32105. min: number;
  32106. mag: number;
  32107. };
  32108. /** @hidden */
  32109. _createTexture(): WebGLTexture;
  32110. /**
  32111. * Usually called from Texture.ts.
  32112. * Passed information to create a WebGLTexture
  32113. * @param urlArg defines a value which contains one of the following:
  32114. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32115. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32116. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32117. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32118. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  32119. * @param scene needed for loading to the correct scene
  32120. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32121. * @param onLoad optional callback to be called upon successful completion
  32122. * @param onError optional callback to be called upon failure
  32123. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  32124. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32125. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32126. * @param forcedExtension defines the extension to use to pick the right loader
  32127. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32128. * @param mimeType defines an optional mime type
  32129. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32130. */
  32131. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32132. /**
  32133. * @hidden
  32134. */
  32135. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32136. /**
  32137. * Creates a raw texture
  32138. * @param data defines the data to store in the texture
  32139. * @param width defines the width of the texture
  32140. * @param height defines the height of the texture
  32141. * @param format defines the format of the data
  32142. * @param generateMipMaps defines if the engine should generate the mip levels
  32143. * @param invertY defines if data must be stored with Y axis inverted
  32144. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32145. * @param compression defines the compression used (null by default)
  32146. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32147. * @returns the raw texture inside an InternalTexture
  32148. */
  32149. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32150. /**
  32151. * Creates a new raw cube texture
  32152. * @param data defines the array of data to use to create each face
  32153. * @param size defines the size of the textures
  32154. * @param format defines the format of the data
  32155. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32156. * @param generateMipMaps defines if the engine should generate the mip levels
  32157. * @param invertY defines if data must be stored with Y axis inverted
  32158. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32159. * @param compression defines the compression used (null by default)
  32160. * @returns the cube texture as an InternalTexture
  32161. */
  32162. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32163. /**
  32164. * Creates a new raw 3D texture
  32165. * @param data defines the data used to create the texture
  32166. * @param width defines the width of the texture
  32167. * @param height defines the height of the texture
  32168. * @param depth defines the depth of the texture
  32169. * @param format defines the format of the texture
  32170. * @param generateMipMaps defines if the engine must generate mip levels
  32171. * @param invertY defines if data must be stored with Y axis inverted
  32172. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32173. * @param compression defines the compressed used (can be null)
  32174. * @param textureType defines the compressed used (can be null)
  32175. * @returns a new raw 3D texture (stored in an InternalTexture)
  32176. */
  32177. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32178. /**
  32179. * Creates a new raw 2D array texture
  32180. * @param data defines the data used to create the texture
  32181. * @param width defines the width of the texture
  32182. * @param height defines the height of the texture
  32183. * @param depth defines the number of layers of the texture
  32184. * @param format defines the format of the texture
  32185. * @param generateMipMaps defines if the engine must generate mip levels
  32186. * @param invertY defines if data must be stored with Y axis inverted
  32187. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32188. * @param compression defines the compressed used (can be null)
  32189. * @param textureType defines the compressed used (can be null)
  32190. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32191. */
  32192. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32193. private _unpackFlipYCached;
  32194. /**
  32195. * In case you are sharing the context with other applications, it might
  32196. * be interested to not cache the unpack flip y state to ensure a consistent
  32197. * value would be set.
  32198. */
  32199. enableUnpackFlipYCached: boolean;
  32200. /** @hidden */
  32201. _unpackFlipY(value: boolean): void;
  32202. /** @hidden */
  32203. _getUnpackAlignement(): number;
  32204. /**
  32205. * Update the sampling mode of a given texture
  32206. * @param samplingMode defines the required sampling mode
  32207. * @param texture defines the texture to update
  32208. */
  32209. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32210. /** @hidden */
  32211. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32212. width: number;
  32213. height: number;
  32214. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32215. /** @hidden */
  32216. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32217. /** @hidden */
  32218. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32219. /** @hidden */
  32220. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32221. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32222. private _prepareWebGLTexture;
  32223. /** @hidden */
  32224. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32225. /** @hidden */
  32226. _releaseFramebufferObjects(texture: InternalTexture): void;
  32227. /** @hidden */
  32228. _releaseTexture(texture: InternalTexture): void;
  32229. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32230. protected _setProgram(program: WebGLProgram): void;
  32231. protected _boundUniforms: {
  32232. [key: number]: WebGLUniformLocation;
  32233. };
  32234. /**
  32235. * Binds an effect to the webGL context
  32236. * @param effect defines the effect to bind
  32237. */
  32238. bindSamplers(effect: Effect): void;
  32239. private _activateCurrentTexture;
  32240. /** @hidden */
  32241. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32242. /** @hidden */
  32243. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32244. /**
  32245. * Unbind all textures from the webGL context
  32246. */
  32247. unbindAllTextures(): void;
  32248. /**
  32249. * Sets a texture to the according uniform.
  32250. * @param channel The texture channel
  32251. * @param uniform The uniform to set
  32252. * @param texture The texture to apply
  32253. */
  32254. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32255. private _bindSamplerUniformToChannel;
  32256. private _getTextureWrapMode;
  32257. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32258. /**
  32259. * Sets an array of texture to the webGL context
  32260. * @param channel defines the channel where the texture array must be set
  32261. * @param uniform defines the associated uniform location
  32262. * @param textures defines the array of textures to bind
  32263. */
  32264. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32265. /** @hidden */
  32266. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32267. private _setTextureParameterFloat;
  32268. private _setTextureParameterInteger;
  32269. /**
  32270. * Unbind all vertex attributes from the webGL context
  32271. */
  32272. unbindAllAttributes(): void;
  32273. /**
  32274. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  32275. */
  32276. releaseEffects(): void;
  32277. /**
  32278. * Dispose and release all associated resources
  32279. */
  32280. dispose(): void;
  32281. /**
  32282. * Attach a new callback raised when context lost event is fired
  32283. * @param callback defines the callback to call
  32284. */
  32285. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32286. /**
  32287. * Attach a new callback raised when context restored event is fired
  32288. * @param callback defines the callback to call
  32289. */
  32290. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32291. /**
  32292. * Get the current error code of the webGL context
  32293. * @returns the error code
  32294. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32295. */
  32296. getError(): number;
  32297. private _canRenderToFloatFramebuffer;
  32298. private _canRenderToHalfFloatFramebuffer;
  32299. private _canRenderToFramebuffer;
  32300. /** @hidden */
  32301. _getWebGLTextureType(type: number): number;
  32302. /** @hidden */
  32303. _getInternalFormat(format: number): number;
  32304. /** @hidden */
  32305. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32306. /** @hidden */
  32307. _getRGBAMultiSampleBufferFormat(type: number): number;
  32308. /** @hidden */
  32309. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  32310. /**
  32311. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32312. * @returns true if the engine can be created
  32313. * @ignorenaming
  32314. */
  32315. static isSupported(): boolean;
  32316. /**
  32317. * Find the next highest power of two.
  32318. * @param x Number to start search from.
  32319. * @return Next highest power of two.
  32320. */
  32321. static CeilingPOT(x: number): number;
  32322. /**
  32323. * Find the next lowest power of two.
  32324. * @param x Number to start search from.
  32325. * @return Next lowest power of two.
  32326. */
  32327. static FloorPOT(x: number): number;
  32328. /**
  32329. * Find the nearest power of two.
  32330. * @param x Number to start search from.
  32331. * @return Next nearest power of two.
  32332. */
  32333. static NearestPOT(x: number): number;
  32334. /**
  32335. * Get the closest exponent of two
  32336. * @param value defines the value to approximate
  32337. * @param max defines the maximum value to return
  32338. * @param mode defines how to define the closest value
  32339. * @returns closest exponent of two of the given value
  32340. */
  32341. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32342. /**
  32343. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32344. * @param func - the function to be called
  32345. * @param requester - the object that will request the next frame. Falls back to window.
  32346. * @returns frame number
  32347. */
  32348. static QueueNewFrame(func: () => void, requester?: any): number;
  32349. /**
  32350. * Gets host document
  32351. * @returns the host document object
  32352. */
  32353. getHostDocument(): Document;
  32354. }
  32355. }
  32356. declare module "babylonjs/Maths/sphericalPolynomial" {
  32357. import { Vector3 } from "babylonjs/Maths/math.vector";
  32358. import { Color3 } from "babylonjs/Maths/math.color";
  32359. /**
  32360. * Class representing spherical harmonics coefficients to the 3rd degree
  32361. */
  32362. export class SphericalHarmonics {
  32363. /**
  32364. * Defines whether or not the harmonics have been prescaled for rendering.
  32365. */
  32366. preScaled: boolean;
  32367. /**
  32368. * The l0,0 coefficients of the spherical harmonics
  32369. */
  32370. l00: Vector3;
  32371. /**
  32372. * The l1,-1 coefficients of the spherical harmonics
  32373. */
  32374. l1_1: Vector3;
  32375. /**
  32376. * The l1,0 coefficients of the spherical harmonics
  32377. */
  32378. l10: Vector3;
  32379. /**
  32380. * The l1,1 coefficients of the spherical harmonics
  32381. */
  32382. l11: Vector3;
  32383. /**
  32384. * The l2,-2 coefficients of the spherical harmonics
  32385. */
  32386. l2_2: Vector3;
  32387. /**
  32388. * The l2,-1 coefficients of the spherical harmonics
  32389. */
  32390. l2_1: Vector3;
  32391. /**
  32392. * The l2,0 coefficients of the spherical harmonics
  32393. */
  32394. l20: Vector3;
  32395. /**
  32396. * The l2,1 coefficients of the spherical harmonics
  32397. */
  32398. l21: Vector3;
  32399. /**
  32400. * The l2,2 coefficients of the spherical harmonics
  32401. */
  32402. l22: Vector3;
  32403. /**
  32404. * Adds a light to the spherical harmonics
  32405. * @param direction the direction of the light
  32406. * @param color the color of the light
  32407. * @param deltaSolidAngle the delta solid angle of the light
  32408. */
  32409. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32410. /**
  32411. * Scales the spherical harmonics by the given amount
  32412. * @param scale the amount to scale
  32413. */
  32414. scaleInPlace(scale: number): void;
  32415. /**
  32416. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32417. *
  32418. * ```
  32419. * E_lm = A_l * L_lm
  32420. * ```
  32421. *
  32422. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32423. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32424. * the scaling factors are given in equation 9.
  32425. */
  32426. convertIncidentRadianceToIrradiance(): void;
  32427. /**
  32428. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32429. *
  32430. * ```
  32431. * L = (1/pi) * E * rho
  32432. * ```
  32433. *
  32434. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32435. */
  32436. convertIrradianceToLambertianRadiance(): void;
  32437. /**
  32438. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32439. * required operations at run time.
  32440. *
  32441. * This is simply done by scaling back the SH with Ylm constants parameter.
  32442. * The trigonometric part being applied by the shader at run time.
  32443. */
  32444. preScaleForRendering(): void;
  32445. /**
  32446. * Constructs a spherical harmonics from an array.
  32447. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32448. * @returns the spherical harmonics
  32449. */
  32450. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32451. /**
  32452. * Gets the spherical harmonics from polynomial
  32453. * @param polynomial the spherical polynomial
  32454. * @returns the spherical harmonics
  32455. */
  32456. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32457. }
  32458. /**
  32459. * Class representing spherical polynomial coefficients to the 3rd degree
  32460. */
  32461. export class SphericalPolynomial {
  32462. private _harmonics;
  32463. /**
  32464. * The spherical harmonics used to create the polynomials.
  32465. */
  32466. readonly preScaledHarmonics: SphericalHarmonics;
  32467. /**
  32468. * The x coefficients of the spherical polynomial
  32469. */
  32470. x: Vector3;
  32471. /**
  32472. * The y coefficients of the spherical polynomial
  32473. */
  32474. y: Vector3;
  32475. /**
  32476. * The z coefficients of the spherical polynomial
  32477. */
  32478. z: Vector3;
  32479. /**
  32480. * The xx coefficients of the spherical polynomial
  32481. */
  32482. xx: Vector3;
  32483. /**
  32484. * The yy coefficients of the spherical polynomial
  32485. */
  32486. yy: Vector3;
  32487. /**
  32488. * The zz coefficients of the spherical polynomial
  32489. */
  32490. zz: Vector3;
  32491. /**
  32492. * The xy coefficients of the spherical polynomial
  32493. */
  32494. xy: Vector3;
  32495. /**
  32496. * The yz coefficients of the spherical polynomial
  32497. */
  32498. yz: Vector3;
  32499. /**
  32500. * The zx coefficients of the spherical polynomial
  32501. */
  32502. zx: Vector3;
  32503. /**
  32504. * Adds an ambient color to the spherical polynomial
  32505. * @param color the color to add
  32506. */
  32507. addAmbient(color: Color3): void;
  32508. /**
  32509. * Scales the spherical polynomial by the given amount
  32510. * @param scale the amount to scale
  32511. */
  32512. scaleInPlace(scale: number): void;
  32513. /**
  32514. * Gets the spherical polynomial from harmonics
  32515. * @param harmonics the spherical harmonics
  32516. * @returns the spherical polynomial
  32517. */
  32518. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32519. /**
  32520. * Constructs a spherical polynomial from an array.
  32521. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32522. * @returns the spherical polynomial
  32523. */
  32524. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32525. }
  32526. }
  32527. declare module "babylonjs/Materials/Textures/internalTexture" {
  32528. import { Observable } from "babylonjs/Misc/observable";
  32529. import { Nullable, int } from "babylonjs/types";
  32530. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32532. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32533. /**
  32534. * Defines the source of the internal texture
  32535. */
  32536. export enum InternalTextureSource {
  32537. /**
  32538. * The source of the texture data is unknown
  32539. */
  32540. Unknown = 0,
  32541. /**
  32542. * Texture data comes from an URL
  32543. */
  32544. Url = 1,
  32545. /**
  32546. * Texture data is only used for temporary storage
  32547. */
  32548. Temp = 2,
  32549. /**
  32550. * Texture data comes from raw data (ArrayBuffer)
  32551. */
  32552. Raw = 3,
  32553. /**
  32554. * Texture content is dynamic (video or dynamic texture)
  32555. */
  32556. Dynamic = 4,
  32557. /**
  32558. * Texture content is generated by rendering to it
  32559. */
  32560. RenderTarget = 5,
  32561. /**
  32562. * Texture content is part of a multi render target process
  32563. */
  32564. MultiRenderTarget = 6,
  32565. /**
  32566. * Texture data comes from a cube data file
  32567. */
  32568. Cube = 7,
  32569. /**
  32570. * Texture data comes from a raw cube data
  32571. */
  32572. CubeRaw = 8,
  32573. /**
  32574. * Texture data come from a prefiltered cube data file
  32575. */
  32576. CubePrefiltered = 9,
  32577. /**
  32578. * Texture content is raw 3D data
  32579. */
  32580. Raw3D = 10,
  32581. /**
  32582. * Texture content is raw 2D array data
  32583. */
  32584. Raw2DArray = 11,
  32585. /**
  32586. * Texture content is a depth texture
  32587. */
  32588. Depth = 12,
  32589. /**
  32590. * Texture data comes from a raw cube data encoded with RGBD
  32591. */
  32592. CubeRawRGBD = 13
  32593. }
  32594. /**
  32595. * Class used to store data associated with WebGL texture data for the engine
  32596. * This class should not be used directly
  32597. */
  32598. export class InternalTexture {
  32599. /** @hidden */
  32600. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32601. /**
  32602. * Defines if the texture is ready
  32603. */
  32604. isReady: boolean;
  32605. /**
  32606. * Defines if the texture is a cube texture
  32607. */
  32608. isCube: boolean;
  32609. /**
  32610. * Defines if the texture contains 3D data
  32611. */
  32612. is3D: boolean;
  32613. /**
  32614. * Defines if the texture contains 2D array data
  32615. */
  32616. is2DArray: boolean;
  32617. /**
  32618. * Defines if the texture contains multiview data
  32619. */
  32620. isMultiview: boolean;
  32621. /**
  32622. * Gets the URL used to load this texture
  32623. */
  32624. url: string;
  32625. /**
  32626. * Gets the sampling mode of the texture
  32627. */
  32628. samplingMode: number;
  32629. /**
  32630. * Gets a boolean indicating if the texture needs mipmaps generation
  32631. */
  32632. generateMipMaps: boolean;
  32633. /**
  32634. * Gets the number of samples used by the texture (WebGL2+ only)
  32635. */
  32636. samples: number;
  32637. /**
  32638. * Gets the type of the texture (int, float...)
  32639. */
  32640. type: number;
  32641. /**
  32642. * Gets the format of the texture (RGB, RGBA...)
  32643. */
  32644. format: number;
  32645. /**
  32646. * Observable called when the texture is loaded
  32647. */
  32648. onLoadedObservable: Observable<InternalTexture>;
  32649. /**
  32650. * Gets the width of the texture
  32651. */
  32652. width: number;
  32653. /**
  32654. * Gets the height of the texture
  32655. */
  32656. height: number;
  32657. /**
  32658. * Gets the depth of the texture
  32659. */
  32660. depth: number;
  32661. /**
  32662. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32663. */
  32664. baseWidth: number;
  32665. /**
  32666. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32667. */
  32668. baseHeight: number;
  32669. /**
  32670. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32671. */
  32672. baseDepth: number;
  32673. /**
  32674. * Gets a boolean indicating if the texture is inverted on Y axis
  32675. */
  32676. invertY: boolean;
  32677. /** @hidden */
  32678. _invertVScale: boolean;
  32679. /** @hidden */
  32680. _associatedChannel: number;
  32681. /** @hidden */
  32682. _source: InternalTextureSource;
  32683. /** @hidden */
  32684. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32685. /** @hidden */
  32686. _bufferView: Nullable<ArrayBufferView>;
  32687. /** @hidden */
  32688. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32689. /** @hidden */
  32690. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32691. /** @hidden */
  32692. _size: number;
  32693. /** @hidden */
  32694. _extension: string;
  32695. /** @hidden */
  32696. _files: Nullable<string[]>;
  32697. /** @hidden */
  32698. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32699. /** @hidden */
  32700. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32701. /** @hidden */
  32702. _framebuffer: Nullable<WebGLFramebuffer>;
  32703. /** @hidden */
  32704. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32705. /** @hidden */
  32706. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32707. /** @hidden */
  32708. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32709. /** @hidden */
  32710. _attachments: Nullable<number[]>;
  32711. /** @hidden */
  32712. _cachedCoordinatesMode: Nullable<number>;
  32713. /** @hidden */
  32714. _cachedWrapU: Nullable<number>;
  32715. /** @hidden */
  32716. _cachedWrapV: Nullable<number>;
  32717. /** @hidden */
  32718. _cachedWrapR: Nullable<number>;
  32719. /** @hidden */
  32720. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32721. /** @hidden */
  32722. _isDisabled: boolean;
  32723. /** @hidden */
  32724. _compression: Nullable<string>;
  32725. /** @hidden */
  32726. _generateStencilBuffer: boolean;
  32727. /** @hidden */
  32728. _generateDepthBuffer: boolean;
  32729. /** @hidden */
  32730. _comparisonFunction: number;
  32731. /** @hidden */
  32732. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32733. /** @hidden */
  32734. _lodGenerationScale: number;
  32735. /** @hidden */
  32736. _lodGenerationOffset: number;
  32737. /** @hidden */
  32738. _colorTextureArray: Nullable<WebGLTexture>;
  32739. /** @hidden */
  32740. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32741. /** @hidden */
  32742. _lodTextureHigh: Nullable<BaseTexture>;
  32743. /** @hidden */
  32744. _lodTextureMid: Nullable<BaseTexture>;
  32745. /** @hidden */
  32746. _lodTextureLow: Nullable<BaseTexture>;
  32747. /** @hidden */
  32748. _isRGBD: boolean;
  32749. /** @hidden */
  32750. _linearSpecularLOD: boolean;
  32751. /** @hidden */
  32752. _irradianceTexture: Nullable<BaseTexture>;
  32753. /** @hidden */
  32754. _webGLTexture: Nullable<WebGLTexture>;
  32755. /** @hidden */
  32756. _references: number;
  32757. private _engine;
  32758. /**
  32759. * Gets the Engine the texture belongs to.
  32760. * @returns The babylon engine
  32761. */
  32762. getEngine(): ThinEngine;
  32763. /**
  32764. * Gets the data source type of the texture
  32765. */
  32766. readonly source: InternalTextureSource;
  32767. /**
  32768. * Creates a new InternalTexture
  32769. * @param engine defines the engine to use
  32770. * @param source defines the type of data that will be used
  32771. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32772. */
  32773. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32774. /**
  32775. * Increments the number of references (ie. the number of Texture that point to it)
  32776. */
  32777. incrementReferences(): void;
  32778. /**
  32779. * Change the size of the texture (not the size of the content)
  32780. * @param width defines the new width
  32781. * @param height defines the new height
  32782. * @param depth defines the new depth (1 by default)
  32783. */
  32784. updateSize(width: int, height: int, depth?: int): void;
  32785. /** @hidden */
  32786. _rebuild(): void;
  32787. /** @hidden */
  32788. _swapAndDie(target: InternalTexture): void;
  32789. /**
  32790. * Dispose the current allocated resources
  32791. */
  32792. dispose(): void;
  32793. }
  32794. }
  32795. declare module "babylonjs/Audio/analyser" {
  32796. import { Scene } from "babylonjs/scene";
  32797. /**
  32798. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32800. */
  32801. export class Analyser {
  32802. /**
  32803. * Gets or sets the smoothing
  32804. * @ignorenaming
  32805. */
  32806. SMOOTHING: number;
  32807. /**
  32808. * Gets or sets the FFT table size
  32809. * @ignorenaming
  32810. */
  32811. FFT_SIZE: number;
  32812. /**
  32813. * Gets or sets the bar graph amplitude
  32814. * @ignorenaming
  32815. */
  32816. BARGRAPHAMPLITUDE: number;
  32817. /**
  32818. * Gets or sets the position of the debug canvas
  32819. * @ignorenaming
  32820. */
  32821. DEBUGCANVASPOS: {
  32822. x: number;
  32823. y: number;
  32824. };
  32825. /**
  32826. * Gets or sets the debug canvas size
  32827. * @ignorenaming
  32828. */
  32829. DEBUGCANVASSIZE: {
  32830. width: number;
  32831. height: number;
  32832. };
  32833. private _byteFreqs;
  32834. private _byteTime;
  32835. private _floatFreqs;
  32836. private _webAudioAnalyser;
  32837. private _debugCanvas;
  32838. private _debugCanvasContext;
  32839. private _scene;
  32840. private _registerFunc;
  32841. private _audioEngine;
  32842. /**
  32843. * Creates a new analyser
  32844. * @param scene defines hosting scene
  32845. */
  32846. constructor(scene: Scene);
  32847. /**
  32848. * Get the number of data values you will have to play with for the visualization
  32849. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32850. * @returns a number
  32851. */
  32852. getFrequencyBinCount(): number;
  32853. /**
  32854. * Gets the current frequency data as a byte array
  32855. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32856. * @returns a Uint8Array
  32857. */
  32858. getByteFrequencyData(): Uint8Array;
  32859. /**
  32860. * Gets the current waveform as a byte array
  32861. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32862. * @returns a Uint8Array
  32863. */
  32864. getByteTimeDomainData(): Uint8Array;
  32865. /**
  32866. * Gets the current frequency data as a float array
  32867. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32868. * @returns a Float32Array
  32869. */
  32870. getFloatFrequencyData(): Float32Array;
  32871. /**
  32872. * Renders the debug canvas
  32873. */
  32874. drawDebugCanvas(): void;
  32875. /**
  32876. * Stops rendering the debug canvas and removes it
  32877. */
  32878. stopDebugCanvas(): void;
  32879. /**
  32880. * Connects two audio nodes
  32881. * @param inputAudioNode defines first node to connect
  32882. * @param outputAudioNode defines second node to connect
  32883. */
  32884. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32885. /**
  32886. * Releases all associated resources
  32887. */
  32888. dispose(): void;
  32889. }
  32890. }
  32891. declare module "babylonjs/Audio/audioEngine" {
  32892. import { IDisposable } from "babylonjs/scene";
  32893. import { Analyser } from "babylonjs/Audio/analyser";
  32894. import { Nullable } from "babylonjs/types";
  32895. import { Observable } from "babylonjs/Misc/observable";
  32896. /**
  32897. * This represents an audio engine and it is responsible
  32898. * to play, synchronize and analyse sounds throughout the application.
  32899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32900. */
  32901. export interface IAudioEngine extends IDisposable {
  32902. /**
  32903. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32904. */
  32905. readonly canUseWebAudio: boolean;
  32906. /**
  32907. * Gets the current AudioContext if available.
  32908. */
  32909. readonly audioContext: Nullable<AudioContext>;
  32910. /**
  32911. * The master gain node defines the global audio volume of your audio engine.
  32912. */
  32913. readonly masterGain: GainNode;
  32914. /**
  32915. * Gets whether or not mp3 are supported by your browser.
  32916. */
  32917. readonly isMP3supported: boolean;
  32918. /**
  32919. * Gets whether or not ogg are supported by your browser.
  32920. */
  32921. readonly isOGGsupported: boolean;
  32922. /**
  32923. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32924. * @ignoreNaming
  32925. */
  32926. WarnedWebAudioUnsupported: boolean;
  32927. /**
  32928. * Defines if the audio engine relies on a custom unlocked button.
  32929. * In this case, the embedded button will not be displayed.
  32930. */
  32931. useCustomUnlockedButton: boolean;
  32932. /**
  32933. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32934. */
  32935. readonly unlocked: boolean;
  32936. /**
  32937. * Event raised when audio has been unlocked on the browser.
  32938. */
  32939. onAudioUnlockedObservable: Observable<AudioEngine>;
  32940. /**
  32941. * Event raised when audio has been locked on the browser.
  32942. */
  32943. onAudioLockedObservable: Observable<AudioEngine>;
  32944. /**
  32945. * Flags the audio engine in Locked state.
  32946. * This happens due to new browser policies preventing audio to autoplay.
  32947. */
  32948. lock(): void;
  32949. /**
  32950. * Unlocks the audio engine once a user action has been done on the dom.
  32951. * This is helpful to resume play once browser policies have been satisfied.
  32952. */
  32953. unlock(): void;
  32954. }
  32955. /**
  32956. * This represents the default audio engine used in babylon.
  32957. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32959. */
  32960. export class AudioEngine implements IAudioEngine {
  32961. private _audioContext;
  32962. private _audioContextInitialized;
  32963. private _muteButton;
  32964. private _hostElement;
  32965. /**
  32966. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32967. */
  32968. canUseWebAudio: boolean;
  32969. /**
  32970. * The master gain node defines the global audio volume of your audio engine.
  32971. */
  32972. masterGain: GainNode;
  32973. /**
  32974. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32975. * @ignoreNaming
  32976. */
  32977. WarnedWebAudioUnsupported: boolean;
  32978. /**
  32979. * Gets whether or not mp3 are supported by your browser.
  32980. */
  32981. isMP3supported: boolean;
  32982. /**
  32983. * Gets whether or not ogg are supported by your browser.
  32984. */
  32985. isOGGsupported: boolean;
  32986. /**
  32987. * Gets whether audio has been unlocked on the device.
  32988. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32989. * a user interaction has happened.
  32990. */
  32991. unlocked: boolean;
  32992. /**
  32993. * Defines if the audio engine relies on a custom unlocked button.
  32994. * In this case, the embedded button will not be displayed.
  32995. */
  32996. useCustomUnlockedButton: boolean;
  32997. /**
  32998. * Event raised when audio has been unlocked on the browser.
  32999. */
  33000. onAudioUnlockedObservable: Observable<AudioEngine>;
  33001. /**
  33002. * Event raised when audio has been locked on the browser.
  33003. */
  33004. onAudioLockedObservable: Observable<AudioEngine>;
  33005. /**
  33006. * Gets the current AudioContext if available.
  33007. */
  33008. readonly audioContext: Nullable<AudioContext>;
  33009. private _connectedAnalyser;
  33010. /**
  33011. * Instantiates a new audio engine.
  33012. *
  33013. * There should be only one per page as some browsers restrict the number
  33014. * of audio contexts you can create.
  33015. * @param hostElement defines the host element where to display the mute icon if necessary
  33016. */
  33017. constructor(hostElement?: Nullable<HTMLElement>);
  33018. /**
  33019. * Flags the audio engine in Locked state.
  33020. * This happens due to new browser policies preventing audio to autoplay.
  33021. */
  33022. lock(): void;
  33023. /**
  33024. * Unlocks the audio engine once a user action has been done on the dom.
  33025. * This is helpful to resume play once browser policies have been satisfied.
  33026. */
  33027. unlock(): void;
  33028. private _resumeAudioContext;
  33029. private _initializeAudioContext;
  33030. private _tryToRun;
  33031. private _triggerRunningState;
  33032. private _triggerSuspendedState;
  33033. private _displayMuteButton;
  33034. private _moveButtonToTopLeft;
  33035. private _onResize;
  33036. private _hideMuteButton;
  33037. /**
  33038. * Destroy and release the resources associated with the audio ccontext.
  33039. */
  33040. dispose(): void;
  33041. /**
  33042. * Gets the global volume sets on the master gain.
  33043. * @returns the global volume if set or -1 otherwise
  33044. */
  33045. getGlobalVolume(): number;
  33046. /**
  33047. * Sets the global volume of your experience (sets on the master gain).
  33048. * @param newVolume Defines the new global volume of the application
  33049. */
  33050. setGlobalVolume(newVolume: number): void;
  33051. /**
  33052. * Connect the audio engine to an audio analyser allowing some amazing
  33053. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33055. * @param analyser The analyser to connect to the engine
  33056. */
  33057. connectToAnalyser(analyser: Analyser): void;
  33058. }
  33059. }
  33060. declare module "babylonjs/Loading/loadingScreen" {
  33061. /**
  33062. * Interface used to present a loading screen while loading a scene
  33063. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33064. */
  33065. export interface ILoadingScreen {
  33066. /**
  33067. * Function called to display the loading screen
  33068. */
  33069. displayLoadingUI: () => void;
  33070. /**
  33071. * Function called to hide the loading screen
  33072. */
  33073. hideLoadingUI: () => void;
  33074. /**
  33075. * Gets or sets the color to use for the background
  33076. */
  33077. loadingUIBackgroundColor: string;
  33078. /**
  33079. * Gets or sets the text to display while loading
  33080. */
  33081. loadingUIText: string;
  33082. }
  33083. /**
  33084. * Class used for the default loading screen
  33085. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33086. */
  33087. export class DefaultLoadingScreen implements ILoadingScreen {
  33088. private _renderingCanvas;
  33089. private _loadingText;
  33090. private _loadingDivBackgroundColor;
  33091. private _loadingDiv;
  33092. private _loadingTextDiv;
  33093. /** Gets or sets the logo url to use for the default loading screen */
  33094. static DefaultLogoUrl: string;
  33095. /** Gets or sets the spinner url to use for the default loading screen */
  33096. static DefaultSpinnerUrl: string;
  33097. /**
  33098. * Creates a new default loading screen
  33099. * @param _renderingCanvas defines the canvas used to render the scene
  33100. * @param _loadingText defines the default text to display
  33101. * @param _loadingDivBackgroundColor defines the default background color
  33102. */
  33103. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33104. /**
  33105. * Function called to display the loading screen
  33106. */
  33107. displayLoadingUI(): void;
  33108. /**
  33109. * Function called to hide the loading screen
  33110. */
  33111. hideLoadingUI(): void;
  33112. /**
  33113. * Gets or sets the text to display while loading
  33114. */
  33115. loadingUIText: string;
  33116. /**
  33117. * Gets or sets the color to use for the background
  33118. */
  33119. loadingUIBackgroundColor: string;
  33120. private _resizeLoadingUI;
  33121. }
  33122. }
  33123. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33124. /**
  33125. * Interface for any object that can request an animation frame
  33126. */
  33127. export interface ICustomAnimationFrameRequester {
  33128. /**
  33129. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33130. */
  33131. renderFunction?: Function;
  33132. /**
  33133. * Called to request the next frame to render to
  33134. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33135. */
  33136. requestAnimationFrame: Function;
  33137. /**
  33138. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33139. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33140. */
  33141. requestID?: number;
  33142. }
  33143. }
  33144. declare module "babylonjs/Misc/performanceMonitor" {
  33145. /**
  33146. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33147. */
  33148. export class PerformanceMonitor {
  33149. private _enabled;
  33150. private _rollingFrameTime;
  33151. private _lastFrameTimeMs;
  33152. /**
  33153. * constructor
  33154. * @param frameSampleSize The number of samples required to saturate the sliding window
  33155. */
  33156. constructor(frameSampleSize?: number);
  33157. /**
  33158. * Samples current frame
  33159. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33160. */
  33161. sampleFrame(timeMs?: number): void;
  33162. /**
  33163. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33164. */
  33165. readonly averageFrameTime: number;
  33166. /**
  33167. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33168. */
  33169. readonly averageFrameTimeVariance: number;
  33170. /**
  33171. * Returns the frame time of the most recent frame
  33172. */
  33173. readonly instantaneousFrameTime: number;
  33174. /**
  33175. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33176. */
  33177. readonly averageFPS: number;
  33178. /**
  33179. * Returns the average framerate in frames per second using the most recent frame time
  33180. */
  33181. readonly instantaneousFPS: number;
  33182. /**
  33183. * Returns true if enough samples have been taken to completely fill the sliding window
  33184. */
  33185. readonly isSaturated: boolean;
  33186. /**
  33187. * Enables contributions to the sliding window sample set
  33188. */
  33189. enable(): void;
  33190. /**
  33191. * Disables contributions to the sliding window sample set
  33192. * Samples will not be interpolated over the disabled period
  33193. */
  33194. disable(): void;
  33195. /**
  33196. * Returns true if sampling is enabled
  33197. */
  33198. readonly isEnabled: boolean;
  33199. /**
  33200. * Resets performance monitor
  33201. */
  33202. reset(): void;
  33203. }
  33204. /**
  33205. * RollingAverage
  33206. *
  33207. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33208. */
  33209. export class RollingAverage {
  33210. /**
  33211. * Current average
  33212. */
  33213. average: number;
  33214. /**
  33215. * Current variance
  33216. */
  33217. variance: number;
  33218. protected _samples: Array<number>;
  33219. protected _sampleCount: number;
  33220. protected _pos: number;
  33221. protected _m2: number;
  33222. /**
  33223. * constructor
  33224. * @param length The number of samples required to saturate the sliding window
  33225. */
  33226. constructor(length: number);
  33227. /**
  33228. * Adds a sample to the sample set
  33229. * @param v The sample value
  33230. */
  33231. add(v: number): void;
  33232. /**
  33233. * Returns previously added values or null if outside of history or outside the sliding window domain
  33234. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33235. * @return Value previously recorded with add() or null if outside of range
  33236. */
  33237. history(i: number): number;
  33238. /**
  33239. * Returns true if enough samples have been taken to completely fill the sliding window
  33240. * @return true if sample-set saturated
  33241. */
  33242. isSaturated(): boolean;
  33243. /**
  33244. * Resets the rolling average (equivalent to 0 samples taken so far)
  33245. */
  33246. reset(): void;
  33247. /**
  33248. * Wraps a value around the sample range boundaries
  33249. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33250. * @return Wrapped position in sample range
  33251. */
  33252. protected _wrapPosition(i: number): number;
  33253. }
  33254. }
  33255. declare module "babylonjs/Misc/perfCounter" {
  33256. /**
  33257. * This class is used to track a performance counter which is number based.
  33258. * The user has access to many properties which give statistics of different nature.
  33259. *
  33260. * The implementer can track two kinds of Performance Counter: time and count.
  33261. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  33262. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  33263. */
  33264. export class PerfCounter {
  33265. /**
  33266. * Gets or sets a global boolean to turn on and off all the counters
  33267. */
  33268. static Enabled: boolean;
  33269. /**
  33270. * Returns the smallest value ever
  33271. */
  33272. readonly min: number;
  33273. /**
  33274. * Returns the biggest value ever
  33275. */
  33276. readonly max: number;
  33277. /**
  33278. * Returns the average value since the performance counter is running
  33279. */
  33280. readonly average: number;
  33281. /**
  33282. * Returns the average value of the last second the counter was monitored
  33283. */
  33284. readonly lastSecAverage: number;
  33285. /**
  33286. * Returns the current value
  33287. */
  33288. readonly current: number;
  33289. /**
  33290. * Gets the accumulated total
  33291. */
  33292. readonly total: number;
  33293. /**
  33294. * Gets the total value count
  33295. */
  33296. readonly count: number;
  33297. /**
  33298. * Creates a new counter
  33299. */
  33300. constructor();
  33301. /**
  33302. * Call this method to start monitoring a new frame.
  33303. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  33304. */
  33305. fetchNewFrame(): void;
  33306. /**
  33307. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33308. * @param newCount the count value to add to the monitored count
  33309. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  33310. */
  33311. addCount(newCount: number, fetchResult: boolean): void;
  33312. /**
  33313. * Start monitoring this performance counter
  33314. */
  33315. beginMonitoring(): void;
  33316. /**
  33317. * Compute the time lapsed since the previous beginMonitoring() call.
  33318. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  33319. */
  33320. endMonitoring(newFrame?: boolean): void;
  33321. private _fetchResult;
  33322. private _startMonitoringTime;
  33323. private _min;
  33324. private _max;
  33325. private _average;
  33326. private _current;
  33327. private _totalValueCount;
  33328. private _totalAccumulated;
  33329. private _lastSecAverage;
  33330. private _lastSecAccumulated;
  33331. private _lastSecTime;
  33332. private _lastSecValueCount;
  33333. }
  33334. }
  33335. declare module "babylonjs/Engines/engine" {
  33336. import { Observable } from "babylonjs/Misc/observable";
  33337. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33338. import { Scene } from "babylonjs/scene";
  33339. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33340. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33341. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33342. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33343. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33344. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33345. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33346. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33347. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33349. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33350. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33351. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33352. import { Material } from "babylonjs/Materials/material";
  33353. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33354. /**
  33355. * Defines the interface used by display changed events
  33356. */
  33357. export interface IDisplayChangedEventArgs {
  33358. /** Gets the vrDisplay object (if any) */
  33359. vrDisplay: Nullable<any>;
  33360. /** Gets a boolean indicating if webVR is supported */
  33361. vrSupported: boolean;
  33362. }
  33363. /**
  33364. * Defines the interface used by objects containing a viewport (like a camera)
  33365. */
  33366. interface IViewportOwnerLike {
  33367. /**
  33368. * Gets or sets the viewport
  33369. */
  33370. viewport: IViewportLike;
  33371. }
  33372. /**
  33373. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33374. */
  33375. export class Engine extends ThinEngine {
  33376. /** Defines that alpha blending is disabled */
  33377. static readonly ALPHA_DISABLE: number;
  33378. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33379. static readonly ALPHA_ADD: number;
  33380. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33381. static readonly ALPHA_COMBINE: number;
  33382. /** Defines that alpha blending to DEST - SRC * DEST */
  33383. static readonly ALPHA_SUBTRACT: number;
  33384. /** Defines that alpha blending to SRC * DEST */
  33385. static readonly ALPHA_MULTIPLY: number;
  33386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33387. static readonly ALPHA_MAXIMIZED: number;
  33388. /** Defines that alpha blending to SRC + DEST */
  33389. static readonly ALPHA_ONEONE: number;
  33390. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33391. static readonly ALPHA_PREMULTIPLIED: number;
  33392. /**
  33393. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33394. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33395. */
  33396. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33397. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33398. static readonly ALPHA_INTERPOLATE: number;
  33399. /**
  33400. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33401. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33402. */
  33403. static readonly ALPHA_SCREENMODE: number;
  33404. /** Defines that the ressource is not delayed*/
  33405. static readonly DELAYLOADSTATE_NONE: number;
  33406. /** Defines that the ressource was successfully delay loaded */
  33407. static readonly DELAYLOADSTATE_LOADED: number;
  33408. /** Defines that the ressource is currently delay loading */
  33409. static readonly DELAYLOADSTATE_LOADING: number;
  33410. /** Defines that the ressource is delayed and has not started loading */
  33411. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33413. static readonly NEVER: number;
  33414. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  33415. static readonly ALWAYS: number;
  33416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33417. static readonly LESS: number;
  33418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33419. static readonly EQUAL: number;
  33420. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  33421. static readonly LEQUAL: number;
  33422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33423. static readonly GREATER: number;
  33424. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  33425. static readonly GEQUAL: number;
  33426. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  33427. static readonly NOTEQUAL: number;
  33428. /** Passed to stencilOperation to specify that stencil value must be kept */
  33429. static readonly KEEP: number;
  33430. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33431. static readonly REPLACE: number;
  33432. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33433. static readonly INCR: number;
  33434. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33435. static readonly DECR: number;
  33436. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33437. static readonly INVERT: number;
  33438. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33439. static readonly INCR_WRAP: number;
  33440. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33441. static readonly DECR_WRAP: number;
  33442. /** Texture is not repeating outside of 0..1 UVs */
  33443. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33444. /** Texture is repeating outside of 0..1 UVs */
  33445. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33446. /** Texture is repeating and mirrored */
  33447. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33448. /** ALPHA */
  33449. static readonly TEXTUREFORMAT_ALPHA: number;
  33450. /** LUMINANCE */
  33451. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33452. /** LUMINANCE_ALPHA */
  33453. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33454. /** RGB */
  33455. static readonly TEXTUREFORMAT_RGB: number;
  33456. /** RGBA */
  33457. static readonly TEXTUREFORMAT_RGBA: number;
  33458. /** RED */
  33459. static readonly TEXTUREFORMAT_RED: number;
  33460. /** RED (2nd reference) */
  33461. static readonly TEXTUREFORMAT_R: number;
  33462. /** RG */
  33463. static readonly TEXTUREFORMAT_RG: number;
  33464. /** RED_INTEGER */
  33465. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33466. /** RED_INTEGER (2nd reference) */
  33467. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33468. /** RG_INTEGER */
  33469. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33470. /** RGB_INTEGER */
  33471. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33472. /** RGBA_INTEGER */
  33473. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33474. /** UNSIGNED_BYTE */
  33475. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33476. /** UNSIGNED_BYTE (2nd reference) */
  33477. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33478. /** FLOAT */
  33479. static readonly TEXTURETYPE_FLOAT: number;
  33480. /** HALF_FLOAT */
  33481. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33482. /** BYTE */
  33483. static readonly TEXTURETYPE_BYTE: number;
  33484. /** SHORT */
  33485. static readonly TEXTURETYPE_SHORT: number;
  33486. /** UNSIGNED_SHORT */
  33487. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33488. /** INT */
  33489. static readonly TEXTURETYPE_INT: number;
  33490. /** UNSIGNED_INT */
  33491. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33492. /** UNSIGNED_SHORT_4_4_4_4 */
  33493. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33494. /** UNSIGNED_SHORT_5_5_5_1 */
  33495. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33496. /** UNSIGNED_SHORT_5_6_5 */
  33497. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33498. /** UNSIGNED_INT_2_10_10_10_REV */
  33499. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33500. /** UNSIGNED_INT_24_8 */
  33501. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33502. /** UNSIGNED_INT_10F_11F_11F_REV */
  33503. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33504. /** UNSIGNED_INT_5_9_9_9_REV */
  33505. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33506. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33507. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33508. /** nearest is mag = nearest and min = nearest and mip = linear */
  33509. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33511. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33512. /** Trilinear is mag = linear and min = linear and mip = linear */
  33513. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33514. /** nearest is mag = nearest and min = nearest and mip = linear */
  33515. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33517. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33518. /** Trilinear is mag = linear and min = linear and mip = linear */
  33519. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33520. /** mag = nearest and min = nearest and mip = nearest */
  33521. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33522. /** mag = nearest and min = linear and mip = nearest */
  33523. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33524. /** mag = nearest and min = linear and mip = linear */
  33525. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33526. /** mag = nearest and min = linear and mip = none */
  33527. static readonly TEXTURE_NEAREST_LINEAR: number;
  33528. /** mag = nearest and min = nearest and mip = none */
  33529. static readonly TEXTURE_NEAREST_NEAREST: number;
  33530. /** mag = linear and min = nearest and mip = nearest */
  33531. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33532. /** mag = linear and min = nearest and mip = linear */
  33533. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33534. /** mag = linear and min = linear and mip = none */
  33535. static readonly TEXTURE_LINEAR_LINEAR: number;
  33536. /** mag = linear and min = nearest and mip = none */
  33537. static readonly TEXTURE_LINEAR_NEAREST: number;
  33538. /** Explicit coordinates mode */
  33539. static readonly TEXTURE_EXPLICIT_MODE: number;
  33540. /** Spherical coordinates mode */
  33541. static readonly TEXTURE_SPHERICAL_MODE: number;
  33542. /** Planar coordinates mode */
  33543. static readonly TEXTURE_PLANAR_MODE: number;
  33544. /** Cubic coordinates mode */
  33545. static readonly TEXTURE_CUBIC_MODE: number;
  33546. /** Projection coordinates mode */
  33547. static readonly TEXTURE_PROJECTION_MODE: number;
  33548. /** Skybox coordinates mode */
  33549. static readonly TEXTURE_SKYBOX_MODE: number;
  33550. /** Inverse Cubic coordinates mode */
  33551. static readonly TEXTURE_INVCUBIC_MODE: number;
  33552. /** Equirectangular coordinates mode */
  33553. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33554. /** Equirectangular Fixed coordinates mode */
  33555. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33556. /** Equirectangular Fixed Mirrored coordinates mode */
  33557. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33558. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33559. static readonly SCALEMODE_FLOOR: number;
  33560. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33561. static readonly SCALEMODE_NEAREST: number;
  33562. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33563. static readonly SCALEMODE_CEILING: number;
  33564. /**
  33565. * Returns the current npm package of the sdk
  33566. */
  33567. static readonly NpmPackage: string;
  33568. /**
  33569. * Returns the current version of the framework
  33570. */
  33571. static readonly Version: string;
  33572. /** Gets the list of created engines */
  33573. static readonly Instances: Engine[];
  33574. /**
  33575. * Gets the latest created engine
  33576. */
  33577. static readonly LastCreatedEngine: Nullable<Engine>;
  33578. /**
  33579. * Gets the latest created scene
  33580. */
  33581. static readonly LastCreatedScene: Nullable<Scene>;
  33582. /**
  33583. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33584. * @param flag defines which part of the materials must be marked as dirty
  33585. * @param predicate defines a predicate used to filter which materials should be affected
  33586. */
  33587. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33588. /**
  33589. * Method called to create the default loading screen.
  33590. * This can be overriden in your own app.
  33591. * @param canvas The rendering canvas element
  33592. * @returns The loading screen
  33593. */
  33594. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33595. /**
  33596. * Method called to create the default rescale post process on each engine.
  33597. */
  33598. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33599. /**
  33600. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33601. **/
  33602. enableOfflineSupport: boolean;
  33603. /**
  33604. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  33605. **/
  33606. disableManifestCheck: boolean;
  33607. /**
  33608. * Gets the list of created scenes
  33609. */
  33610. scenes: Scene[];
  33611. /**
  33612. * Event raised when a new scene is created
  33613. */
  33614. onNewSceneAddedObservable: Observable<Scene>;
  33615. /**
  33616. * Gets the list of created postprocesses
  33617. */
  33618. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33619. /**
  33620. * Gets a boolean indicating if the pointer is currently locked
  33621. */
  33622. isPointerLock: boolean;
  33623. /**
  33624. * Observable event triggered each time the rendering canvas is resized
  33625. */
  33626. onResizeObservable: Observable<Engine>;
  33627. /**
  33628. * Observable event triggered each time the canvas loses focus
  33629. */
  33630. onCanvasBlurObservable: Observable<Engine>;
  33631. /**
  33632. * Observable event triggered each time the canvas gains focus
  33633. */
  33634. onCanvasFocusObservable: Observable<Engine>;
  33635. /**
  33636. * Observable event triggered each time the canvas receives pointerout event
  33637. */
  33638. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33639. /**
  33640. * Observable raised when the engine begins a new frame
  33641. */
  33642. onBeginFrameObservable: Observable<Engine>;
  33643. /**
  33644. * If set, will be used to request the next animation frame for the render loop
  33645. */
  33646. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33647. /**
  33648. * Observable raised when the engine ends the current frame
  33649. */
  33650. onEndFrameObservable: Observable<Engine>;
  33651. /**
  33652. * Observable raised when the engine is about to compile a shader
  33653. */
  33654. onBeforeShaderCompilationObservable: Observable<Engine>;
  33655. /**
  33656. * Observable raised when the engine has jsut compiled a shader
  33657. */
  33658. onAfterShaderCompilationObservable: Observable<Engine>;
  33659. /**
  33660. * Gets the audio engine
  33661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33662. * @ignorenaming
  33663. */
  33664. static audioEngine: IAudioEngine;
  33665. /**
  33666. * Default AudioEngine factory responsible of creating the Audio Engine.
  33667. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33668. */
  33669. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33670. /**
  33671. * Default offline support factory responsible of creating a tool used to store data locally.
  33672. * By default, this will create a Database object if the workload has been embedded.
  33673. */
  33674. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33675. private _loadingScreen;
  33676. private _pointerLockRequested;
  33677. private _dummyFramebuffer;
  33678. private _rescalePostProcess;
  33679. /** @hidden */
  33680. protected _alphaMode: number;
  33681. /** @hidden */
  33682. protected _alphaEquation: number;
  33683. private _deterministicLockstep;
  33684. private _lockstepMaxSteps;
  33685. private _timeStep;
  33686. protected readonly _supportsHardwareTextureRescaling: boolean;
  33687. private _fps;
  33688. private _deltaTime;
  33689. /** @hidden */
  33690. _drawCalls: PerfCounter;
  33691. /**
  33692. * Turn this value on if you want to pause FPS computation when in background
  33693. */
  33694. disablePerformanceMonitorInBackground: boolean;
  33695. private _performanceMonitor;
  33696. /**
  33697. * Gets the performance monitor attached to this engine
  33698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33699. */
  33700. readonly performanceMonitor: PerformanceMonitor;
  33701. private _onFocus;
  33702. private _onBlur;
  33703. private _onCanvasPointerOut;
  33704. private _onCanvasBlur;
  33705. private _onCanvasFocus;
  33706. private _onFullscreenChange;
  33707. private _onPointerLockChange;
  33708. /**
  33709. * Gets the HTML element used to attach event listeners
  33710. * @returns a HTML element
  33711. */
  33712. getInputElement(): Nullable<HTMLElement>;
  33713. /**
  33714. * Creates a new engine
  33715. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  33716. * @param antialias defines enable antialiasing (default: false)
  33717. * @param options defines further options to be sent to the getContext() function
  33718. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33719. */
  33720. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33721. /**
  33722. * Gets current aspect ratio
  33723. * @param viewportOwner defines the camera to use to get the aspect ratio
  33724. * @param useScreen defines if screen size must be used (or the current render target if any)
  33725. * @returns a number defining the aspect ratio
  33726. */
  33727. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33728. /**
  33729. * Gets current screen aspect ratio
  33730. * @returns a number defining the aspect ratio
  33731. */
  33732. getScreenAspectRatio(): number;
  33733. /**
  33734. * Gets the client rect of the HTML canvas attached with the current webGL context
  33735. * @returns a client rectanglee
  33736. */
  33737. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33738. /**
  33739. * Gets the client rect of the HTML element used for events
  33740. * @returns a client rectanglee
  33741. */
  33742. getInputElementClientRect(): Nullable<ClientRect>;
  33743. /**
  33744. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33746. * @returns true if engine is in deterministic lock step mode
  33747. */
  33748. isDeterministicLockStep(): boolean;
  33749. /**
  33750. * Gets the max steps when engine is running in deterministic lock step
  33751. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33752. * @returns the max steps
  33753. */
  33754. getLockstepMaxSteps(): number;
  33755. /**
  33756. * Returns the time in ms between steps when using deterministic lock step.
  33757. * @returns time step in (ms)
  33758. */
  33759. getTimeStep(): number;
  33760. /**
  33761. * Force the mipmap generation for the given render target texture
  33762. * @param texture defines the render target texture to use
  33763. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33764. */
  33765. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33766. /** States */
  33767. /**
  33768. * Set various states to the webGL context
  33769. * @param culling defines backface culling state
  33770. * @param zOffset defines the value to apply to zOffset (0 by default)
  33771. * @param force defines if states must be applied even if cache is up to date
  33772. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33773. */
  33774. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33775. /**
  33776. * Set the z offset to apply to current rendering
  33777. * @param value defines the offset to apply
  33778. */
  33779. setZOffset(value: number): void;
  33780. /**
  33781. * Gets the current value of the zOffset
  33782. * @returns the current zOffset state
  33783. */
  33784. getZOffset(): number;
  33785. /**
  33786. * Enable or disable depth buffering
  33787. * @param enable defines the state to set
  33788. */
  33789. setDepthBuffer(enable: boolean): void;
  33790. /**
  33791. * Gets a boolean indicating if depth writing is enabled
  33792. * @returns the current depth writing state
  33793. */
  33794. getDepthWrite(): boolean;
  33795. /**
  33796. * Enable or disable depth writing
  33797. * @param enable defines the state to set
  33798. */
  33799. setDepthWrite(enable: boolean): void;
  33800. /**
  33801. * Enable or disable color writing
  33802. * @param enable defines the state to set
  33803. */
  33804. setColorWrite(enable: boolean): void;
  33805. /**
  33806. * Gets a boolean indicating if color writing is enabled
  33807. * @returns the current color writing state
  33808. */
  33809. getColorWrite(): boolean;
  33810. /**
  33811. * Sets alpha constants used by some alpha blending modes
  33812. * @param r defines the red component
  33813. * @param g defines the green component
  33814. * @param b defines the blue component
  33815. * @param a defines the alpha component
  33816. */
  33817. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33818. /**
  33819. * Sets the current alpha mode
  33820. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33821. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33822. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33823. */
  33824. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33825. /**
  33826. * Gets the current alpha mode
  33827. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33828. * @returns the current alpha mode
  33829. */
  33830. getAlphaMode(): number;
  33831. /**
  33832. * Sets the current alpha equation
  33833. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33834. */
  33835. setAlphaEquation(equation: number): void;
  33836. /**
  33837. * Gets the current alpha equation.
  33838. * @returns the current alpha equation
  33839. */
  33840. getAlphaEquation(): number;
  33841. /**
  33842. * Gets a boolean indicating if stencil buffer is enabled
  33843. * @returns the current stencil buffer state
  33844. */
  33845. getStencilBuffer(): boolean;
  33846. /**
  33847. * Enable or disable the stencil buffer
  33848. * @param enable defines if the stencil buffer must be enabled or disabled
  33849. */
  33850. setStencilBuffer(enable: boolean): void;
  33851. /**
  33852. * Gets the current stencil mask
  33853. * @returns a number defining the new stencil mask to use
  33854. */
  33855. getStencilMask(): number;
  33856. /**
  33857. * Sets the current stencil mask
  33858. * @param mask defines the new stencil mask to use
  33859. */
  33860. setStencilMask(mask: number): void;
  33861. /**
  33862. * Gets the current stencil function
  33863. * @returns a number defining the stencil function to use
  33864. */
  33865. getStencilFunction(): number;
  33866. /**
  33867. * Gets the current stencil reference value
  33868. * @returns a number defining the stencil reference value to use
  33869. */
  33870. getStencilFunctionReference(): number;
  33871. /**
  33872. * Gets the current stencil mask
  33873. * @returns a number defining the stencil mask to use
  33874. */
  33875. getStencilFunctionMask(): number;
  33876. /**
  33877. * Sets the current stencil function
  33878. * @param stencilFunc defines the new stencil function to use
  33879. */
  33880. setStencilFunction(stencilFunc: number): void;
  33881. /**
  33882. * Sets the current stencil reference
  33883. * @param reference defines the new stencil reference to use
  33884. */
  33885. setStencilFunctionReference(reference: number): void;
  33886. /**
  33887. * Sets the current stencil mask
  33888. * @param mask defines the new stencil mask to use
  33889. */
  33890. setStencilFunctionMask(mask: number): void;
  33891. /**
  33892. * Gets the current stencil operation when stencil fails
  33893. * @returns a number defining stencil operation to use when stencil fails
  33894. */
  33895. getStencilOperationFail(): number;
  33896. /**
  33897. * Gets the current stencil operation when depth fails
  33898. * @returns a number defining stencil operation to use when depth fails
  33899. */
  33900. getStencilOperationDepthFail(): number;
  33901. /**
  33902. * Gets the current stencil operation when stencil passes
  33903. * @returns a number defining stencil operation to use when stencil passes
  33904. */
  33905. getStencilOperationPass(): number;
  33906. /**
  33907. * Sets the stencil operation to use when stencil fails
  33908. * @param operation defines the stencil operation to use when stencil fails
  33909. */
  33910. setStencilOperationFail(operation: number): void;
  33911. /**
  33912. * Sets the stencil operation to use when depth fails
  33913. * @param operation defines the stencil operation to use when depth fails
  33914. */
  33915. setStencilOperationDepthFail(operation: number): void;
  33916. /**
  33917. * Sets the stencil operation to use when stencil passes
  33918. * @param operation defines the stencil operation to use when stencil passes
  33919. */
  33920. setStencilOperationPass(operation: number): void;
  33921. /**
  33922. * Sets a boolean indicating if the dithering state is enabled or disabled
  33923. * @param value defines the dithering state
  33924. */
  33925. setDitheringState(value: boolean): void;
  33926. /**
  33927. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33928. * @param value defines the rasterizer state
  33929. */
  33930. setRasterizerState(value: boolean): void;
  33931. /**
  33932. * Gets the current depth function
  33933. * @returns a number defining the depth function
  33934. */
  33935. getDepthFunction(): Nullable<number>;
  33936. /**
  33937. * Sets the current depth function
  33938. * @param depthFunc defines the function to use
  33939. */
  33940. setDepthFunction(depthFunc: number): void;
  33941. /**
  33942. * Sets the current depth function to GREATER
  33943. */
  33944. setDepthFunctionToGreater(): void;
  33945. /**
  33946. * Sets the current depth function to GEQUAL
  33947. */
  33948. setDepthFunctionToGreaterOrEqual(): void;
  33949. /**
  33950. * Sets the current depth function to LESS
  33951. */
  33952. setDepthFunctionToLess(): void;
  33953. /**
  33954. * Sets the current depth function to LEQUAL
  33955. */
  33956. setDepthFunctionToLessOrEqual(): void;
  33957. private _cachedStencilBuffer;
  33958. private _cachedStencilFunction;
  33959. private _cachedStencilMask;
  33960. private _cachedStencilOperationPass;
  33961. private _cachedStencilOperationFail;
  33962. private _cachedStencilOperationDepthFail;
  33963. private _cachedStencilReference;
  33964. /**
  33965. * Caches the the state of the stencil buffer
  33966. */
  33967. cacheStencilState(): void;
  33968. /**
  33969. * Restores the state of the stencil buffer
  33970. */
  33971. restoreStencilState(): void;
  33972. /**
  33973. * Directly set the WebGL Viewport
  33974. * @param x defines the x coordinate of the viewport (in screen space)
  33975. * @param y defines the y coordinate of the viewport (in screen space)
  33976. * @param width defines the width of the viewport (in screen space)
  33977. * @param height defines the height of the viewport (in screen space)
  33978. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  33979. */
  33980. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33981. /**
  33982. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33983. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33984. * @param y defines the y-coordinate of the corner of the clear rectangle
  33985. * @param width defines the width of the clear rectangle
  33986. * @param height defines the height of the clear rectangle
  33987. * @param clearColor defines the clear color
  33988. */
  33989. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33990. /**
  33991. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33992. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33993. * @param y defines the y-coordinate of the corner of the clear rectangle
  33994. * @param width defines the width of the clear rectangle
  33995. * @param height defines the height of the clear rectangle
  33996. */
  33997. enableScissor(x: number, y: number, width: number, height: number): void;
  33998. /**
  33999. * Disable previously set scissor test rectangle
  34000. */
  34001. disableScissor(): void;
  34002. protected _reportDrawCall(): void;
  34003. /**
  34004. * Initializes a webVR display and starts listening to display change events
  34005. * The onVRDisplayChangedObservable will be notified upon these changes
  34006. * @returns The onVRDisplayChangedObservable
  34007. */
  34008. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34009. /** @hidden */
  34010. _prepareVRComponent(): void;
  34011. /** @hidden */
  34012. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34013. /** @hidden */
  34014. _submitVRFrame(): void;
  34015. /**
  34016. * Call this function to leave webVR mode
  34017. * Will do nothing if webVR is not supported or if there is no webVR device
  34018. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34019. */
  34020. disableVR(): void;
  34021. /**
  34022. * Gets a boolean indicating that the system is in VR mode and is presenting
  34023. * @returns true if VR mode is engaged
  34024. */
  34025. isVRPresenting(): boolean;
  34026. /** @hidden */
  34027. _requestVRFrame(): void;
  34028. /** @hidden */
  34029. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34030. /**
  34031. * Gets the source code of the vertex shader associated with a specific webGL program
  34032. * @param program defines the program to use
  34033. * @returns a string containing the source code of the vertex shader associated with the program
  34034. */
  34035. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34036. /**
  34037. * Gets the source code of the fragment shader associated with a specific webGL program
  34038. * @param program defines the program to use
  34039. * @returns a string containing the source code of the fragment shader associated with the program
  34040. */
  34041. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34042. /**
  34043. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34044. * @param x defines the x coordinate of the rectangle where pixels must be read
  34045. * @param y defines the y coordinate of the rectangle where pixels must be read
  34046. * @param width defines the width of the rectangle where pixels must be read
  34047. * @param height defines the height of the rectangle where pixels must be read
  34048. * @returns a Uint8Array containing RGBA colors
  34049. */
  34050. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  34051. /**
  34052. * Sets a depth stencil texture from a render target to the according uniform.
  34053. * @param channel The texture channel
  34054. * @param uniform The uniform to set
  34055. * @param texture The render target texture containing the depth stencil texture to apply
  34056. */
  34057. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34058. /**
  34059. * Sets a texture to the webGL context from a postprocess
  34060. * @param channel defines the channel to use
  34061. * @param postProcess defines the source postprocess
  34062. */
  34063. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34064. /**
  34065. * Binds the output of the passed in post process to the texture channel specified
  34066. * @param channel The channel the texture should be bound to
  34067. * @param postProcess The post process which's output should be bound
  34068. */
  34069. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34070. /** @hidden */
  34071. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34072. protected _rebuildBuffers(): void;
  34073. /** @hidden */
  34074. _renderFrame(): void;
  34075. _renderLoop(): void;
  34076. /** @hidden */
  34077. _renderViews(): boolean;
  34078. /**
  34079. * Toggle full screen mode
  34080. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34081. */
  34082. switchFullscreen(requestPointerLock: boolean): void;
  34083. /**
  34084. * Enters full screen mode
  34085. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34086. */
  34087. enterFullscreen(requestPointerLock: boolean): void;
  34088. /**
  34089. * Exits full screen mode
  34090. */
  34091. exitFullscreen(): void;
  34092. /**
  34093. * Enters Pointerlock mode
  34094. */
  34095. enterPointerlock(): void;
  34096. /**
  34097. * Exits Pointerlock mode
  34098. */
  34099. exitPointerlock(): void;
  34100. /**
  34101. * Begin a new frame
  34102. */
  34103. beginFrame(): void;
  34104. /**
  34105. * Enf the current frame
  34106. */
  34107. endFrame(): void;
  34108. resize(): void;
  34109. /**
  34110. * Set the compressed texture format to use, based on the formats you have, and the formats
  34111. * supported by the hardware / browser.
  34112. *
  34113. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34114. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34115. * to API arguments needed to compressed textures. This puts the burden on the container
  34116. * generator to house the arcane code for determining these for current & future formats.
  34117. *
  34118. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34119. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34120. *
  34121. * Note: The result of this call is not taken into account when a texture is base64.
  34122. *
  34123. * @param formatsAvailable defines the list of those format families you have created
  34124. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34125. *
  34126. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34127. * @returns The extension selected.
  34128. */
  34129. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34130. /**
  34131. * Set the compressed texture extensions or file names to skip.
  34132. *
  34133. * @param skippedFiles defines the list of those texture files you want to skip
  34134. * Example: [".dds", ".env", "myfile.png"]
  34135. */
  34136. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34137. /**
  34138. * Force a specific size of the canvas
  34139. * @param width defines the new canvas' width
  34140. * @param height defines the new canvas' height
  34141. */
  34142. setSize(width: number, height: number): void;
  34143. /**
  34144. * Updates a dynamic vertex buffer.
  34145. * @param vertexBuffer the vertex buffer to update
  34146. * @param data the data used to update the vertex buffer
  34147. * @param byteOffset the byte offset of the data
  34148. * @param byteLength the byte length of the data
  34149. */
  34150. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34151. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34152. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34153. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34154. _releaseTexture(texture: InternalTexture): void;
  34155. /**
  34156. * @hidden
  34157. * Rescales a texture
  34158. * @param source input texutre
  34159. * @param destination destination texture
  34160. * @param scene scene to use to render the resize
  34161. * @param internalFormat format to use when resizing
  34162. * @param onComplete callback to be called when resize has completed
  34163. */
  34164. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34165. /**
  34166. * Gets the current framerate
  34167. * @returns a number representing the framerate
  34168. */
  34169. getFps(): number;
  34170. /**
  34171. * Gets the time spent between current and previous frame
  34172. * @returns a number representing the delta time in ms
  34173. */
  34174. getDeltaTime(): number;
  34175. private _measureFps;
  34176. /** @hidden */
  34177. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34178. /**
  34179. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34180. * @param renderTarget The render target to set the frame buffer for
  34181. */
  34182. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34183. /**
  34184. * Update a dynamic index buffer
  34185. * @param indexBuffer defines the target index buffer
  34186. * @param indices defines the data to update
  34187. * @param offset defines the offset in the target index buffer where update should start
  34188. */
  34189. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34190. /**
  34191. * Updates the sample count of a render target texture
  34192. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34193. * @param texture defines the texture to update
  34194. * @param samples defines the sample count to set
  34195. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34196. */
  34197. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34198. /**
  34199. * Updates a depth texture Comparison Mode and Function.
  34200. * If the comparison Function is equal to 0, the mode will be set to none.
  34201. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34202. * @param texture The texture to set the comparison function for
  34203. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34204. */
  34205. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34206. /**
  34207. * Creates a webGL buffer to use with instanciation
  34208. * @param capacity defines the size of the buffer
  34209. * @returns the webGL buffer
  34210. */
  34211. createInstancesBuffer(capacity: number): DataBuffer;
  34212. /**
  34213. * Delete a webGL buffer used with instanciation
  34214. * @param buffer defines the webGL buffer to delete
  34215. */
  34216. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34217. /** @hidden */
  34218. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34219. dispose(): void;
  34220. private _disableTouchAction;
  34221. /**
  34222. * Display the loading screen
  34223. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34224. */
  34225. displayLoadingUI(): void;
  34226. /**
  34227. * Hide the loading screen
  34228. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34229. */
  34230. hideLoadingUI(): void;
  34231. /**
  34232. * Gets the current loading screen object
  34233. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34234. */
  34235. /**
  34236. * Sets the current loading screen object
  34237. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34238. */
  34239. loadingScreen: ILoadingScreen;
  34240. /**
  34241. * Sets the current loading screen text
  34242. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34243. */
  34244. loadingUIText: string;
  34245. /**
  34246. * Sets the current loading screen background color
  34247. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34248. */
  34249. loadingUIBackgroundColor: string;
  34250. /** Pointerlock and fullscreen */
  34251. /**
  34252. * Ask the browser to promote the current element to pointerlock mode
  34253. * @param element defines the DOM element to promote
  34254. */
  34255. static _RequestPointerlock(element: HTMLElement): void;
  34256. /**
  34257. * Asks the browser to exit pointerlock mode
  34258. */
  34259. static _ExitPointerlock(): void;
  34260. /**
  34261. * Ask the browser to promote the current element to fullscreen rendering mode
  34262. * @param element defines the DOM element to promote
  34263. */
  34264. static _RequestFullscreen(element: HTMLElement): void;
  34265. /**
  34266. * Asks the browser to exit fullscreen mode
  34267. */
  34268. static _ExitFullscreen(): void;
  34269. }
  34270. }
  34271. declare module "babylonjs/Engines/engineStore" {
  34272. import { Nullable } from "babylonjs/types";
  34273. import { Engine } from "babylonjs/Engines/engine";
  34274. import { Scene } from "babylonjs/scene";
  34275. /**
  34276. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34277. * during the life time of the application.
  34278. */
  34279. export class EngineStore {
  34280. /** Gets the list of created engines */
  34281. static Instances: import("babylonjs/Engines/engine").Engine[];
  34282. /** @hidden */
  34283. static _LastCreatedScene: Nullable<Scene>;
  34284. /**
  34285. * Gets the latest created engine
  34286. */
  34287. static readonly LastCreatedEngine: Nullable<Engine>;
  34288. /**
  34289. * Gets the latest created scene
  34290. */
  34291. static readonly LastCreatedScene: Nullable<Scene>;
  34292. /**
  34293. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34294. * @ignorenaming
  34295. */
  34296. static UseFallbackTexture: boolean;
  34297. /**
  34298. * Texture content used if a texture cannot loaded
  34299. * @ignorenaming
  34300. */
  34301. static FallbackTexture: string;
  34302. }
  34303. }
  34304. declare module "babylonjs/Misc/promise" {
  34305. /**
  34306. * Helper class that provides a small promise polyfill
  34307. */
  34308. export class PromisePolyfill {
  34309. /**
  34310. * Static function used to check if the polyfill is required
  34311. * If this is the case then the function will inject the polyfill to window.Promise
  34312. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34313. */
  34314. static Apply(force?: boolean): void;
  34315. }
  34316. }
  34317. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34318. /**
  34319. * Interface for screenshot methods with describe argument called `size` as object with options
  34320. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34321. */
  34322. export interface IScreenshotSize {
  34323. /**
  34324. * number in pixels for canvas height
  34325. */
  34326. height?: number;
  34327. /**
  34328. * multiplier allowing render at a higher or lower resolution
  34329. * If value is defined then height and width will be ignored and taken from camera
  34330. */
  34331. precision?: number;
  34332. /**
  34333. * number in pixels for canvas width
  34334. */
  34335. width?: number;
  34336. }
  34337. }
  34338. declare module "babylonjs/Misc/tools" {
  34339. import { Nullable, float } from "babylonjs/types";
  34340. import { DomManagement } from "babylonjs/Misc/domManagement";
  34341. import { WebRequest } from "babylonjs/Misc/webRequest";
  34342. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34343. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34344. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34345. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34346. import { Camera } from "babylonjs/Cameras/camera";
  34347. import { Engine } from "babylonjs/Engines/engine";
  34348. interface IColor4Like {
  34349. r: float;
  34350. g: float;
  34351. b: float;
  34352. a: float;
  34353. }
  34354. /**
  34355. * Class containing a set of static utilities functions
  34356. */
  34357. export class Tools {
  34358. /**
  34359. * Gets or sets the base URL to use to load assets
  34360. */
  34361. static BaseUrl: string;
  34362. /**
  34363. * Enable/Disable Custom HTTP Request Headers globally.
  34364. * default = false
  34365. * @see CustomRequestHeaders
  34366. */
  34367. static UseCustomRequestHeaders: boolean;
  34368. /**
  34369. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34370. * i.e. when loading files, where the server/service expects an Authorization header
  34371. */
  34372. static CustomRequestHeaders: {
  34373. [key: string]: string;
  34374. };
  34375. /**
  34376. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34377. */
  34378. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  34379. /**
  34380. * Default behaviour for cors in the application.
  34381. * It can be a string if the expected behavior is identical in the entire app.
  34382. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34383. */
  34384. static CorsBehavior: string | ((url: string | string[]) => string);
  34385. /**
  34386. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34387. * @ignorenaming
  34388. */
  34389. static UseFallbackTexture: boolean;
  34390. /**
  34391. * Use this object to register external classes like custom textures or material
  34392. * to allow the laoders to instantiate them
  34393. */
  34394. static RegisteredExternalClasses: {
  34395. [key: string]: Object;
  34396. };
  34397. /**
  34398. * Texture content used if a texture cannot loaded
  34399. * @ignorenaming
  34400. */
  34401. static fallbackTexture: string;
  34402. /**
  34403. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34404. * @param u defines the coordinate on X axis
  34405. * @param v defines the coordinate on Y axis
  34406. * @param width defines the width of the source data
  34407. * @param height defines the height of the source data
  34408. * @param pixels defines the source byte array
  34409. * @param color defines the output color
  34410. */
  34411. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34412. /**
  34413. * Interpolates between a and b via alpha
  34414. * @param a The lower value (returned when alpha = 0)
  34415. * @param b The upper value (returned when alpha = 1)
  34416. * @param alpha The interpolation-factor
  34417. * @return The mixed value
  34418. */
  34419. static Mix(a: number, b: number, alpha: number): number;
  34420. /**
  34421. * Tries to instantiate a new object from a given class name
  34422. * @param className defines the class name to instantiate
  34423. * @returns the new object or null if the system was not able to do the instantiation
  34424. */
  34425. static Instantiate(className: string): any;
  34426. /**
  34427. * Provides a slice function that will work even on IE
  34428. * @param data defines the array to slice
  34429. * @param start defines the start of the data (optional)
  34430. * @param end defines the end of the data (optional)
  34431. * @returns the new sliced array
  34432. */
  34433. static Slice<T>(data: T, start?: number, end?: number): T;
  34434. /**
  34435. * Polyfill for setImmediate
  34436. * @param action defines the action to execute after the current execution block
  34437. */
  34438. static SetImmediate(action: () => void): void;
  34439. /**
  34440. * Function indicating if a number is an exponent of 2
  34441. * @param value defines the value to test
  34442. * @returns true if the value is an exponent of 2
  34443. */
  34444. static IsExponentOfTwo(value: number): boolean;
  34445. private static _tmpFloatArray;
  34446. /**
  34447. * Returns the nearest 32-bit single precision float representation of a Number
  34448. * @param value A Number. If the parameter is of a different type, it will get converted
  34449. * to a number or to NaN if it cannot be converted
  34450. * @returns number
  34451. */
  34452. static FloatRound(value: number): number;
  34453. /**
  34454. * Extracts the filename from a path
  34455. * @param path defines the path to use
  34456. * @returns the filename
  34457. */
  34458. static GetFilename(path: string): string;
  34459. /**
  34460. * Extracts the "folder" part of a path (everything before the filename).
  34461. * @param uri The URI to extract the info from
  34462. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34463. * @returns The "folder" part of the path
  34464. */
  34465. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34466. /**
  34467. * Extracts text content from a DOM element hierarchy
  34468. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34469. */
  34470. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34471. /**
  34472. * Convert an angle in radians to degrees
  34473. * @param angle defines the angle to convert
  34474. * @returns the angle in degrees
  34475. */
  34476. static ToDegrees(angle: number): number;
  34477. /**
  34478. * Convert an angle in degrees to radians
  34479. * @param angle defines the angle to convert
  34480. * @returns the angle in radians
  34481. */
  34482. static ToRadians(angle: number): number;
  34483. /**
  34484. * Returns an array if obj is not an array
  34485. * @param obj defines the object to evaluate as an array
  34486. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34487. * @returns either obj directly if obj is an array or a new array containing obj
  34488. */
  34489. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34490. /**
  34491. * Gets the pointer prefix to use
  34492. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34493. */
  34494. static GetPointerPrefix(): string;
  34495. /**
  34496. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34497. * @param url define the url we are trying
  34498. * @param element define the dom element where to configure the cors policy
  34499. */
  34500. static SetCorsBehavior(url: string | string[], element: {
  34501. crossOrigin: string | null;
  34502. }): void;
  34503. /**
  34504. * Removes unwanted characters from an url
  34505. * @param url defines the url to clean
  34506. * @returns the cleaned url
  34507. */
  34508. static CleanUrl(url: string): string;
  34509. /**
  34510. * Gets or sets a function used to pre-process url before using them to load assets
  34511. */
  34512. static PreprocessUrl: (url: string) => string;
  34513. /**
  34514. * Loads an image as an HTMLImageElement.
  34515. * @param input url string, ArrayBuffer, or Blob to load
  34516. * @param onLoad callback called when the image successfully loads
  34517. * @param onError callback called when the image fails to load
  34518. * @param offlineProvider offline provider for caching
  34519. * @param mimeType optional mime type
  34520. * @returns the HTMLImageElement of the loaded image
  34521. */
  34522. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34523. /**
  34524. * Loads a file from a url
  34525. * @param url url string, ArrayBuffer, or Blob to load
  34526. * @param onSuccess callback called when the file successfully loads
  34527. * @param onProgress callback called while file is loading (if the server supports this mode)
  34528. * @param offlineProvider defines the offline provider for caching
  34529. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34530. * @param onError callback called when the file fails to load
  34531. * @returns a file request object
  34532. */
  34533. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34534. /**
  34535. * Loads a file from a url
  34536. * @param url the file url to load
  34537. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34538. */
  34539. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34540. /**
  34541. * Load a script (identified by an url). When the url returns, the
  34542. * content of this file is added into a new script element, attached to the DOM (body element)
  34543. * @param scriptUrl defines the url of the script to laod
  34544. * @param onSuccess defines the callback called when the script is loaded
  34545. * @param onError defines the callback to call if an error occurs
  34546. * @param scriptId defines the id of the script element
  34547. */
  34548. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34549. /**
  34550. * Load an asynchronous script (identified by an url). When the url returns, the
  34551. * content of this file is added into a new script element, attached to the DOM (body element)
  34552. * @param scriptUrl defines the url of the script to laod
  34553. * @param scriptId defines the id of the script element
  34554. * @returns a promise request object
  34555. */
  34556. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34557. /**
  34558. * Loads a file from a blob
  34559. * @param fileToLoad defines the blob to use
  34560. * @param callback defines the callback to call when data is loaded
  34561. * @param progressCallback defines the callback to call during loading process
  34562. * @returns a file request object
  34563. */
  34564. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34565. /**
  34566. * Reads a file from a File object
  34567. * @param file defines the file to load
  34568. * @param onSuccess defines the callback to call when data is loaded
  34569. * @param onProgress defines the callback to call during loading process
  34570. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34571. * @param onError defines the callback to call when an error occurs
  34572. * @returns a file request object
  34573. */
  34574. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34575. /**
  34576. * Creates a data url from a given string content
  34577. * @param content defines the content to convert
  34578. * @returns the new data url link
  34579. */
  34580. static FileAsURL(content: string): string;
  34581. /**
  34582. * Format the given number to a specific decimal format
  34583. * @param value defines the number to format
  34584. * @param decimals defines the number of decimals to use
  34585. * @returns the formatted string
  34586. */
  34587. static Format(value: number, decimals?: number): string;
  34588. /**
  34589. * Tries to copy an object by duplicating every property
  34590. * @param source defines the source object
  34591. * @param destination defines the target object
  34592. * @param doNotCopyList defines a list of properties to avoid
  34593. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34594. */
  34595. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34596. /**
  34597. * Gets a boolean indicating if the given object has no own property
  34598. * @param obj defines the object to test
  34599. * @returns true if object has no own property
  34600. */
  34601. static IsEmpty(obj: any): boolean;
  34602. /**
  34603. * Function used to register events at window level
  34604. * @param windowElement defines the Window object to use
  34605. * @param events defines the events to register
  34606. */
  34607. static RegisterTopRootEvents(windowElement: Window, events: {
  34608. name: string;
  34609. handler: Nullable<(e: FocusEvent) => any>;
  34610. }[]): void;
  34611. /**
  34612. * Function used to unregister events from window level
  34613. * @param windowElement defines the Window object to use
  34614. * @param events defines the events to unregister
  34615. */
  34616. static UnregisterTopRootEvents(windowElement: Window, events: {
  34617. name: string;
  34618. handler: Nullable<(e: FocusEvent) => any>;
  34619. }[]): void;
  34620. /**
  34621. * @ignore
  34622. */
  34623. static _ScreenshotCanvas: HTMLCanvasElement;
  34624. /**
  34625. * Dumps the current bound framebuffer
  34626. * @param width defines the rendering width
  34627. * @param height defines the rendering height
  34628. * @param engine defines the hosting engine
  34629. * @param successCallback defines the callback triggered once the data are available
  34630. * @param mimeType defines the mime type of the result
  34631. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34632. */
  34633. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34634. /**
  34635. * Converts the canvas data to blob.
  34636. * This acts as a polyfill for browsers not supporting the to blob function.
  34637. * @param canvas Defines the canvas to extract the data from
  34638. * @param successCallback Defines the callback triggered once the data are available
  34639. * @param mimeType Defines the mime type of the result
  34640. */
  34641. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34642. /**
  34643. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34644. * @param successCallback defines the callback triggered once the data are available
  34645. * @param mimeType defines the mime type of the result
  34646. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34647. */
  34648. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34649. /**
  34650. * Downloads a blob in the browser
  34651. * @param blob defines the blob to download
  34652. * @param fileName defines the name of the downloaded file
  34653. */
  34654. static Download(blob: Blob, fileName: string): void;
  34655. /**
  34656. * Captures a screenshot of the current rendering
  34657. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34658. * @param engine defines the rendering engine
  34659. * @param camera defines the source camera
  34660. * @param size This parameter can be set to a single number or to an object with the
  34661. * following (optional) properties: precision, width, height. If a single number is passed,
  34662. * it will be used for both width and height. If an object is passed, the screenshot size
  34663. * will be derived from the parameters. The precision property is a multiplier allowing
  34664. * rendering at a higher or lower resolution
  34665. * @param successCallback defines the callback receives a single parameter which contains the
  34666. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34667. * src parameter of an <img> to display it
  34668. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34669. * Check your browser for supported MIME types
  34670. */
  34671. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34672. /**
  34673. * Captures a screenshot of the current rendering
  34674. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34675. * @param engine defines the rendering engine
  34676. * @param camera defines the source camera
  34677. * @param size This parameter can be set to a single number or to an object with the
  34678. * following (optional) properties: precision, width, height. If a single number is passed,
  34679. * it will be used for both width and height. If an object is passed, the screenshot size
  34680. * will be derived from the parameters. The precision property is a multiplier allowing
  34681. * rendering at a higher or lower resolution
  34682. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34683. * Check your browser for supported MIME types
  34684. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34685. * to the src parameter of an <img> to display it
  34686. */
  34687. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34688. /**
  34689. * Generates an image screenshot from the specified camera.
  34690. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34691. * @param engine The engine to use for rendering
  34692. * @param camera The camera to use for rendering
  34693. * @param size This parameter can be set to a single number or to an object with the
  34694. * following (optional) properties: precision, width, height. If a single number is passed,
  34695. * it will be used for both width and height. If an object is passed, the screenshot size
  34696. * will be derived from the parameters. The precision property is a multiplier allowing
  34697. * rendering at a higher or lower resolution
  34698. * @param successCallback The callback receives a single parameter which contains the
  34699. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34700. * src parameter of an <img> to display it
  34701. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34702. * Check your browser for supported MIME types
  34703. * @param samples Texture samples (default: 1)
  34704. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34705. * @param fileName A name for for the downloaded file.
  34706. */
  34707. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34708. /**
  34709. * Generates an image screenshot from the specified camera.
  34710. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34711. * @param engine The engine to use for rendering
  34712. * @param camera The camera to use for rendering
  34713. * @param size This parameter can be set to a single number or to an object with the
  34714. * following (optional) properties: precision, width, height. If a single number is passed,
  34715. * it will be used for both width and height. If an object is passed, the screenshot size
  34716. * will be derived from the parameters. The precision property is a multiplier allowing
  34717. * rendering at a higher or lower resolution
  34718. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34719. * Check your browser for supported MIME types
  34720. * @param samples Texture samples (default: 1)
  34721. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34722. * @param fileName A name for for the downloaded file.
  34723. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34724. * to the src parameter of an <img> to display it
  34725. */
  34726. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34727. /**
  34728. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34729. * Be aware Math.random() could cause collisions, but:
  34730. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  34731. * @returns a pseudo random id
  34732. */
  34733. static RandomId(): string;
  34734. /**
  34735. * Test if the given uri is a base64 string
  34736. * @param uri The uri to test
  34737. * @return True if the uri is a base64 string or false otherwise
  34738. */
  34739. static IsBase64(uri: string): boolean;
  34740. /**
  34741. * Decode the given base64 uri.
  34742. * @param uri The uri to decode
  34743. * @return The decoded base64 data.
  34744. */
  34745. static DecodeBase64(uri: string): ArrayBuffer;
  34746. /**
  34747. * Gets the absolute url.
  34748. * @param url the input url
  34749. * @return the absolute url
  34750. */
  34751. static GetAbsoluteUrl(url: string): string;
  34752. /**
  34753. * No log
  34754. */
  34755. static readonly NoneLogLevel: number;
  34756. /**
  34757. * Only message logs
  34758. */
  34759. static readonly MessageLogLevel: number;
  34760. /**
  34761. * Only warning logs
  34762. */
  34763. static readonly WarningLogLevel: number;
  34764. /**
  34765. * Only error logs
  34766. */
  34767. static readonly ErrorLogLevel: number;
  34768. /**
  34769. * All logs
  34770. */
  34771. static readonly AllLogLevel: number;
  34772. /**
  34773. * Gets a value indicating the number of loading errors
  34774. * @ignorenaming
  34775. */
  34776. static readonly errorsCount: number;
  34777. /**
  34778. * Callback called when a new log is added
  34779. */
  34780. static OnNewCacheEntry: (entry: string) => void;
  34781. /**
  34782. * Log a message to the console
  34783. * @param message defines the message to log
  34784. */
  34785. static Log(message: string): void;
  34786. /**
  34787. * Write a warning message to the console
  34788. * @param message defines the message to log
  34789. */
  34790. static Warn(message: string): void;
  34791. /**
  34792. * Write an error message to the console
  34793. * @param message defines the message to log
  34794. */
  34795. static Error(message: string): void;
  34796. /**
  34797. * Gets current log cache (list of logs)
  34798. */
  34799. static readonly LogCache: string;
  34800. /**
  34801. * Clears the log cache
  34802. */
  34803. static ClearLogCache(): void;
  34804. /**
  34805. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34806. */
  34807. static LogLevels: number;
  34808. /**
  34809. * Checks if the window object exists
  34810. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34811. */
  34812. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34813. /**
  34814. * No performance log
  34815. */
  34816. static readonly PerformanceNoneLogLevel: number;
  34817. /**
  34818. * Use user marks to log performance
  34819. */
  34820. static readonly PerformanceUserMarkLogLevel: number;
  34821. /**
  34822. * Log performance to the console
  34823. */
  34824. static readonly PerformanceConsoleLogLevel: number;
  34825. private static _performance;
  34826. /**
  34827. * Sets the current performance log level
  34828. */
  34829. static PerformanceLogLevel: number;
  34830. private static _StartPerformanceCounterDisabled;
  34831. private static _EndPerformanceCounterDisabled;
  34832. private static _StartUserMark;
  34833. private static _EndUserMark;
  34834. private static _StartPerformanceConsole;
  34835. private static _EndPerformanceConsole;
  34836. /**
  34837. * Starts a performance counter
  34838. */
  34839. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34840. /**
  34841. * Ends a specific performance coutner
  34842. */
  34843. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34844. /**
  34845. * Gets either window.performance.now() if supported or Date.now() else
  34846. */
  34847. static readonly Now: number;
  34848. /**
  34849. * This method will return the name of the class used to create the instance of the given object.
  34850. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34851. * @param object the object to get the class name from
  34852. * @param isType defines if the object is actually a type
  34853. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34854. */
  34855. static GetClassName(object: any, isType?: boolean): string;
  34856. /**
  34857. * Gets the first element of an array satisfying a given predicate
  34858. * @param array defines the array to browse
  34859. * @param predicate defines the predicate to use
  34860. * @returns null if not found or the element
  34861. */
  34862. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34863. /**
  34864. * This method will return the name of the full name of the class, including its owning module (if any).
  34865. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  34866. * @param object the object to get the class name from
  34867. * @param isType defines if the object is actually a type
  34868. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  34869. * @ignorenaming
  34870. */
  34871. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34872. /**
  34873. * Returns a promise that resolves after the given amount of time.
  34874. * @param delay Number of milliseconds to delay
  34875. * @returns Promise that resolves after the given amount of time
  34876. */
  34877. static DelayAsync(delay: number): Promise<void>;
  34878. }
  34879. /**
  34880. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34881. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34882. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34883. * @param name The name of the class, case should be preserved
  34884. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34885. */
  34886. export function className(name: string, module?: string): (target: Object) => void;
  34887. /**
  34888. * An implementation of a loop for asynchronous functions.
  34889. */
  34890. export class AsyncLoop {
  34891. /**
  34892. * Defines the number of iterations for the loop
  34893. */
  34894. iterations: number;
  34895. /**
  34896. * Defines the current index of the loop.
  34897. */
  34898. index: number;
  34899. private _done;
  34900. private _fn;
  34901. private _successCallback;
  34902. /**
  34903. * Constructor.
  34904. * @param iterations the number of iterations.
  34905. * @param func the function to run each iteration
  34906. * @param successCallback the callback that will be called upon succesful execution
  34907. * @param offset starting offset.
  34908. */
  34909. constructor(
  34910. /**
  34911. * Defines the number of iterations for the loop
  34912. */
  34913. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34914. /**
  34915. * Execute the next iteration. Must be called after the last iteration was finished.
  34916. */
  34917. executeNext(): void;
  34918. /**
  34919. * Break the loop and run the success callback.
  34920. */
  34921. breakLoop(): void;
  34922. /**
  34923. * Create and run an async loop.
  34924. * @param iterations the number of iterations.
  34925. * @param fn the function to run each iteration
  34926. * @param successCallback the callback that will be called upon succesful execution
  34927. * @param offset starting offset.
  34928. * @returns the created async loop object
  34929. */
  34930. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34931. /**
  34932. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34933. * @param iterations total number of iterations
  34934. * @param syncedIterations number of synchronous iterations in each async iteration.
  34935. * @param fn the function to call each iteration.
  34936. * @param callback a success call back that will be called when iterating stops.
  34937. * @param breakFunction a break condition (optional)
  34938. * @param timeout timeout settings for the setTimeout function. default - 0.
  34939. * @returns the created async loop object
  34940. */
  34941. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34942. }
  34943. }
  34944. declare module "babylonjs/Misc/stringDictionary" {
  34945. import { Nullable } from "babylonjs/types";
  34946. /**
  34947. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34948. * The underlying implementation relies on an associative array to ensure the best performances.
  34949. * The value can be anything including 'null' but except 'undefined'
  34950. */
  34951. export class StringDictionary<T> {
  34952. /**
  34953. * This will clear this dictionary and copy the content from the 'source' one.
  34954. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34955. * @param source the dictionary to take the content from and copy to this dictionary
  34956. */
  34957. copyFrom(source: StringDictionary<T>): void;
  34958. /**
  34959. * Get a value based from its key
  34960. * @param key the given key to get the matching value from
  34961. * @return the value if found, otherwise undefined is returned
  34962. */
  34963. get(key: string): T | undefined;
  34964. /**
  34965. * Get a value from its key or add it if it doesn't exist.
  34966. * This method will ensure you that a given key/data will be present in the dictionary.
  34967. * @param key the given key to get the matching value from
  34968. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34969. * The factory will only be invoked if there's no data for the given key.
  34970. * @return the value corresponding to the key.
  34971. */
  34972. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34973. /**
  34974. * Get a value from its key if present in the dictionary otherwise add it
  34975. * @param key the key to get the value from
  34976. * @param val if there's no such key/value pair in the dictionary add it with this value
  34977. * @return the value corresponding to the key
  34978. */
  34979. getOrAdd(key: string, val: T): T;
  34980. /**
  34981. * Check if there's a given key in the dictionary
  34982. * @param key the key to check for
  34983. * @return true if the key is present, false otherwise
  34984. */
  34985. contains(key: string): boolean;
  34986. /**
  34987. * Add a new key and its corresponding value
  34988. * @param key the key to add
  34989. * @param value the value corresponding to the key
  34990. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  34991. */
  34992. add(key: string, value: T): boolean;
  34993. /**
  34994. * Update a specific value associated to a key
  34995. * @param key defines the key to use
  34996. * @param value defines the value to store
  34997. * @returns true if the value was updated (or false if the key was not found)
  34998. */
  34999. set(key: string, value: T): boolean;
  35000. /**
  35001. * Get the element of the given key and remove it from the dictionary
  35002. * @param key defines the key to search
  35003. * @returns the value associated with the key or null if not found
  35004. */
  35005. getAndRemove(key: string): Nullable<T>;
  35006. /**
  35007. * Remove a key/value from the dictionary.
  35008. * @param key the key to remove
  35009. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35010. */
  35011. remove(key: string): boolean;
  35012. /**
  35013. * Clear the whole content of the dictionary
  35014. */
  35015. clear(): void;
  35016. /**
  35017. * Gets the current count
  35018. */
  35019. readonly count: number;
  35020. /**
  35021. * Execute a callback on each key/val of the dictionary.
  35022. * Note that you can remove any element in this dictionary in the callback implementation
  35023. * @param callback the callback to execute on a given key/value pair
  35024. */
  35025. forEach(callback: (key: string, val: T) => void): void;
  35026. /**
  35027. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35028. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35029. * Note that you can remove any element in this dictionary in the callback implementation
  35030. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35031. * @returns the first item
  35032. */
  35033. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35034. private _count;
  35035. private _data;
  35036. }
  35037. }
  35038. declare module "babylonjs/Collisions/collisionCoordinator" {
  35039. import { Nullable } from "babylonjs/types";
  35040. import { Scene } from "babylonjs/scene";
  35041. import { Vector3 } from "babylonjs/Maths/math.vector";
  35042. import { Collider } from "babylonjs/Collisions/collider";
  35043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35044. /** @hidden */
  35045. export interface ICollisionCoordinator {
  35046. createCollider(): Collider;
  35047. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35048. init(scene: Scene): void;
  35049. }
  35050. /** @hidden */
  35051. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35052. private _scene;
  35053. private _scaledPosition;
  35054. private _scaledVelocity;
  35055. private _finalPosition;
  35056. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35057. createCollider(): Collider;
  35058. init(scene: Scene): void;
  35059. private _collideWithWorld;
  35060. }
  35061. }
  35062. declare module "babylonjs/Inputs/scene.inputManager" {
  35063. import { Nullable } from "babylonjs/types";
  35064. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35065. import { Vector2 } from "babylonjs/Maths/math.vector";
  35066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35067. import { Scene } from "babylonjs/scene";
  35068. /**
  35069. * Class used to manage all inputs for the scene.
  35070. */
  35071. export class InputManager {
  35072. /** The distance in pixel that you have to move to prevent some events */
  35073. static DragMovementThreshold: number;
  35074. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35075. static LongPressDelay: number;
  35076. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35077. static DoubleClickDelay: number;
  35078. /** If you need to check double click without raising a single click at first click, enable this flag */
  35079. static ExclusiveDoubleClickMode: boolean;
  35080. private _wheelEventName;
  35081. private _onPointerMove;
  35082. private _onPointerDown;
  35083. private _onPointerUp;
  35084. private _initClickEvent;
  35085. private _initActionManager;
  35086. private _delayedSimpleClick;
  35087. private _delayedSimpleClickTimeout;
  35088. private _previousDelayedSimpleClickTimeout;
  35089. private _meshPickProceed;
  35090. private _previousButtonPressed;
  35091. private _currentPickResult;
  35092. private _previousPickResult;
  35093. private _totalPointersPressed;
  35094. private _doubleClickOccured;
  35095. private _pointerOverMesh;
  35096. private _pickedDownMesh;
  35097. private _pickedUpMesh;
  35098. private _pointerX;
  35099. private _pointerY;
  35100. private _unTranslatedPointerX;
  35101. private _unTranslatedPointerY;
  35102. private _startingPointerPosition;
  35103. private _previousStartingPointerPosition;
  35104. private _startingPointerTime;
  35105. private _previousStartingPointerTime;
  35106. private _pointerCaptures;
  35107. private _onKeyDown;
  35108. private _onKeyUp;
  35109. private _onCanvasFocusObserver;
  35110. private _onCanvasBlurObserver;
  35111. private _scene;
  35112. /**
  35113. * Creates a new InputManager
  35114. * @param scene defines the hosting scene
  35115. */
  35116. constructor(scene: Scene);
  35117. /**
  35118. * Gets the mesh that is currently under the pointer
  35119. */
  35120. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35121. /**
  35122. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35123. */
  35124. readonly unTranslatedPointer: Vector2;
  35125. /**
  35126. * Gets or sets the current on-screen X position of the pointer
  35127. */
  35128. pointerX: number;
  35129. /**
  35130. * Gets or sets the current on-screen Y position of the pointer
  35131. */
  35132. pointerY: number;
  35133. private _updatePointerPosition;
  35134. private _processPointerMove;
  35135. private _setRayOnPointerInfo;
  35136. private _checkPrePointerObservable;
  35137. /**
  35138. * Use this method to simulate a pointer move on a mesh
  35139. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35140. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35141. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35142. */
  35143. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35144. /**
  35145. * Use this method to simulate a pointer down on a mesh
  35146. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35147. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35148. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35149. */
  35150. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35151. private _processPointerDown;
  35152. /** @hidden */
  35153. _isPointerSwiping(): boolean;
  35154. /**
  35155. * Use this method to simulate a pointer up on a mesh
  35156. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35157. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35158. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35159. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35160. */
  35161. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35162. private _processPointerUp;
  35163. /**
  35164. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35165. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35166. * @returns true if the pointer was captured
  35167. */
  35168. isPointerCaptured(pointerId?: number): boolean;
  35169. /**
  35170. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35171. * @param attachUp defines if you want to attach events to pointerup
  35172. * @param attachDown defines if you want to attach events to pointerdown
  35173. * @param attachMove defines if you want to attach events to pointermove
  35174. */
  35175. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35176. /**
  35177. * Detaches all event handlers
  35178. */
  35179. detachControl(): void;
  35180. /**
  35181. * Force the value of meshUnderPointer
  35182. * @param mesh defines the mesh to use
  35183. */
  35184. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35185. /**
  35186. * Gets the mesh under the pointer
  35187. * @returns a Mesh or null if no mesh is under the pointer
  35188. */
  35189. getPointerOverMesh(): Nullable<AbstractMesh>;
  35190. }
  35191. }
  35192. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35193. /**
  35194. * Helper class used to generate session unique ID
  35195. */
  35196. export class UniqueIdGenerator {
  35197. private static _UniqueIdCounter;
  35198. /**
  35199. * Gets an unique (relatively to the current scene) Id
  35200. */
  35201. static readonly UniqueId: number;
  35202. }
  35203. }
  35204. declare module "babylonjs/Animations/animationGroup" {
  35205. import { Animatable } from "babylonjs/Animations/animatable";
  35206. import { Animation } from "babylonjs/Animations/animation";
  35207. import { Scene, IDisposable } from "babylonjs/scene";
  35208. import { Observable } from "babylonjs/Misc/observable";
  35209. import { Nullable } from "babylonjs/types";
  35210. import "babylonjs/Animations/animatable";
  35211. /**
  35212. * This class defines the direct association between an animation and a target
  35213. */
  35214. export class TargetedAnimation {
  35215. /**
  35216. * Animation to perform
  35217. */
  35218. animation: Animation;
  35219. /**
  35220. * Target to animate
  35221. */
  35222. target: any;
  35223. /**
  35224. * Serialize the object
  35225. * @returns the JSON object representing the current entity
  35226. */
  35227. serialize(): any;
  35228. }
  35229. /**
  35230. * Use this class to create coordinated animations on multiple targets
  35231. */
  35232. export class AnimationGroup implements IDisposable {
  35233. /** The name of the animation group */
  35234. name: string;
  35235. private _scene;
  35236. private _targetedAnimations;
  35237. private _animatables;
  35238. private _from;
  35239. private _to;
  35240. private _isStarted;
  35241. private _isPaused;
  35242. private _speedRatio;
  35243. private _loopAnimation;
  35244. /**
  35245. * Gets or sets the unique id of the node
  35246. */
  35247. uniqueId: number;
  35248. /**
  35249. * This observable will notify when one animation have ended
  35250. */
  35251. onAnimationEndObservable: Observable<TargetedAnimation>;
  35252. /**
  35253. * Observer raised when one animation loops
  35254. */
  35255. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35256. /**
  35257. * Observer raised when all animations have looped
  35258. */
  35259. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35260. /**
  35261. * This observable will notify when all animations have ended.
  35262. */
  35263. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35264. /**
  35265. * This observable will notify when all animations have paused.
  35266. */
  35267. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35268. /**
  35269. * This observable will notify when all animations are playing.
  35270. */
  35271. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35272. /**
  35273. * Gets the first frame
  35274. */
  35275. readonly from: number;
  35276. /**
  35277. * Gets the last frame
  35278. */
  35279. readonly to: number;
  35280. /**
  35281. * Define if the animations are started
  35282. */
  35283. readonly isStarted: boolean;
  35284. /**
  35285. * Gets a value indicating that the current group is playing
  35286. */
  35287. readonly isPlaying: boolean;
  35288. /**
  35289. * Gets or sets the speed ratio to use for all animations
  35290. */
  35291. /**
  35292. * Gets or sets the speed ratio to use for all animations
  35293. */
  35294. speedRatio: number;
  35295. /**
  35296. * Gets or sets if all animations should loop or not
  35297. */
  35298. loopAnimation: boolean;
  35299. /**
  35300. * Gets the targeted animations for this animation group
  35301. */
  35302. readonly targetedAnimations: Array<TargetedAnimation>;
  35303. /**
  35304. * returning the list of animatables controlled by this animation group.
  35305. */
  35306. readonly animatables: Array<Animatable>;
  35307. /**
  35308. * Instantiates a new Animation Group.
  35309. * This helps managing several animations at once.
  35310. * @see http://doc.babylonjs.com/how_to/group
  35311. * @param name Defines the name of the group
  35312. * @param scene Defines the scene the group belongs to
  35313. */
  35314. constructor(
  35315. /** The name of the animation group */
  35316. name: string, scene?: Nullable<Scene>);
  35317. /**
  35318. * Add an animation (with its target) in the group
  35319. * @param animation defines the animation we want to add
  35320. * @param target defines the target of the animation
  35321. * @returns the TargetedAnimation object
  35322. */
  35323. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35324. /**
  35325. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35326. * It can add constant keys at begin or end
  35327. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35328. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35329. * @returns the animation group
  35330. */
  35331. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35332. private _animationLoopCount;
  35333. private _animationLoopFlags;
  35334. private _processLoop;
  35335. /**
  35336. * Start all animations on given targets
  35337. * @param loop defines if animations must loop
  35338. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35339. * @param from defines the from key (optional)
  35340. * @param to defines the to key (optional)
  35341. * @returns the current animation group
  35342. */
  35343. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35344. /**
  35345. * Pause all animations
  35346. * @returns the animation group
  35347. */
  35348. pause(): AnimationGroup;
  35349. /**
  35350. * Play all animations to initial state
  35351. * This function will start() the animations if they were not started or will restart() them if they were paused
  35352. * @param loop defines if animations must loop
  35353. * @returns the animation group
  35354. */
  35355. play(loop?: boolean): AnimationGroup;
  35356. /**
  35357. * Reset all animations to initial state
  35358. * @returns the animation group
  35359. */
  35360. reset(): AnimationGroup;
  35361. /**
  35362. * Restart animations from key 0
  35363. * @returns the animation group
  35364. */
  35365. restart(): AnimationGroup;
  35366. /**
  35367. * Stop all animations
  35368. * @returns the animation group
  35369. */
  35370. stop(): AnimationGroup;
  35371. /**
  35372. * Set animation weight for all animatables
  35373. * @param weight defines the weight to use
  35374. * @return the animationGroup
  35375. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35376. */
  35377. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35378. /**
  35379. * Synchronize and normalize all animatables with a source animatable
  35380. * @param root defines the root animatable to synchronize with
  35381. * @return the animationGroup
  35382. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35383. */
  35384. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35385. /**
  35386. * Goes to a specific frame in this animation group
  35387. * @param frame the frame number to go to
  35388. * @return the animationGroup
  35389. */
  35390. goToFrame(frame: number): AnimationGroup;
  35391. /**
  35392. * Dispose all associated resources
  35393. */
  35394. dispose(): void;
  35395. private _checkAnimationGroupEnded;
  35396. /**
  35397. * Clone the current animation group and returns a copy
  35398. * @param newName defines the name of the new group
  35399. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35400. * @returns the new aniamtion group
  35401. */
  35402. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35403. /**
  35404. * Serializes the animationGroup to an object
  35405. * @returns Serialized object
  35406. */
  35407. serialize(): any;
  35408. /**
  35409. * Returns a new AnimationGroup object parsed from the source provided.
  35410. * @param parsedAnimationGroup defines the source
  35411. * @param scene defines the scene that will receive the animationGroup
  35412. * @returns a new AnimationGroup
  35413. */
  35414. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35415. /**
  35416. * Returns the string "AnimationGroup"
  35417. * @returns "AnimationGroup"
  35418. */
  35419. getClassName(): string;
  35420. /**
  35421. * Creates a detailled string about the object
  35422. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35423. * @returns a string representing the object
  35424. */
  35425. toString(fullDetails?: boolean): string;
  35426. }
  35427. }
  35428. declare module "babylonjs/scene" {
  35429. import { Nullable } from "babylonjs/types";
  35430. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35431. import { Observable } from "babylonjs/Misc/observable";
  35432. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35433. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35434. import { Geometry } from "babylonjs/Meshes/geometry";
  35435. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35436. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35438. import { Mesh } from "babylonjs/Meshes/mesh";
  35439. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35440. import { Bone } from "babylonjs/Bones/bone";
  35441. import { Skeleton } from "babylonjs/Bones/skeleton";
  35442. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35443. import { Camera } from "babylonjs/Cameras/camera";
  35444. import { AbstractScene } from "babylonjs/abstractScene";
  35445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35447. import { Material } from "babylonjs/Materials/material";
  35448. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35449. import { Effect } from "babylonjs/Materials/effect";
  35450. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35451. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35452. import { Light } from "babylonjs/Lights/light";
  35453. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35454. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35455. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35456. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35457. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35458. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35459. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35460. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35461. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35462. import { Engine } from "babylonjs/Engines/engine";
  35463. import { Node } from "babylonjs/node";
  35464. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35465. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35466. import { WebRequest } from "babylonjs/Misc/webRequest";
  35467. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35468. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35469. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35470. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35471. import { Plane } from "babylonjs/Maths/math.plane";
  35472. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35473. import { Ray } from "babylonjs/Culling/ray";
  35474. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35475. import { Animation } from "babylonjs/Animations/animation";
  35476. import { Animatable } from "babylonjs/Animations/animatable";
  35477. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35478. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35479. import { Collider } from "babylonjs/Collisions/collider";
  35480. /**
  35481. * Define an interface for all classes that will hold resources
  35482. */
  35483. export interface IDisposable {
  35484. /**
  35485. * Releases all held resources
  35486. */
  35487. dispose(): void;
  35488. }
  35489. /** Interface defining initialization parameters for Scene class */
  35490. export interface SceneOptions {
  35491. /**
  35492. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35493. * It will improve performance when the number of geometries becomes important.
  35494. */
  35495. useGeometryUniqueIdsMap?: boolean;
  35496. /**
  35497. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35498. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35499. */
  35500. useMaterialMeshMap?: boolean;
  35501. /**
  35502. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35503. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35504. */
  35505. useClonedMeshhMap?: boolean;
  35506. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35507. virtual?: boolean;
  35508. }
  35509. /**
  35510. * Represents a scene to be rendered by the engine.
  35511. * @see http://doc.babylonjs.com/features/scene
  35512. */
  35513. export class Scene extends AbstractScene implements IAnimatable {
  35514. /** The fog is deactivated */
  35515. static readonly FOGMODE_NONE: number;
  35516. /** The fog density is following an exponential function */
  35517. static readonly FOGMODE_EXP: number;
  35518. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35519. static readonly FOGMODE_EXP2: number;
  35520. /** The fog density is following a linear function. */
  35521. static readonly FOGMODE_LINEAR: number;
  35522. /**
  35523. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35524. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35525. */
  35526. static MinDeltaTime: number;
  35527. /**
  35528. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35530. */
  35531. static MaxDeltaTime: number;
  35532. /**
  35533. * Factory used to create the default material.
  35534. * @param name The name of the material to create
  35535. * @param scene The scene to create the material for
  35536. * @returns The default material
  35537. */
  35538. static DefaultMaterialFactory(scene: Scene): Material;
  35539. /**
  35540. * Factory used to create the a collision coordinator.
  35541. * @returns The collision coordinator
  35542. */
  35543. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35544. /** @hidden */
  35545. _inputManager: InputManager;
  35546. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35547. cameraToUseForPointers: Nullable<Camera>;
  35548. /** @hidden */
  35549. readonly _isScene: boolean;
  35550. /**
  35551. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35552. */
  35553. autoClear: boolean;
  35554. /**
  35555. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35556. */
  35557. autoClearDepthAndStencil: boolean;
  35558. /**
  35559. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35560. */
  35561. clearColor: Color4;
  35562. /**
  35563. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35564. */
  35565. ambientColor: Color3;
  35566. /**
  35567. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35568. * It should only be one of the following (if not the default embedded one):
  35569. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35570. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35571. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35572. * The material properties need to be setup according to the type of texture in use.
  35573. */
  35574. environmentBRDFTexture: BaseTexture;
  35575. /** @hidden */
  35576. protected _environmentTexture: Nullable<BaseTexture>;
  35577. /**
  35578. * Texture used in all pbr material as the reflection texture.
  35579. * As in the majority of the scene they are the same (exception for multi room and so on),
  35580. * this is easier to reference from here than from all the materials.
  35581. */
  35582. /**
  35583. * Texture used in all pbr material as the reflection texture.
  35584. * As in the majority of the scene they are the same (exception for multi room and so on),
  35585. * this is easier to set here than in all the materials.
  35586. */
  35587. environmentTexture: Nullable<BaseTexture>;
  35588. /** @hidden */
  35589. protected _environmentIntensity: number;
  35590. /**
  35591. * Intensity of the environment in all pbr material.
  35592. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35593. * As in the majority of the scene they are the same (exception for multi room and so on),
  35594. * this is easier to reference from here than from all the materials.
  35595. */
  35596. /**
  35597. * Intensity of the environment in all pbr material.
  35598. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35599. * As in the majority of the scene they are the same (exception for multi room and so on),
  35600. * this is easier to set here than in all the materials.
  35601. */
  35602. environmentIntensity: number;
  35603. /** @hidden */
  35604. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35605. /**
  35606. * Default image processing configuration used either in the rendering
  35607. * Forward main pass or through the imageProcessingPostProcess if present.
  35608. * As in the majority of the scene they are the same (exception for multi camera),
  35609. * this is easier to reference from here than from all the materials and post process.
  35610. *
  35611. * No setter as we it is a shared configuration, you can set the values instead.
  35612. */
  35613. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  35614. private _forceWireframe;
  35615. /**
  35616. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35617. */
  35618. forceWireframe: boolean;
  35619. private _forcePointsCloud;
  35620. /**
  35621. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35622. */
  35623. forcePointsCloud: boolean;
  35624. /**
  35625. * Gets or sets the active clipplane 1
  35626. */
  35627. clipPlane: Nullable<Plane>;
  35628. /**
  35629. * Gets or sets the active clipplane 2
  35630. */
  35631. clipPlane2: Nullable<Plane>;
  35632. /**
  35633. * Gets or sets the active clipplane 3
  35634. */
  35635. clipPlane3: Nullable<Plane>;
  35636. /**
  35637. * Gets or sets the active clipplane 4
  35638. */
  35639. clipPlane4: Nullable<Plane>;
  35640. /**
  35641. * Gets or sets a boolean indicating if animations are enabled
  35642. */
  35643. animationsEnabled: boolean;
  35644. private _animationPropertiesOverride;
  35645. /**
  35646. * Gets or sets the animation properties override
  35647. */
  35648. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  35649. /**
  35650. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35651. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35652. */
  35653. useConstantAnimationDeltaTime: boolean;
  35654. /**
  35655. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35656. * Please note that it requires to run a ray cast through the scene on every frame
  35657. */
  35658. constantlyUpdateMeshUnderPointer: boolean;
  35659. /**
  35660. * Defines the HTML cursor to use when hovering over interactive elements
  35661. */
  35662. hoverCursor: string;
  35663. /**
  35664. * Defines the HTML default cursor to use (empty by default)
  35665. */
  35666. defaultCursor: string;
  35667. /**
  35668. * Defines wether cursors are handled by the scene.
  35669. */
  35670. doNotHandleCursors: boolean;
  35671. /**
  35672. * This is used to call preventDefault() on pointer down
  35673. * in order to block unwanted artifacts like system double clicks
  35674. */
  35675. preventDefaultOnPointerDown: boolean;
  35676. /**
  35677. * This is used to call preventDefault() on pointer up
  35678. * in order to block unwanted artifacts like system double clicks
  35679. */
  35680. preventDefaultOnPointerUp: boolean;
  35681. /**
  35682. * Gets or sets user defined metadata
  35683. */
  35684. metadata: any;
  35685. /**
  35686. * For internal use only. Please do not use.
  35687. */
  35688. reservedDataStore: any;
  35689. /**
  35690. * Gets the name of the plugin used to load this scene (null by default)
  35691. */
  35692. loadingPluginName: string;
  35693. /**
  35694. * Use this array to add regular expressions used to disable offline support for specific urls
  35695. */
  35696. disableOfflineSupportExceptionRules: RegExp[];
  35697. /**
  35698. * An event triggered when the scene is disposed.
  35699. */
  35700. onDisposeObservable: Observable<Scene>;
  35701. private _onDisposeObserver;
  35702. /** Sets a function to be executed when this scene is disposed. */
  35703. onDispose: () => void;
  35704. /**
  35705. * An event triggered before rendering the scene (right after animations and physics)
  35706. */
  35707. onBeforeRenderObservable: Observable<Scene>;
  35708. private _onBeforeRenderObserver;
  35709. /** Sets a function to be executed before rendering this scene */
  35710. beforeRender: Nullable<() => void>;
  35711. /**
  35712. * An event triggered after rendering the scene
  35713. */
  35714. onAfterRenderObservable: Observable<Scene>;
  35715. /**
  35716. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35717. */
  35718. onAfterRenderCameraObservable: Observable<Camera>;
  35719. private _onAfterRenderObserver;
  35720. /** Sets a function to be executed after rendering this scene */
  35721. afterRender: Nullable<() => void>;
  35722. /**
  35723. * An event triggered before animating the scene
  35724. */
  35725. onBeforeAnimationsObservable: Observable<Scene>;
  35726. /**
  35727. * An event triggered after animations processing
  35728. */
  35729. onAfterAnimationsObservable: Observable<Scene>;
  35730. /**
  35731. * An event triggered before draw calls are ready to be sent
  35732. */
  35733. onBeforeDrawPhaseObservable: Observable<Scene>;
  35734. /**
  35735. * An event triggered after draw calls have been sent
  35736. */
  35737. onAfterDrawPhaseObservable: Observable<Scene>;
  35738. /**
  35739. * An event triggered when the scene is ready
  35740. */
  35741. onReadyObservable: Observable<Scene>;
  35742. /**
  35743. * An event triggered before rendering a camera
  35744. */
  35745. onBeforeCameraRenderObservable: Observable<Camera>;
  35746. private _onBeforeCameraRenderObserver;
  35747. /** Sets a function to be executed before rendering a camera*/
  35748. beforeCameraRender: () => void;
  35749. /**
  35750. * An event triggered after rendering a camera
  35751. */
  35752. onAfterCameraRenderObservable: Observable<Camera>;
  35753. private _onAfterCameraRenderObserver;
  35754. /** Sets a function to be executed after rendering a camera*/
  35755. afterCameraRender: () => void;
  35756. /**
  35757. * An event triggered when active meshes evaluation is about to start
  35758. */
  35759. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35760. /**
  35761. * An event triggered when active meshes evaluation is done
  35762. */
  35763. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35764. /**
  35765. * An event triggered when particles rendering is about to start
  35766. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35767. */
  35768. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35769. /**
  35770. * An event triggered when particles rendering is done
  35771. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35772. */
  35773. onAfterParticlesRenderingObservable: Observable<Scene>;
  35774. /**
  35775. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35776. */
  35777. onDataLoadedObservable: Observable<Scene>;
  35778. /**
  35779. * An event triggered when a camera is created
  35780. */
  35781. onNewCameraAddedObservable: Observable<Camera>;
  35782. /**
  35783. * An event triggered when a camera is removed
  35784. */
  35785. onCameraRemovedObservable: Observable<Camera>;
  35786. /**
  35787. * An event triggered when a light is created
  35788. */
  35789. onNewLightAddedObservable: Observable<Light>;
  35790. /**
  35791. * An event triggered when a light is removed
  35792. */
  35793. onLightRemovedObservable: Observable<Light>;
  35794. /**
  35795. * An event triggered when a geometry is created
  35796. */
  35797. onNewGeometryAddedObservable: Observable<Geometry>;
  35798. /**
  35799. * An event triggered when a geometry is removed
  35800. */
  35801. onGeometryRemovedObservable: Observable<Geometry>;
  35802. /**
  35803. * An event triggered when a transform node is created
  35804. */
  35805. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35806. /**
  35807. * An event triggered when a transform node is removed
  35808. */
  35809. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35810. /**
  35811. * An event triggered when a mesh is created
  35812. */
  35813. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35814. /**
  35815. * An event triggered when a mesh is removed
  35816. */
  35817. onMeshRemovedObservable: Observable<AbstractMesh>;
  35818. /**
  35819. * An event triggered when a skeleton is created
  35820. */
  35821. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35822. /**
  35823. * An event triggered when a skeleton is removed
  35824. */
  35825. onSkeletonRemovedObservable: Observable<Skeleton>;
  35826. /**
  35827. * An event triggered when a material is created
  35828. */
  35829. onNewMaterialAddedObservable: Observable<Material>;
  35830. /**
  35831. * An event triggered when a material is removed
  35832. */
  35833. onMaterialRemovedObservable: Observable<Material>;
  35834. /**
  35835. * An event triggered when a texture is created
  35836. */
  35837. onNewTextureAddedObservable: Observable<BaseTexture>;
  35838. /**
  35839. * An event triggered when a texture is removed
  35840. */
  35841. onTextureRemovedObservable: Observable<BaseTexture>;
  35842. /**
  35843. * An event triggered when render targets are about to be rendered
  35844. * Can happen multiple times per frame.
  35845. */
  35846. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35847. /**
  35848. * An event triggered when render targets were rendered.
  35849. * Can happen multiple times per frame.
  35850. */
  35851. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35852. /**
  35853. * An event triggered before calculating deterministic simulation step
  35854. */
  35855. onBeforeStepObservable: Observable<Scene>;
  35856. /**
  35857. * An event triggered after calculating deterministic simulation step
  35858. */
  35859. onAfterStepObservable: Observable<Scene>;
  35860. /**
  35861. * An event triggered when the activeCamera property is updated
  35862. */
  35863. onActiveCameraChanged: Observable<Scene>;
  35864. /**
  35865. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35866. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35867. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  35868. */
  35869. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35870. /**
  35871. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35872. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35873. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  35874. */
  35875. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35876. /**
  35877. * This Observable will when a mesh has been imported into the scene.
  35878. */
  35879. onMeshImportedObservable: Observable<AbstractMesh>;
  35880. /**
  35881. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35882. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35883. */
  35884. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35885. /** @hidden */
  35886. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35887. /**
  35888. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35889. */
  35890. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35891. /**
  35892. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35893. */
  35894. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35895. /**
  35896. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35897. */
  35898. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35899. /** Callback called when a pointer move is detected */
  35900. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35901. /** Callback called when a pointer down is detected */
  35902. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35903. /** Callback called when a pointer up is detected */
  35904. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35905. /** Callback called when a pointer pick is detected */
  35906. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35907. /**
  35908. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  35909. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35910. */
  35911. onPrePointerObservable: Observable<PointerInfoPre>;
  35912. /**
  35913. * Observable event triggered each time an input event is received from the rendering canvas
  35914. */
  35915. onPointerObservable: Observable<PointerInfo>;
  35916. /**
  35917. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35918. */
  35919. readonly unTranslatedPointer: Vector2;
  35920. /**
  35921. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35922. */
  35923. static DragMovementThreshold: number;
  35924. /**
  35925. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35926. */
  35927. static LongPressDelay: number;
  35928. /**
  35929. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35930. */
  35931. static DoubleClickDelay: number;
  35932. /** If you need to check double click without raising a single click at first click, enable this flag */
  35933. static ExclusiveDoubleClickMode: boolean;
  35934. /** @hidden */
  35935. _mirroredCameraPosition: Nullable<Vector3>;
  35936. /**
  35937. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35938. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35939. */
  35940. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35941. /**
  35942. * Observable event triggered each time an keyboard event is received from the hosting window
  35943. */
  35944. onKeyboardObservable: Observable<KeyboardInfo>;
  35945. private _useRightHandedSystem;
  35946. /**
  35947. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35948. */
  35949. useRightHandedSystem: boolean;
  35950. private _timeAccumulator;
  35951. private _currentStepId;
  35952. private _currentInternalStep;
  35953. /**
  35954. * Sets the step Id used by deterministic lock step
  35955. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35956. * @param newStepId defines the step Id
  35957. */
  35958. setStepId(newStepId: number): void;
  35959. /**
  35960. * Gets the step Id used by deterministic lock step
  35961. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35962. * @returns the step Id
  35963. */
  35964. getStepId(): number;
  35965. /**
  35966. * Gets the internal step used by deterministic lock step
  35967. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35968. * @returns the internal step
  35969. */
  35970. getInternalStep(): number;
  35971. private _fogEnabled;
  35972. /**
  35973. * Gets or sets a boolean indicating if fog is enabled on this scene
  35974. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35975. * (Default is true)
  35976. */
  35977. fogEnabled: boolean;
  35978. private _fogMode;
  35979. /**
  35980. * Gets or sets the fog mode to use
  35981. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35982. * | mode | value |
  35983. * | --- | --- |
  35984. * | FOGMODE_NONE | 0 |
  35985. * | FOGMODE_EXP | 1 |
  35986. * | FOGMODE_EXP2 | 2 |
  35987. * | FOGMODE_LINEAR | 3 |
  35988. */
  35989. fogMode: number;
  35990. /**
  35991. * Gets or sets the fog color to use
  35992. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35993. * (Default is Color3(0.2, 0.2, 0.3))
  35994. */
  35995. fogColor: Color3;
  35996. /**
  35997. * Gets or sets the fog density to use
  35998. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35999. * (Default is 0.1)
  36000. */
  36001. fogDensity: number;
  36002. /**
  36003. * Gets or sets the fog start distance to use
  36004. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36005. * (Default is 0)
  36006. */
  36007. fogStart: number;
  36008. /**
  36009. * Gets or sets the fog end distance to use
  36010. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36011. * (Default is 1000)
  36012. */
  36013. fogEnd: number;
  36014. private _shadowsEnabled;
  36015. /**
  36016. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36017. */
  36018. shadowsEnabled: boolean;
  36019. private _lightsEnabled;
  36020. /**
  36021. * Gets or sets a boolean indicating if lights are enabled on this scene
  36022. */
  36023. lightsEnabled: boolean;
  36024. /** All of the active cameras added to this scene. */
  36025. activeCameras: Camera[];
  36026. /** @hidden */
  36027. _activeCamera: Nullable<Camera>;
  36028. /** Gets or sets the current active camera */
  36029. activeCamera: Nullable<Camera>;
  36030. private _defaultMaterial;
  36031. /** The default material used on meshes when no material is affected */
  36032. /** The default material used on meshes when no material is affected */
  36033. defaultMaterial: Material;
  36034. private _texturesEnabled;
  36035. /**
  36036. * Gets or sets a boolean indicating if textures are enabled on this scene
  36037. */
  36038. texturesEnabled: boolean;
  36039. /**
  36040. * Gets or sets a boolean indicating if particles are enabled on this scene
  36041. */
  36042. particlesEnabled: boolean;
  36043. /**
  36044. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36045. */
  36046. spritesEnabled: boolean;
  36047. private _skeletonsEnabled;
  36048. /**
  36049. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36050. */
  36051. skeletonsEnabled: boolean;
  36052. /**
  36053. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36054. */
  36055. lensFlaresEnabled: boolean;
  36056. /**
  36057. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36058. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36059. */
  36060. collisionsEnabled: boolean;
  36061. private _collisionCoordinator;
  36062. /** @hidden */
  36063. readonly collisionCoordinator: ICollisionCoordinator;
  36064. /**
  36065. * Defines the gravity applied to this scene (used only for collisions)
  36066. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36067. */
  36068. gravity: Vector3;
  36069. /**
  36070. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36071. */
  36072. postProcessesEnabled: boolean;
  36073. /**
  36074. * The list of postprocesses added to the scene
  36075. */
  36076. postProcesses: PostProcess[];
  36077. /**
  36078. * Gets the current postprocess manager
  36079. */
  36080. postProcessManager: PostProcessManager;
  36081. /**
  36082. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36083. */
  36084. renderTargetsEnabled: boolean;
  36085. /**
  36086. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36087. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36088. */
  36089. dumpNextRenderTargets: boolean;
  36090. /**
  36091. * The list of user defined render targets added to the scene
  36092. */
  36093. customRenderTargets: RenderTargetTexture[];
  36094. /**
  36095. * Defines if texture loading must be delayed
  36096. * If true, textures will only be loaded when they need to be rendered
  36097. */
  36098. useDelayedTextureLoading: boolean;
  36099. /**
  36100. * Gets the list of meshes imported to the scene through SceneLoader
  36101. */
  36102. importedMeshesFiles: String[];
  36103. /**
  36104. * Gets or sets a boolean indicating if probes are enabled on this scene
  36105. */
  36106. probesEnabled: boolean;
  36107. /**
  36108. * Gets or sets the current offline provider to use to store scene data
  36109. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36110. */
  36111. offlineProvider: IOfflineProvider;
  36112. /**
  36113. * Gets or sets the action manager associated with the scene
  36114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36115. */
  36116. actionManager: AbstractActionManager;
  36117. private _meshesForIntersections;
  36118. /**
  36119. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36120. */
  36121. proceduralTexturesEnabled: boolean;
  36122. private _engine;
  36123. private _totalVertices;
  36124. /** @hidden */
  36125. _activeIndices: PerfCounter;
  36126. /** @hidden */
  36127. _activeParticles: PerfCounter;
  36128. /** @hidden */
  36129. _activeBones: PerfCounter;
  36130. private _animationRatio;
  36131. /** @hidden */
  36132. _animationTimeLast: number;
  36133. /** @hidden */
  36134. _animationTime: number;
  36135. /**
  36136. * Gets or sets a general scale for animation speed
  36137. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36138. */
  36139. animationTimeScale: number;
  36140. /** @hidden */
  36141. _cachedMaterial: Nullable<Material>;
  36142. /** @hidden */
  36143. _cachedEffect: Nullable<Effect>;
  36144. /** @hidden */
  36145. _cachedVisibility: Nullable<number>;
  36146. private _renderId;
  36147. private _frameId;
  36148. private _executeWhenReadyTimeoutId;
  36149. private _intermediateRendering;
  36150. private _viewUpdateFlag;
  36151. private _projectionUpdateFlag;
  36152. /** @hidden */
  36153. _toBeDisposed: Nullable<IDisposable>[];
  36154. private _activeRequests;
  36155. /** @hidden */
  36156. _pendingData: any[];
  36157. private _isDisposed;
  36158. /**
  36159. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36160. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36161. */
  36162. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36163. private _activeMeshes;
  36164. private _processedMaterials;
  36165. private _renderTargets;
  36166. /** @hidden */
  36167. _activeParticleSystems: SmartArray<IParticleSystem>;
  36168. private _activeSkeletons;
  36169. private _softwareSkinnedMeshes;
  36170. private _renderingManager;
  36171. /** @hidden */
  36172. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36173. private _transformMatrix;
  36174. private _sceneUbo;
  36175. /** @hidden */
  36176. _viewMatrix: Matrix;
  36177. private _projectionMatrix;
  36178. /** @hidden */
  36179. _forcedViewPosition: Nullable<Vector3>;
  36180. /** @hidden */
  36181. _frustumPlanes: Plane[];
  36182. /**
  36183. * Gets the list of frustum planes (built from the active camera)
  36184. */
  36185. readonly frustumPlanes: Plane[];
  36186. /**
  36187. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36188. * This is useful if there are more lights that the maximum simulteanous authorized
  36189. */
  36190. requireLightSorting: boolean;
  36191. /** @hidden */
  36192. readonly useMaterialMeshMap: boolean;
  36193. /** @hidden */
  36194. readonly useClonedMeshhMap: boolean;
  36195. private _externalData;
  36196. private _uid;
  36197. /**
  36198. * @hidden
  36199. * Backing store of defined scene components.
  36200. */
  36201. _components: ISceneComponent[];
  36202. /**
  36203. * @hidden
  36204. * Backing store of defined scene components.
  36205. */
  36206. _serializableComponents: ISceneSerializableComponent[];
  36207. /**
  36208. * List of components to register on the next registration step.
  36209. */
  36210. private _transientComponents;
  36211. /**
  36212. * Registers the transient components if needed.
  36213. */
  36214. private _registerTransientComponents;
  36215. /**
  36216. * @hidden
  36217. * Add a component to the scene.
  36218. * Note that the ccomponent could be registered on th next frame if this is called after
  36219. * the register component stage.
  36220. * @param component Defines the component to add to the scene
  36221. */
  36222. _addComponent(component: ISceneComponent): void;
  36223. /**
  36224. * @hidden
  36225. * Gets a component from the scene.
  36226. * @param name defines the name of the component to retrieve
  36227. * @returns the component or null if not present
  36228. */
  36229. _getComponent(name: string): Nullable<ISceneComponent>;
  36230. /**
  36231. * @hidden
  36232. * Defines the actions happening before camera updates.
  36233. */
  36234. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36235. /**
  36236. * @hidden
  36237. * Defines the actions happening before clear the canvas.
  36238. */
  36239. _beforeClearStage: Stage<SimpleStageAction>;
  36240. /**
  36241. * @hidden
  36242. * Defines the actions when collecting render targets for the frame.
  36243. */
  36244. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36245. /**
  36246. * @hidden
  36247. * Defines the actions happening for one camera in the frame.
  36248. */
  36249. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36250. /**
  36251. * @hidden
  36252. * Defines the actions happening during the per mesh ready checks.
  36253. */
  36254. _isReadyForMeshStage: Stage<MeshStageAction>;
  36255. /**
  36256. * @hidden
  36257. * Defines the actions happening before evaluate active mesh checks.
  36258. */
  36259. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36260. /**
  36261. * @hidden
  36262. * Defines the actions happening during the evaluate sub mesh checks.
  36263. */
  36264. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36265. /**
  36266. * @hidden
  36267. * Defines the actions happening during the active mesh stage.
  36268. */
  36269. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36270. /**
  36271. * @hidden
  36272. * Defines the actions happening during the per camera render target step.
  36273. */
  36274. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36275. /**
  36276. * @hidden
  36277. * Defines the actions happening just before the active camera is drawing.
  36278. */
  36279. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36280. /**
  36281. * @hidden
  36282. * Defines the actions happening just before a render target is drawing.
  36283. */
  36284. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36285. /**
  36286. * @hidden
  36287. * Defines the actions happening just before a rendering group is drawing.
  36288. */
  36289. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36290. /**
  36291. * @hidden
  36292. * Defines the actions happening just before a mesh is drawing.
  36293. */
  36294. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36295. /**
  36296. * @hidden
  36297. * Defines the actions happening just after a mesh has been drawn.
  36298. */
  36299. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36300. /**
  36301. * @hidden
  36302. * Defines the actions happening just after a rendering group has been drawn.
  36303. */
  36304. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36305. /**
  36306. * @hidden
  36307. * Defines the actions happening just after the active camera has been drawn.
  36308. */
  36309. _afterCameraDrawStage: Stage<CameraStageAction>;
  36310. /**
  36311. * @hidden
  36312. * Defines the actions happening just after a render target has been drawn.
  36313. */
  36314. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36315. /**
  36316. * @hidden
  36317. * Defines the actions happening just after rendering all cameras and computing intersections.
  36318. */
  36319. _afterRenderStage: Stage<SimpleStageAction>;
  36320. /**
  36321. * @hidden
  36322. * Defines the actions happening when a pointer move event happens.
  36323. */
  36324. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36325. /**
  36326. * @hidden
  36327. * Defines the actions happening when a pointer down event happens.
  36328. */
  36329. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36330. /**
  36331. * @hidden
  36332. * Defines the actions happening when a pointer up event happens.
  36333. */
  36334. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36335. /**
  36336. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36337. */
  36338. private geometriesByUniqueId;
  36339. /**
  36340. * Creates a new Scene
  36341. * @param engine defines the engine to use to render this scene
  36342. * @param options defines the scene options
  36343. */
  36344. constructor(engine: Engine, options?: SceneOptions);
  36345. /**
  36346. * Gets a string idenfifying the name of the class
  36347. * @returns "Scene" string
  36348. */
  36349. getClassName(): string;
  36350. private _defaultMeshCandidates;
  36351. /**
  36352. * @hidden
  36353. */
  36354. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36355. private _defaultSubMeshCandidates;
  36356. /**
  36357. * @hidden
  36358. */
  36359. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36360. /**
  36361. * Sets the default candidate providers for the scene.
  36362. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36363. * and getCollidingSubMeshCandidates to their default function
  36364. */
  36365. setDefaultCandidateProviders(): void;
  36366. /**
  36367. * Gets the mesh that is currently under the pointer
  36368. */
  36369. readonly meshUnderPointer: Nullable<AbstractMesh>;
  36370. /**
  36371. * Gets or sets the current on-screen X position of the pointer
  36372. */
  36373. pointerX: number;
  36374. /**
  36375. * Gets or sets the current on-screen Y position of the pointer
  36376. */
  36377. pointerY: number;
  36378. /**
  36379. * Gets the cached material (ie. the latest rendered one)
  36380. * @returns the cached material
  36381. */
  36382. getCachedMaterial(): Nullable<Material>;
  36383. /**
  36384. * Gets the cached effect (ie. the latest rendered one)
  36385. * @returns the cached effect
  36386. */
  36387. getCachedEffect(): Nullable<Effect>;
  36388. /**
  36389. * Gets the cached visibility state (ie. the latest rendered one)
  36390. * @returns the cached visibility state
  36391. */
  36392. getCachedVisibility(): Nullable<number>;
  36393. /**
  36394. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36395. * @param material defines the current material
  36396. * @param effect defines the current effect
  36397. * @param visibility defines the current visibility state
  36398. * @returns true if one parameter is not cached
  36399. */
  36400. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36401. /**
  36402. * Gets the engine associated with the scene
  36403. * @returns an Engine
  36404. */
  36405. getEngine(): Engine;
  36406. /**
  36407. * Gets the total number of vertices rendered per frame
  36408. * @returns the total number of vertices rendered per frame
  36409. */
  36410. getTotalVertices(): number;
  36411. /**
  36412. * Gets the performance counter for total vertices
  36413. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36414. */
  36415. readonly totalVerticesPerfCounter: PerfCounter;
  36416. /**
  36417. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36418. * @returns the total number of active indices rendered per frame
  36419. */
  36420. getActiveIndices(): number;
  36421. /**
  36422. * Gets the performance counter for active indices
  36423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36424. */
  36425. readonly totalActiveIndicesPerfCounter: PerfCounter;
  36426. /**
  36427. * Gets the total number of active particles rendered per frame
  36428. * @returns the total number of active particles rendered per frame
  36429. */
  36430. getActiveParticles(): number;
  36431. /**
  36432. * Gets the performance counter for active particles
  36433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36434. */
  36435. readonly activeParticlesPerfCounter: PerfCounter;
  36436. /**
  36437. * Gets the total number of active bones rendered per frame
  36438. * @returns the total number of active bones rendered per frame
  36439. */
  36440. getActiveBones(): number;
  36441. /**
  36442. * Gets the performance counter for active bones
  36443. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36444. */
  36445. readonly activeBonesPerfCounter: PerfCounter;
  36446. /**
  36447. * Gets the array of active meshes
  36448. * @returns an array of AbstractMesh
  36449. */
  36450. getActiveMeshes(): SmartArray<AbstractMesh>;
  36451. /**
  36452. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36453. * @returns a number
  36454. */
  36455. getAnimationRatio(): number;
  36456. /**
  36457. * Gets an unique Id for the current render phase
  36458. * @returns a number
  36459. */
  36460. getRenderId(): number;
  36461. /**
  36462. * Gets an unique Id for the current frame
  36463. * @returns a number
  36464. */
  36465. getFrameId(): number;
  36466. /** Call this function if you want to manually increment the render Id*/
  36467. incrementRenderId(): void;
  36468. private _createUbo;
  36469. /**
  36470. * Use this method to simulate a pointer move on a mesh
  36471. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36472. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36473. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36474. * @returns the current scene
  36475. */
  36476. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36477. /**
  36478. * Use this method to simulate a pointer down on a mesh
  36479. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36480. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36481. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36482. * @returns the current scene
  36483. */
  36484. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36485. /**
  36486. * Use this method to simulate a pointer up on a mesh
  36487. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36488. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36489. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36490. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36491. * @returns the current scene
  36492. */
  36493. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36494. /**
  36495. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36496. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36497. * @returns true if the pointer was captured
  36498. */
  36499. isPointerCaptured(pointerId?: number): boolean;
  36500. /**
  36501. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36502. * @param attachUp defines if you want to attach events to pointerup
  36503. * @param attachDown defines if you want to attach events to pointerdown
  36504. * @param attachMove defines if you want to attach events to pointermove
  36505. */
  36506. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36507. /** Detaches all event handlers*/
  36508. detachControl(): void;
  36509. /**
  36510. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36511. * Delay loaded resources are not taking in account
  36512. * @return true if all required resources are ready
  36513. */
  36514. isReady(): boolean;
  36515. /** Resets all cached information relative to material (including effect and visibility) */
  36516. resetCachedMaterial(): void;
  36517. /**
  36518. * Registers a function to be called before every frame render
  36519. * @param func defines the function to register
  36520. */
  36521. registerBeforeRender(func: () => void): void;
  36522. /**
  36523. * Unregisters a function called before every frame render
  36524. * @param func defines the function to unregister
  36525. */
  36526. unregisterBeforeRender(func: () => void): void;
  36527. /**
  36528. * Registers a function to be called after every frame render
  36529. * @param func defines the function to register
  36530. */
  36531. registerAfterRender(func: () => void): void;
  36532. /**
  36533. * Unregisters a function called after every frame render
  36534. * @param func defines the function to unregister
  36535. */
  36536. unregisterAfterRender(func: () => void): void;
  36537. private _executeOnceBeforeRender;
  36538. /**
  36539. * The provided function will run before render once and will be disposed afterwards.
  36540. * A timeout delay can be provided so that the function will be executed in N ms.
  36541. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36542. * @param func The function to be executed.
  36543. * @param timeout optional delay in ms
  36544. */
  36545. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36546. /** @hidden */
  36547. _addPendingData(data: any): void;
  36548. /** @hidden */
  36549. _removePendingData(data: any): void;
  36550. /**
  36551. * Returns the number of items waiting to be loaded
  36552. * @returns the number of items waiting to be loaded
  36553. */
  36554. getWaitingItemsCount(): number;
  36555. /**
  36556. * Returns a boolean indicating if the scene is still loading data
  36557. */
  36558. readonly isLoading: boolean;
  36559. /**
  36560. * Registers a function to be executed when the scene is ready
  36561. * @param {Function} func - the function to be executed
  36562. */
  36563. executeWhenReady(func: () => void): void;
  36564. /**
  36565. * Returns a promise that resolves when the scene is ready
  36566. * @returns A promise that resolves when the scene is ready
  36567. */
  36568. whenReadyAsync(): Promise<void>;
  36569. /** @hidden */
  36570. _checkIsReady(): void;
  36571. /**
  36572. * Gets all animatable attached to the scene
  36573. */
  36574. readonly animatables: Animatable[];
  36575. /**
  36576. * Resets the last animation time frame.
  36577. * Useful to override when animations start running when loading a scene for the first time.
  36578. */
  36579. resetLastAnimationTimeFrame(): void;
  36580. /**
  36581. * Gets the current view matrix
  36582. * @returns a Matrix
  36583. */
  36584. getViewMatrix(): Matrix;
  36585. /**
  36586. * Gets the current projection matrix
  36587. * @returns a Matrix
  36588. */
  36589. getProjectionMatrix(): Matrix;
  36590. /**
  36591. * Gets the current transform matrix
  36592. * @returns a Matrix made of View * Projection
  36593. */
  36594. getTransformMatrix(): Matrix;
  36595. /**
  36596. * Sets the current transform matrix
  36597. * @param viewL defines the View matrix to use
  36598. * @param projectionL defines the Projection matrix to use
  36599. * @param viewR defines the right View matrix to use (if provided)
  36600. * @param projectionR defines the right Projection matrix to use (if provided)
  36601. */
  36602. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36603. /**
  36604. * Gets the uniform buffer used to store scene data
  36605. * @returns a UniformBuffer
  36606. */
  36607. getSceneUniformBuffer(): UniformBuffer;
  36608. /**
  36609. * Gets an unique (relatively to the current scene) Id
  36610. * @returns an unique number for the scene
  36611. */
  36612. getUniqueId(): number;
  36613. /**
  36614. * Add a mesh to the list of scene's meshes
  36615. * @param newMesh defines the mesh to add
  36616. * @param recursive if all child meshes should also be added to the scene
  36617. */
  36618. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36619. /**
  36620. * Remove a mesh for the list of scene's meshes
  36621. * @param toRemove defines the mesh to remove
  36622. * @param recursive if all child meshes should also be removed from the scene
  36623. * @returns the index where the mesh was in the mesh list
  36624. */
  36625. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36626. /**
  36627. * Add a transform node to the list of scene's transform nodes
  36628. * @param newTransformNode defines the transform node to add
  36629. */
  36630. addTransformNode(newTransformNode: TransformNode): void;
  36631. /**
  36632. * Remove a transform node for the list of scene's transform nodes
  36633. * @param toRemove defines the transform node to remove
  36634. * @returns the index where the transform node was in the transform node list
  36635. */
  36636. removeTransformNode(toRemove: TransformNode): number;
  36637. /**
  36638. * Remove a skeleton for the list of scene's skeletons
  36639. * @param toRemove defines the skeleton to remove
  36640. * @returns the index where the skeleton was in the skeleton list
  36641. */
  36642. removeSkeleton(toRemove: Skeleton): number;
  36643. /**
  36644. * Remove a morph target for the list of scene's morph targets
  36645. * @param toRemove defines the morph target to remove
  36646. * @returns the index where the morph target was in the morph target list
  36647. */
  36648. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36649. /**
  36650. * Remove a light for the list of scene's lights
  36651. * @param toRemove defines the light to remove
  36652. * @returns the index where the light was in the light list
  36653. */
  36654. removeLight(toRemove: Light): number;
  36655. /**
  36656. * Remove a camera for the list of scene's cameras
  36657. * @param toRemove defines the camera to remove
  36658. * @returns the index where the camera was in the camera list
  36659. */
  36660. removeCamera(toRemove: Camera): number;
  36661. /**
  36662. * Remove a particle system for the list of scene's particle systems
  36663. * @param toRemove defines the particle system to remove
  36664. * @returns the index where the particle system was in the particle system list
  36665. */
  36666. removeParticleSystem(toRemove: IParticleSystem): number;
  36667. /**
  36668. * Remove a animation for the list of scene's animations
  36669. * @param toRemove defines the animation to remove
  36670. * @returns the index where the animation was in the animation list
  36671. */
  36672. removeAnimation(toRemove: Animation): number;
  36673. /**
  36674. * Will stop the animation of the given target
  36675. * @param target - the target
  36676. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36677. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  36678. */
  36679. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36680. /**
  36681. * Removes the given animation group from this scene.
  36682. * @param toRemove The animation group to remove
  36683. * @returns The index of the removed animation group
  36684. */
  36685. removeAnimationGroup(toRemove: AnimationGroup): number;
  36686. /**
  36687. * Removes the given multi-material from this scene.
  36688. * @param toRemove The multi-material to remove
  36689. * @returns The index of the removed multi-material
  36690. */
  36691. removeMultiMaterial(toRemove: MultiMaterial): number;
  36692. /**
  36693. * Removes the given material from this scene.
  36694. * @param toRemove The material to remove
  36695. * @returns The index of the removed material
  36696. */
  36697. removeMaterial(toRemove: Material): number;
  36698. /**
  36699. * Removes the given action manager from this scene.
  36700. * @param toRemove The action manager to remove
  36701. * @returns The index of the removed action manager
  36702. */
  36703. removeActionManager(toRemove: AbstractActionManager): number;
  36704. /**
  36705. * Removes the given texture from this scene.
  36706. * @param toRemove The texture to remove
  36707. * @returns The index of the removed texture
  36708. */
  36709. removeTexture(toRemove: BaseTexture): number;
  36710. /**
  36711. * Adds the given light to this scene
  36712. * @param newLight The light to add
  36713. */
  36714. addLight(newLight: Light): void;
  36715. /**
  36716. * Sorts the list list based on light priorities
  36717. */
  36718. sortLightsByPriority(): void;
  36719. /**
  36720. * Adds the given camera to this scene
  36721. * @param newCamera The camera to add
  36722. */
  36723. addCamera(newCamera: Camera): void;
  36724. /**
  36725. * Adds the given skeleton to this scene
  36726. * @param newSkeleton The skeleton to add
  36727. */
  36728. addSkeleton(newSkeleton: Skeleton): void;
  36729. /**
  36730. * Adds the given particle system to this scene
  36731. * @param newParticleSystem The particle system to add
  36732. */
  36733. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36734. /**
  36735. * Adds the given animation to this scene
  36736. * @param newAnimation The animation to add
  36737. */
  36738. addAnimation(newAnimation: Animation): void;
  36739. /**
  36740. * Adds the given animation group to this scene.
  36741. * @param newAnimationGroup The animation group to add
  36742. */
  36743. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36744. /**
  36745. * Adds the given multi-material to this scene
  36746. * @param newMultiMaterial The multi-material to add
  36747. */
  36748. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36749. /**
  36750. * Adds the given material to this scene
  36751. * @param newMaterial The material to add
  36752. */
  36753. addMaterial(newMaterial: Material): void;
  36754. /**
  36755. * Adds the given morph target to this scene
  36756. * @param newMorphTargetManager The morph target to add
  36757. */
  36758. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36759. /**
  36760. * Adds the given geometry to this scene
  36761. * @param newGeometry The geometry to add
  36762. */
  36763. addGeometry(newGeometry: Geometry): void;
  36764. /**
  36765. * Adds the given action manager to this scene
  36766. * @param newActionManager The action manager to add
  36767. */
  36768. addActionManager(newActionManager: AbstractActionManager): void;
  36769. /**
  36770. * Adds the given texture to this scene.
  36771. * @param newTexture The texture to add
  36772. */
  36773. addTexture(newTexture: BaseTexture): void;
  36774. /**
  36775. * Switch active camera
  36776. * @param newCamera defines the new active camera
  36777. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36778. */
  36779. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36780. /**
  36781. * sets the active camera of the scene using its ID
  36782. * @param id defines the camera's ID
  36783. * @return the new active camera or null if none found.
  36784. */
  36785. setActiveCameraByID(id: string): Nullable<Camera>;
  36786. /**
  36787. * sets the active camera of the scene using its name
  36788. * @param name defines the camera's name
  36789. * @returns the new active camera or null if none found.
  36790. */
  36791. setActiveCameraByName(name: string): Nullable<Camera>;
  36792. /**
  36793. * get an animation group using its name
  36794. * @param name defines the material's name
  36795. * @return the animation group or null if none found.
  36796. */
  36797. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36798. /**
  36799. * Get a material using its unique id
  36800. * @param uniqueId defines the material's unique id
  36801. * @return the material or null if none found.
  36802. */
  36803. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36804. /**
  36805. * get a material using its id
  36806. * @param id defines the material's ID
  36807. * @return the material or null if none found.
  36808. */
  36809. getMaterialByID(id: string): Nullable<Material>;
  36810. /**
  36811. * Gets a the last added material using a given id
  36812. * @param id defines the material's ID
  36813. * @return the last material with the given id or null if none found.
  36814. */
  36815. getLastMaterialByID(id: string): Nullable<Material>;
  36816. /**
  36817. * Gets a material using its name
  36818. * @param name defines the material's name
  36819. * @return the material or null if none found.
  36820. */
  36821. getMaterialByName(name: string): Nullable<Material>;
  36822. /**
  36823. * Get a texture using its unique id
  36824. * @param uniqueId defines the texture's unique id
  36825. * @return the texture or null if none found.
  36826. */
  36827. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36828. /**
  36829. * Gets a camera using its id
  36830. * @param id defines the id to look for
  36831. * @returns the camera or null if not found
  36832. */
  36833. getCameraByID(id: string): Nullable<Camera>;
  36834. /**
  36835. * Gets a camera using its unique id
  36836. * @param uniqueId defines the unique id to look for
  36837. * @returns the camera or null if not found
  36838. */
  36839. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36840. /**
  36841. * Gets a camera using its name
  36842. * @param name defines the camera's name
  36843. * @return the camera or null if none found.
  36844. */
  36845. getCameraByName(name: string): Nullable<Camera>;
  36846. /**
  36847. * Gets a bone using its id
  36848. * @param id defines the bone's id
  36849. * @return the bone or null if not found
  36850. */
  36851. getBoneByID(id: string): Nullable<Bone>;
  36852. /**
  36853. * Gets a bone using its id
  36854. * @param name defines the bone's name
  36855. * @return the bone or null if not found
  36856. */
  36857. getBoneByName(name: string): Nullable<Bone>;
  36858. /**
  36859. * Gets a light node using its name
  36860. * @param name defines the the light's name
  36861. * @return the light or null if none found.
  36862. */
  36863. getLightByName(name: string): Nullable<Light>;
  36864. /**
  36865. * Gets a light node using its id
  36866. * @param id defines the light's id
  36867. * @return the light or null if none found.
  36868. */
  36869. getLightByID(id: string): Nullable<Light>;
  36870. /**
  36871. * Gets a light node using its scene-generated unique ID
  36872. * @param uniqueId defines the light's unique id
  36873. * @return the light or null if none found.
  36874. */
  36875. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36876. /**
  36877. * Gets a particle system by id
  36878. * @param id defines the particle system id
  36879. * @return the corresponding system or null if none found
  36880. */
  36881. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36882. /**
  36883. * Gets a geometry using its ID
  36884. * @param id defines the geometry's id
  36885. * @return the geometry or null if none found.
  36886. */
  36887. getGeometryByID(id: string): Nullable<Geometry>;
  36888. private _getGeometryByUniqueID;
  36889. /**
  36890. * Add a new geometry to this scene
  36891. * @param geometry defines the geometry to be added to the scene.
  36892. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36893. * @return a boolean defining if the geometry was added or not
  36894. */
  36895. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36896. /**
  36897. * Removes an existing geometry
  36898. * @param geometry defines the geometry to be removed from the scene
  36899. * @return a boolean defining if the geometry was removed or not
  36900. */
  36901. removeGeometry(geometry: Geometry): boolean;
  36902. /**
  36903. * Gets the list of geometries attached to the scene
  36904. * @returns an array of Geometry
  36905. */
  36906. getGeometries(): Geometry[];
  36907. /**
  36908. * Gets the first added mesh found of a given ID
  36909. * @param id defines the id to search for
  36910. * @return the mesh found or null if not found at all
  36911. */
  36912. getMeshByID(id: string): Nullable<AbstractMesh>;
  36913. /**
  36914. * Gets a list of meshes using their id
  36915. * @param id defines the id to search for
  36916. * @returns a list of meshes
  36917. */
  36918. getMeshesByID(id: string): Array<AbstractMesh>;
  36919. /**
  36920. * Gets the first added transform node found of a given ID
  36921. * @param id defines the id to search for
  36922. * @return the found transform node or null if not found at all.
  36923. */
  36924. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36925. /**
  36926. * Gets a transform node with its auto-generated unique id
  36927. * @param uniqueId efines the unique id to search for
  36928. * @return the found transform node or null if not found at all.
  36929. */
  36930. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36931. /**
  36932. * Gets a list of transform nodes using their id
  36933. * @param id defines the id to search for
  36934. * @returns a list of transform nodes
  36935. */
  36936. getTransformNodesByID(id: string): Array<TransformNode>;
  36937. /**
  36938. * Gets a mesh with its auto-generated unique id
  36939. * @param uniqueId defines the unique id to search for
  36940. * @return the found mesh or null if not found at all.
  36941. */
  36942. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36943. /**
  36944. * Gets a the last added mesh using a given id
  36945. * @param id defines the id to search for
  36946. * @return the found mesh or null if not found at all.
  36947. */
  36948. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36949. /**
  36950. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36951. * @param id defines the id to search for
  36952. * @return the found node or null if not found at all
  36953. */
  36954. getLastEntryByID(id: string): Nullable<Node>;
  36955. /**
  36956. * Gets a node (Mesh, Camera, Light) using a given id
  36957. * @param id defines the id to search for
  36958. * @return the found node or null if not found at all
  36959. */
  36960. getNodeByID(id: string): Nullable<Node>;
  36961. /**
  36962. * Gets a node (Mesh, Camera, Light) using a given name
  36963. * @param name defines the name to search for
  36964. * @return the found node or null if not found at all.
  36965. */
  36966. getNodeByName(name: string): Nullable<Node>;
  36967. /**
  36968. * Gets a mesh using a given name
  36969. * @param name defines the name to search for
  36970. * @return the found mesh or null if not found at all.
  36971. */
  36972. getMeshByName(name: string): Nullable<AbstractMesh>;
  36973. /**
  36974. * Gets a transform node using a given name
  36975. * @param name defines the name to search for
  36976. * @return the found transform node or null if not found at all.
  36977. */
  36978. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36979. /**
  36980. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36981. * @param id defines the id to search for
  36982. * @return the found skeleton or null if not found at all.
  36983. */
  36984. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36985. /**
  36986. * Gets a skeleton using a given auto generated unique id
  36987. * @param uniqueId defines the unique id to search for
  36988. * @return the found skeleton or null if not found at all.
  36989. */
  36990. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36991. /**
  36992. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36993. * @param id defines the id to search for
  36994. * @return the found skeleton or null if not found at all.
  36995. */
  36996. getSkeletonById(id: string): Nullable<Skeleton>;
  36997. /**
  36998. * Gets a skeleton using a given name
  36999. * @param name defines the name to search for
  37000. * @return the found skeleton or null if not found at all.
  37001. */
  37002. getSkeletonByName(name: string): Nullable<Skeleton>;
  37003. /**
  37004. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37005. * @param id defines the id to search for
  37006. * @return the found morph target manager or null if not found at all.
  37007. */
  37008. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37009. /**
  37010. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37011. * @param id defines the id to search for
  37012. * @return the found morph target or null if not found at all.
  37013. */
  37014. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37015. /**
  37016. * Gets a boolean indicating if the given mesh is active
  37017. * @param mesh defines the mesh to look for
  37018. * @returns true if the mesh is in the active list
  37019. */
  37020. isActiveMesh(mesh: AbstractMesh): boolean;
  37021. /**
  37022. * Return a unique id as a string which can serve as an identifier for the scene
  37023. */
  37024. readonly uid: string;
  37025. /**
  37026. * Add an externaly attached data from its key.
  37027. * This method call will fail and return false, if such key already exists.
  37028. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37029. * @param key the unique key that identifies the data
  37030. * @param data the data object to associate to the key for this Engine instance
  37031. * @return true if no such key were already present and the data was added successfully, false otherwise
  37032. */
  37033. addExternalData<T>(key: string, data: T): boolean;
  37034. /**
  37035. * Get an externaly attached data from its key
  37036. * @param key the unique key that identifies the data
  37037. * @return the associated data, if present (can be null), or undefined if not present
  37038. */
  37039. getExternalData<T>(key: string): Nullable<T>;
  37040. /**
  37041. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37042. * @param key the unique key that identifies the data
  37043. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37044. * @return the associated data, can be null if the factory returned null.
  37045. */
  37046. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37047. /**
  37048. * Remove an externaly attached data from the Engine instance
  37049. * @param key the unique key that identifies the data
  37050. * @return true if the data was successfully removed, false if it doesn't exist
  37051. */
  37052. removeExternalData(key: string): boolean;
  37053. private _evaluateSubMesh;
  37054. /**
  37055. * Clear the processed materials smart array preventing retention point in material dispose.
  37056. */
  37057. freeProcessedMaterials(): void;
  37058. private _preventFreeActiveMeshesAndRenderingGroups;
  37059. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37060. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37061. * when disposing several meshes in a row or a hierarchy of meshes.
  37062. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37063. */
  37064. blockfreeActiveMeshesAndRenderingGroups: boolean;
  37065. /**
  37066. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37067. */
  37068. freeActiveMeshes(): void;
  37069. /**
  37070. * Clear the info related to rendering groups preventing retention points during dispose.
  37071. */
  37072. freeRenderingGroups(): void;
  37073. /** @hidden */
  37074. _isInIntermediateRendering(): boolean;
  37075. /**
  37076. * Lambda returning the list of potentially active meshes.
  37077. */
  37078. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37079. /**
  37080. * Lambda returning the list of potentially active sub meshes.
  37081. */
  37082. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37083. /**
  37084. * Lambda returning the list of potentially intersecting sub meshes.
  37085. */
  37086. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37087. /**
  37088. * Lambda returning the list of potentially colliding sub meshes.
  37089. */
  37090. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37091. private _activeMeshesFrozen;
  37092. private _skipEvaluateActiveMeshesCompletely;
  37093. /**
  37094. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37095. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37096. * @returns the current scene
  37097. */
  37098. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37099. /**
  37100. * Use this function to restart evaluating active meshes on every frame
  37101. * @returns the current scene
  37102. */
  37103. unfreezeActiveMeshes(): Scene;
  37104. private _evaluateActiveMeshes;
  37105. private _activeMesh;
  37106. /**
  37107. * Update the transform matrix to update from the current active camera
  37108. * @param force defines a boolean used to force the update even if cache is up to date
  37109. */
  37110. updateTransformMatrix(force?: boolean): void;
  37111. private _bindFrameBuffer;
  37112. /** @hidden */
  37113. _allowPostProcessClearColor: boolean;
  37114. /** @hidden */
  37115. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37116. private _processSubCameras;
  37117. private _checkIntersections;
  37118. /** @hidden */
  37119. _advancePhysicsEngineStep(step: number): void;
  37120. /**
  37121. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37122. */
  37123. getDeterministicFrameTime: () => number;
  37124. /** @hidden */
  37125. _animate(): void;
  37126. /** Execute all animations (for a frame) */
  37127. animate(): void;
  37128. /**
  37129. * Render the scene
  37130. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37131. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37132. */
  37133. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37134. /**
  37135. * Freeze all materials
  37136. * A frozen material will not be updatable but should be faster to render
  37137. */
  37138. freezeMaterials(): void;
  37139. /**
  37140. * Unfreeze all materials
  37141. * A frozen material will not be updatable but should be faster to render
  37142. */
  37143. unfreezeMaterials(): void;
  37144. /**
  37145. * Releases all held ressources
  37146. */
  37147. dispose(): void;
  37148. /**
  37149. * Gets if the scene is already disposed
  37150. */
  37151. readonly isDisposed: boolean;
  37152. /**
  37153. * Call this function to reduce memory footprint of the scene.
  37154. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37155. */
  37156. clearCachedVertexData(): void;
  37157. /**
  37158. * This function will remove the local cached buffer data from texture.
  37159. * It will save memory but will prevent the texture from being rebuilt
  37160. */
  37161. cleanCachedTextureBuffer(): void;
  37162. /**
  37163. * Get the world extend vectors with an optional filter
  37164. *
  37165. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37166. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37167. */
  37168. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37169. min: Vector3;
  37170. max: Vector3;
  37171. };
  37172. /**
  37173. * Creates a ray that can be used to pick in the scene
  37174. * @param x defines the x coordinate of the origin (on-screen)
  37175. * @param y defines the y coordinate of the origin (on-screen)
  37176. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37177. * @param camera defines the camera to use for the picking
  37178. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37179. * @returns a Ray
  37180. */
  37181. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37182. /**
  37183. * Creates a ray that can be used to pick in the scene
  37184. * @param x defines the x coordinate of the origin (on-screen)
  37185. * @param y defines the y coordinate of the origin (on-screen)
  37186. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37187. * @param result defines the ray where to store the picking ray
  37188. * @param camera defines the camera to use for the picking
  37189. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37190. * @returns the current scene
  37191. */
  37192. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37193. /**
  37194. * Creates a ray that can be used to pick in the scene
  37195. * @param x defines the x coordinate of the origin (on-screen)
  37196. * @param y defines the y coordinate of the origin (on-screen)
  37197. * @param camera defines the camera to use for the picking
  37198. * @returns a Ray
  37199. */
  37200. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37201. /**
  37202. * Creates a ray that can be used to pick in the scene
  37203. * @param x defines the x coordinate of the origin (on-screen)
  37204. * @param y defines the y coordinate of the origin (on-screen)
  37205. * @param result defines the ray where to store the picking ray
  37206. * @param camera defines the camera to use for the picking
  37207. * @returns the current scene
  37208. */
  37209. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37210. /** Launch a ray to try to pick a mesh in the scene
  37211. * @param x position on screen
  37212. * @param y position on screen
  37213. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  37214. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37215. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37216. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37217. * @returns a PickingInfo
  37218. */
  37219. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37220. /** Use the given ray to pick a mesh in the scene
  37221. * @param ray The ray to use to pick meshes
  37222. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  37223. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37224. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37225. * @returns a PickingInfo
  37226. */
  37227. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37228. /**
  37229. * Launch a ray to try to pick a mesh in the scene
  37230. * @param x X position on screen
  37231. * @param y Y position on screen
  37232. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  37233. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37234. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37235. * @returns an array of PickingInfo
  37236. */
  37237. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37238. /**
  37239. * Launch a ray to try to pick a mesh in the scene
  37240. * @param ray Ray to use
  37241. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  37242. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37243. * @returns an array of PickingInfo
  37244. */
  37245. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37246. /**
  37247. * Force the value of meshUnderPointer
  37248. * @param mesh defines the mesh to use
  37249. */
  37250. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37251. /**
  37252. * Gets the mesh under the pointer
  37253. * @returns a Mesh or null if no mesh is under the pointer
  37254. */
  37255. getPointerOverMesh(): Nullable<AbstractMesh>;
  37256. /** @hidden */
  37257. _rebuildGeometries(): void;
  37258. /** @hidden */
  37259. _rebuildTextures(): void;
  37260. private _getByTags;
  37261. /**
  37262. * Get a list of meshes by tags
  37263. * @param tagsQuery defines the tags query to use
  37264. * @param forEach defines a predicate used to filter results
  37265. * @returns an array of Mesh
  37266. */
  37267. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37268. /**
  37269. * Get a list of cameras by tags
  37270. * @param tagsQuery defines the tags query to use
  37271. * @param forEach defines a predicate used to filter results
  37272. * @returns an array of Camera
  37273. */
  37274. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37275. /**
  37276. * Get a list of lights by tags
  37277. * @param tagsQuery defines the tags query to use
  37278. * @param forEach defines a predicate used to filter results
  37279. * @returns an array of Light
  37280. */
  37281. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37282. /**
  37283. * Get a list of materials by tags
  37284. * @param tagsQuery defines the tags query to use
  37285. * @param forEach defines a predicate used to filter results
  37286. * @returns an array of Material
  37287. */
  37288. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37289. /**
  37290. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37291. * This allowed control for front to back rendering or reversly depending of the special needs.
  37292. *
  37293. * @param renderingGroupId The rendering group id corresponding to its index
  37294. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37295. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37296. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37297. */
  37298. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  37299. /**
  37300. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37301. *
  37302. * @param renderingGroupId The rendering group id corresponding to its index
  37303. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37304. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37305. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37306. */
  37307. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37308. /**
  37309. * Gets the current auto clear configuration for one rendering group of the rendering
  37310. * manager.
  37311. * @param index the rendering group index to get the information for
  37312. * @returns The auto clear setup for the requested rendering group
  37313. */
  37314. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37315. private _blockMaterialDirtyMechanism;
  37316. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37317. blockMaterialDirtyMechanism: boolean;
  37318. /**
  37319. * Will flag all materials as dirty to trigger new shader compilation
  37320. * @param flag defines the flag used to specify which material part must be marked as dirty
  37321. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37322. */
  37323. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37324. /** @hidden */
  37325. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  37326. /** @hidden */
  37327. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37328. /** @hidden */
  37329. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  37330. /** @hidden */
  37331. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37332. /** @hidden */
  37333. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37334. /** @hidden */
  37335. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37336. }
  37337. }
  37338. declare module "babylonjs/assetContainer" {
  37339. import { AbstractScene } from "babylonjs/abstractScene";
  37340. import { Scene } from "babylonjs/scene";
  37341. import { Mesh } from "babylonjs/Meshes/mesh";
  37342. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37343. import { Skeleton } from "babylonjs/Bones/skeleton";
  37344. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37345. /**
  37346. * Set of assets to keep when moving a scene into an asset container.
  37347. */
  37348. export class KeepAssets extends AbstractScene {
  37349. }
  37350. /**
  37351. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37352. */
  37353. export class InstantiatedEntries {
  37354. /**
  37355. * List of new root nodes (eg. nodes with no parent)
  37356. */
  37357. rootNodes: TransformNode[];
  37358. /**
  37359. * List of new skeletons
  37360. */
  37361. skeletons: Skeleton[];
  37362. /**
  37363. * List of new animation groups
  37364. */
  37365. animationGroups: AnimationGroup[];
  37366. }
  37367. /**
  37368. * Container with a set of assets that can be added or removed from a scene.
  37369. */
  37370. export class AssetContainer extends AbstractScene {
  37371. /**
  37372. * The scene the AssetContainer belongs to.
  37373. */
  37374. scene: Scene;
  37375. /**
  37376. * Instantiates an AssetContainer.
  37377. * @param scene The scene the AssetContainer belongs to.
  37378. */
  37379. constructor(scene: Scene);
  37380. /**
  37381. * Instantiate or clone all meshes and add the new ones to the scene.
  37382. * Skeletons and animation groups will all be cloned
  37383. * @param nameFunction defines an optional function used to get new names for clones
  37384. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37385. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37386. */
  37387. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37388. /**
  37389. * Adds all the assets from the container to the scene.
  37390. */
  37391. addAllToScene(): void;
  37392. /**
  37393. * Removes all the assets in the container from the scene
  37394. */
  37395. removeAllFromScene(): void;
  37396. /**
  37397. * Disposes all the assets in the container
  37398. */
  37399. dispose(): void;
  37400. private _moveAssets;
  37401. /**
  37402. * Removes all the assets contained in the scene and adds them to the container.
  37403. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37404. */
  37405. moveAllFromScene(keepAssets?: KeepAssets): void;
  37406. /**
  37407. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  37408. * @returns the root mesh
  37409. */
  37410. createRootMesh(): Mesh;
  37411. }
  37412. }
  37413. declare module "babylonjs/abstractScene" {
  37414. import { Scene } from "babylonjs/scene";
  37415. import { Nullable } from "babylonjs/types";
  37416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37417. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37418. import { Geometry } from "babylonjs/Meshes/geometry";
  37419. import { Skeleton } from "babylonjs/Bones/skeleton";
  37420. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37421. import { AssetContainer } from "babylonjs/assetContainer";
  37422. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37423. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37425. import { Material } from "babylonjs/Materials/material";
  37426. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37427. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37428. import { Camera } from "babylonjs/Cameras/camera";
  37429. import { Light } from "babylonjs/Lights/light";
  37430. import { Node } from "babylonjs/node";
  37431. import { Animation } from "babylonjs/Animations/animation";
  37432. /**
  37433. * Defines how the parser contract is defined.
  37434. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37435. */
  37436. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37437. /**
  37438. * Defines how the individual parser contract is defined.
  37439. * These parser can parse an individual asset
  37440. */
  37441. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37442. /**
  37443. * Base class of the scene acting as a container for the different elements composing a scene.
  37444. * This class is dynamically extended by the different components of the scene increasing
  37445. * flexibility and reducing coupling
  37446. */
  37447. export abstract class AbstractScene {
  37448. /**
  37449. * Stores the list of available parsers in the application.
  37450. */
  37451. private static _BabylonFileParsers;
  37452. /**
  37453. * Stores the list of available individual parsers in the application.
  37454. */
  37455. private static _IndividualBabylonFileParsers;
  37456. /**
  37457. * Adds a parser in the list of available ones
  37458. * @param name Defines the name of the parser
  37459. * @param parser Defines the parser to add
  37460. */
  37461. static AddParser(name: string, parser: BabylonFileParser): void;
  37462. /**
  37463. * Gets a general parser from the list of avaialble ones
  37464. * @param name Defines the name of the parser
  37465. * @returns the requested parser or null
  37466. */
  37467. static GetParser(name: string): Nullable<BabylonFileParser>;
  37468. /**
  37469. * Adds n individual parser in the list of available ones
  37470. * @param name Defines the name of the parser
  37471. * @param parser Defines the parser to add
  37472. */
  37473. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37474. /**
  37475. * Gets an individual parser from the list of avaialble ones
  37476. * @param name Defines the name of the parser
  37477. * @returns the requested parser or null
  37478. */
  37479. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37480. /**
  37481. * Parser json data and populate both a scene and its associated container object
  37482. * @param jsonData Defines the data to parse
  37483. * @param scene Defines the scene to parse the data for
  37484. * @param container Defines the container attached to the parsing sequence
  37485. * @param rootUrl Defines the root url of the data
  37486. */
  37487. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37488. /**
  37489. * Gets the list of root nodes (ie. nodes with no parent)
  37490. */
  37491. rootNodes: Node[];
  37492. /** All of the cameras added to this scene
  37493. * @see http://doc.babylonjs.com/babylon101/cameras
  37494. */
  37495. cameras: Camera[];
  37496. /**
  37497. * All of the lights added to this scene
  37498. * @see http://doc.babylonjs.com/babylon101/lights
  37499. */
  37500. lights: Light[];
  37501. /**
  37502. * All of the (abstract) meshes added to this scene
  37503. */
  37504. meshes: AbstractMesh[];
  37505. /**
  37506. * The list of skeletons added to the scene
  37507. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37508. */
  37509. skeletons: Skeleton[];
  37510. /**
  37511. * All of the particle systems added to this scene
  37512. * @see http://doc.babylonjs.com/babylon101/particles
  37513. */
  37514. particleSystems: IParticleSystem[];
  37515. /**
  37516. * Gets a list of Animations associated with the scene
  37517. */
  37518. animations: Animation[];
  37519. /**
  37520. * All of the animation groups added to this scene
  37521. * @see http://doc.babylonjs.com/how_to/group
  37522. */
  37523. animationGroups: AnimationGroup[];
  37524. /**
  37525. * All of the multi-materials added to this scene
  37526. * @see http://doc.babylonjs.com/how_to/multi_materials
  37527. */
  37528. multiMaterials: MultiMaterial[];
  37529. /**
  37530. * All of the materials added to this scene
  37531. * In the context of a Scene, it is not supposed to be modified manually.
  37532. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37533. * Note also that the order of the Material within the array is not significant and might change.
  37534. * @see http://doc.babylonjs.com/babylon101/materials
  37535. */
  37536. materials: Material[];
  37537. /**
  37538. * The list of morph target managers added to the scene
  37539. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37540. */
  37541. morphTargetManagers: MorphTargetManager[];
  37542. /**
  37543. * The list of geometries used in the scene.
  37544. */
  37545. geometries: Geometry[];
  37546. /**
  37547. * All of the tranform nodes added to this scene
  37548. * In the context of a Scene, it is not supposed to be modified manually.
  37549. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37550. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37551. * @see http://doc.babylonjs.com/how_to/transformnode
  37552. */
  37553. transformNodes: TransformNode[];
  37554. /**
  37555. * ActionManagers available on the scene.
  37556. */
  37557. actionManagers: AbstractActionManager[];
  37558. /**
  37559. * Textures to keep.
  37560. */
  37561. textures: BaseTexture[];
  37562. /**
  37563. * Environment texture for the scene
  37564. */
  37565. environmentTexture: Nullable<BaseTexture>;
  37566. }
  37567. }
  37568. declare module "babylonjs/Audio/sound" {
  37569. import { Observable } from "babylonjs/Misc/observable";
  37570. import { Vector3 } from "babylonjs/Maths/math.vector";
  37571. import { Nullable } from "babylonjs/types";
  37572. import { Scene } from "babylonjs/scene";
  37573. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37574. /**
  37575. * Interface used to define options for Sound class
  37576. */
  37577. export interface ISoundOptions {
  37578. /**
  37579. * Does the sound autoplay once loaded.
  37580. */
  37581. autoplay?: boolean;
  37582. /**
  37583. * Does the sound loop after it finishes playing once.
  37584. */
  37585. loop?: boolean;
  37586. /**
  37587. * Sound's volume
  37588. */
  37589. volume?: number;
  37590. /**
  37591. * Is it a spatial sound?
  37592. */
  37593. spatialSound?: boolean;
  37594. /**
  37595. * Maximum distance to hear that sound
  37596. */
  37597. maxDistance?: number;
  37598. /**
  37599. * Uses user defined attenuation function
  37600. */
  37601. useCustomAttenuation?: boolean;
  37602. /**
  37603. * Define the roll off factor of spatial sounds.
  37604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37605. */
  37606. rolloffFactor?: number;
  37607. /**
  37608. * Define the reference distance the sound should be heard perfectly.
  37609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37610. */
  37611. refDistance?: number;
  37612. /**
  37613. * Define the distance attenuation model the sound will follow.
  37614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37615. */
  37616. distanceModel?: string;
  37617. /**
  37618. * Defines the playback speed (1 by default)
  37619. */
  37620. playbackRate?: number;
  37621. /**
  37622. * Defines if the sound is from a streaming source
  37623. */
  37624. streaming?: boolean;
  37625. /**
  37626. * Defines an optional length (in seconds) inside the sound file
  37627. */
  37628. length?: number;
  37629. /**
  37630. * Defines an optional offset (in seconds) inside the sound file
  37631. */
  37632. offset?: number;
  37633. /**
  37634. * If true, URLs will not be required to state the audio file codec to use.
  37635. */
  37636. skipCodecCheck?: boolean;
  37637. }
  37638. /**
  37639. * Defines a sound that can be played in the application.
  37640. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37642. */
  37643. export class Sound {
  37644. /**
  37645. * The name of the sound in the scene.
  37646. */
  37647. name: string;
  37648. /**
  37649. * Does the sound autoplay once loaded.
  37650. */
  37651. autoplay: boolean;
  37652. /**
  37653. * Does the sound loop after it finishes playing once.
  37654. */
  37655. loop: boolean;
  37656. /**
  37657. * Does the sound use a custom attenuation curve to simulate the falloff
  37658. * happening when the source gets further away from the camera.
  37659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37660. */
  37661. useCustomAttenuation: boolean;
  37662. /**
  37663. * The sound track id this sound belongs to.
  37664. */
  37665. soundTrackId: number;
  37666. /**
  37667. * Is this sound currently played.
  37668. */
  37669. isPlaying: boolean;
  37670. /**
  37671. * Is this sound currently paused.
  37672. */
  37673. isPaused: boolean;
  37674. /**
  37675. * Does this sound enables spatial sound.
  37676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37677. */
  37678. spatialSound: boolean;
  37679. /**
  37680. * Define the reference distance the sound should be heard perfectly.
  37681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37682. */
  37683. refDistance: number;
  37684. /**
  37685. * Define the roll off factor of spatial sounds.
  37686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37687. */
  37688. rolloffFactor: number;
  37689. /**
  37690. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37692. */
  37693. maxDistance: number;
  37694. /**
  37695. * Define the distance attenuation model the sound will follow.
  37696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37697. */
  37698. distanceModel: string;
  37699. /**
  37700. * @hidden
  37701. * Back Compat
  37702. **/
  37703. onended: () => any;
  37704. /**
  37705. * Observable event when the current playing sound finishes.
  37706. */
  37707. onEndedObservable: Observable<Sound>;
  37708. private _panningModel;
  37709. private _playbackRate;
  37710. private _streaming;
  37711. private _startTime;
  37712. private _startOffset;
  37713. private _position;
  37714. /** @hidden */
  37715. _positionInEmitterSpace: boolean;
  37716. private _localDirection;
  37717. private _volume;
  37718. private _isReadyToPlay;
  37719. private _isDirectional;
  37720. private _readyToPlayCallback;
  37721. private _audioBuffer;
  37722. private _soundSource;
  37723. private _streamingSource;
  37724. private _soundPanner;
  37725. private _soundGain;
  37726. private _inputAudioNode;
  37727. private _outputAudioNode;
  37728. private _coneInnerAngle;
  37729. private _coneOuterAngle;
  37730. private _coneOuterGain;
  37731. private _scene;
  37732. private _connectedTransformNode;
  37733. private _customAttenuationFunction;
  37734. private _registerFunc;
  37735. private _isOutputConnected;
  37736. private _htmlAudioElement;
  37737. private _urlType;
  37738. private _length?;
  37739. private _offset?;
  37740. /** @hidden */
  37741. static _SceneComponentInitialization: (scene: Scene) => void;
  37742. /**
  37743. * Create a sound and attach it to a scene
  37744. * @param name Name of your sound
  37745. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37746. * @param scene defines the scene the sound belongs to
  37747. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37748. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37749. */
  37750. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37751. /**
  37752. * Release the sound and its associated resources
  37753. */
  37754. dispose(): void;
  37755. /**
  37756. * Gets if the sounds is ready to be played or not.
  37757. * @returns true if ready, otherwise false
  37758. */
  37759. isReady(): boolean;
  37760. private _soundLoaded;
  37761. /**
  37762. * Sets the data of the sound from an audiobuffer
  37763. * @param audioBuffer The audioBuffer containing the data
  37764. */
  37765. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37766. /**
  37767. * Updates the current sounds options such as maxdistance, loop...
  37768. * @param options A JSON object containing values named as the object properties
  37769. */
  37770. updateOptions(options: ISoundOptions): void;
  37771. private _createSpatialParameters;
  37772. private _updateSpatialParameters;
  37773. /**
  37774. * Switch the panning model to HRTF:
  37775. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37777. */
  37778. switchPanningModelToHRTF(): void;
  37779. /**
  37780. * Switch the panning model to Equal Power:
  37781. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37783. */
  37784. switchPanningModelToEqualPower(): void;
  37785. private _switchPanningModel;
  37786. /**
  37787. * Connect this sound to a sound track audio node like gain...
  37788. * @param soundTrackAudioNode the sound track audio node to connect to
  37789. */
  37790. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37791. /**
  37792. * Transform this sound into a directional source
  37793. * @param coneInnerAngle Size of the inner cone in degree
  37794. * @param coneOuterAngle Size of the outer cone in degree
  37795. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37796. */
  37797. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37798. /**
  37799. * Gets or sets the inner angle for the directional cone.
  37800. */
  37801. /**
  37802. * Gets or sets the inner angle for the directional cone.
  37803. */
  37804. directionalConeInnerAngle: number;
  37805. /**
  37806. * Gets or sets the outer angle for the directional cone.
  37807. */
  37808. /**
  37809. * Gets or sets the outer angle for the directional cone.
  37810. */
  37811. directionalConeOuterAngle: number;
  37812. /**
  37813. * Sets the position of the emitter if spatial sound is enabled
  37814. * @param newPosition Defines the new posisiton
  37815. */
  37816. setPosition(newPosition: Vector3): void;
  37817. /**
  37818. * Sets the local direction of the emitter if spatial sound is enabled
  37819. * @param newLocalDirection Defines the new local direction
  37820. */
  37821. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37822. private _updateDirection;
  37823. /** @hidden */
  37824. updateDistanceFromListener(): void;
  37825. /**
  37826. * Sets a new custom attenuation function for the sound.
  37827. * @param callback Defines the function used for the attenuation
  37828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37829. */
  37830. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37831. /**
  37832. * Play the sound
  37833. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37834. * @param offset (optional) Start the sound at a specific time in seconds
  37835. * @param length (optional) Sound duration (in seconds)
  37836. */
  37837. play(time?: number, offset?: number, length?: number): void;
  37838. private _onended;
  37839. /**
  37840. * Stop the sound
  37841. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37842. */
  37843. stop(time?: number): void;
  37844. /**
  37845. * Put the sound in pause
  37846. */
  37847. pause(): void;
  37848. /**
  37849. * Sets a dedicated volume for this sounds
  37850. * @param newVolume Define the new volume of the sound
  37851. * @param time Define time for gradual change to new volume
  37852. */
  37853. setVolume(newVolume: number, time?: number): void;
  37854. /**
  37855. * Set the sound play back rate
  37856. * @param newPlaybackRate Define the playback rate the sound should be played at
  37857. */
  37858. setPlaybackRate(newPlaybackRate: number): void;
  37859. /**
  37860. * Gets the volume of the sound.
  37861. * @returns the volume of the sound
  37862. */
  37863. getVolume(): number;
  37864. /**
  37865. * Attach the sound to a dedicated mesh
  37866. * @param transformNode The transform node to connect the sound with
  37867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37868. */
  37869. attachToMesh(transformNode: TransformNode): void;
  37870. /**
  37871. * Detach the sound from the previously attached mesh
  37872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37873. */
  37874. detachFromMesh(): void;
  37875. private _onRegisterAfterWorldMatrixUpdate;
  37876. /**
  37877. * Clone the current sound in the scene.
  37878. * @returns the new sound clone
  37879. */
  37880. clone(): Nullable<Sound>;
  37881. /**
  37882. * Gets the current underlying audio buffer containing the data
  37883. * @returns the audio buffer
  37884. */
  37885. getAudioBuffer(): Nullable<AudioBuffer>;
  37886. /**
  37887. * Serializes the Sound in a JSON representation
  37888. * @returns the JSON representation of the sound
  37889. */
  37890. serialize(): any;
  37891. /**
  37892. * Parse a JSON representation of a sound to innstantiate in a given scene
  37893. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37894. * @param scene Define the scene the new parsed sound should be created in
  37895. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37896. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37897. * @returns the newly parsed sound
  37898. */
  37899. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37900. }
  37901. }
  37902. declare module "babylonjs/Actions/directAudioActions" {
  37903. import { Action } from "babylonjs/Actions/action";
  37904. import { Condition } from "babylonjs/Actions/condition";
  37905. import { Sound } from "babylonjs/Audio/sound";
  37906. /**
  37907. * This defines an action helpful to play a defined sound on a triggered action.
  37908. */
  37909. export class PlaySoundAction extends Action {
  37910. private _sound;
  37911. /**
  37912. * Instantiate the action
  37913. * @param triggerOptions defines the trigger options
  37914. * @param sound defines the sound to play
  37915. * @param condition defines the trigger related conditions
  37916. */
  37917. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37918. /** @hidden */
  37919. _prepare(): void;
  37920. /**
  37921. * Execute the action and play the sound.
  37922. */
  37923. execute(): void;
  37924. /**
  37925. * Serializes the actions and its related information.
  37926. * @param parent defines the object to serialize in
  37927. * @returns the serialized object
  37928. */
  37929. serialize(parent: any): any;
  37930. }
  37931. /**
  37932. * This defines an action helpful to stop a defined sound on a triggered action.
  37933. */
  37934. export class StopSoundAction extends Action {
  37935. private _sound;
  37936. /**
  37937. * Instantiate the action
  37938. * @param triggerOptions defines the trigger options
  37939. * @param sound defines the sound to stop
  37940. * @param condition defines the trigger related conditions
  37941. */
  37942. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37943. /** @hidden */
  37944. _prepare(): void;
  37945. /**
  37946. * Execute the action and stop the sound.
  37947. */
  37948. execute(): void;
  37949. /**
  37950. * Serializes the actions and its related information.
  37951. * @param parent defines the object to serialize in
  37952. * @returns the serialized object
  37953. */
  37954. serialize(parent: any): any;
  37955. }
  37956. }
  37957. declare module "babylonjs/Actions/interpolateValueAction" {
  37958. import { Action } from "babylonjs/Actions/action";
  37959. import { Condition } from "babylonjs/Actions/condition";
  37960. import { Observable } from "babylonjs/Misc/observable";
  37961. /**
  37962. * This defines an action responsible to change the value of a property
  37963. * by interpolating between its current value and the newly set one once triggered.
  37964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37965. */
  37966. export class InterpolateValueAction extends Action {
  37967. /**
  37968. * Defines the path of the property where the value should be interpolated
  37969. */
  37970. propertyPath: string;
  37971. /**
  37972. * Defines the target value at the end of the interpolation.
  37973. */
  37974. value: any;
  37975. /**
  37976. * Defines the time it will take for the property to interpolate to the value.
  37977. */
  37978. duration: number;
  37979. /**
  37980. * Defines if the other scene animations should be stopped when the action has been triggered
  37981. */
  37982. stopOtherAnimations?: boolean;
  37983. /**
  37984. * Defines a callback raised once the interpolation animation has been done.
  37985. */
  37986. onInterpolationDone?: () => void;
  37987. /**
  37988. * Observable triggered once the interpolation animation has been done.
  37989. */
  37990. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37991. private _target;
  37992. private _effectiveTarget;
  37993. private _property;
  37994. /**
  37995. * Instantiate the action
  37996. * @param triggerOptions defines the trigger options
  37997. * @param target defines the object containing the value to interpolate
  37998. * @param propertyPath defines the path to the property in the target object
  37999. * @param value defines the target value at the end of the interpolation
  38000. * @param duration deines the time it will take for the property to interpolate to the value.
  38001. * @param condition defines the trigger related conditions
  38002. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38003. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38004. */
  38005. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38006. /** @hidden */
  38007. _prepare(): void;
  38008. /**
  38009. * Execute the action starts the value interpolation.
  38010. */
  38011. execute(): void;
  38012. /**
  38013. * Serializes the actions and its related information.
  38014. * @param parent defines the object to serialize in
  38015. * @returns the serialized object
  38016. */
  38017. serialize(parent: any): any;
  38018. }
  38019. }
  38020. declare module "babylonjs/Actions/index" {
  38021. export * from "babylonjs/Actions/abstractActionManager";
  38022. export * from "babylonjs/Actions/action";
  38023. export * from "babylonjs/Actions/actionEvent";
  38024. export * from "babylonjs/Actions/actionManager";
  38025. export * from "babylonjs/Actions/condition";
  38026. export * from "babylonjs/Actions/directActions";
  38027. export * from "babylonjs/Actions/directAudioActions";
  38028. export * from "babylonjs/Actions/interpolateValueAction";
  38029. }
  38030. declare module "babylonjs/Animations/index" {
  38031. export * from "babylonjs/Animations/animatable";
  38032. export * from "babylonjs/Animations/animation";
  38033. export * from "babylonjs/Animations/animationGroup";
  38034. export * from "babylonjs/Animations/animationPropertiesOverride";
  38035. export * from "babylonjs/Animations/easing";
  38036. export * from "babylonjs/Animations/runtimeAnimation";
  38037. export * from "babylonjs/Animations/animationEvent";
  38038. export * from "babylonjs/Animations/animationGroup";
  38039. export * from "babylonjs/Animations/animationKey";
  38040. export * from "babylonjs/Animations/animationRange";
  38041. export * from "babylonjs/Animations/animatable.interface";
  38042. }
  38043. declare module "babylonjs/Audio/soundTrack" {
  38044. import { Sound } from "babylonjs/Audio/sound";
  38045. import { Analyser } from "babylonjs/Audio/analyser";
  38046. import { Scene } from "babylonjs/scene";
  38047. /**
  38048. * Options allowed during the creation of a sound track.
  38049. */
  38050. export interface ISoundTrackOptions {
  38051. /**
  38052. * The volume the sound track should take during creation
  38053. */
  38054. volume?: number;
  38055. /**
  38056. * Define if the sound track is the main sound track of the scene
  38057. */
  38058. mainTrack?: boolean;
  38059. }
  38060. /**
  38061. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38062. * It will be also used in a future release to apply effects on a specific track.
  38063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38064. */
  38065. export class SoundTrack {
  38066. /**
  38067. * The unique identifier of the sound track in the scene.
  38068. */
  38069. id: number;
  38070. /**
  38071. * The list of sounds included in the sound track.
  38072. */
  38073. soundCollection: Array<Sound>;
  38074. private _outputAudioNode;
  38075. private _scene;
  38076. private _connectedAnalyser;
  38077. private _options;
  38078. private _isInitialized;
  38079. /**
  38080. * Creates a new sound track.
  38081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38082. * @param scene Define the scene the sound track belongs to
  38083. * @param options
  38084. */
  38085. constructor(scene: Scene, options?: ISoundTrackOptions);
  38086. private _initializeSoundTrackAudioGraph;
  38087. /**
  38088. * Release the sound track and its associated resources
  38089. */
  38090. dispose(): void;
  38091. /**
  38092. * Adds a sound to this sound track
  38093. * @param sound define the cound to add
  38094. * @ignoreNaming
  38095. */
  38096. AddSound(sound: Sound): void;
  38097. /**
  38098. * Removes a sound to this sound track
  38099. * @param sound define the cound to remove
  38100. * @ignoreNaming
  38101. */
  38102. RemoveSound(sound: Sound): void;
  38103. /**
  38104. * Set a global volume for the full sound track.
  38105. * @param newVolume Define the new volume of the sound track
  38106. */
  38107. setVolume(newVolume: number): void;
  38108. /**
  38109. * Switch the panning model to HRTF:
  38110. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38112. */
  38113. switchPanningModelToHRTF(): void;
  38114. /**
  38115. * Switch the panning model to Equal Power:
  38116. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38118. */
  38119. switchPanningModelToEqualPower(): void;
  38120. /**
  38121. * Connect the sound track to an audio analyser allowing some amazing
  38122. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38124. * @param analyser The analyser to connect to the engine
  38125. */
  38126. connectToAnalyser(analyser: Analyser): void;
  38127. }
  38128. }
  38129. declare module "babylonjs/Audio/audioSceneComponent" {
  38130. import { Sound } from "babylonjs/Audio/sound";
  38131. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38132. import { Nullable } from "babylonjs/types";
  38133. import { Vector3 } from "babylonjs/Maths/math.vector";
  38134. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38135. import { Scene } from "babylonjs/scene";
  38136. import { AbstractScene } from "babylonjs/abstractScene";
  38137. import "babylonjs/Audio/audioEngine";
  38138. module "babylonjs/abstractScene" {
  38139. interface AbstractScene {
  38140. /**
  38141. * The list of sounds used in the scene.
  38142. */
  38143. sounds: Nullable<Array<Sound>>;
  38144. }
  38145. }
  38146. module "babylonjs/scene" {
  38147. interface Scene {
  38148. /**
  38149. * @hidden
  38150. * Backing field
  38151. */
  38152. _mainSoundTrack: SoundTrack;
  38153. /**
  38154. * The main sound track played by the scene.
  38155. * It cotains your primary collection of sounds.
  38156. */
  38157. mainSoundTrack: SoundTrack;
  38158. /**
  38159. * The list of sound tracks added to the scene
  38160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38161. */
  38162. soundTracks: Nullable<Array<SoundTrack>>;
  38163. /**
  38164. * Gets a sound using a given name
  38165. * @param name defines the name to search for
  38166. * @return the found sound or null if not found at all.
  38167. */
  38168. getSoundByName(name: string): Nullable<Sound>;
  38169. /**
  38170. * Gets or sets if audio support is enabled
  38171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38172. */
  38173. audioEnabled: boolean;
  38174. /**
  38175. * Gets or sets if audio will be output to headphones
  38176. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38177. */
  38178. headphone: boolean;
  38179. /**
  38180. * Gets or sets custom audio listener position provider
  38181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38182. */
  38183. audioListenerPositionProvider: Nullable<() => Vector3>;
  38184. /**
  38185. * Gets or sets a refresh rate when using 3D audio positioning
  38186. */
  38187. audioPositioningRefreshRate: number;
  38188. }
  38189. }
  38190. /**
  38191. * Defines the sound scene component responsible to manage any sounds
  38192. * in a given scene.
  38193. */
  38194. export class AudioSceneComponent implements ISceneSerializableComponent {
  38195. /**
  38196. * The component name helpfull to identify the component in the list of scene components.
  38197. */
  38198. readonly name: string;
  38199. /**
  38200. * The scene the component belongs to.
  38201. */
  38202. scene: Scene;
  38203. private _audioEnabled;
  38204. /**
  38205. * Gets whether audio is enabled or not.
  38206. * Please use related enable/disable method to switch state.
  38207. */
  38208. readonly audioEnabled: boolean;
  38209. private _headphone;
  38210. /**
  38211. * Gets whether audio is outputing to headphone or not.
  38212. * Please use the according Switch methods to change output.
  38213. */
  38214. readonly headphone: boolean;
  38215. /**
  38216. * Gets or sets a refresh rate when using 3D audio positioning
  38217. */
  38218. audioPositioningRefreshRate: number;
  38219. private _audioListenerPositionProvider;
  38220. /**
  38221. * Gets the current audio listener position provider
  38222. */
  38223. /**
  38224. * Sets a custom listener position for all sounds in the scene
  38225. * By default, this is the position of the first active camera
  38226. */
  38227. audioListenerPositionProvider: Nullable<() => Vector3>;
  38228. /**
  38229. * Creates a new instance of the component for the given scene
  38230. * @param scene Defines the scene to register the component in
  38231. */
  38232. constructor(scene: Scene);
  38233. /**
  38234. * Registers the component in a given scene
  38235. */
  38236. register(): void;
  38237. /**
  38238. * Rebuilds the elements related to this component in case of
  38239. * context lost for instance.
  38240. */
  38241. rebuild(): void;
  38242. /**
  38243. * Serializes the component data to the specified json object
  38244. * @param serializationObject The object to serialize to
  38245. */
  38246. serialize(serializationObject: any): void;
  38247. /**
  38248. * Adds all the elements from the container to the scene
  38249. * @param container the container holding the elements
  38250. */
  38251. addFromContainer(container: AbstractScene): void;
  38252. /**
  38253. * Removes all the elements in the container from the scene
  38254. * @param container contains the elements to remove
  38255. * @param dispose if the removed element should be disposed (default: false)
  38256. */
  38257. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38258. /**
  38259. * Disposes the component and the associated ressources.
  38260. */
  38261. dispose(): void;
  38262. /**
  38263. * Disables audio in the associated scene.
  38264. */
  38265. disableAudio(): void;
  38266. /**
  38267. * Enables audio in the associated scene.
  38268. */
  38269. enableAudio(): void;
  38270. /**
  38271. * Switch audio to headphone output.
  38272. */
  38273. switchAudioModeForHeadphones(): void;
  38274. /**
  38275. * Switch audio to normal speakers.
  38276. */
  38277. switchAudioModeForNormalSpeakers(): void;
  38278. private _cachedCameraDirection;
  38279. private _cachedCameraPosition;
  38280. private _lastCheck;
  38281. private _afterRender;
  38282. }
  38283. }
  38284. declare module "babylonjs/Audio/weightedsound" {
  38285. import { Sound } from "babylonjs/Audio/sound";
  38286. /**
  38287. * Wraps one or more Sound objects and selects one with random weight for playback.
  38288. */
  38289. export class WeightedSound {
  38290. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38291. loop: boolean;
  38292. private _coneInnerAngle;
  38293. private _coneOuterAngle;
  38294. private _volume;
  38295. /** A Sound is currently playing. */
  38296. isPlaying: boolean;
  38297. /** A Sound is currently paused. */
  38298. isPaused: boolean;
  38299. private _sounds;
  38300. private _weights;
  38301. private _currentIndex?;
  38302. /**
  38303. * Creates a new WeightedSound from the list of sounds given.
  38304. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38305. * @param sounds Array of Sounds that will be selected from.
  38306. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38307. */
  38308. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38309. /**
  38310. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38311. */
  38312. /**
  38313. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38314. */
  38315. directionalConeInnerAngle: number;
  38316. /**
  38317. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38318. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38319. */
  38320. /**
  38321. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38322. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38323. */
  38324. directionalConeOuterAngle: number;
  38325. /**
  38326. * Playback volume.
  38327. */
  38328. /**
  38329. * Playback volume.
  38330. */
  38331. volume: number;
  38332. private _onended;
  38333. /**
  38334. * Suspend playback
  38335. */
  38336. pause(): void;
  38337. /**
  38338. * Stop playback
  38339. */
  38340. stop(): void;
  38341. /**
  38342. * Start playback.
  38343. * @param startOffset Position the clip head at a specific time in seconds.
  38344. */
  38345. play(startOffset?: number): void;
  38346. }
  38347. }
  38348. declare module "babylonjs/Audio/index" {
  38349. export * from "babylonjs/Audio/analyser";
  38350. export * from "babylonjs/Audio/audioEngine";
  38351. export * from "babylonjs/Audio/audioSceneComponent";
  38352. export * from "babylonjs/Audio/sound";
  38353. export * from "babylonjs/Audio/soundTrack";
  38354. export * from "babylonjs/Audio/weightedsound";
  38355. }
  38356. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38357. import { Behavior } from "babylonjs/Behaviors/behavior";
  38358. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38359. import { BackEase } from "babylonjs/Animations/easing";
  38360. /**
  38361. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38362. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38363. */
  38364. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38365. /**
  38366. * Gets the name of the behavior.
  38367. */
  38368. readonly name: string;
  38369. /**
  38370. * The easing function used by animations
  38371. */
  38372. static EasingFunction: BackEase;
  38373. /**
  38374. * The easing mode used by animations
  38375. */
  38376. static EasingMode: number;
  38377. /**
  38378. * The duration of the animation, in milliseconds
  38379. */
  38380. transitionDuration: number;
  38381. /**
  38382. * Length of the distance animated by the transition when lower radius is reached
  38383. */
  38384. lowerRadiusTransitionRange: number;
  38385. /**
  38386. * Length of the distance animated by the transition when upper radius is reached
  38387. */
  38388. upperRadiusTransitionRange: number;
  38389. private _autoTransitionRange;
  38390. /**
  38391. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38392. */
  38393. /**
  38394. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38395. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38396. */
  38397. autoTransitionRange: boolean;
  38398. private _attachedCamera;
  38399. private _onAfterCheckInputsObserver;
  38400. private _onMeshTargetChangedObserver;
  38401. /**
  38402. * Initializes the behavior.
  38403. */
  38404. init(): void;
  38405. /**
  38406. * Attaches the behavior to its arc rotate camera.
  38407. * @param camera Defines the camera to attach the behavior to
  38408. */
  38409. attach(camera: ArcRotateCamera): void;
  38410. /**
  38411. * Detaches the behavior from its current arc rotate camera.
  38412. */
  38413. detach(): void;
  38414. private _radiusIsAnimating;
  38415. private _radiusBounceTransition;
  38416. private _animatables;
  38417. private _cachedWheelPrecision;
  38418. /**
  38419. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38420. * @param radiusLimit The limit to check against.
  38421. * @return Bool to indicate if at limit.
  38422. */
  38423. private _isRadiusAtLimit;
  38424. /**
  38425. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38426. * @param radiusDelta The delta by which to animate to. Can be negative.
  38427. */
  38428. private _applyBoundRadiusAnimation;
  38429. /**
  38430. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38431. */
  38432. protected _clearAnimationLocks(): void;
  38433. /**
  38434. * Stops and removes all animations that have been applied to the camera
  38435. */
  38436. stopAllAnimations(): void;
  38437. }
  38438. }
  38439. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38440. import { Behavior } from "babylonjs/Behaviors/behavior";
  38441. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38442. import { ExponentialEase } from "babylonjs/Animations/easing";
  38443. import { Nullable } from "babylonjs/types";
  38444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38445. import { Vector3 } from "babylonjs/Maths/math.vector";
  38446. /**
  38447. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  38448. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38449. */
  38450. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38451. /**
  38452. * Gets the name of the behavior.
  38453. */
  38454. readonly name: string;
  38455. private _mode;
  38456. private _radiusScale;
  38457. private _positionScale;
  38458. private _defaultElevation;
  38459. private _elevationReturnTime;
  38460. private _elevationReturnWaitTime;
  38461. private _zoomStopsAnimation;
  38462. private _framingTime;
  38463. /**
  38464. * The easing function used by animations
  38465. */
  38466. static EasingFunction: ExponentialEase;
  38467. /**
  38468. * The easing mode used by animations
  38469. */
  38470. static EasingMode: number;
  38471. /**
  38472. * Sets the current mode used by the behavior
  38473. */
  38474. /**
  38475. * Gets current mode used by the behavior.
  38476. */
  38477. mode: number;
  38478. /**
  38479. * Sets the scale applied to the radius (1 by default)
  38480. */
  38481. /**
  38482. * Gets the scale applied to the radius
  38483. */
  38484. radiusScale: number;
  38485. /**
  38486. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38487. */
  38488. /**
  38489. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38490. */
  38491. positionScale: number;
  38492. /**
  38493. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38494. * behaviour is triggered, in radians.
  38495. */
  38496. /**
  38497. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38498. * behaviour is triggered, in radians.
  38499. */
  38500. defaultElevation: number;
  38501. /**
  38502. * Sets the time (in milliseconds) taken to return to the default beta position.
  38503. * Negative value indicates camera should not return to default.
  38504. */
  38505. /**
  38506. * Gets the time (in milliseconds) taken to return to the default beta position.
  38507. * Negative value indicates camera should not return to default.
  38508. */
  38509. elevationReturnTime: number;
  38510. /**
  38511. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38512. */
  38513. /**
  38514. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38515. */
  38516. elevationReturnWaitTime: number;
  38517. /**
  38518. * Sets the flag that indicates if user zooming should stop animation.
  38519. */
  38520. /**
  38521. * Gets the flag that indicates if user zooming should stop animation.
  38522. */
  38523. zoomStopsAnimation: boolean;
  38524. /**
  38525. * Sets the transition time when framing the mesh, in milliseconds
  38526. */
  38527. /**
  38528. * Gets the transition time when framing the mesh, in milliseconds
  38529. */
  38530. framingTime: number;
  38531. /**
  38532. * Define if the behavior should automatically change the configured
  38533. * camera limits and sensibilities.
  38534. */
  38535. autoCorrectCameraLimitsAndSensibility: boolean;
  38536. private _onPrePointerObservableObserver;
  38537. private _onAfterCheckInputsObserver;
  38538. private _onMeshTargetChangedObserver;
  38539. private _attachedCamera;
  38540. private _isPointerDown;
  38541. private _lastInteractionTime;
  38542. /**
  38543. * Initializes the behavior.
  38544. */
  38545. init(): void;
  38546. /**
  38547. * Attaches the behavior to its arc rotate camera.
  38548. * @param camera Defines the camera to attach the behavior to
  38549. */
  38550. attach(camera: ArcRotateCamera): void;
  38551. /**
  38552. * Detaches the behavior from its current arc rotate camera.
  38553. */
  38554. detach(): void;
  38555. private _animatables;
  38556. private _betaIsAnimating;
  38557. private _betaTransition;
  38558. private _radiusTransition;
  38559. private _vectorTransition;
  38560. /**
  38561. * Targets the given mesh and updates zoom level accordingly.
  38562. * @param mesh The mesh to target.
  38563. * @param radius Optional. If a cached radius position already exists, overrides default.
  38564. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38565. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38566. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38567. */
  38568. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38569. /**
  38570. * Targets the given mesh with its children and updates zoom level accordingly.
  38571. * @param mesh The mesh to target.
  38572. * @param radius Optional. If a cached radius position already exists, overrides default.
  38573. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38574. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38575. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38576. */
  38577. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38578. /**
  38579. * Targets the given meshes with their children and updates zoom level accordingly.
  38580. * @param meshes The mesh to target.
  38581. * @param radius Optional. If a cached radius position already exists, overrides default.
  38582. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38583. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38584. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38585. */
  38586. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38587. /**
  38588. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38589. * @param minimumWorld Determines the smaller position of the bounding box extend
  38590. * @param maximumWorld Determines the bigger position of the bounding box extend
  38591. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38592. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38593. */
  38594. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38595. /**
  38596. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38597. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38598. * frustum width.
  38599. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38600. * to fully enclose the mesh in the viewing frustum.
  38601. */
  38602. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38603. /**
  38604. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38605. * is automatically returned to its default position (expected to be above ground plane).
  38606. */
  38607. private _maintainCameraAboveGround;
  38608. /**
  38609. * Returns the frustum slope based on the canvas ratio and camera FOV
  38610. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38611. */
  38612. private _getFrustumSlope;
  38613. /**
  38614. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38615. */
  38616. private _clearAnimationLocks;
  38617. /**
  38618. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38619. */
  38620. private _applyUserInteraction;
  38621. /**
  38622. * Stops and removes all animations that have been applied to the camera
  38623. */
  38624. stopAllAnimations(): void;
  38625. /**
  38626. * Gets a value indicating if the user is moving the camera
  38627. */
  38628. readonly isUserIsMoving: boolean;
  38629. /**
  38630. * The camera can move all the way towards the mesh.
  38631. */
  38632. static IgnoreBoundsSizeMode: number;
  38633. /**
  38634. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38635. */
  38636. static FitFrustumSidesMode: number;
  38637. }
  38638. }
  38639. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  38640. import { Nullable } from "babylonjs/types";
  38641. import { Camera } from "babylonjs/Cameras/camera";
  38642. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38643. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38644. /**
  38645. * Base class for Camera Pointer Inputs.
  38646. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38647. * for example usage.
  38648. */
  38649. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38650. /**
  38651. * Defines the camera the input is attached to.
  38652. */
  38653. abstract camera: Camera;
  38654. /**
  38655. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38656. */
  38657. protected _altKey: boolean;
  38658. protected _ctrlKey: boolean;
  38659. protected _metaKey: boolean;
  38660. protected _shiftKey: boolean;
  38661. /**
  38662. * Which mouse buttons were pressed at time of last mouse event.
  38663. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38664. */
  38665. protected _buttonsPressed: number;
  38666. /**
  38667. * Defines the buttons associated with the input to handle camera move.
  38668. */
  38669. buttons: number[];
  38670. /**
  38671. * Attach the input controls to a specific dom element to get the input from.
  38672. * @param element Defines the element the controls should be listened from
  38673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38674. */
  38675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38676. /**
  38677. * Detach the current controls from the specified dom element.
  38678. * @param element Defines the element to stop listening the inputs from
  38679. */
  38680. detachControl(element: Nullable<HTMLElement>): void;
  38681. /**
  38682. * Gets the class name of the current input.
  38683. * @returns the class name
  38684. */
  38685. getClassName(): string;
  38686. /**
  38687. * Get the friendly name associated with the input class.
  38688. * @returns the input friendly name
  38689. */
  38690. getSimpleName(): string;
  38691. /**
  38692. * Called on pointer POINTERDOUBLETAP event.
  38693. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38694. */
  38695. protected onDoubleTap(type: string): void;
  38696. /**
  38697. * Called on pointer POINTERMOVE event if only a single touch is active.
  38698. * Override this method to provide functionality.
  38699. */
  38700. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38701. /**
  38702. * Called on pointer POINTERMOVE event if multiple touches are active.
  38703. * Override this method to provide functionality.
  38704. */
  38705. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38706. /**
  38707. * Called on JS contextmenu event.
  38708. * Override this method to provide functionality.
  38709. */
  38710. protected onContextMenu(evt: PointerEvent): void;
  38711. /**
  38712. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38713. * press.
  38714. * Override this method to provide functionality.
  38715. */
  38716. protected onButtonDown(evt: PointerEvent): void;
  38717. /**
  38718. * Called each time a new POINTERUP event occurs. Ie, for each button
  38719. * release.
  38720. * Override this method to provide functionality.
  38721. */
  38722. protected onButtonUp(evt: PointerEvent): void;
  38723. /**
  38724. * Called when window becomes inactive.
  38725. * Override this method to provide functionality.
  38726. */
  38727. protected onLostFocus(): void;
  38728. private _pointerInput;
  38729. private _observer;
  38730. private _onLostFocus;
  38731. private pointA;
  38732. private pointB;
  38733. }
  38734. }
  38735. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  38736. import { Nullable } from "babylonjs/types";
  38737. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38738. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38739. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38740. /**
  38741. * Manage the pointers inputs to control an arc rotate camera.
  38742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38743. */
  38744. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38745. /**
  38746. * Defines the camera the input is attached to.
  38747. */
  38748. camera: ArcRotateCamera;
  38749. /**
  38750. * Gets the class name of the current input.
  38751. * @returns the class name
  38752. */
  38753. getClassName(): string;
  38754. /**
  38755. * Defines the buttons associated with the input to handle camera move.
  38756. */
  38757. buttons: number[];
  38758. /**
  38759. * Defines the pointer angular sensibility along the X axis or how fast is
  38760. * the camera rotating.
  38761. */
  38762. angularSensibilityX: number;
  38763. /**
  38764. * Defines the pointer angular sensibility along the Y axis or how fast is
  38765. * the camera rotating.
  38766. */
  38767. angularSensibilityY: number;
  38768. /**
  38769. * Defines the pointer pinch precision or how fast is the camera zooming.
  38770. */
  38771. pinchPrecision: number;
  38772. /**
  38773. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38774. * from 0.
  38775. * It defines the percentage of current camera.radius to use as delta when
  38776. * pinch zoom is used.
  38777. */
  38778. pinchDeltaPercentage: number;
  38779. /**
  38780. * Defines the pointer panning sensibility or how fast is the camera moving.
  38781. */
  38782. panningSensibility: number;
  38783. /**
  38784. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38785. */
  38786. multiTouchPanning: boolean;
  38787. /**
  38788. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38789. * zoom (pinch) through multitouch.
  38790. */
  38791. multiTouchPanAndZoom: boolean;
  38792. /**
  38793. * Revers pinch action direction.
  38794. */
  38795. pinchInwards: boolean;
  38796. private _isPanClick;
  38797. private _twoFingerActivityCount;
  38798. private _isPinching;
  38799. /**
  38800. * Called on pointer POINTERMOVE event if only a single touch is active.
  38801. */
  38802. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38803. /**
  38804. * Called on pointer POINTERDOUBLETAP event.
  38805. */
  38806. protected onDoubleTap(type: string): void;
  38807. /**
  38808. * Called on pointer POINTERMOVE event if multiple touches are active.
  38809. */
  38810. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38811. /**
  38812. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38813. * press.
  38814. */
  38815. protected onButtonDown(evt: PointerEvent): void;
  38816. /**
  38817. * Called each time a new POINTERUP event occurs. Ie, for each button
  38818. * release.
  38819. */
  38820. protected onButtonUp(evt: PointerEvent): void;
  38821. /**
  38822. * Called when window becomes inactive.
  38823. */
  38824. protected onLostFocus(): void;
  38825. }
  38826. }
  38827. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  38828. import { Nullable } from "babylonjs/types";
  38829. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38830. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38831. /**
  38832. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38834. */
  38835. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38836. /**
  38837. * Defines the camera the input is attached to.
  38838. */
  38839. camera: ArcRotateCamera;
  38840. /**
  38841. * Defines the list of key codes associated with the up action (increase alpha)
  38842. */
  38843. keysUp: number[];
  38844. /**
  38845. * Defines the list of key codes associated with the down action (decrease alpha)
  38846. */
  38847. keysDown: number[];
  38848. /**
  38849. * Defines the list of key codes associated with the left action (increase beta)
  38850. */
  38851. keysLeft: number[];
  38852. /**
  38853. * Defines the list of key codes associated with the right action (decrease beta)
  38854. */
  38855. keysRight: number[];
  38856. /**
  38857. * Defines the list of key codes associated with the reset action.
  38858. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38859. */
  38860. keysReset: number[];
  38861. /**
  38862. * Defines the panning sensibility of the inputs.
  38863. * (How fast is the camera paning)
  38864. */
  38865. panningSensibility: number;
  38866. /**
  38867. * Defines the zooming sensibility of the inputs.
  38868. * (How fast is the camera zooming)
  38869. */
  38870. zoomingSensibility: number;
  38871. /**
  38872. * Defines wether maintaining the alt key down switch the movement mode from
  38873. * orientation to zoom.
  38874. */
  38875. useAltToZoom: boolean;
  38876. /**
  38877. * Rotation speed of the camera
  38878. */
  38879. angularSpeed: number;
  38880. private _keys;
  38881. private _ctrlPressed;
  38882. private _altPressed;
  38883. private _onCanvasBlurObserver;
  38884. private _onKeyboardObserver;
  38885. private _engine;
  38886. private _scene;
  38887. /**
  38888. * Attach the input controls to a specific dom element to get the input from.
  38889. * @param element Defines the element the controls should be listened from
  38890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38891. */
  38892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38893. /**
  38894. * Detach the current controls from the specified dom element.
  38895. * @param element Defines the element to stop listening the inputs from
  38896. */
  38897. detachControl(element: Nullable<HTMLElement>): void;
  38898. /**
  38899. * Update the current camera state depending on the inputs that have been used this frame.
  38900. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38901. */
  38902. checkInputs(): void;
  38903. /**
  38904. * Gets the class name of the current intput.
  38905. * @returns the class name
  38906. */
  38907. getClassName(): string;
  38908. /**
  38909. * Get the friendly name associated with the input class.
  38910. * @returns the input friendly name
  38911. */
  38912. getSimpleName(): string;
  38913. }
  38914. }
  38915. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  38916. import { Nullable } from "babylonjs/types";
  38917. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38918. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38919. /**
  38920. * Manage the mouse wheel inputs to control an arc rotate camera.
  38921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38922. */
  38923. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38924. /**
  38925. * Defines the camera the input is attached to.
  38926. */
  38927. camera: ArcRotateCamera;
  38928. /**
  38929. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38930. */
  38931. wheelPrecision: number;
  38932. /**
  38933. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38934. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38935. */
  38936. wheelDeltaPercentage: number;
  38937. private _wheel;
  38938. private _observer;
  38939. private computeDeltaFromMouseWheelLegacyEvent;
  38940. /**
  38941. * Attach the input controls to a specific dom element to get the input from.
  38942. * @param element Defines the element the controls should be listened from
  38943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38944. */
  38945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38946. /**
  38947. * Detach the current controls from the specified dom element.
  38948. * @param element Defines the element to stop listening the inputs from
  38949. */
  38950. detachControl(element: Nullable<HTMLElement>): void;
  38951. /**
  38952. * Gets the class name of the current intput.
  38953. * @returns the class name
  38954. */
  38955. getClassName(): string;
  38956. /**
  38957. * Get the friendly name associated with the input class.
  38958. * @returns the input friendly name
  38959. */
  38960. getSimpleName(): string;
  38961. }
  38962. }
  38963. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38964. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38965. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38966. /**
  38967. * Default Inputs manager for the ArcRotateCamera.
  38968. * It groups all the default supported inputs for ease of use.
  38969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38970. */
  38971. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38972. /**
  38973. * Instantiates a new ArcRotateCameraInputsManager.
  38974. * @param camera Defines the camera the inputs belong to
  38975. */
  38976. constructor(camera: ArcRotateCamera);
  38977. /**
  38978. * Add mouse wheel input support to the input manager.
  38979. * @returns the current input manager
  38980. */
  38981. addMouseWheel(): ArcRotateCameraInputsManager;
  38982. /**
  38983. * Add pointers input support to the input manager.
  38984. * @returns the current input manager
  38985. */
  38986. addPointers(): ArcRotateCameraInputsManager;
  38987. /**
  38988. * Add keyboard input support to the input manager.
  38989. * @returns the current input manager
  38990. */
  38991. addKeyboard(): ArcRotateCameraInputsManager;
  38992. }
  38993. }
  38994. declare module "babylonjs/Cameras/arcRotateCamera" {
  38995. import { Observable } from "babylonjs/Misc/observable";
  38996. import { Nullable } from "babylonjs/types";
  38997. import { Scene } from "babylonjs/scene";
  38998. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  38999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39000. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39001. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39002. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39003. import { Camera } from "babylonjs/Cameras/camera";
  39004. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39005. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39006. import { Collider } from "babylonjs/Collisions/collider";
  39007. /**
  39008. * This represents an orbital type of camera.
  39009. *
  39010. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  39011. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  39012. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39013. */
  39014. export class ArcRotateCamera extends TargetCamera {
  39015. /**
  39016. * Defines the rotation angle of the camera along the longitudinal axis.
  39017. */
  39018. alpha: number;
  39019. /**
  39020. * Defines the rotation angle of the camera along the latitudinal axis.
  39021. */
  39022. beta: number;
  39023. /**
  39024. * Defines the radius of the camera from it s target point.
  39025. */
  39026. radius: number;
  39027. protected _target: Vector3;
  39028. protected _targetHost: Nullable<AbstractMesh>;
  39029. /**
  39030. * Defines the target point of the camera.
  39031. * The camera looks towards it form the radius distance.
  39032. */
  39033. target: Vector3;
  39034. /**
  39035. * Define the current local position of the camera in the scene
  39036. */
  39037. position: Vector3;
  39038. protected _upVector: Vector3;
  39039. protected _upToYMatrix: Matrix;
  39040. protected _YToUpMatrix: Matrix;
  39041. /**
  39042. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39043. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39044. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39045. */
  39046. upVector: Vector3;
  39047. /**
  39048. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39049. */
  39050. setMatUp(): void;
  39051. /**
  39052. * Current inertia value on the longitudinal axis.
  39053. * The bigger this number the longer it will take for the camera to stop.
  39054. */
  39055. inertialAlphaOffset: number;
  39056. /**
  39057. * Current inertia value on the latitudinal axis.
  39058. * The bigger this number the longer it will take for the camera to stop.
  39059. */
  39060. inertialBetaOffset: number;
  39061. /**
  39062. * Current inertia value on the radius axis.
  39063. * The bigger this number the longer it will take for the camera to stop.
  39064. */
  39065. inertialRadiusOffset: number;
  39066. /**
  39067. * Minimum allowed angle on the longitudinal axis.
  39068. * This can help limiting how the Camera is able to move in the scene.
  39069. */
  39070. lowerAlphaLimit: Nullable<number>;
  39071. /**
  39072. * Maximum allowed angle on the longitudinal axis.
  39073. * This can help limiting how the Camera is able to move in the scene.
  39074. */
  39075. upperAlphaLimit: Nullable<number>;
  39076. /**
  39077. * Minimum allowed angle on the latitudinal axis.
  39078. * This can help limiting how the Camera is able to move in the scene.
  39079. */
  39080. lowerBetaLimit: number;
  39081. /**
  39082. * Maximum allowed angle on the latitudinal axis.
  39083. * This can help limiting how the Camera is able to move in the scene.
  39084. */
  39085. upperBetaLimit: number;
  39086. /**
  39087. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39088. * This can help limiting how the Camera is able to move in the scene.
  39089. */
  39090. lowerRadiusLimit: Nullable<number>;
  39091. /**
  39092. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39093. * This can help limiting how the Camera is able to move in the scene.
  39094. */
  39095. upperRadiusLimit: Nullable<number>;
  39096. /**
  39097. * Defines the current inertia value used during panning of the camera along the X axis.
  39098. */
  39099. inertialPanningX: number;
  39100. /**
  39101. * Defines the current inertia value used during panning of the camera along the Y axis.
  39102. */
  39103. inertialPanningY: number;
  39104. /**
  39105. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39106. * Basically if your fingers moves away from more than this distance you will be considered
  39107. * in pinch mode.
  39108. */
  39109. pinchToPanMaxDistance: number;
  39110. /**
  39111. * Defines the maximum distance the camera can pan.
  39112. * This could help keeping the cammera always in your scene.
  39113. */
  39114. panningDistanceLimit: Nullable<number>;
  39115. /**
  39116. * Defines the target of the camera before paning.
  39117. */
  39118. panningOriginTarget: Vector3;
  39119. /**
  39120. * Defines the value of the inertia used during panning.
  39121. * 0 would mean stop inertia and one would mean no decelleration at all.
  39122. */
  39123. panningInertia: number;
  39124. /**
  39125. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39126. */
  39127. angularSensibilityX: number;
  39128. /**
  39129. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39130. */
  39131. angularSensibilityY: number;
  39132. /**
  39133. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39134. */
  39135. pinchPrecision: number;
  39136. /**
  39137. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39138. * It will be used instead of pinchDeltaPrecision if different from 0.
  39139. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39140. */
  39141. pinchDeltaPercentage: number;
  39142. /**
  39143. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39144. */
  39145. panningSensibility: number;
  39146. /**
  39147. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39148. */
  39149. keysUp: number[];
  39150. /**
  39151. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39152. */
  39153. keysDown: number[];
  39154. /**
  39155. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39156. */
  39157. keysLeft: number[];
  39158. /**
  39159. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39160. */
  39161. keysRight: number[];
  39162. /**
  39163. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39164. */
  39165. wheelPrecision: number;
  39166. /**
  39167. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39168. * It will be used instead of pinchDeltaPrecision if different from 0.
  39169. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39170. */
  39171. wheelDeltaPercentage: number;
  39172. /**
  39173. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39174. */
  39175. zoomOnFactor: number;
  39176. /**
  39177. * Defines a screen offset for the camera position.
  39178. */
  39179. targetScreenOffset: Vector2;
  39180. /**
  39181. * Allows the camera to be completely reversed.
  39182. * If false the camera can not arrive upside down.
  39183. */
  39184. allowUpsideDown: boolean;
  39185. /**
  39186. * Define if double tap/click is used to restore the previously saved state of the camera.
  39187. */
  39188. useInputToRestoreState: boolean;
  39189. /** @hidden */
  39190. _viewMatrix: Matrix;
  39191. /** @hidden */
  39192. _useCtrlForPanning: boolean;
  39193. /** @hidden */
  39194. _panningMouseButton: number;
  39195. /**
  39196. * Defines the input associated to the camera.
  39197. */
  39198. inputs: ArcRotateCameraInputsManager;
  39199. /** @hidden */
  39200. _reset: () => void;
  39201. /**
  39202. * Defines the allowed panning axis.
  39203. */
  39204. panningAxis: Vector3;
  39205. protected _localDirection: Vector3;
  39206. protected _transformedDirection: Vector3;
  39207. private _bouncingBehavior;
  39208. /**
  39209. * Gets the bouncing behavior of the camera if it has been enabled.
  39210. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39211. */
  39212. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  39213. /**
  39214. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39216. */
  39217. useBouncingBehavior: boolean;
  39218. private _framingBehavior;
  39219. /**
  39220. * Gets the framing behavior of the camera if it has been enabled.
  39221. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39222. */
  39223. readonly framingBehavior: Nullable<FramingBehavior>;
  39224. /**
  39225. * Defines if the framing behavior of the camera is enabled on the camera.
  39226. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39227. */
  39228. useFramingBehavior: boolean;
  39229. private _autoRotationBehavior;
  39230. /**
  39231. * Gets the auto rotation behavior of the camera if it has been enabled.
  39232. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39233. */
  39234. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  39235. /**
  39236. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39237. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39238. */
  39239. useAutoRotationBehavior: boolean;
  39240. /**
  39241. * Observable triggered when the mesh target has been changed on the camera.
  39242. */
  39243. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39244. /**
  39245. * Event raised when the camera is colliding with a mesh.
  39246. */
  39247. onCollide: (collidedMesh: AbstractMesh) => void;
  39248. /**
  39249. * Defines whether the camera should check collision with the objects oh the scene.
  39250. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39251. */
  39252. checkCollisions: boolean;
  39253. /**
  39254. * Defines the collision radius of the camera.
  39255. * This simulates a sphere around the camera.
  39256. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39257. */
  39258. collisionRadius: Vector3;
  39259. protected _collider: Collider;
  39260. protected _previousPosition: Vector3;
  39261. protected _collisionVelocity: Vector3;
  39262. protected _newPosition: Vector3;
  39263. protected _previousAlpha: number;
  39264. protected _previousBeta: number;
  39265. protected _previousRadius: number;
  39266. protected _collisionTriggered: boolean;
  39267. protected _targetBoundingCenter: Nullable<Vector3>;
  39268. private _computationVector;
  39269. /**
  39270. * Instantiates a new ArcRotateCamera in a given scene
  39271. * @param name Defines the name of the camera
  39272. * @param alpha Defines the camera rotation along the logitudinal axis
  39273. * @param beta Defines the camera rotation along the latitudinal axis
  39274. * @param radius Defines the camera distance from its target
  39275. * @param target Defines the camera target
  39276. * @param scene Defines the scene the camera belongs to
  39277. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39278. */
  39279. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39280. /** @hidden */
  39281. _initCache(): void;
  39282. /** @hidden */
  39283. _updateCache(ignoreParentClass?: boolean): void;
  39284. protected _getTargetPosition(): Vector3;
  39285. private _storedAlpha;
  39286. private _storedBeta;
  39287. private _storedRadius;
  39288. private _storedTarget;
  39289. private _storedTargetScreenOffset;
  39290. /**
  39291. * Stores the current state of the camera (alpha, beta, radius and target)
  39292. * @returns the camera itself
  39293. */
  39294. storeState(): Camera;
  39295. /**
  39296. * @hidden
  39297. * Restored camera state. You must call storeState() first
  39298. */
  39299. _restoreStateValues(): boolean;
  39300. /** @hidden */
  39301. _isSynchronizedViewMatrix(): boolean;
  39302. /**
  39303. * Attached controls to the current camera.
  39304. * @param element Defines the element the controls should be listened from
  39305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39306. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39307. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39308. */
  39309. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39310. /**
  39311. * Detach the current controls from the camera.
  39312. * The camera will stop reacting to inputs.
  39313. * @param element Defines the element to stop listening the inputs from
  39314. */
  39315. detachControl(element: HTMLElement): void;
  39316. /** @hidden */
  39317. _checkInputs(): void;
  39318. protected _checkLimits(): void;
  39319. /**
  39320. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39321. */
  39322. rebuildAnglesAndRadius(): void;
  39323. /**
  39324. * Use a position to define the current camera related information like alpha, beta and radius
  39325. * @param position Defines the position to set the camera at
  39326. */
  39327. setPosition(position: Vector3): void;
  39328. /**
  39329. * Defines the target the camera should look at.
  39330. * This will automatically adapt alpha beta and radius to fit within the new target.
  39331. * @param target Defines the new target as a Vector or a mesh
  39332. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39333. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39334. */
  39335. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39336. /** @hidden */
  39337. _getViewMatrix(): Matrix;
  39338. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39339. /**
  39340. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39341. * @param meshes Defines the mesh to zoom on
  39342. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  39343. */
  39344. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39345. /**
  39346. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39347. * The target will be changed but the radius
  39348. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39349. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  39350. */
  39351. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39352. min: Vector3;
  39353. max: Vector3;
  39354. distance: number;
  39355. }, doNotUpdateMaxZ?: boolean): void;
  39356. /**
  39357. * @override
  39358. * Override Camera.createRigCamera
  39359. */
  39360. createRigCamera(name: string, cameraIndex: number): Camera;
  39361. /**
  39362. * @hidden
  39363. * @override
  39364. * Override Camera._updateRigCameras
  39365. */
  39366. _updateRigCameras(): void;
  39367. /**
  39368. * Destroy the camera and release the current resources hold by it.
  39369. */
  39370. dispose(): void;
  39371. /**
  39372. * Gets the current object class name.
  39373. * @return the class name
  39374. */
  39375. getClassName(): string;
  39376. }
  39377. }
  39378. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39379. import { Behavior } from "babylonjs/Behaviors/behavior";
  39380. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39381. /**
  39382. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39383. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39384. */
  39385. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39386. /**
  39387. * Gets the name of the behavior.
  39388. */
  39389. readonly name: string;
  39390. private _zoomStopsAnimation;
  39391. private _idleRotationSpeed;
  39392. private _idleRotationWaitTime;
  39393. private _idleRotationSpinupTime;
  39394. /**
  39395. * Sets the flag that indicates if user zooming should stop animation.
  39396. */
  39397. /**
  39398. * Gets the flag that indicates if user zooming should stop animation.
  39399. */
  39400. zoomStopsAnimation: boolean;
  39401. /**
  39402. * Sets the default speed at which the camera rotates around the model.
  39403. */
  39404. /**
  39405. * Gets the default speed at which the camera rotates around the model.
  39406. */
  39407. idleRotationSpeed: number;
  39408. /**
  39409. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39410. */
  39411. /**
  39412. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39413. */
  39414. idleRotationWaitTime: number;
  39415. /**
  39416. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39417. */
  39418. /**
  39419. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39420. */
  39421. idleRotationSpinupTime: number;
  39422. /**
  39423. * Gets a value indicating if the camera is currently rotating because of this behavior
  39424. */
  39425. readonly rotationInProgress: boolean;
  39426. private _onPrePointerObservableObserver;
  39427. private _onAfterCheckInputsObserver;
  39428. private _attachedCamera;
  39429. private _isPointerDown;
  39430. private _lastFrameTime;
  39431. private _lastInteractionTime;
  39432. private _cameraRotationSpeed;
  39433. /**
  39434. * Initializes the behavior.
  39435. */
  39436. init(): void;
  39437. /**
  39438. * Attaches the behavior to its arc rotate camera.
  39439. * @param camera Defines the camera to attach the behavior to
  39440. */
  39441. attach(camera: ArcRotateCamera): void;
  39442. /**
  39443. * Detaches the behavior from its current arc rotate camera.
  39444. */
  39445. detach(): void;
  39446. /**
  39447. * Returns true if user is scrolling.
  39448. * @return true if user is scrolling.
  39449. */
  39450. private _userIsZooming;
  39451. private _lastFrameRadius;
  39452. private _shouldAnimationStopForInteraction;
  39453. /**
  39454. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39455. */
  39456. private _applyUserInteraction;
  39457. private _userIsMoving;
  39458. }
  39459. }
  39460. declare module "babylonjs/Behaviors/Cameras/index" {
  39461. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39462. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39463. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39464. }
  39465. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39466. import { Mesh } from "babylonjs/Meshes/mesh";
  39467. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39468. import { Behavior } from "babylonjs/Behaviors/behavior";
  39469. /**
  39470. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39471. */
  39472. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39473. private ui;
  39474. /**
  39475. * The name of the behavior
  39476. */
  39477. name: string;
  39478. /**
  39479. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39480. */
  39481. distanceAwayFromFace: number;
  39482. /**
  39483. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39484. */
  39485. distanceAwayFromBottomOfFace: number;
  39486. private _faceVectors;
  39487. private _target;
  39488. private _scene;
  39489. private _onRenderObserver;
  39490. private _tmpMatrix;
  39491. private _tmpVector;
  39492. /**
  39493. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39494. * @param ui The transform node that should be attched to the mesh
  39495. */
  39496. constructor(ui: TransformNode);
  39497. /**
  39498. * Initializes the behavior
  39499. */
  39500. init(): void;
  39501. private _closestFace;
  39502. private _zeroVector;
  39503. private _lookAtTmpMatrix;
  39504. private _lookAtToRef;
  39505. /**
  39506. * Attaches the AttachToBoxBehavior to the passed in mesh
  39507. * @param target The mesh that the specified node will be attached to
  39508. */
  39509. attach(target: Mesh): void;
  39510. /**
  39511. * Detaches the behavior from the mesh
  39512. */
  39513. detach(): void;
  39514. }
  39515. }
  39516. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39517. import { Behavior } from "babylonjs/Behaviors/behavior";
  39518. import { Mesh } from "babylonjs/Meshes/mesh";
  39519. /**
  39520. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39521. */
  39522. export class FadeInOutBehavior implements Behavior<Mesh> {
  39523. /**
  39524. * Time in milliseconds to delay before fading in (Default: 0)
  39525. */
  39526. delay: number;
  39527. /**
  39528. * Time in milliseconds for the mesh to fade in (Default: 300)
  39529. */
  39530. fadeInTime: number;
  39531. private _millisecondsPerFrame;
  39532. private _hovered;
  39533. private _hoverValue;
  39534. private _ownerNode;
  39535. /**
  39536. * Instatiates the FadeInOutBehavior
  39537. */
  39538. constructor();
  39539. /**
  39540. * The name of the behavior
  39541. */
  39542. readonly name: string;
  39543. /**
  39544. * Initializes the behavior
  39545. */
  39546. init(): void;
  39547. /**
  39548. * Attaches the fade behavior on the passed in mesh
  39549. * @param ownerNode The mesh that will be faded in/out once attached
  39550. */
  39551. attach(ownerNode: Mesh): void;
  39552. /**
  39553. * Detaches the behavior from the mesh
  39554. */
  39555. detach(): void;
  39556. /**
  39557. * Triggers the mesh to begin fading in or out
  39558. * @param value if the object should fade in or out (true to fade in)
  39559. */
  39560. fadeIn(value: boolean): void;
  39561. private _update;
  39562. private _setAllVisibility;
  39563. }
  39564. }
  39565. declare module "babylonjs/Misc/pivotTools" {
  39566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39567. /**
  39568. * Class containing a set of static utilities functions for managing Pivots
  39569. * @hidden
  39570. */
  39571. export class PivotTools {
  39572. private static _PivotCached;
  39573. private static _OldPivotPoint;
  39574. private static _PivotTranslation;
  39575. private static _PivotTmpVector;
  39576. /** @hidden */
  39577. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39578. /** @hidden */
  39579. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39580. }
  39581. }
  39582. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39583. import { Scene } from "babylonjs/scene";
  39584. import { Vector4 } from "babylonjs/Maths/math.vector";
  39585. import { Mesh } from "babylonjs/Meshes/mesh";
  39586. import { Nullable } from "babylonjs/types";
  39587. import { Plane } from "babylonjs/Maths/math.plane";
  39588. /**
  39589. * Class containing static functions to help procedurally build meshes
  39590. */
  39591. export class PlaneBuilder {
  39592. /**
  39593. * Creates a plane mesh
  39594. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39595. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39596. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39600. * @param name defines the name of the mesh
  39601. * @param options defines the options used to create the mesh
  39602. * @param scene defines the hosting scene
  39603. * @returns the plane mesh
  39604. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39605. */
  39606. static CreatePlane(name: string, options: {
  39607. size?: number;
  39608. width?: number;
  39609. height?: number;
  39610. sideOrientation?: number;
  39611. frontUVs?: Vector4;
  39612. backUVs?: Vector4;
  39613. updatable?: boolean;
  39614. sourcePlane?: Plane;
  39615. }, scene?: Nullable<Scene>): Mesh;
  39616. }
  39617. }
  39618. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  39619. import { Behavior } from "babylonjs/Behaviors/behavior";
  39620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39621. import { Observable } from "babylonjs/Misc/observable";
  39622. import { Vector3 } from "babylonjs/Maths/math.vector";
  39623. import { Ray } from "babylonjs/Culling/ray";
  39624. import "babylonjs/Meshes/Builders/planeBuilder";
  39625. /**
  39626. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39627. */
  39628. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39629. private static _AnyMouseID;
  39630. /**
  39631. * Abstract mesh the behavior is set on
  39632. */
  39633. attachedNode: AbstractMesh;
  39634. private _dragPlane;
  39635. private _scene;
  39636. private _pointerObserver;
  39637. private _beforeRenderObserver;
  39638. private static _planeScene;
  39639. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39640. /**
  39641. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  39642. */
  39643. maxDragAngle: number;
  39644. /**
  39645. * @hidden
  39646. */
  39647. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39648. /**
  39649. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39650. */
  39651. currentDraggingPointerID: number;
  39652. /**
  39653. * The last position where the pointer hit the drag plane in world space
  39654. */
  39655. lastDragPosition: Vector3;
  39656. /**
  39657. * If the behavior is currently in a dragging state
  39658. */
  39659. dragging: boolean;
  39660. /**
  39661. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  39662. */
  39663. dragDeltaRatio: number;
  39664. /**
  39665. * If the drag plane orientation should be updated during the dragging (Default: true)
  39666. */
  39667. updateDragPlane: boolean;
  39668. private _debugMode;
  39669. private _moving;
  39670. /**
  39671. * Fires each time the attached mesh is dragged with the pointer
  39672. * * delta between last drag position and current drag position in world space
  39673. * * dragDistance along the drag axis
  39674. * * dragPlaneNormal normal of the current drag plane used during the drag
  39675. * * dragPlanePoint in world space where the drag intersects the drag plane
  39676. */
  39677. onDragObservable: Observable<{
  39678. delta: Vector3;
  39679. dragPlanePoint: Vector3;
  39680. dragPlaneNormal: Vector3;
  39681. dragDistance: number;
  39682. pointerId: number;
  39683. }>;
  39684. /**
  39685. * Fires each time a drag begins (eg. mouse down on mesh)
  39686. */
  39687. onDragStartObservable: Observable<{
  39688. dragPlanePoint: Vector3;
  39689. pointerId: number;
  39690. }>;
  39691. /**
  39692. * Fires each time a drag ends (eg. mouse release after drag)
  39693. */
  39694. onDragEndObservable: Observable<{
  39695. dragPlanePoint: Vector3;
  39696. pointerId: number;
  39697. }>;
  39698. /**
  39699. * If the attached mesh should be moved when dragged
  39700. */
  39701. moveAttached: boolean;
  39702. /**
  39703. * If the drag behavior will react to drag events (Default: true)
  39704. */
  39705. enabled: boolean;
  39706. /**
  39707. * If pointer events should start and release the drag (Default: true)
  39708. */
  39709. startAndReleaseDragOnPointerEvents: boolean;
  39710. /**
  39711. * If camera controls should be detached during the drag
  39712. */
  39713. detachCameraControls: boolean;
  39714. /**
  39715. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39716. */
  39717. useObjectOrienationForDragging: boolean;
  39718. private _options;
  39719. /**
  39720. * Gets the options used by the behavior
  39721. */
  39722. /**
  39723. * Sets the options used by the behavior
  39724. */
  39725. options: {
  39726. dragAxis?: Vector3;
  39727. dragPlaneNormal?: Vector3;
  39728. };
  39729. /**
  39730. * Creates a pointer drag behavior that can be attached to a mesh
  39731. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  39732. */
  39733. constructor(options?: {
  39734. dragAxis?: Vector3;
  39735. dragPlaneNormal?: Vector3;
  39736. });
  39737. /**
  39738. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39739. */
  39740. validateDrag: (targetPosition: Vector3) => boolean;
  39741. /**
  39742. * The name of the behavior
  39743. */
  39744. readonly name: string;
  39745. /**
  39746. * Initializes the behavior
  39747. */
  39748. init(): void;
  39749. private _tmpVector;
  39750. private _alternatePickedPoint;
  39751. private _worldDragAxis;
  39752. private _targetPosition;
  39753. private _attachedElement;
  39754. /**
  39755. * Attaches the drag behavior the passed in mesh
  39756. * @param ownerNode The mesh that will be dragged around once attached
  39757. * @param predicate Predicate to use for pick filtering
  39758. */
  39759. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39760. /**
  39761. * Force relase the drag action by code.
  39762. */
  39763. releaseDrag(): void;
  39764. private _startDragRay;
  39765. private _lastPointerRay;
  39766. /**
  39767. * Simulates the start of a pointer drag event on the behavior
  39768. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39769. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39770. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39771. */
  39772. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39773. private _startDrag;
  39774. private _dragDelta;
  39775. private _moveDrag;
  39776. private _pickWithRayOnDragPlane;
  39777. private _pointA;
  39778. private _pointB;
  39779. private _pointC;
  39780. private _lineA;
  39781. private _lineB;
  39782. private _localAxis;
  39783. private _lookAt;
  39784. private _updateDragPlanePosition;
  39785. /**
  39786. * Detaches the behavior from the mesh
  39787. */
  39788. detach(): void;
  39789. }
  39790. }
  39791. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  39792. import { Mesh } from "babylonjs/Meshes/mesh";
  39793. import { Behavior } from "babylonjs/Behaviors/behavior";
  39794. /**
  39795. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39796. */
  39797. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39798. private _dragBehaviorA;
  39799. private _dragBehaviorB;
  39800. private _startDistance;
  39801. private _initialScale;
  39802. private _targetScale;
  39803. private _ownerNode;
  39804. private _sceneRenderObserver;
  39805. /**
  39806. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39807. */
  39808. constructor();
  39809. /**
  39810. * The name of the behavior
  39811. */
  39812. readonly name: string;
  39813. /**
  39814. * Initializes the behavior
  39815. */
  39816. init(): void;
  39817. private _getCurrentDistance;
  39818. /**
  39819. * Attaches the scale behavior the passed in mesh
  39820. * @param ownerNode The mesh that will be scaled around once attached
  39821. */
  39822. attach(ownerNode: Mesh): void;
  39823. /**
  39824. * Detaches the behavior from the mesh
  39825. */
  39826. detach(): void;
  39827. }
  39828. }
  39829. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  39830. import { Behavior } from "babylonjs/Behaviors/behavior";
  39831. import { Mesh } from "babylonjs/Meshes/mesh";
  39832. import { Observable } from "babylonjs/Misc/observable";
  39833. /**
  39834. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  39835. */
  39836. export class SixDofDragBehavior implements Behavior<Mesh> {
  39837. private static _virtualScene;
  39838. private _ownerNode;
  39839. private _sceneRenderObserver;
  39840. private _scene;
  39841. private _targetPosition;
  39842. private _virtualOriginMesh;
  39843. private _virtualDragMesh;
  39844. private _pointerObserver;
  39845. private _moving;
  39846. private _startingOrientation;
  39847. /**
  39848. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  39849. */
  39850. private zDragFactor;
  39851. /**
  39852. * If the object should rotate to face the drag origin
  39853. */
  39854. rotateDraggedObject: boolean;
  39855. /**
  39856. * If the behavior is currently in a dragging state
  39857. */
  39858. dragging: boolean;
  39859. /**
  39860. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  39861. */
  39862. dragDeltaRatio: number;
  39863. /**
  39864. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39865. */
  39866. currentDraggingPointerID: number;
  39867. /**
  39868. * If camera controls should be detached during the drag
  39869. */
  39870. detachCameraControls: boolean;
  39871. /**
  39872. * Fires each time a drag starts
  39873. */
  39874. onDragStartObservable: Observable<{}>;
  39875. /**
  39876. * Fires each time a drag ends (eg. mouse release after drag)
  39877. */
  39878. onDragEndObservable: Observable<{}>;
  39879. /**
  39880. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  39881. */
  39882. constructor();
  39883. /**
  39884. * The name of the behavior
  39885. */
  39886. readonly name: string;
  39887. /**
  39888. * Initializes the behavior
  39889. */
  39890. init(): void;
  39891. /**
  39892. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39893. */
  39894. private readonly _pointerCamera;
  39895. /**
  39896. * Attaches the scale behavior the passed in mesh
  39897. * @param ownerNode The mesh that will be scaled around once attached
  39898. */
  39899. attach(ownerNode: Mesh): void;
  39900. /**
  39901. * Detaches the behavior from the mesh
  39902. */
  39903. detach(): void;
  39904. }
  39905. }
  39906. declare module "babylonjs/Behaviors/Meshes/index" {
  39907. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  39908. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  39909. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  39910. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  39911. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  39912. }
  39913. declare module "babylonjs/Behaviors/index" {
  39914. export * from "babylonjs/Behaviors/behavior";
  39915. export * from "babylonjs/Behaviors/Cameras/index";
  39916. export * from "babylonjs/Behaviors/Meshes/index";
  39917. }
  39918. declare module "babylonjs/Bones/boneIKController" {
  39919. import { Bone } from "babylonjs/Bones/bone";
  39920. import { Vector3 } from "babylonjs/Maths/math.vector";
  39921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39922. import { Nullable } from "babylonjs/types";
  39923. /**
  39924. * Class used to apply inverse kinematics to bones
  39925. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39926. */
  39927. export class BoneIKController {
  39928. private static _tmpVecs;
  39929. private static _tmpQuat;
  39930. private static _tmpMats;
  39931. /**
  39932. * Gets or sets the target mesh
  39933. */
  39934. targetMesh: AbstractMesh;
  39935. /** Gets or sets the mesh used as pole */
  39936. poleTargetMesh: AbstractMesh;
  39937. /**
  39938. * Gets or sets the bone used as pole
  39939. */
  39940. poleTargetBone: Nullable<Bone>;
  39941. /**
  39942. * Gets or sets the target position
  39943. */
  39944. targetPosition: Vector3;
  39945. /**
  39946. * Gets or sets the pole target position
  39947. */
  39948. poleTargetPosition: Vector3;
  39949. /**
  39950. * Gets or sets the pole target local offset
  39951. */
  39952. poleTargetLocalOffset: Vector3;
  39953. /**
  39954. * Gets or sets the pole angle
  39955. */
  39956. poleAngle: number;
  39957. /**
  39958. * Gets or sets the mesh associated with the controller
  39959. */
  39960. mesh: AbstractMesh;
  39961. /**
  39962. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  39963. */
  39964. slerpAmount: number;
  39965. private _bone1Quat;
  39966. private _bone1Mat;
  39967. private _bone2Ang;
  39968. private _bone1;
  39969. private _bone2;
  39970. private _bone1Length;
  39971. private _bone2Length;
  39972. private _maxAngle;
  39973. private _maxReach;
  39974. private _rightHandedSystem;
  39975. private _bendAxis;
  39976. private _slerping;
  39977. private _adjustRoll;
  39978. /**
  39979. * Gets or sets maximum allowed angle
  39980. */
  39981. maxAngle: number;
  39982. /**
  39983. * Creates a new BoneIKController
  39984. * @param mesh defines the mesh to control
  39985. * @param bone defines the bone to control
  39986. * @param options defines options to set up the controller
  39987. */
  39988. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39989. targetMesh?: AbstractMesh;
  39990. poleTargetMesh?: AbstractMesh;
  39991. poleTargetBone?: Bone;
  39992. poleTargetLocalOffset?: Vector3;
  39993. poleAngle?: number;
  39994. bendAxis?: Vector3;
  39995. maxAngle?: number;
  39996. slerpAmount?: number;
  39997. });
  39998. private _setMaxAngle;
  39999. /**
  40000. * Force the controller to update the bones
  40001. */
  40002. update(): void;
  40003. }
  40004. }
  40005. declare module "babylonjs/Bones/boneLookController" {
  40006. import { Vector3 } from "babylonjs/Maths/math.vector";
  40007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40008. import { Bone } from "babylonjs/Bones/bone";
  40009. import { Space } from "babylonjs/Maths/math.axis";
  40010. /**
  40011. * Class used to make a bone look toward a point in space
  40012. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40013. */
  40014. export class BoneLookController {
  40015. private static _tmpVecs;
  40016. private static _tmpQuat;
  40017. private static _tmpMats;
  40018. /**
  40019. * The target Vector3 that the bone will look at
  40020. */
  40021. target: Vector3;
  40022. /**
  40023. * The mesh that the bone is attached to
  40024. */
  40025. mesh: AbstractMesh;
  40026. /**
  40027. * The bone that will be looking to the target
  40028. */
  40029. bone: Bone;
  40030. /**
  40031. * The up axis of the coordinate system that is used when the bone is rotated
  40032. */
  40033. upAxis: Vector3;
  40034. /**
  40035. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40036. */
  40037. upAxisSpace: Space;
  40038. /**
  40039. * Used to make an adjustment to the yaw of the bone
  40040. */
  40041. adjustYaw: number;
  40042. /**
  40043. * Used to make an adjustment to the pitch of the bone
  40044. */
  40045. adjustPitch: number;
  40046. /**
  40047. * Used to make an adjustment to the roll of the bone
  40048. */
  40049. adjustRoll: number;
  40050. /**
  40051. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  40052. */
  40053. slerpAmount: number;
  40054. private _minYaw;
  40055. private _maxYaw;
  40056. private _minPitch;
  40057. private _maxPitch;
  40058. private _minYawSin;
  40059. private _minYawCos;
  40060. private _maxYawSin;
  40061. private _maxYawCos;
  40062. private _midYawConstraint;
  40063. private _minPitchTan;
  40064. private _maxPitchTan;
  40065. private _boneQuat;
  40066. private _slerping;
  40067. private _transformYawPitch;
  40068. private _transformYawPitchInv;
  40069. private _firstFrameSkipped;
  40070. private _yawRange;
  40071. private _fowardAxis;
  40072. /**
  40073. * Gets or sets the minimum yaw angle that the bone can look to
  40074. */
  40075. minYaw: number;
  40076. /**
  40077. * Gets or sets the maximum yaw angle that the bone can look to
  40078. */
  40079. maxYaw: number;
  40080. /**
  40081. * Gets or sets the minimum pitch angle that the bone can look to
  40082. */
  40083. minPitch: number;
  40084. /**
  40085. * Gets or sets the maximum pitch angle that the bone can look to
  40086. */
  40087. maxPitch: number;
  40088. /**
  40089. * Create a BoneLookController
  40090. * @param mesh the mesh that the bone belongs to
  40091. * @param bone the bone that will be looking to the target
  40092. * @param target the target Vector3 to look at
  40093. * @param options optional settings:
  40094. * * maxYaw: the maximum angle the bone will yaw to
  40095. * * minYaw: the minimum angle the bone will yaw to
  40096. * * maxPitch: the maximum angle the bone will pitch to
  40097. * * minPitch: the minimum angle the bone will yaw to
  40098. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40099. * * upAxis: the up axis of the coordinate system
  40100. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40101. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40102. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40103. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40104. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40105. * * adjustRoll: used to make an adjustment to the roll of the bone
  40106. **/
  40107. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40108. maxYaw?: number;
  40109. minYaw?: number;
  40110. maxPitch?: number;
  40111. minPitch?: number;
  40112. slerpAmount?: number;
  40113. upAxis?: Vector3;
  40114. upAxisSpace?: Space;
  40115. yawAxis?: Vector3;
  40116. pitchAxis?: Vector3;
  40117. adjustYaw?: number;
  40118. adjustPitch?: number;
  40119. adjustRoll?: number;
  40120. });
  40121. /**
  40122. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40123. */
  40124. update(): void;
  40125. private _getAngleDiff;
  40126. private _getAngleBetween;
  40127. private _isAngleBetween;
  40128. }
  40129. }
  40130. declare module "babylonjs/Bones/index" {
  40131. export * from "babylonjs/Bones/bone";
  40132. export * from "babylonjs/Bones/boneIKController";
  40133. export * from "babylonjs/Bones/boneLookController";
  40134. export * from "babylonjs/Bones/skeleton";
  40135. }
  40136. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40137. import { Nullable } from "babylonjs/types";
  40138. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40139. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40140. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40141. /**
  40142. * Manage the gamepad inputs to control an arc rotate camera.
  40143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40144. */
  40145. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40146. /**
  40147. * Defines the camera the input is attached to.
  40148. */
  40149. camera: ArcRotateCamera;
  40150. /**
  40151. * Defines the gamepad the input is gathering event from.
  40152. */
  40153. gamepad: Nullable<Gamepad>;
  40154. /**
  40155. * Defines the gamepad rotation sensiblity.
  40156. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40157. */
  40158. gamepadRotationSensibility: number;
  40159. /**
  40160. * Defines the gamepad move sensiblity.
  40161. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40162. */
  40163. gamepadMoveSensibility: number;
  40164. private _yAxisScale;
  40165. /**
  40166. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40167. */
  40168. invertYAxis: boolean;
  40169. private _onGamepadConnectedObserver;
  40170. private _onGamepadDisconnectedObserver;
  40171. /**
  40172. * Attach the input controls to a specific dom element to get the input from.
  40173. * @param element Defines the element the controls should be listened from
  40174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40175. */
  40176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40177. /**
  40178. * Detach the current controls from the specified dom element.
  40179. * @param element Defines the element to stop listening the inputs from
  40180. */
  40181. detachControl(element: Nullable<HTMLElement>): void;
  40182. /**
  40183. * Update the current camera state depending on the inputs that have been used this frame.
  40184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40185. */
  40186. checkInputs(): void;
  40187. /**
  40188. * Gets the class name of the current intput.
  40189. * @returns the class name
  40190. */
  40191. getClassName(): string;
  40192. /**
  40193. * Get the friendly name associated with the input class.
  40194. * @returns the input friendly name
  40195. */
  40196. getSimpleName(): string;
  40197. }
  40198. }
  40199. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40200. import { Nullable } from "babylonjs/types";
  40201. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40202. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40203. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40204. interface ArcRotateCameraInputsManager {
  40205. /**
  40206. * Add orientation input support to the input manager.
  40207. * @returns the current input manager
  40208. */
  40209. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40210. }
  40211. }
  40212. /**
  40213. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40215. */
  40216. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40217. /**
  40218. * Defines the camera the input is attached to.
  40219. */
  40220. camera: ArcRotateCamera;
  40221. /**
  40222. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40223. */
  40224. alphaCorrection: number;
  40225. /**
  40226. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40227. */
  40228. gammaCorrection: number;
  40229. private _alpha;
  40230. private _gamma;
  40231. private _dirty;
  40232. private _deviceOrientationHandler;
  40233. /**
  40234. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40235. */
  40236. constructor();
  40237. /**
  40238. * Attach the input controls to a specific dom element to get the input from.
  40239. * @param element Defines the element the controls should be listened from
  40240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40241. */
  40242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40243. /** @hidden */
  40244. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40245. /**
  40246. * Update the current camera state depending on the inputs that have been used this frame.
  40247. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40248. */
  40249. checkInputs(): void;
  40250. /**
  40251. * Detach the current controls from the specified dom element.
  40252. * @param element Defines the element to stop listening the inputs from
  40253. */
  40254. detachControl(element: Nullable<HTMLElement>): void;
  40255. /**
  40256. * Gets the class name of the current intput.
  40257. * @returns the class name
  40258. */
  40259. getClassName(): string;
  40260. /**
  40261. * Get the friendly name associated with the input class.
  40262. * @returns the input friendly name
  40263. */
  40264. getSimpleName(): string;
  40265. }
  40266. }
  40267. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40268. import { Nullable } from "babylonjs/types";
  40269. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40270. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40271. /**
  40272. * Listen to mouse events to control the camera.
  40273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40274. */
  40275. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40276. /**
  40277. * Defines the camera the input is attached to.
  40278. */
  40279. camera: FlyCamera;
  40280. /**
  40281. * Defines if touch is enabled. (Default is true.)
  40282. */
  40283. touchEnabled: boolean;
  40284. /**
  40285. * Defines the buttons associated with the input to handle camera rotation.
  40286. */
  40287. buttons: number[];
  40288. /**
  40289. * Assign buttons for Yaw control.
  40290. */
  40291. buttonsYaw: number[];
  40292. /**
  40293. * Assign buttons for Pitch control.
  40294. */
  40295. buttonsPitch: number[];
  40296. /**
  40297. * Assign buttons for Roll control.
  40298. */
  40299. buttonsRoll: number[];
  40300. /**
  40301. * Detect if any button is being pressed while mouse is moved.
  40302. * -1 = Mouse locked.
  40303. * 0 = Left button.
  40304. * 1 = Middle Button.
  40305. * 2 = Right Button.
  40306. */
  40307. activeButton: number;
  40308. /**
  40309. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40310. * Higher values reduce its sensitivity.
  40311. */
  40312. angularSensibility: number;
  40313. private _mousemoveCallback;
  40314. private _observer;
  40315. private _rollObserver;
  40316. private previousPosition;
  40317. private noPreventDefault;
  40318. private element;
  40319. /**
  40320. * Listen to mouse events to control the camera.
  40321. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40323. */
  40324. constructor(touchEnabled?: boolean);
  40325. /**
  40326. * Attach the mouse control to the HTML DOM element.
  40327. * @param element Defines the element that listens to the input events.
  40328. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40329. */
  40330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40331. /**
  40332. * Detach the current controls from the specified dom element.
  40333. * @param element Defines the element to stop listening the inputs from
  40334. */
  40335. detachControl(element: Nullable<HTMLElement>): void;
  40336. /**
  40337. * Gets the class name of the current input.
  40338. * @returns the class name.
  40339. */
  40340. getClassName(): string;
  40341. /**
  40342. * Get the friendly name associated with the input class.
  40343. * @returns the input's friendly name.
  40344. */
  40345. getSimpleName(): string;
  40346. private _pointerInput;
  40347. private _onMouseMove;
  40348. /**
  40349. * Rotate camera by mouse offset.
  40350. */
  40351. private rotateCamera;
  40352. }
  40353. }
  40354. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40355. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40356. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40357. /**
  40358. * Default Inputs manager for the FlyCamera.
  40359. * It groups all the default supported inputs for ease of use.
  40360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40361. */
  40362. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40363. /**
  40364. * Instantiates a new FlyCameraInputsManager.
  40365. * @param camera Defines the camera the inputs belong to.
  40366. */
  40367. constructor(camera: FlyCamera);
  40368. /**
  40369. * Add keyboard input support to the input manager.
  40370. * @returns the new FlyCameraKeyboardMoveInput().
  40371. */
  40372. addKeyboard(): FlyCameraInputsManager;
  40373. /**
  40374. * Add mouse input support to the input manager.
  40375. * @param touchEnabled Enable touch screen support.
  40376. * @returns the new FlyCameraMouseInput().
  40377. */
  40378. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40379. }
  40380. }
  40381. declare module "babylonjs/Cameras/flyCamera" {
  40382. import { Scene } from "babylonjs/scene";
  40383. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40385. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40386. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40387. /**
  40388. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40389. * such as in a 3D Space Shooter or a Flight Simulator.
  40390. */
  40391. export class FlyCamera extends TargetCamera {
  40392. /**
  40393. * Define the collision ellipsoid of the camera.
  40394. * This is helpful for simulating a camera body, like a player's body.
  40395. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40396. */
  40397. ellipsoid: Vector3;
  40398. /**
  40399. * Define an offset for the position of the ellipsoid around the camera.
  40400. * This can be helpful if the camera is attached away from the player's body center,
  40401. * such as at its head.
  40402. */
  40403. ellipsoidOffset: Vector3;
  40404. /**
  40405. * Enable or disable collisions of the camera with the rest of the scene objects.
  40406. */
  40407. checkCollisions: boolean;
  40408. /**
  40409. * Enable or disable gravity on the camera.
  40410. */
  40411. applyGravity: boolean;
  40412. /**
  40413. * Define the current direction the camera is moving to.
  40414. */
  40415. cameraDirection: Vector3;
  40416. /**
  40417. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40418. * This overrides and empties cameraRotation.
  40419. */
  40420. rotationQuaternion: Quaternion;
  40421. /**
  40422. * Track Roll to maintain the wanted Rolling when looking around.
  40423. */
  40424. _trackRoll: number;
  40425. /**
  40426. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40427. */
  40428. rollCorrect: number;
  40429. /**
  40430. * Mimic a banked turn, Rolling the camera when Yawing.
  40431. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40432. */
  40433. bankedTurn: boolean;
  40434. /**
  40435. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40436. */
  40437. bankedTurnLimit: number;
  40438. /**
  40439. * Value of 0 disables the banked Roll.
  40440. * Value of 1 is equal to the Yaw angle in radians.
  40441. */
  40442. bankedTurnMultiplier: number;
  40443. /**
  40444. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40445. */
  40446. inputs: FlyCameraInputsManager;
  40447. /**
  40448. * Gets the input sensibility for mouse input.
  40449. * Higher values reduce sensitivity.
  40450. */
  40451. /**
  40452. * Sets the input sensibility for a mouse input.
  40453. * Higher values reduce sensitivity.
  40454. */
  40455. angularSensibility: number;
  40456. /**
  40457. * Get the keys for camera movement forward.
  40458. */
  40459. /**
  40460. * Set the keys for camera movement forward.
  40461. */
  40462. keysForward: number[];
  40463. /**
  40464. * Get the keys for camera movement backward.
  40465. */
  40466. keysBackward: number[];
  40467. /**
  40468. * Get the keys for camera movement up.
  40469. */
  40470. /**
  40471. * Set the keys for camera movement up.
  40472. */
  40473. keysUp: number[];
  40474. /**
  40475. * Get the keys for camera movement down.
  40476. */
  40477. /**
  40478. * Set the keys for camera movement down.
  40479. */
  40480. keysDown: number[];
  40481. /**
  40482. * Get the keys for camera movement left.
  40483. */
  40484. /**
  40485. * Set the keys for camera movement left.
  40486. */
  40487. keysLeft: number[];
  40488. /**
  40489. * Set the keys for camera movement right.
  40490. */
  40491. /**
  40492. * Set the keys for camera movement right.
  40493. */
  40494. keysRight: number[];
  40495. /**
  40496. * Event raised when the camera collides with a mesh in the scene.
  40497. */
  40498. onCollide: (collidedMesh: AbstractMesh) => void;
  40499. private _collider;
  40500. private _needMoveForGravity;
  40501. private _oldPosition;
  40502. private _diffPosition;
  40503. private _newPosition;
  40504. /** @hidden */
  40505. _localDirection: Vector3;
  40506. /** @hidden */
  40507. _transformedDirection: Vector3;
  40508. /**
  40509. * Instantiates a FlyCamera.
  40510. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40511. * such as in a 3D Space Shooter or a Flight Simulator.
  40512. * @param name Define the name of the camera in the scene.
  40513. * @param position Define the starting position of the camera in the scene.
  40514. * @param scene Define the scene the camera belongs to.
  40515. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40516. */
  40517. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40518. /**
  40519. * Attach a control to the HTML DOM element.
  40520. * @param element Defines the element that listens to the input events.
  40521. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40522. */
  40523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40524. /**
  40525. * Detach a control from the HTML DOM element.
  40526. * The camera will stop reacting to that input.
  40527. * @param element Defines the element that listens to the input events.
  40528. */
  40529. detachControl(element: HTMLElement): void;
  40530. private _collisionMask;
  40531. /**
  40532. * Get the mask that the camera ignores in collision events.
  40533. */
  40534. /**
  40535. * Set the mask that the camera ignores in collision events.
  40536. */
  40537. collisionMask: number;
  40538. /** @hidden */
  40539. _collideWithWorld(displacement: Vector3): void;
  40540. /** @hidden */
  40541. private _onCollisionPositionChange;
  40542. /** @hidden */
  40543. _checkInputs(): void;
  40544. /** @hidden */
  40545. _decideIfNeedsToMove(): boolean;
  40546. /** @hidden */
  40547. _updatePosition(): void;
  40548. /**
  40549. * Restore the Roll to its target value at the rate specified.
  40550. * @param rate - Higher means slower restoring.
  40551. * @hidden
  40552. */
  40553. restoreRoll(rate: number): void;
  40554. /**
  40555. * Destroy the camera and release the current resources held by it.
  40556. */
  40557. dispose(): void;
  40558. /**
  40559. * Get the current object class name.
  40560. * @returns the class name.
  40561. */
  40562. getClassName(): string;
  40563. }
  40564. }
  40565. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40566. import { Nullable } from "babylonjs/types";
  40567. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40568. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40569. /**
  40570. * Listen to keyboard events to control the camera.
  40571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40572. */
  40573. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40574. /**
  40575. * Defines the camera the input is attached to.
  40576. */
  40577. camera: FlyCamera;
  40578. /**
  40579. * The list of keyboard keys used to control the forward move of the camera.
  40580. */
  40581. keysForward: number[];
  40582. /**
  40583. * The list of keyboard keys used to control the backward move of the camera.
  40584. */
  40585. keysBackward: number[];
  40586. /**
  40587. * The list of keyboard keys used to control the forward move of the camera.
  40588. */
  40589. keysUp: number[];
  40590. /**
  40591. * The list of keyboard keys used to control the backward move of the camera.
  40592. */
  40593. keysDown: number[];
  40594. /**
  40595. * The list of keyboard keys used to control the right strafe move of the camera.
  40596. */
  40597. keysRight: number[];
  40598. /**
  40599. * The list of keyboard keys used to control the left strafe move of the camera.
  40600. */
  40601. keysLeft: number[];
  40602. private _keys;
  40603. private _onCanvasBlurObserver;
  40604. private _onKeyboardObserver;
  40605. private _engine;
  40606. private _scene;
  40607. /**
  40608. * Attach the input controls to a specific dom element to get the input from.
  40609. * @param element Defines the element the controls should be listened from
  40610. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40611. */
  40612. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40613. /**
  40614. * Detach the current controls from the specified dom element.
  40615. * @param element Defines the element to stop listening the inputs from
  40616. */
  40617. detachControl(element: Nullable<HTMLElement>): void;
  40618. /**
  40619. * Gets the class name of the current intput.
  40620. * @returns the class name
  40621. */
  40622. getClassName(): string;
  40623. /** @hidden */
  40624. _onLostFocus(e: FocusEvent): void;
  40625. /**
  40626. * Get the friendly name associated with the input class.
  40627. * @returns the input friendly name
  40628. */
  40629. getSimpleName(): string;
  40630. /**
  40631. * Update the current camera state depending on the inputs that have been used this frame.
  40632. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40633. */
  40634. checkInputs(): void;
  40635. }
  40636. }
  40637. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  40638. import { Nullable } from "babylonjs/types";
  40639. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40640. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40641. /**
  40642. * Manage the mouse wheel inputs to control a follow camera.
  40643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40644. */
  40645. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40646. /**
  40647. * Defines the camera the input is attached to.
  40648. */
  40649. camera: FollowCamera;
  40650. /**
  40651. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40652. */
  40653. axisControlRadius: boolean;
  40654. /**
  40655. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40656. */
  40657. axisControlHeight: boolean;
  40658. /**
  40659. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40660. */
  40661. axisControlRotation: boolean;
  40662. /**
  40663. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40664. * relation to mouseWheel events.
  40665. */
  40666. wheelPrecision: number;
  40667. /**
  40668. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40669. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40670. */
  40671. wheelDeltaPercentage: number;
  40672. private _wheel;
  40673. private _observer;
  40674. /**
  40675. * Attach the input controls to a specific dom element to get the input from.
  40676. * @param element Defines the element the controls should be listened from
  40677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40678. */
  40679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40680. /**
  40681. * Detach the current controls from the specified dom element.
  40682. * @param element Defines the element to stop listening the inputs from
  40683. */
  40684. detachControl(element: Nullable<HTMLElement>): void;
  40685. /**
  40686. * Gets the class name of the current intput.
  40687. * @returns the class name
  40688. */
  40689. getClassName(): string;
  40690. /**
  40691. * Get the friendly name associated with the input class.
  40692. * @returns the input friendly name
  40693. */
  40694. getSimpleName(): string;
  40695. }
  40696. }
  40697. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  40698. import { Nullable } from "babylonjs/types";
  40699. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40700. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40701. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40702. /**
  40703. * Manage the pointers inputs to control an follow camera.
  40704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40705. */
  40706. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40707. /**
  40708. * Defines the camera the input is attached to.
  40709. */
  40710. camera: FollowCamera;
  40711. /**
  40712. * Gets the class name of the current input.
  40713. * @returns the class name
  40714. */
  40715. getClassName(): string;
  40716. /**
  40717. * Defines the pointer angular sensibility along the X axis or how fast is
  40718. * the camera rotating.
  40719. * A negative number will reverse the axis direction.
  40720. */
  40721. angularSensibilityX: number;
  40722. /**
  40723. * Defines the pointer angular sensibility along the Y axis or how fast is
  40724. * the camera rotating.
  40725. * A negative number will reverse the axis direction.
  40726. */
  40727. angularSensibilityY: number;
  40728. /**
  40729. * Defines the pointer pinch precision or how fast is the camera zooming.
  40730. * A negative number will reverse the axis direction.
  40731. */
  40732. pinchPrecision: number;
  40733. /**
  40734. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40735. * from 0.
  40736. * It defines the percentage of current camera.radius to use as delta when
  40737. * pinch zoom is used.
  40738. */
  40739. pinchDeltaPercentage: number;
  40740. /**
  40741. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40742. */
  40743. axisXControlRadius: boolean;
  40744. /**
  40745. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40746. */
  40747. axisXControlHeight: boolean;
  40748. /**
  40749. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40750. */
  40751. axisXControlRotation: boolean;
  40752. /**
  40753. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40754. */
  40755. axisYControlRadius: boolean;
  40756. /**
  40757. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40758. */
  40759. axisYControlHeight: boolean;
  40760. /**
  40761. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40762. */
  40763. axisYControlRotation: boolean;
  40764. /**
  40765. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40766. */
  40767. axisPinchControlRadius: boolean;
  40768. /**
  40769. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40770. */
  40771. axisPinchControlHeight: boolean;
  40772. /**
  40773. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40774. */
  40775. axisPinchControlRotation: boolean;
  40776. /**
  40777. * Log error messages if basic misconfiguration has occurred.
  40778. */
  40779. warningEnable: boolean;
  40780. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40781. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40782. private _warningCounter;
  40783. private _warning;
  40784. }
  40785. }
  40786. declare module "babylonjs/Cameras/followCameraInputsManager" {
  40787. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40788. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40789. /**
  40790. * Default Inputs manager for the FollowCamera.
  40791. * It groups all the default supported inputs for ease of use.
  40792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40793. */
  40794. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40795. /**
  40796. * Instantiates a new FollowCameraInputsManager.
  40797. * @param camera Defines the camera the inputs belong to
  40798. */
  40799. constructor(camera: FollowCamera);
  40800. /**
  40801. * Add keyboard input support to the input manager.
  40802. * @returns the current input manager
  40803. */
  40804. addKeyboard(): FollowCameraInputsManager;
  40805. /**
  40806. * Add mouse wheel input support to the input manager.
  40807. * @returns the current input manager
  40808. */
  40809. addMouseWheel(): FollowCameraInputsManager;
  40810. /**
  40811. * Add pointers input support to the input manager.
  40812. * @returns the current input manager
  40813. */
  40814. addPointers(): FollowCameraInputsManager;
  40815. /**
  40816. * Add orientation input support to the input manager.
  40817. * @returns the current input manager
  40818. */
  40819. addVRDeviceOrientation(): FollowCameraInputsManager;
  40820. }
  40821. }
  40822. declare module "babylonjs/Cameras/followCamera" {
  40823. import { Nullable } from "babylonjs/types";
  40824. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40825. import { Scene } from "babylonjs/scene";
  40826. import { Vector3 } from "babylonjs/Maths/math.vector";
  40827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40828. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  40829. /**
  40830. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40831. * an arc rotate version arcFollowCamera are available.
  40832. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40833. */
  40834. export class FollowCamera extends TargetCamera {
  40835. /**
  40836. * Distance the follow camera should follow an object at
  40837. */
  40838. radius: number;
  40839. /**
  40840. * Minimum allowed distance of the camera to the axis of rotation
  40841. * (The camera can not get closer).
  40842. * This can help limiting how the Camera is able to move in the scene.
  40843. */
  40844. lowerRadiusLimit: Nullable<number>;
  40845. /**
  40846. * Maximum allowed distance of the camera to the axis of rotation
  40847. * (The camera can not get further).
  40848. * This can help limiting how the Camera is able to move in the scene.
  40849. */
  40850. upperRadiusLimit: Nullable<number>;
  40851. /**
  40852. * Define a rotation offset between the camera and the object it follows
  40853. */
  40854. rotationOffset: number;
  40855. /**
  40856. * Minimum allowed angle to camera position relative to target object.
  40857. * This can help limiting how the Camera is able to move in the scene.
  40858. */
  40859. lowerRotationOffsetLimit: Nullable<number>;
  40860. /**
  40861. * Maximum allowed angle to camera position relative to target object.
  40862. * This can help limiting how the Camera is able to move in the scene.
  40863. */
  40864. upperRotationOffsetLimit: Nullable<number>;
  40865. /**
  40866. * Define a height offset between the camera and the object it follows.
  40867. * It can help following an object from the top (like a car chaing a plane)
  40868. */
  40869. heightOffset: number;
  40870. /**
  40871. * Minimum allowed height of camera position relative to target object.
  40872. * This can help limiting how the Camera is able to move in the scene.
  40873. */
  40874. lowerHeightOffsetLimit: Nullable<number>;
  40875. /**
  40876. * Maximum allowed height of camera position relative to target object.
  40877. * This can help limiting how the Camera is able to move in the scene.
  40878. */
  40879. upperHeightOffsetLimit: Nullable<number>;
  40880. /**
  40881. * Define how fast the camera can accelerate to follow it s target.
  40882. */
  40883. cameraAcceleration: number;
  40884. /**
  40885. * Define the speed limit of the camera following an object.
  40886. */
  40887. maxCameraSpeed: number;
  40888. /**
  40889. * Define the target of the camera.
  40890. */
  40891. lockedTarget: Nullable<AbstractMesh>;
  40892. /**
  40893. * Defines the input associated with the camera.
  40894. */
  40895. inputs: FollowCameraInputsManager;
  40896. /**
  40897. * Instantiates the follow camera.
  40898. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40899. * @param name Define the name of the camera in the scene
  40900. * @param position Define the position of the camera
  40901. * @param scene Define the scene the camera belong to
  40902. * @param lockedTarget Define the target of the camera
  40903. */
  40904. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40905. private _follow;
  40906. /**
  40907. * Attached controls to the current camera.
  40908. * @param element Defines the element the controls should be listened from
  40909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40910. */
  40911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40912. /**
  40913. * Detach the current controls from the camera.
  40914. * The camera will stop reacting to inputs.
  40915. * @param element Defines the element to stop listening the inputs from
  40916. */
  40917. detachControl(element: HTMLElement): void;
  40918. /** @hidden */
  40919. _checkInputs(): void;
  40920. private _checkLimits;
  40921. /**
  40922. * Gets the camera class name.
  40923. * @returns the class name
  40924. */
  40925. getClassName(): string;
  40926. }
  40927. /**
  40928. * Arc Rotate version of the follow camera.
  40929. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40930. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40931. */
  40932. export class ArcFollowCamera extends TargetCamera {
  40933. /** The longitudinal angle of the camera */
  40934. alpha: number;
  40935. /** The latitudinal angle of the camera */
  40936. beta: number;
  40937. /** The radius of the camera from its target */
  40938. radius: number;
  40939. /** Define the camera target (the messh it should follow) */
  40940. target: Nullable<AbstractMesh>;
  40941. private _cartesianCoordinates;
  40942. /**
  40943. * Instantiates a new ArcFollowCamera
  40944. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40945. * @param name Define the name of the camera
  40946. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40947. * @param beta Define the rotation angle of the camera around the elevation axis
  40948. * @param radius Define the radius of the camera from its target point
  40949. * @param target Define the target of the camera
  40950. * @param scene Define the scene the camera belongs to
  40951. */
  40952. constructor(name: string,
  40953. /** The longitudinal angle of the camera */
  40954. alpha: number,
  40955. /** The latitudinal angle of the camera */
  40956. beta: number,
  40957. /** The radius of the camera from its target */
  40958. radius: number,
  40959. /** Define the camera target (the messh it should follow) */
  40960. target: Nullable<AbstractMesh>, scene: Scene);
  40961. private _follow;
  40962. /** @hidden */
  40963. _checkInputs(): void;
  40964. /**
  40965. * Returns the class name of the object.
  40966. * It is mostly used internally for serialization purposes.
  40967. */
  40968. getClassName(): string;
  40969. }
  40970. }
  40971. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  40972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40973. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40974. import { Nullable } from "babylonjs/types";
  40975. /**
  40976. * Manage the keyboard inputs to control the movement of a follow camera.
  40977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40978. */
  40979. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40980. /**
  40981. * Defines the camera the input is attached to.
  40982. */
  40983. camera: FollowCamera;
  40984. /**
  40985. * Defines the list of key codes associated with the up action (increase heightOffset)
  40986. */
  40987. keysHeightOffsetIncr: number[];
  40988. /**
  40989. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40990. */
  40991. keysHeightOffsetDecr: number[];
  40992. /**
  40993. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40994. */
  40995. keysHeightOffsetModifierAlt: boolean;
  40996. /**
  40997. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40998. */
  40999. keysHeightOffsetModifierCtrl: boolean;
  41000. /**
  41001. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41002. */
  41003. keysHeightOffsetModifierShift: boolean;
  41004. /**
  41005. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41006. */
  41007. keysRotationOffsetIncr: number[];
  41008. /**
  41009. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41010. */
  41011. keysRotationOffsetDecr: number[];
  41012. /**
  41013. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41014. */
  41015. keysRotationOffsetModifierAlt: boolean;
  41016. /**
  41017. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41018. */
  41019. keysRotationOffsetModifierCtrl: boolean;
  41020. /**
  41021. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41022. */
  41023. keysRotationOffsetModifierShift: boolean;
  41024. /**
  41025. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41026. */
  41027. keysRadiusIncr: number[];
  41028. /**
  41029. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41030. */
  41031. keysRadiusDecr: number[];
  41032. /**
  41033. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41034. */
  41035. keysRadiusModifierAlt: boolean;
  41036. /**
  41037. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41038. */
  41039. keysRadiusModifierCtrl: boolean;
  41040. /**
  41041. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41042. */
  41043. keysRadiusModifierShift: boolean;
  41044. /**
  41045. * Defines the rate of change of heightOffset.
  41046. */
  41047. heightSensibility: number;
  41048. /**
  41049. * Defines the rate of change of rotationOffset.
  41050. */
  41051. rotationSensibility: number;
  41052. /**
  41053. * Defines the rate of change of radius.
  41054. */
  41055. radiusSensibility: number;
  41056. private _keys;
  41057. private _ctrlPressed;
  41058. private _altPressed;
  41059. private _shiftPressed;
  41060. private _onCanvasBlurObserver;
  41061. private _onKeyboardObserver;
  41062. private _engine;
  41063. private _scene;
  41064. /**
  41065. * Attach the input controls to a specific dom element to get the input from.
  41066. * @param element Defines the element the controls should be listened from
  41067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41068. */
  41069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41070. /**
  41071. * Detach the current controls from the specified dom element.
  41072. * @param element Defines the element to stop listening the inputs from
  41073. */
  41074. detachControl(element: Nullable<HTMLElement>): void;
  41075. /**
  41076. * Update the current camera state depending on the inputs that have been used this frame.
  41077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41078. */
  41079. checkInputs(): void;
  41080. /**
  41081. * Gets the class name of the current input.
  41082. * @returns the class name
  41083. */
  41084. getClassName(): string;
  41085. /**
  41086. * Get the friendly name associated with the input class.
  41087. * @returns the input friendly name
  41088. */
  41089. getSimpleName(): string;
  41090. /**
  41091. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41092. * allow modification of the heightOffset value.
  41093. */
  41094. private _modifierHeightOffset;
  41095. /**
  41096. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41097. * allow modification of the rotationOffset value.
  41098. */
  41099. private _modifierRotationOffset;
  41100. /**
  41101. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41102. * allow modification of the radius value.
  41103. */
  41104. private _modifierRadius;
  41105. }
  41106. }
  41107. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41108. import { Nullable } from "babylonjs/types";
  41109. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41110. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41111. import { Observable } from "babylonjs/Misc/observable";
  41112. module "babylonjs/Cameras/freeCameraInputsManager" {
  41113. interface FreeCameraInputsManager {
  41114. /**
  41115. * @hidden
  41116. */
  41117. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41118. /**
  41119. * Add orientation input support to the input manager.
  41120. * @returns the current input manager
  41121. */
  41122. addDeviceOrientation(): FreeCameraInputsManager;
  41123. }
  41124. }
  41125. /**
  41126. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41127. * Screen rotation is taken into account.
  41128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41129. */
  41130. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41131. private _camera;
  41132. private _screenOrientationAngle;
  41133. private _constantTranform;
  41134. private _screenQuaternion;
  41135. private _alpha;
  41136. private _beta;
  41137. private _gamma;
  41138. /**
  41139. * Can be used to detect if a device orientation sensor is available on a device
  41140. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41141. * @returns a promise that will resolve on orientation change
  41142. */
  41143. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41144. /**
  41145. * @hidden
  41146. */
  41147. _onDeviceOrientationChangedObservable: Observable<void>;
  41148. /**
  41149. * Instantiates a new input
  41150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41151. */
  41152. constructor();
  41153. /**
  41154. * Define the camera controlled by the input.
  41155. */
  41156. camera: FreeCamera;
  41157. /**
  41158. * Attach the input controls to a specific dom element to get the input from.
  41159. * @param element Defines the element the controls should be listened from
  41160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41161. */
  41162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41163. private _orientationChanged;
  41164. private _deviceOrientation;
  41165. /**
  41166. * Detach the current controls from the specified dom element.
  41167. * @param element Defines the element to stop listening the inputs from
  41168. */
  41169. detachControl(element: Nullable<HTMLElement>): void;
  41170. /**
  41171. * Update the current camera state depending on the inputs that have been used this frame.
  41172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41173. */
  41174. checkInputs(): void;
  41175. /**
  41176. * Gets the class name of the current intput.
  41177. * @returns the class name
  41178. */
  41179. getClassName(): string;
  41180. /**
  41181. * Get the friendly name associated with the input class.
  41182. * @returns the input friendly name
  41183. */
  41184. getSimpleName(): string;
  41185. }
  41186. }
  41187. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41188. import { Nullable } from "babylonjs/types";
  41189. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41190. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41191. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41192. /**
  41193. * Manage the gamepad inputs to control a free camera.
  41194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41195. */
  41196. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41197. /**
  41198. * Define the camera the input is attached to.
  41199. */
  41200. camera: FreeCamera;
  41201. /**
  41202. * Define the Gamepad controlling the input
  41203. */
  41204. gamepad: Nullable<Gamepad>;
  41205. /**
  41206. * Defines the gamepad rotation sensiblity.
  41207. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41208. */
  41209. gamepadAngularSensibility: number;
  41210. /**
  41211. * Defines the gamepad move sensiblity.
  41212. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41213. */
  41214. gamepadMoveSensibility: number;
  41215. private _yAxisScale;
  41216. /**
  41217. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41218. */
  41219. invertYAxis: boolean;
  41220. private _onGamepadConnectedObserver;
  41221. private _onGamepadDisconnectedObserver;
  41222. private _cameraTransform;
  41223. private _deltaTransform;
  41224. private _vector3;
  41225. private _vector2;
  41226. /**
  41227. * Attach the input controls to a specific dom element to get the input from.
  41228. * @param element Defines the element the controls should be listened from
  41229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41230. */
  41231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41232. /**
  41233. * Detach the current controls from the specified dom element.
  41234. * @param element Defines the element to stop listening the inputs from
  41235. */
  41236. detachControl(element: Nullable<HTMLElement>): void;
  41237. /**
  41238. * Update the current camera state depending on the inputs that have been used this frame.
  41239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41240. */
  41241. checkInputs(): void;
  41242. /**
  41243. * Gets the class name of the current intput.
  41244. * @returns the class name
  41245. */
  41246. getClassName(): string;
  41247. /**
  41248. * Get the friendly name associated with the input class.
  41249. * @returns the input friendly name
  41250. */
  41251. getSimpleName(): string;
  41252. }
  41253. }
  41254. declare module "babylonjs/Misc/virtualJoystick" {
  41255. import { Nullable } from "babylonjs/types";
  41256. import { Vector3 } from "babylonjs/Maths/math.vector";
  41257. /**
  41258. * Defines the potential axis of a Joystick
  41259. */
  41260. export enum JoystickAxis {
  41261. /** X axis */
  41262. X = 0,
  41263. /** Y axis */
  41264. Y = 1,
  41265. /** Z axis */
  41266. Z = 2
  41267. }
  41268. /**
  41269. * Class used to define virtual joystick (used in touch mode)
  41270. */
  41271. export class VirtualJoystick {
  41272. /**
  41273. * Gets or sets a boolean indicating that left and right values must be inverted
  41274. */
  41275. reverseLeftRight: boolean;
  41276. /**
  41277. * Gets or sets a boolean indicating that up and down values must be inverted
  41278. */
  41279. reverseUpDown: boolean;
  41280. /**
  41281. * Gets the offset value for the position (ie. the change of the position value)
  41282. */
  41283. deltaPosition: Vector3;
  41284. /**
  41285. * Gets a boolean indicating if the virtual joystick was pressed
  41286. */
  41287. pressed: boolean;
  41288. /**
  41289. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41290. */
  41291. static Canvas: Nullable<HTMLCanvasElement>;
  41292. private static _globalJoystickIndex;
  41293. private static vjCanvasContext;
  41294. private static vjCanvasWidth;
  41295. private static vjCanvasHeight;
  41296. private static halfWidth;
  41297. private _action;
  41298. private _axisTargetedByLeftAndRight;
  41299. private _axisTargetedByUpAndDown;
  41300. private _joystickSensibility;
  41301. private _inversedSensibility;
  41302. private _joystickPointerID;
  41303. private _joystickColor;
  41304. private _joystickPointerPos;
  41305. private _joystickPreviousPointerPos;
  41306. private _joystickPointerStartPos;
  41307. private _deltaJoystickVector;
  41308. private _leftJoystick;
  41309. private _touches;
  41310. private _onPointerDownHandlerRef;
  41311. private _onPointerMoveHandlerRef;
  41312. private _onPointerUpHandlerRef;
  41313. private _onResize;
  41314. /**
  41315. * Creates a new virtual joystick
  41316. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41317. */
  41318. constructor(leftJoystick?: boolean);
  41319. /**
  41320. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41321. * @param newJoystickSensibility defines the new sensibility
  41322. */
  41323. setJoystickSensibility(newJoystickSensibility: number): void;
  41324. private _onPointerDown;
  41325. private _onPointerMove;
  41326. private _onPointerUp;
  41327. /**
  41328. * Change the color of the virtual joystick
  41329. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41330. */
  41331. setJoystickColor(newColor: string): void;
  41332. /**
  41333. * Defines a callback to call when the joystick is touched
  41334. * @param action defines the callback
  41335. */
  41336. setActionOnTouch(action: () => any): void;
  41337. /**
  41338. * Defines which axis you'd like to control for left & right
  41339. * @param axis defines the axis to use
  41340. */
  41341. setAxisForLeftRight(axis: JoystickAxis): void;
  41342. /**
  41343. * Defines which axis you'd like to control for up & down
  41344. * @param axis defines the axis to use
  41345. */
  41346. setAxisForUpDown(axis: JoystickAxis): void;
  41347. private _drawVirtualJoystick;
  41348. /**
  41349. * Release internal HTML canvas
  41350. */
  41351. releaseCanvas(): void;
  41352. }
  41353. }
  41354. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41355. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41356. import { Nullable } from "babylonjs/types";
  41357. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41358. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41359. module "babylonjs/Cameras/freeCameraInputsManager" {
  41360. interface FreeCameraInputsManager {
  41361. /**
  41362. * Add virtual joystick input support to the input manager.
  41363. * @returns the current input manager
  41364. */
  41365. addVirtualJoystick(): FreeCameraInputsManager;
  41366. }
  41367. }
  41368. /**
  41369. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41371. */
  41372. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41373. /**
  41374. * Defines the camera the input is attached to.
  41375. */
  41376. camera: FreeCamera;
  41377. private _leftjoystick;
  41378. private _rightjoystick;
  41379. /**
  41380. * Gets the left stick of the virtual joystick.
  41381. * @returns The virtual Joystick
  41382. */
  41383. getLeftJoystick(): VirtualJoystick;
  41384. /**
  41385. * Gets the right stick of the virtual joystick.
  41386. * @returns The virtual Joystick
  41387. */
  41388. getRightJoystick(): VirtualJoystick;
  41389. /**
  41390. * Update the current camera state depending on the inputs that have been used this frame.
  41391. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41392. */
  41393. checkInputs(): void;
  41394. /**
  41395. * Attach the input controls to a specific dom element to get the input from.
  41396. * @param element Defines the element the controls should be listened from
  41397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41398. */
  41399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41400. /**
  41401. * Detach the current controls from the specified dom element.
  41402. * @param element Defines the element to stop listening the inputs from
  41403. */
  41404. detachControl(element: Nullable<HTMLElement>): void;
  41405. /**
  41406. * Gets the class name of the current intput.
  41407. * @returns the class name
  41408. */
  41409. getClassName(): string;
  41410. /**
  41411. * Get the friendly name associated with the input class.
  41412. * @returns the input friendly name
  41413. */
  41414. getSimpleName(): string;
  41415. }
  41416. }
  41417. declare module "babylonjs/Cameras/Inputs/index" {
  41418. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41419. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41420. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41421. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41422. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41423. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41424. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41425. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41426. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41427. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41428. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41429. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41430. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41431. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41432. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41433. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41434. }
  41435. declare module "babylonjs/Cameras/touchCamera" {
  41436. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41437. import { Scene } from "babylonjs/scene";
  41438. import { Vector3 } from "babylonjs/Maths/math.vector";
  41439. /**
  41440. * This represents a FPS type of camera controlled by touch.
  41441. * This is like a universal camera minus the Gamepad controls.
  41442. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41443. */
  41444. export class TouchCamera extends FreeCamera {
  41445. /**
  41446. * Defines the touch sensibility for rotation.
  41447. * The higher the faster.
  41448. */
  41449. touchAngularSensibility: number;
  41450. /**
  41451. * Defines the touch sensibility for move.
  41452. * The higher the faster.
  41453. */
  41454. touchMoveSensibility: number;
  41455. /**
  41456. * Instantiates a new touch camera.
  41457. * This represents a FPS type of camera controlled by touch.
  41458. * This is like a universal camera minus the Gamepad controls.
  41459. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41460. * @param name Define the name of the camera in the scene
  41461. * @param position Define the start position of the camera in the scene
  41462. * @param scene Define the scene the camera belongs to
  41463. */
  41464. constructor(name: string, position: Vector3, scene: Scene);
  41465. /**
  41466. * Gets the current object class name.
  41467. * @return the class name
  41468. */
  41469. getClassName(): string;
  41470. /** @hidden */
  41471. _setupInputs(): void;
  41472. }
  41473. }
  41474. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41475. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41476. import { Scene } from "babylonjs/scene";
  41477. import { Vector3 } from "babylonjs/Maths/math.vector";
  41478. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41479. import { Axis } from "babylonjs/Maths/math.axis";
  41480. /**
  41481. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41482. * being tilted forward or back and left or right.
  41483. */
  41484. export class DeviceOrientationCamera extends FreeCamera {
  41485. private _initialQuaternion;
  41486. private _quaternionCache;
  41487. private _tmpDragQuaternion;
  41488. private _disablePointerInputWhenUsingDeviceOrientation;
  41489. /**
  41490. * Creates a new device orientation camera
  41491. * @param name The name of the camera
  41492. * @param position The start position camera
  41493. * @param scene The scene the camera belongs to
  41494. */
  41495. constructor(name: string, position: Vector3, scene: Scene);
  41496. /**
  41497. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41498. */
  41499. disablePointerInputWhenUsingDeviceOrientation: boolean;
  41500. private _dragFactor;
  41501. /**
  41502. * Enabled turning on the y axis when the orientation sensor is active
  41503. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41504. */
  41505. enableHorizontalDragging(dragFactor?: number): void;
  41506. /**
  41507. * Gets the current instance class name ("DeviceOrientationCamera").
  41508. * This helps avoiding instanceof at run time.
  41509. * @returns the class name
  41510. */
  41511. getClassName(): string;
  41512. /**
  41513. * @hidden
  41514. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41515. */
  41516. _checkInputs(): void;
  41517. /**
  41518. * Reset the camera to its default orientation on the specified axis only.
  41519. * @param axis The axis to reset
  41520. */
  41521. resetToCurrentRotation(axis?: Axis): void;
  41522. }
  41523. }
  41524. declare module "babylonjs/Gamepads/xboxGamepad" {
  41525. import { Observable } from "babylonjs/Misc/observable";
  41526. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41527. /**
  41528. * Defines supported buttons for XBox360 compatible gamepads
  41529. */
  41530. export enum Xbox360Button {
  41531. /** A */
  41532. A = 0,
  41533. /** B */
  41534. B = 1,
  41535. /** X */
  41536. X = 2,
  41537. /** Y */
  41538. Y = 3,
  41539. /** Start */
  41540. Start = 4,
  41541. /** Back */
  41542. Back = 5,
  41543. /** Left button */
  41544. LB = 6,
  41545. /** Right button */
  41546. RB = 7,
  41547. /** Left stick */
  41548. LeftStick = 8,
  41549. /** Right stick */
  41550. RightStick = 9
  41551. }
  41552. /** Defines values for XBox360 DPad */
  41553. export enum Xbox360Dpad {
  41554. /** Up */
  41555. Up = 0,
  41556. /** Down */
  41557. Down = 1,
  41558. /** Left */
  41559. Left = 2,
  41560. /** Right */
  41561. Right = 3
  41562. }
  41563. /**
  41564. * Defines a XBox360 gamepad
  41565. */
  41566. export class Xbox360Pad extends Gamepad {
  41567. private _leftTrigger;
  41568. private _rightTrigger;
  41569. private _onlefttriggerchanged;
  41570. private _onrighttriggerchanged;
  41571. private _onbuttondown;
  41572. private _onbuttonup;
  41573. private _ondpaddown;
  41574. private _ondpadup;
  41575. /** Observable raised when a button is pressed */
  41576. onButtonDownObservable: Observable<Xbox360Button>;
  41577. /** Observable raised when a button is released */
  41578. onButtonUpObservable: Observable<Xbox360Button>;
  41579. /** Observable raised when a pad is pressed */
  41580. onPadDownObservable: Observable<Xbox360Dpad>;
  41581. /** Observable raised when a pad is released */
  41582. onPadUpObservable: Observable<Xbox360Dpad>;
  41583. private _buttonA;
  41584. private _buttonB;
  41585. private _buttonX;
  41586. private _buttonY;
  41587. private _buttonBack;
  41588. private _buttonStart;
  41589. private _buttonLB;
  41590. private _buttonRB;
  41591. private _buttonLeftStick;
  41592. private _buttonRightStick;
  41593. private _dPadUp;
  41594. private _dPadDown;
  41595. private _dPadLeft;
  41596. private _dPadRight;
  41597. private _isXboxOnePad;
  41598. /**
  41599. * Creates a new XBox360 gamepad object
  41600. * @param id defines the id of this gamepad
  41601. * @param index defines its index
  41602. * @param gamepad defines the internal HTML gamepad object
  41603. * @param xboxOne defines if it is a XBox One gamepad
  41604. */
  41605. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41606. /**
  41607. * Defines the callback to call when left trigger is pressed
  41608. * @param callback defines the callback to use
  41609. */
  41610. onlefttriggerchanged(callback: (value: number) => void): void;
  41611. /**
  41612. * Defines the callback to call when right trigger is pressed
  41613. * @param callback defines the callback to use
  41614. */
  41615. onrighttriggerchanged(callback: (value: number) => void): void;
  41616. /**
  41617. * Gets the left trigger value
  41618. */
  41619. /**
  41620. * Sets the left trigger value
  41621. */
  41622. leftTrigger: number;
  41623. /**
  41624. * Gets the right trigger value
  41625. */
  41626. /**
  41627. * Sets the right trigger value
  41628. */
  41629. rightTrigger: number;
  41630. /**
  41631. * Defines the callback to call when a button is pressed
  41632. * @param callback defines the callback to use
  41633. */
  41634. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41635. /**
  41636. * Defines the callback to call when a button is released
  41637. * @param callback defines the callback to use
  41638. */
  41639. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41640. /**
  41641. * Defines the callback to call when a pad is pressed
  41642. * @param callback defines the callback to use
  41643. */
  41644. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41645. /**
  41646. * Defines the callback to call when a pad is released
  41647. * @param callback defines the callback to use
  41648. */
  41649. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41650. private _setButtonValue;
  41651. private _setDPadValue;
  41652. /**
  41653. * Gets the value of the `A` button
  41654. */
  41655. /**
  41656. * Sets the value of the `A` button
  41657. */
  41658. buttonA: number;
  41659. /**
  41660. * Gets the value of the `B` button
  41661. */
  41662. /**
  41663. * Sets the value of the `B` button
  41664. */
  41665. buttonB: number;
  41666. /**
  41667. * Gets the value of the `X` button
  41668. */
  41669. /**
  41670. * Sets the value of the `X` button
  41671. */
  41672. buttonX: number;
  41673. /**
  41674. * Gets the value of the `Y` button
  41675. */
  41676. /**
  41677. * Sets the value of the `Y` button
  41678. */
  41679. buttonY: number;
  41680. /**
  41681. * Gets the value of the `Start` button
  41682. */
  41683. /**
  41684. * Sets the value of the `Start` button
  41685. */
  41686. buttonStart: number;
  41687. /**
  41688. * Gets the value of the `Back` button
  41689. */
  41690. /**
  41691. * Sets the value of the `Back` button
  41692. */
  41693. buttonBack: number;
  41694. /**
  41695. * Gets the value of the `Left` button
  41696. */
  41697. /**
  41698. * Sets the value of the `Left` button
  41699. */
  41700. buttonLB: number;
  41701. /**
  41702. * Gets the value of the `Right` button
  41703. */
  41704. /**
  41705. * Sets the value of the `Right` button
  41706. */
  41707. buttonRB: number;
  41708. /**
  41709. * Gets the value of the Left joystick
  41710. */
  41711. /**
  41712. * Sets the value of the Left joystick
  41713. */
  41714. buttonLeftStick: number;
  41715. /**
  41716. * Gets the value of the Right joystick
  41717. */
  41718. /**
  41719. * Sets the value of the Right joystick
  41720. */
  41721. buttonRightStick: number;
  41722. /**
  41723. * Gets the value of D-pad up
  41724. */
  41725. /**
  41726. * Sets the value of D-pad up
  41727. */
  41728. dPadUp: number;
  41729. /**
  41730. * Gets the value of D-pad down
  41731. */
  41732. /**
  41733. * Sets the value of D-pad down
  41734. */
  41735. dPadDown: number;
  41736. /**
  41737. * Gets the value of D-pad left
  41738. */
  41739. /**
  41740. * Sets the value of D-pad left
  41741. */
  41742. dPadLeft: number;
  41743. /**
  41744. * Gets the value of D-pad right
  41745. */
  41746. /**
  41747. * Sets the value of D-pad right
  41748. */
  41749. dPadRight: number;
  41750. /**
  41751. * Force the gamepad to synchronize with device values
  41752. */
  41753. update(): void;
  41754. /**
  41755. * Disposes the gamepad
  41756. */
  41757. dispose(): void;
  41758. }
  41759. }
  41760. declare module "babylonjs/Gamepads/dualShockGamepad" {
  41761. import { Observable } from "babylonjs/Misc/observable";
  41762. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41763. /**
  41764. * Defines supported buttons for DualShock compatible gamepads
  41765. */
  41766. export enum DualShockButton {
  41767. /** Cross */
  41768. Cross = 0,
  41769. /** Circle */
  41770. Circle = 1,
  41771. /** Square */
  41772. Square = 2,
  41773. /** Triangle */
  41774. Triangle = 3,
  41775. /** Options */
  41776. Options = 4,
  41777. /** Share */
  41778. Share = 5,
  41779. /** L1 */
  41780. L1 = 6,
  41781. /** R1 */
  41782. R1 = 7,
  41783. /** Left stick */
  41784. LeftStick = 8,
  41785. /** Right stick */
  41786. RightStick = 9
  41787. }
  41788. /** Defines values for DualShock DPad */
  41789. export enum DualShockDpad {
  41790. /** Up */
  41791. Up = 0,
  41792. /** Down */
  41793. Down = 1,
  41794. /** Left */
  41795. Left = 2,
  41796. /** Right */
  41797. Right = 3
  41798. }
  41799. /**
  41800. * Defines a DualShock gamepad
  41801. */
  41802. export class DualShockPad extends Gamepad {
  41803. private _leftTrigger;
  41804. private _rightTrigger;
  41805. private _onlefttriggerchanged;
  41806. private _onrighttriggerchanged;
  41807. private _onbuttondown;
  41808. private _onbuttonup;
  41809. private _ondpaddown;
  41810. private _ondpadup;
  41811. /** Observable raised when a button is pressed */
  41812. onButtonDownObservable: Observable<DualShockButton>;
  41813. /** Observable raised when a button is released */
  41814. onButtonUpObservable: Observable<DualShockButton>;
  41815. /** Observable raised when a pad is pressed */
  41816. onPadDownObservable: Observable<DualShockDpad>;
  41817. /** Observable raised when a pad is released */
  41818. onPadUpObservable: Observable<DualShockDpad>;
  41819. private _buttonCross;
  41820. private _buttonCircle;
  41821. private _buttonSquare;
  41822. private _buttonTriangle;
  41823. private _buttonShare;
  41824. private _buttonOptions;
  41825. private _buttonL1;
  41826. private _buttonR1;
  41827. private _buttonLeftStick;
  41828. private _buttonRightStick;
  41829. private _dPadUp;
  41830. private _dPadDown;
  41831. private _dPadLeft;
  41832. private _dPadRight;
  41833. /**
  41834. * Creates a new DualShock gamepad object
  41835. * @param id defines the id of this gamepad
  41836. * @param index defines its index
  41837. * @param gamepad defines the internal HTML gamepad object
  41838. */
  41839. constructor(id: string, index: number, gamepad: any);
  41840. /**
  41841. * Defines the callback to call when left trigger is pressed
  41842. * @param callback defines the callback to use
  41843. */
  41844. onlefttriggerchanged(callback: (value: number) => void): void;
  41845. /**
  41846. * Defines the callback to call when right trigger is pressed
  41847. * @param callback defines the callback to use
  41848. */
  41849. onrighttriggerchanged(callback: (value: number) => void): void;
  41850. /**
  41851. * Gets the left trigger value
  41852. */
  41853. /**
  41854. * Sets the left trigger value
  41855. */
  41856. leftTrigger: number;
  41857. /**
  41858. * Gets the right trigger value
  41859. */
  41860. /**
  41861. * Sets the right trigger value
  41862. */
  41863. rightTrigger: number;
  41864. /**
  41865. * Defines the callback to call when a button is pressed
  41866. * @param callback defines the callback to use
  41867. */
  41868. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41869. /**
  41870. * Defines the callback to call when a button is released
  41871. * @param callback defines the callback to use
  41872. */
  41873. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41874. /**
  41875. * Defines the callback to call when a pad is pressed
  41876. * @param callback defines the callback to use
  41877. */
  41878. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41879. /**
  41880. * Defines the callback to call when a pad is released
  41881. * @param callback defines the callback to use
  41882. */
  41883. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41884. private _setButtonValue;
  41885. private _setDPadValue;
  41886. /**
  41887. * Gets the value of the `Cross` button
  41888. */
  41889. /**
  41890. * Sets the value of the `Cross` button
  41891. */
  41892. buttonCross: number;
  41893. /**
  41894. * Gets the value of the `Circle` button
  41895. */
  41896. /**
  41897. * Sets the value of the `Circle` button
  41898. */
  41899. buttonCircle: number;
  41900. /**
  41901. * Gets the value of the `Square` button
  41902. */
  41903. /**
  41904. * Sets the value of the `Square` button
  41905. */
  41906. buttonSquare: number;
  41907. /**
  41908. * Gets the value of the `Triangle` button
  41909. */
  41910. /**
  41911. * Sets the value of the `Triangle` button
  41912. */
  41913. buttonTriangle: number;
  41914. /**
  41915. * Gets the value of the `Options` button
  41916. */
  41917. /**
  41918. * Sets the value of the `Options` button
  41919. */
  41920. buttonOptions: number;
  41921. /**
  41922. * Gets the value of the `Share` button
  41923. */
  41924. /**
  41925. * Sets the value of the `Share` button
  41926. */
  41927. buttonShare: number;
  41928. /**
  41929. * Gets the value of the `L1` button
  41930. */
  41931. /**
  41932. * Sets the value of the `L1` button
  41933. */
  41934. buttonL1: number;
  41935. /**
  41936. * Gets the value of the `R1` button
  41937. */
  41938. /**
  41939. * Sets the value of the `R1` button
  41940. */
  41941. buttonR1: number;
  41942. /**
  41943. * Gets the value of the Left joystick
  41944. */
  41945. /**
  41946. * Sets the value of the Left joystick
  41947. */
  41948. buttonLeftStick: number;
  41949. /**
  41950. * Gets the value of the Right joystick
  41951. */
  41952. /**
  41953. * Sets the value of the Right joystick
  41954. */
  41955. buttonRightStick: number;
  41956. /**
  41957. * Gets the value of D-pad up
  41958. */
  41959. /**
  41960. * Sets the value of D-pad up
  41961. */
  41962. dPadUp: number;
  41963. /**
  41964. * Gets the value of D-pad down
  41965. */
  41966. /**
  41967. * Sets the value of D-pad down
  41968. */
  41969. dPadDown: number;
  41970. /**
  41971. * Gets the value of D-pad left
  41972. */
  41973. /**
  41974. * Sets the value of D-pad left
  41975. */
  41976. dPadLeft: number;
  41977. /**
  41978. * Gets the value of D-pad right
  41979. */
  41980. /**
  41981. * Sets the value of D-pad right
  41982. */
  41983. dPadRight: number;
  41984. /**
  41985. * Force the gamepad to synchronize with device values
  41986. */
  41987. update(): void;
  41988. /**
  41989. * Disposes the gamepad
  41990. */
  41991. dispose(): void;
  41992. }
  41993. }
  41994. declare module "babylonjs/Gamepads/gamepadManager" {
  41995. import { Observable } from "babylonjs/Misc/observable";
  41996. import { Nullable } from "babylonjs/types";
  41997. import { Scene } from "babylonjs/scene";
  41998. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41999. /**
  42000. * Manager for handling gamepads
  42001. */
  42002. export class GamepadManager {
  42003. private _scene?;
  42004. private _babylonGamepads;
  42005. private _oneGamepadConnected;
  42006. /** @hidden */
  42007. _isMonitoring: boolean;
  42008. private _gamepadEventSupported;
  42009. private _gamepadSupport;
  42010. /**
  42011. * observable to be triggered when the gamepad controller has been connected
  42012. */
  42013. onGamepadConnectedObservable: Observable<Gamepad>;
  42014. /**
  42015. * observable to be triggered when the gamepad controller has been disconnected
  42016. */
  42017. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42018. private _onGamepadConnectedEvent;
  42019. private _onGamepadDisconnectedEvent;
  42020. /**
  42021. * Initializes the gamepad manager
  42022. * @param _scene BabylonJS scene
  42023. */
  42024. constructor(_scene?: Scene | undefined);
  42025. /**
  42026. * The gamepads in the game pad manager
  42027. */
  42028. readonly gamepads: Gamepad[];
  42029. /**
  42030. * Get the gamepad controllers based on type
  42031. * @param type The type of gamepad controller
  42032. * @returns Nullable gamepad
  42033. */
  42034. getGamepadByType(type?: number): Nullable<Gamepad>;
  42035. /**
  42036. * Disposes the gamepad manager
  42037. */
  42038. dispose(): void;
  42039. private _addNewGamepad;
  42040. private _startMonitoringGamepads;
  42041. private _stopMonitoringGamepads;
  42042. /** @hidden */
  42043. _checkGamepadsStatus(): void;
  42044. private _updateGamepadObjects;
  42045. }
  42046. }
  42047. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42048. import { Nullable } from "babylonjs/types";
  42049. import { Scene } from "babylonjs/scene";
  42050. import { ISceneComponent } from "babylonjs/sceneComponent";
  42051. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42052. module "babylonjs/scene" {
  42053. interface Scene {
  42054. /** @hidden */
  42055. _gamepadManager: Nullable<GamepadManager>;
  42056. /**
  42057. * Gets the gamepad manager associated with the scene
  42058. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42059. */
  42060. gamepadManager: GamepadManager;
  42061. }
  42062. }
  42063. module "babylonjs/Cameras/freeCameraInputsManager" {
  42064. /**
  42065. * Interface representing a free camera inputs manager
  42066. */
  42067. interface FreeCameraInputsManager {
  42068. /**
  42069. * Adds gamepad input support to the FreeCameraInputsManager.
  42070. * @returns the FreeCameraInputsManager
  42071. */
  42072. addGamepad(): FreeCameraInputsManager;
  42073. }
  42074. }
  42075. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42076. /**
  42077. * Interface representing an arc rotate camera inputs manager
  42078. */
  42079. interface ArcRotateCameraInputsManager {
  42080. /**
  42081. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42082. * @returns the camera inputs manager
  42083. */
  42084. addGamepad(): ArcRotateCameraInputsManager;
  42085. }
  42086. }
  42087. /**
  42088. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42089. */
  42090. export class GamepadSystemSceneComponent implements ISceneComponent {
  42091. /**
  42092. * The component name helpfull to identify the component in the list of scene components.
  42093. */
  42094. readonly name: string;
  42095. /**
  42096. * The scene the component belongs to.
  42097. */
  42098. scene: Scene;
  42099. /**
  42100. * Creates a new instance of the component for the given scene
  42101. * @param scene Defines the scene to register the component in
  42102. */
  42103. constructor(scene: Scene);
  42104. /**
  42105. * Registers the component in a given scene
  42106. */
  42107. register(): void;
  42108. /**
  42109. * Rebuilds the elements related to this component in case of
  42110. * context lost for instance.
  42111. */
  42112. rebuild(): void;
  42113. /**
  42114. * Disposes the component and the associated ressources
  42115. */
  42116. dispose(): void;
  42117. private _beforeCameraUpdate;
  42118. }
  42119. }
  42120. declare module "babylonjs/Cameras/universalCamera" {
  42121. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42122. import { Scene } from "babylonjs/scene";
  42123. import { Vector3 } from "babylonjs/Maths/math.vector";
  42124. import "babylonjs/Gamepads/gamepadSceneComponent";
  42125. /**
  42126. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  42127. * which still works and will still be found in many Playgrounds.
  42128. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42129. */
  42130. export class UniversalCamera extends TouchCamera {
  42131. /**
  42132. * Defines the gamepad rotation sensiblity.
  42133. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42134. */
  42135. gamepadAngularSensibility: number;
  42136. /**
  42137. * Defines the gamepad move sensiblity.
  42138. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42139. */
  42140. gamepadMoveSensibility: number;
  42141. /**
  42142. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  42143. * which still works and will still be found in many Playgrounds.
  42144. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42145. * @param name Define the name of the camera in the scene
  42146. * @param position Define the start position of the camera in the scene
  42147. * @param scene Define the scene the camera belongs to
  42148. */
  42149. constructor(name: string, position: Vector3, scene: Scene);
  42150. /**
  42151. * Gets the current object class name.
  42152. * @return the class name
  42153. */
  42154. getClassName(): string;
  42155. }
  42156. }
  42157. declare module "babylonjs/Cameras/gamepadCamera" {
  42158. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42159. import { Scene } from "babylonjs/scene";
  42160. import { Vector3 } from "babylonjs/Maths/math.vector";
  42161. /**
  42162. * This represents a FPS type of camera. This is only here for back compat purpose.
  42163. * Please use the UniversalCamera instead as both are identical.
  42164. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42165. */
  42166. export class GamepadCamera extends UniversalCamera {
  42167. /**
  42168. * Instantiates a new Gamepad Camera
  42169. * This represents a FPS type of camera. This is only here for back compat purpose.
  42170. * Please use the UniversalCamera instead as both are identical.
  42171. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42172. * @param name Define the name of the camera in the scene
  42173. * @param position Define the start position of the camera in the scene
  42174. * @param scene Define the scene the camera belongs to
  42175. */
  42176. constructor(name: string, position: Vector3, scene: Scene);
  42177. /**
  42178. * Gets the current object class name.
  42179. * @return the class name
  42180. */
  42181. getClassName(): string;
  42182. }
  42183. }
  42184. declare module "babylonjs/Shaders/pass.fragment" {
  42185. /** @hidden */
  42186. export var passPixelShader: {
  42187. name: string;
  42188. shader: string;
  42189. };
  42190. }
  42191. declare module "babylonjs/Shaders/passCube.fragment" {
  42192. /** @hidden */
  42193. export var passCubePixelShader: {
  42194. name: string;
  42195. shader: string;
  42196. };
  42197. }
  42198. declare module "babylonjs/PostProcesses/passPostProcess" {
  42199. import { Nullable } from "babylonjs/types";
  42200. import { Camera } from "babylonjs/Cameras/camera";
  42201. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42202. import { Engine } from "babylonjs/Engines/engine";
  42203. import "babylonjs/Shaders/pass.fragment";
  42204. import "babylonjs/Shaders/passCube.fragment";
  42205. /**
  42206. * PassPostProcess which produces an output the same as it's input
  42207. */
  42208. export class PassPostProcess extends PostProcess {
  42209. /**
  42210. * Creates the PassPostProcess
  42211. * @param name The name of the effect.
  42212. * @param options The required width/height ratio to downsize to before computing the render pass.
  42213. * @param camera The camera to apply the render pass to.
  42214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42215. * @param engine The engine which the post process will be applied. (default: current engine)
  42216. * @param reusable If the post process can be reused on the same frame. (default: false)
  42217. * @param textureType The type of texture to be used when performing the post processing.
  42218. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  42219. */
  42220. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42221. }
  42222. /**
  42223. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42224. */
  42225. export class PassCubePostProcess extends PostProcess {
  42226. private _face;
  42227. /**
  42228. * Gets or sets the cube face to display.
  42229. * * 0 is +X
  42230. * * 1 is -X
  42231. * * 2 is +Y
  42232. * * 3 is -Y
  42233. * * 4 is +Z
  42234. * * 5 is -Z
  42235. */
  42236. face: number;
  42237. /**
  42238. * Creates the PassCubePostProcess
  42239. * @param name The name of the effect.
  42240. * @param options The required width/height ratio to downsize to before computing the render pass.
  42241. * @param camera The camera to apply the render pass to.
  42242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42243. * @param engine The engine which the post process will be applied. (default: current engine)
  42244. * @param reusable If the post process can be reused on the same frame. (default: false)
  42245. * @param textureType The type of texture to be used when performing the post processing.
  42246. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  42247. */
  42248. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42249. }
  42250. }
  42251. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42252. /** @hidden */
  42253. export var anaglyphPixelShader: {
  42254. name: string;
  42255. shader: string;
  42256. };
  42257. }
  42258. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42259. import { Engine } from "babylonjs/Engines/engine";
  42260. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42261. import { Camera } from "babylonjs/Cameras/camera";
  42262. import "babylonjs/Shaders/anaglyph.fragment";
  42263. /**
  42264. * Postprocess used to generate anaglyphic rendering
  42265. */
  42266. export class AnaglyphPostProcess extends PostProcess {
  42267. private _passedProcess;
  42268. /**
  42269. * Creates a new AnaglyphPostProcess
  42270. * @param name defines postprocess name
  42271. * @param options defines creation options or target ratio scale
  42272. * @param rigCameras defines cameras using this postprocess
  42273. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42274. * @param engine defines hosting engine
  42275. * @param reusable defines if the postprocess will be reused multiple times per frame
  42276. */
  42277. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42278. }
  42279. }
  42280. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42281. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42282. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42283. import { Scene } from "babylonjs/scene";
  42284. import { Vector3 } from "babylonjs/Maths/math.vector";
  42285. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42286. /**
  42287. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42288. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42289. */
  42290. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42291. /**
  42292. * Creates a new AnaglyphArcRotateCamera
  42293. * @param name defines camera name
  42294. * @param alpha defines alpha angle (in radians)
  42295. * @param beta defines beta angle (in radians)
  42296. * @param radius defines radius
  42297. * @param target defines camera target
  42298. * @param interaxialDistance defines distance between each color axis
  42299. * @param scene defines the hosting scene
  42300. */
  42301. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42302. /**
  42303. * Gets camera class name
  42304. * @returns AnaglyphArcRotateCamera
  42305. */
  42306. getClassName(): string;
  42307. }
  42308. }
  42309. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42310. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42311. import { Scene } from "babylonjs/scene";
  42312. import { Vector3 } from "babylonjs/Maths/math.vector";
  42313. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42314. /**
  42315. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42316. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42317. */
  42318. export class AnaglyphFreeCamera extends FreeCamera {
  42319. /**
  42320. * Creates a new AnaglyphFreeCamera
  42321. * @param name defines camera name
  42322. * @param position defines initial position
  42323. * @param interaxialDistance defines distance between each color axis
  42324. * @param scene defines the hosting scene
  42325. */
  42326. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42327. /**
  42328. * Gets camera class name
  42329. * @returns AnaglyphFreeCamera
  42330. */
  42331. getClassName(): string;
  42332. }
  42333. }
  42334. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42335. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42336. import { Scene } from "babylonjs/scene";
  42337. import { Vector3 } from "babylonjs/Maths/math.vector";
  42338. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42339. /**
  42340. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42341. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42342. */
  42343. export class AnaglyphGamepadCamera extends GamepadCamera {
  42344. /**
  42345. * Creates a new AnaglyphGamepadCamera
  42346. * @param name defines camera name
  42347. * @param position defines initial position
  42348. * @param interaxialDistance defines distance between each color axis
  42349. * @param scene defines the hosting scene
  42350. */
  42351. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42352. /**
  42353. * Gets camera class name
  42354. * @returns AnaglyphGamepadCamera
  42355. */
  42356. getClassName(): string;
  42357. }
  42358. }
  42359. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42360. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42361. import { Scene } from "babylonjs/scene";
  42362. import { Vector3 } from "babylonjs/Maths/math.vector";
  42363. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42364. /**
  42365. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42366. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42367. */
  42368. export class AnaglyphUniversalCamera extends UniversalCamera {
  42369. /**
  42370. * Creates a new AnaglyphUniversalCamera
  42371. * @param name defines camera name
  42372. * @param position defines initial position
  42373. * @param interaxialDistance defines distance between each color axis
  42374. * @param scene defines the hosting scene
  42375. */
  42376. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42377. /**
  42378. * Gets camera class name
  42379. * @returns AnaglyphUniversalCamera
  42380. */
  42381. getClassName(): string;
  42382. }
  42383. }
  42384. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42385. /** @hidden */
  42386. export var stereoscopicInterlacePixelShader: {
  42387. name: string;
  42388. shader: string;
  42389. };
  42390. }
  42391. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42392. import { Camera } from "babylonjs/Cameras/camera";
  42393. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42394. import { Engine } from "babylonjs/Engines/engine";
  42395. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42396. /**
  42397. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42398. */
  42399. export class StereoscopicInterlacePostProcess extends PostProcess {
  42400. private _stepSize;
  42401. private _passedProcess;
  42402. /**
  42403. * Initializes a StereoscopicInterlacePostProcess
  42404. * @param name The name of the effect.
  42405. * @param rigCameras The rig cameras to be appled to the post process
  42406. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42408. * @param engine The engine which the post process will be applied. (default: current engine)
  42409. * @param reusable If the post process can be reused on the same frame. (default: false)
  42410. */
  42411. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42412. }
  42413. }
  42414. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42415. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42416. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42417. import { Scene } from "babylonjs/scene";
  42418. import { Vector3 } from "babylonjs/Maths/math.vector";
  42419. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42420. /**
  42421. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42422. * @see http://doc.babylonjs.com/features/cameras
  42423. */
  42424. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42425. /**
  42426. * Creates a new StereoscopicArcRotateCamera
  42427. * @param name defines camera name
  42428. * @param alpha defines alpha angle (in radians)
  42429. * @param beta defines beta angle (in radians)
  42430. * @param radius defines radius
  42431. * @param target defines camera target
  42432. * @param interaxialDistance defines distance between each color axis
  42433. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42434. * @param scene defines the hosting scene
  42435. */
  42436. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42437. /**
  42438. * Gets camera class name
  42439. * @returns StereoscopicArcRotateCamera
  42440. */
  42441. getClassName(): string;
  42442. }
  42443. }
  42444. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42445. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42446. import { Scene } from "babylonjs/scene";
  42447. import { Vector3 } from "babylonjs/Maths/math.vector";
  42448. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42449. /**
  42450. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42451. * @see http://doc.babylonjs.com/features/cameras
  42452. */
  42453. export class StereoscopicFreeCamera extends FreeCamera {
  42454. /**
  42455. * Creates a new StereoscopicFreeCamera
  42456. * @param name defines camera name
  42457. * @param position defines initial position
  42458. * @param interaxialDistance defines distance between each color axis
  42459. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42460. * @param scene defines the hosting scene
  42461. */
  42462. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42463. /**
  42464. * Gets camera class name
  42465. * @returns StereoscopicFreeCamera
  42466. */
  42467. getClassName(): string;
  42468. }
  42469. }
  42470. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42471. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42472. import { Scene } from "babylonjs/scene";
  42473. import { Vector3 } from "babylonjs/Maths/math.vector";
  42474. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42475. /**
  42476. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42477. * @see http://doc.babylonjs.com/features/cameras
  42478. */
  42479. export class StereoscopicGamepadCamera extends GamepadCamera {
  42480. /**
  42481. * Creates a new StereoscopicGamepadCamera
  42482. * @param name defines camera name
  42483. * @param position defines initial position
  42484. * @param interaxialDistance defines distance between each color axis
  42485. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42486. * @param scene defines the hosting scene
  42487. */
  42488. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42489. /**
  42490. * Gets camera class name
  42491. * @returns StereoscopicGamepadCamera
  42492. */
  42493. getClassName(): string;
  42494. }
  42495. }
  42496. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42497. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42498. import { Scene } from "babylonjs/scene";
  42499. import { Vector3 } from "babylonjs/Maths/math.vector";
  42500. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42501. /**
  42502. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42503. * @see http://doc.babylonjs.com/features/cameras
  42504. */
  42505. export class StereoscopicUniversalCamera extends UniversalCamera {
  42506. /**
  42507. * Creates a new StereoscopicUniversalCamera
  42508. * @param name defines camera name
  42509. * @param position defines initial position
  42510. * @param interaxialDistance defines distance between each color axis
  42511. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42512. * @param scene defines the hosting scene
  42513. */
  42514. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42515. /**
  42516. * Gets camera class name
  42517. * @returns StereoscopicUniversalCamera
  42518. */
  42519. getClassName(): string;
  42520. }
  42521. }
  42522. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42523. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42524. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42525. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42526. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  42527. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  42528. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  42529. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  42530. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  42531. }
  42532. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  42533. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42534. import { Scene } from "babylonjs/scene";
  42535. import { Vector3 } from "babylonjs/Maths/math.vector";
  42536. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42537. /**
  42538. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42539. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42540. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42541. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42542. */
  42543. export class VirtualJoysticksCamera extends FreeCamera {
  42544. /**
  42545. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42546. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42547. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42548. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42549. * @param name Define the name of the camera in the scene
  42550. * @param position Define the start position of the camera in the scene
  42551. * @param scene Define the scene the camera belongs to
  42552. */
  42553. constructor(name: string, position: Vector3, scene: Scene);
  42554. /**
  42555. * Gets the current object class name.
  42556. * @return the class name
  42557. */
  42558. getClassName(): string;
  42559. }
  42560. }
  42561. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  42562. import { Matrix } from "babylonjs/Maths/math.vector";
  42563. /**
  42564. * This represents all the required metrics to create a VR camera.
  42565. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42566. */
  42567. export class VRCameraMetrics {
  42568. /**
  42569. * Define the horizontal resolution off the screen.
  42570. */
  42571. hResolution: number;
  42572. /**
  42573. * Define the vertical resolution off the screen.
  42574. */
  42575. vResolution: number;
  42576. /**
  42577. * Define the horizontal screen size.
  42578. */
  42579. hScreenSize: number;
  42580. /**
  42581. * Define the vertical screen size.
  42582. */
  42583. vScreenSize: number;
  42584. /**
  42585. * Define the vertical screen center position.
  42586. */
  42587. vScreenCenter: number;
  42588. /**
  42589. * Define the distance of the eyes to the screen.
  42590. */
  42591. eyeToScreenDistance: number;
  42592. /**
  42593. * Define the distance between both lenses
  42594. */
  42595. lensSeparationDistance: number;
  42596. /**
  42597. * Define the distance between both viewer's eyes.
  42598. */
  42599. interpupillaryDistance: number;
  42600. /**
  42601. * Define the distortion factor of the VR postprocess.
  42602. * Please, touch with care.
  42603. */
  42604. distortionK: number[];
  42605. /**
  42606. * Define the chromatic aberration correction factors for the VR post process.
  42607. */
  42608. chromaAbCorrection: number[];
  42609. /**
  42610. * Define the scale factor of the post process.
  42611. * The smaller the better but the slower.
  42612. */
  42613. postProcessScaleFactor: number;
  42614. /**
  42615. * Define an offset for the lens center.
  42616. */
  42617. lensCenterOffset: number;
  42618. /**
  42619. * Define if the current vr camera should compensate the distortion of the lense or not.
  42620. */
  42621. compensateDistortion: boolean;
  42622. /**
  42623. * Defines if multiview should be enabled when rendering (Default: false)
  42624. */
  42625. multiviewEnabled: boolean;
  42626. /**
  42627. * Gets the rendering aspect ratio based on the provided resolutions.
  42628. */
  42629. readonly aspectRatio: number;
  42630. /**
  42631. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42632. */
  42633. readonly aspectRatioFov: number;
  42634. /**
  42635. * @hidden
  42636. */
  42637. readonly leftHMatrix: Matrix;
  42638. /**
  42639. * @hidden
  42640. */
  42641. readonly rightHMatrix: Matrix;
  42642. /**
  42643. * @hidden
  42644. */
  42645. readonly leftPreViewMatrix: Matrix;
  42646. /**
  42647. * @hidden
  42648. */
  42649. readonly rightPreViewMatrix: Matrix;
  42650. /**
  42651. * Get the default VRMetrics based on the most generic setup.
  42652. * @returns the default vr metrics
  42653. */
  42654. static GetDefault(): VRCameraMetrics;
  42655. }
  42656. }
  42657. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  42658. /** @hidden */
  42659. export var vrDistortionCorrectionPixelShader: {
  42660. name: string;
  42661. shader: string;
  42662. };
  42663. }
  42664. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  42665. import { Camera } from "babylonjs/Cameras/camera";
  42666. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42667. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42668. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  42669. /**
  42670. * VRDistortionCorrectionPostProcess used for mobile VR
  42671. */
  42672. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42673. private _isRightEye;
  42674. private _distortionFactors;
  42675. private _postProcessScaleFactor;
  42676. private _lensCenterOffset;
  42677. private _scaleIn;
  42678. private _scaleFactor;
  42679. private _lensCenter;
  42680. /**
  42681. * Initializes the VRDistortionCorrectionPostProcess
  42682. * @param name The name of the effect.
  42683. * @param camera The camera to apply the render pass to.
  42684. * @param isRightEye If this is for the right eye distortion
  42685. * @param vrMetrics All the required metrics for the VR camera
  42686. */
  42687. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42688. }
  42689. }
  42690. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  42691. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  42692. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42693. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42694. import { Scene } from "babylonjs/scene";
  42695. import { Vector3 } from "babylonjs/Maths/math.vector";
  42696. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42697. import "babylonjs/Cameras/RigModes/vrRigMode";
  42698. /**
  42699. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42700. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42701. */
  42702. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42703. /**
  42704. * Creates a new VRDeviceOrientationArcRotateCamera
  42705. * @param name defines camera name
  42706. * @param alpha defines the camera rotation along the logitudinal axis
  42707. * @param beta defines the camera rotation along the latitudinal axis
  42708. * @param radius defines the camera distance from its target
  42709. * @param target defines the camera target
  42710. * @param scene defines the scene the camera belongs to
  42711. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42712. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42713. */
  42714. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42715. /**
  42716. * Gets camera class name
  42717. * @returns VRDeviceOrientationArcRotateCamera
  42718. */
  42719. getClassName(): string;
  42720. }
  42721. }
  42722. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  42723. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42724. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42725. import { Scene } from "babylonjs/scene";
  42726. import { Vector3 } from "babylonjs/Maths/math.vector";
  42727. import "babylonjs/Cameras/RigModes/vrRigMode";
  42728. /**
  42729. * Camera used to simulate VR rendering (based on FreeCamera)
  42730. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42731. */
  42732. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42733. /**
  42734. * Creates a new VRDeviceOrientationFreeCamera
  42735. * @param name defines camera name
  42736. * @param position defines the start position of the camera
  42737. * @param scene defines the scene the camera belongs to
  42738. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42739. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42740. */
  42741. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42742. /**
  42743. * Gets camera class name
  42744. * @returns VRDeviceOrientationFreeCamera
  42745. */
  42746. getClassName(): string;
  42747. }
  42748. }
  42749. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  42750. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42751. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42752. import { Scene } from "babylonjs/scene";
  42753. import { Vector3 } from "babylonjs/Maths/math.vector";
  42754. import "babylonjs/Gamepads/gamepadSceneComponent";
  42755. /**
  42756. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42757. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42758. */
  42759. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42760. /**
  42761. * Creates a new VRDeviceOrientationGamepadCamera
  42762. * @param name defines camera name
  42763. * @param position defines the start position of the camera
  42764. * @param scene defines the scene the camera belongs to
  42765. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42766. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42767. */
  42768. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42769. /**
  42770. * Gets camera class name
  42771. * @returns VRDeviceOrientationGamepadCamera
  42772. */
  42773. getClassName(): string;
  42774. }
  42775. }
  42776. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42777. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42778. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42779. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42780. /** @hidden */
  42781. export var imageProcessingPixelShader: {
  42782. name: string;
  42783. shader: string;
  42784. };
  42785. }
  42786. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42787. import { Nullable } from "babylonjs/types";
  42788. import { Color4 } from "babylonjs/Maths/math.color";
  42789. import { Camera } from "babylonjs/Cameras/camera";
  42790. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42791. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42792. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42793. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42794. import { Engine } from "babylonjs/Engines/engine";
  42795. import "babylonjs/Shaders/imageProcessing.fragment";
  42796. import "babylonjs/Shaders/postprocess.vertex";
  42797. /**
  42798. * ImageProcessingPostProcess
  42799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42800. */
  42801. export class ImageProcessingPostProcess extends PostProcess {
  42802. /**
  42803. * Default configuration related to image processing available in the PBR Material.
  42804. */
  42805. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42806. /**
  42807. * Gets the image processing configuration used either in this material.
  42808. */
  42809. /**
  42810. * Sets the Default image processing configuration used either in the this material.
  42811. *
  42812. * If sets to null, the scene one is in use.
  42813. */
  42814. imageProcessingConfiguration: ImageProcessingConfiguration;
  42815. /**
  42816. * Keep track of the image processing observer to allow dispose and replace.
  42817. */
  42818. private _imageProcessingObserver;
  42819. /**
  42820. * Attaches a new image processing configuration to the PBR Material.
  42821. * @param configuration
  42822. */
  42823. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42824. /**
  42825. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42826. */
  42827. /**
  42828. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42829. */
  42830. colorCurves: Nullable<ColorCurves>;
  42831. /**
  42832. * Gets wether the color curves effect is enabled.
  42833. */
  42834. /**
  42835. * Sets wether the color curves effect is enabled.
  42836. */
  42837. colorCurvesEnabled: boolean;
  42838. /**
  42839. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42840. */
  42841. /**
  42842. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42843. */
  42844. colorGradingTexture: Nullable<BaseTexture>;
  42845. /**
  42846. * Gets wether the color grading effect is enabled.
  42847. */
  42848. /**
  42849. * Gets wether the color grading effect is enabled.
  42850. */
  42851. colorGradingEnabled: boolean;
  42852. /**
  42853. * Gets exposure used in the effect.
  42854. */
  42855. /**
  42856. * Sets exposure used in the effect.
  42857. */
  42858. exposure: number;
  42859. /**
  42860. * Gets wether tonemapping is enabled or not.
  42861. */
  42862. /**
  42863. * Sets wether tonemapping is enabled or not
  42864. */
  42865. toneMappingEnabled: boolean;
  42866. /**
  42867. * Gets the type of tone mapping effect.
  42868. */
  42869. /**
  42870. * Sets the type of tone mapping effect.
  42871. */
  42872. toneMappingType: number;
  42873. /**
  42874. * Gets contrast used in the effect.
  42875. */
  42876. /**
  42877. * Sets contrast used in the effect.
  42878. */
  42879. contrast: number;
  42880. /**
  42881. * Gets Vignette stretch size.
  42882. */
  42883. /**
  42884. * Sets Vignette stretch size.
  42885. */
  42886. vignetteStretch: number;
  42887. /**
  42888. * Gets Vignette centre X Offset.
  42889. */
  42890. /**
  42891. * Sets Vignette centre X Offset.
  42892. */
  42893. vignetteCentreX: number;
  42894. /**
  42895. * Gets Vignette centre Y Offset.
  42896. */
  42897. /**
  42898. * Sets Vignette centre Y Offset.
  42899. */
  42900. vignetteCentreY: number;
  42901. /**
  42902. * Gets Vignette weight or intensity of the vignette effect.
  42903. */
  42904. /**
  42905. * Sets Vignette weight or intensity of the vignette effect.
  42906. */
  42907. vignetteWeight: number;
  42908. /**
  42909. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42910. * if vignetteEnabled is set to true.
  42911. */
  42912. /**
  42913. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42914. * if vignetteEnabled is set to true.
  42915. */
  42916. vignetteColor: Color4;
  42917. /**
  42918. * Gets Camera field of view used by the Vignette effect.
  42919. */
  42920. /**
  42921. * Sets Camera field of view used by the Vignette effect.
  42922. */
  42923. vignetteCameraFov: number;
  42924. /**
  42925. * Gets the vignette blend mode allowing different kind of effect.
  42926. */
  42927. /**
  42928. * Sets the vignette blend mode allowing different kind of effect.
  42929. */
  42930. vignetteBlendMode: number;
  42931. /**
  42932. * Gets wether the vignette effect is enabled.
  42933. */
  42934. /**
  42935. * Sets wether the vignette effect is enabled.
  42936. */
  42937. vignetteEnabled: boolean;
  42938. private _fromLinearSpace;
  42939. /**
  42940. * Gets wether the input of the processing is in Gamma or Linear Space.
  42941. */
  42942. /**
  42943. * Sets wether the input of the processing is in Gamma or Linear Space.
  42944. */
  42945. fromLinearSpace: boolean;
  42946. /**
  42947. * Defines cache preventing GC.
  42948. */
  42949. private _defines;
  42950. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42951. /**
  42952. * "ImageProcessingPostProcess"
  42953. * @returns "ImageProcessingPostProcess"
  42954. */
  42955. getClassName(): string;
  42956. protected _updateParameters(): void;
  42957. dispose(camera?: Camera): void;
  42958. }
  42959. }
  42960. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42961. import { Scene } from "babylonjs/scene";
  42962. import { Color3 } from "babylonjs/Maths/math.color";
  42963. import { Mesh } from "babylonjs/Meshes/mesh";
  42964. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42965. import { Nullable } from "babylonjs/types";
  42966. /**
  42967. * Class containing static functions to help procedurally build meshes
  42968. */
  42969. export class GroundBuilder {
  42970. /**
  42971. * Creates a ground mesh
  42972. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42973. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42975. * @param name defines the name of the mesh
  42976. * @param options defines the options used to create the mesh
  42977. * @param scene defines the hosting scene
  42978. * @returns the ground mesh
  42979. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42980. */
  42981. static CreateGround(name: string, options: {
  42982. width?: number;
  42983. height?: number;
  42984. subdivisions?: number;
  42985. subdivisionsX?: number;
  42986. subdivisionsY?: number;
  42987. updatable?: boolean;
  42988. }, scene: any): Mesh;
  42989. /**
  42990. * Creates a tiled ground mesh
  42991. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42992. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42993. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  42994. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  42995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42996. * @param name defines the name of the mesh
  42997. * @param options defines the options used to create the mesh
  42998. * @param scene defines the hosting scene
  42999. * @returns the tiled ground mesh
  43000. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43001. */
  43002. static CreateTiledGround(name: string, options: {
  43003. xmin: number;
  43004. zmin: number;
  43005. xmax: number;
  43006. zmax: number;
  43007. subdivisions?: {
  43008. w: number;
  43009. h: number;
  43010. };
  43011. precision?: {
  43012. w: number;
  43013. h: number;
  43014. };
  43015. updatable?: boolean;
  43016. }, scene?: Nullable<Scene>): Mesh;
  43017. /**
  43018. * Creates a ground mesh from a height map
  43019. * * The parameter `url` sets the URL of the height map image resource.
  43020. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43021. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43022. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43023. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43024. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  43025. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  43026. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43028. * @param name defines the name of the mesh
  43029. * @param url defines the url to the height map
  43030. * @param options defines the options used to create the mesh
  43031. * @param scene defines the hosting scene
  43032. * @returns the ground mesh
  43033. * @see https://doc.babylonjs.com/babylon101/height_map
  43034. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43035. */
  43036. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43037. width?: number;
  43038. height?: number;
  43039. subdivisions?: number;
  43040. minHeight?: number;
  43041. maxHeight?: number;
  43042. colorFilter?: Color3;
  43043. alphaFilter?: number;
  43044. updatable?: boolean;
  43045. onReady?: (mesh: GroundMesh) => void;
  43046. }, scene?: Nullable<Scene>): GroundMesh;
  43047. }
  43048. }
  43049. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43050. import { Vector4 } from "babylonjs/Maths/math.vector";
  43051. import { Mesh } from "babylonjs/Meshes/mesh";
  43052. /**
  43053. * Class containing static functions to help procedurally build meshes
  43054. */
  43055. export class TorusBuilder {
  43056. /**
  43057. * Creates a torus mesh
  43058. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43059. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43060. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43064. * @param name defines the name of the mesh
  43065. * @param options defines the options used to create the mesh
  43066. * @param scene defines the hosting scene
  43067. * @returns the torus mesh
  43068. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43069. */
  43070. static CreateTorus(name: string, options: {
  43071. diameter?: number;
  43072. thickness?: number;
  43073. tessellation?: number;
  43074. updatable?: boolean;
  43075. sideOrientation?: number;
  43076. frontUVs?: Vector4;
  43077. backUVs?: Vector4;
  43078. }, scene: any): Mesh;
  43079. }
  43080. }
  43081. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43082. import { Vector4 } from "babylonjs/Maths/math.vector";
  43083. import { Color4 } from "babylonjs/Maths/math.color";
  43084. import { Mesh } from "babylonjs/Meshes/mesh";
  43085. /**
  43086. * Class containing static functions to help procedurally build meshes
  43087. */
  43088. export class CylinderBuilder {
  43089. /**
  43090. * Creates a cylinder or a cone mesh
  43091. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43092. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43093. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  43094. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43095. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43096. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43097. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43098. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  43099. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43100. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  43101. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  43102. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43103. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  43104. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  43105. * * If `enclose` is false, a ring surface is one element.
  43106. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43107. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  43108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43111. * @param name defines the name of the mesh
  43112. * @param options defines the options used to create the mesh
  43113. * @param scene defines the hosting scene
  43114. * @returns the cylinder mesh
  43115. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43116. */
  43117. static CreateCylinder(name: string, options: {
  43118. height?: number;
  43119. diameterTop?: number;
  43120. diameterBottom?: number;
  43121. diameter?: number;
  43122. tessellation?: number;
  43123. subdivisions?: number;
  43124. arc?: number;
  43125. faceColors?: Color4[];
  43126. faceUV?: Vector4[];
  43127. updatable?: boolean;
  43128. hasRings?: boolean;
  43129. enclose?: boolean;
  43130. cap?: number;
  43131. sideOrientation?: number;
  43132. frontUVs?: Vector4;
  43133. backUVs?: Vector4;
  43134. }, scene: any): Mesh;
  43135. }
  43136. }
  43137. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43138. import { Nullable } from "babylonjs/types";
  43139. import { IDisposable } from "babylonjs/scene";
  43140. /**
  43141. * States of the webXR experience
  43142. */
  43143. export enum WebXRState {
  43144. /**
  43145. * Transitioning to being in XR mode
  43146. */
  43147. ENTERING_XR = 0,
  43148. /**
  43149. * Transitioning to non XR mode
  43150. */
  43151. EXITING_XR = 1,
  43152. /**
  43153. * In XR mode and presenting
  43154. */
  43155. IN_XR = 2,
  43156. /**
  43157. * Not entered XR mode
  43158. */
  43159. NOT_IN_XR = 3
  43160. }
  43161. /**
  43162. * Abstraction of the XR render target
  43163. */
  43164. export interface WebXRRenderTarget extends IDisposable {
  43165. /**
  43166. * xrpresent context of the canvas which can be used to display/mirror xr content
  43167. */
  43168. canvasContext: WebGLRenderingContext;
  43169. /**
  43170. * xr layer for the canvas
  43171. */
  43172. xrLayer: Nullable<XRWebGLLayer>;
  43173. /**
  43174. * Initializes the xr layer for the session
  43175. * @param xrSession xr session
  43176. * @returns a promise that will resolve once the XR Layer has been created
  43177. */
  43178. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43179. }
  43180. }
  43181. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43182. import { Nullable } from "babylonjs/types";
  43183. import { Observable } from "babylonjs/Misc/observable";
  43184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43185. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43186. /**
  43187. * COnfiguration object for WebXR output canvas
  43188. */
  43189. export class WebXRManagedOutputCanvasOptions {
  43190. /**
  43191. * Options for this XR Layer output
  43192. */
  43193. canvasOptions: XRWebGLLayerOptions;
  43194. /**
  43195. * CSS styling for a newly created canvas (if not provided)
  43196. */
  43197. newCanvasCssStyle?: string;
  43198. /**
  43199. * Get the default values of the configuration object
  43200. * @returns default values of this configuration object
  43201. */
  43202. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43203. }
  43204. /**
  43205. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43206. */
  43207. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43208. private configuration;
  43209. private _engine;
  43210. private _canvas;
  43211. /**
  43212. * xrpresent context of the canvas which can be used to display/mirror xr content
  43213. */
  43214. canvasContext: WebGLRenderingContext;
  43215. /**
  43216. * xr layer for the canvas
  43217. */
  43218. xrLayer: Nullable<XRWebGLLayer>;
  43219. /**
  43220. * Initializes the xr layer for the session
  43221. * @param xrSession xr session
  43222. * @returns a promise that will resolve once the XR Layer has been created
  43223. */
  43224. initializeXRLayerAsync(xrSession: any): any;
  43225. /**
  43226. * Initializes the canvas to be added/removed upon entering/exiting xr
  43227. * @param engine the Babylon engine
  43228. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43229. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43230. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43231. */
  43232. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43233. /**
  43234. * Disposes of the object
  43235. */
  43236. dispose(): void;
  43237. private _setManagedOutputCanvas;
  43238. private _addCanvas;
  43239. private _removeCanvas;
  43240. }
  43241. }
  43242. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43243. import { Observable } from "babylonjs/Misc/observable";
  43244. import { Nullable } from "babylonjs/types";
  43245. import { IDisposable, Scene } from "babylonjs/scene";
  43246. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43247. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43248. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43249. /**
  43250. * Manages an XRSession to work with Babylon's engine
  43251. * @see https://doc.babylonjs.com/how_to/webxr
  43252. */
  43253. export class WebXRSessionManager implements IDisposable {
  43254. private scene;
  43255. /**
  43256. * Fires every time a new xrFrame arrives which can be used to update the camera
  43257. */
  43258. onXRFrameObservable: Observable<any>;
  43259. /**
  43260. * Fires when the xr session is ended either by the device or manually done
  43261. */
  43262. onXRSessionEnded: Observable<any>;
  43263. /**
  43264. * Underlying xr session
  43265. */
  43266. session: XRSession;
  43267. /**
  43268. * Type of reference space used when creating the session
  43269. */
  43270. referenceSpace: XRReferenceSpace;
  43271. /**
  43272. * Current XR frame
  43273. */
  43274. currentFrame: Nullable<XRFrame>;
  43275. private _xrNavigator;
  43276. private baseLayer;
  43277. private _rttProvider;
  43278. private _sessionEnded;
  43279. /**
  43280. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43281. * @param scene The scene which the session should be created for
  43282. */
  43283. constructor(scene: Scene);
  43284. /**
  43285. * Initializes the manager
  43286. * After initialization enterXR can be called to start an XR session
  43287. * @returns Promise which resolves after it is initialized
  43288. */
  43289. initializeAsync(): Promise<void>;
  43290. /**
  43291. * Initializes an xr session
  43292. * @param xrSessionMode mode to initialize
  43293. * @param optionalFeatures defines optional values to pass to the session builder
  43294. * @returns a promise which will resolve once the session has been initialized
  43295. */
  43296. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43297. /**
  43298. * Sets the reference space on the xr session
  43299. * @param referenceSpace space to set
  43300. * @returns a promise that will resolve once the reference space has been set
  43301. */
  43302. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43303. /**
  43304. * Updates the render state of the session
  43305. * @param state state to set
  43306. * @returns a promise that resolves once the render state has been updated
  43307. */
  43308. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43309. /**
  43310. * Starts rendering to the xr layer
  43311. * @returns a promise that will resolve once rendering has started
  43312. */
  43313. startRenderingToXRAsync(): Promise<void>;
  43314. /**
  43315. * Gets the correct render target texture to be rendered this frame for this eye
  43316. * @param eye the eye for which to get the render target
  43317. * @returns the render target for the specified eye
  43318. */
  43319. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43320. /**
  43321. * Stops the xrSession and restores the renderloop
  43322. * @returns Promise which resolves after it exits XR
  43323. */
  43324. exitXRAsync(): Promise<void>;
  43325. /**
  43326. * Checks if a session would be supported for the creation options specified
  43327. * @param sessionMode session mode to check if supported eg. immersive-vr
  43328. * @returns true if supported
  43329. */
  43330. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43331. /**
  43332. * Creates a WebXRRenderTarget object for the XR session
  43333. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43334. * @param options optional options to provide when creating a new render target
  43335. * @returns a WebXR render target to which the session can render
  43336. */
  43337. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43338. /**
  43339. * @hidden
  43340. * Converts the render layer of xrSession to a render target
  43341. * @param session session to create render target for
  43342. * @param scene scene the new render target should be created for
  43343. */
  43344. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43345. /**
  43346. * Disposes of the session manager
  43347. */
  43348. dispose(): void;
  43349. /**
  43350. * Gets a promise returning true when fullfiled if the given session mode is supported
  43351. * @param sessionMode defines the session to test
  43352. * @returns a promise
  43353. */
  43354. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43355. }
  43356. }
  43357. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43358. import { Scene } from "babylonjs/scene";
  43359. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43360. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43361. /**
  43362. * WebXR Camera which holds the views for the xrSession
  43363. * @see https://doc.babylonjs.com/how_to/webxr
  43364. */
  43365. export class WebXRCamera extends FreeCamera {
  43366. /**
  43367. * Is the camera in debug mode. Used when using an emulator
  43368. */
  43369. debugMode: boolean;
  43370. /**
  43371. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43372. * @param name the name of the camera
  43373. * @param scene the scene to add the camera to
  43374. */
  43375. constructor(name: string, scene: Scene);
  43376. private _updateNumberOfRigCameras;
  43377. /** @hidden */
  43378. _updateForDualEyeDebugging(): void;
  43379. /**
  43380. * Updates the cameras position from the current pose information of the XR session
  43381. * @param xrSessionManager the session containing pose information
  43382. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43383. */
  43384. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43385. }
  43386. }
  43387. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43388. import { Observable } from "babylonjs/Misc/observable";
  43389. import { IDisposable, Scene } from "babylonjs/scene";
  43390. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43392. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43393. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43394. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43395. /**
  43396. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43397. * @see https://doc.babylonjs.com/how_to/webxr
  43398. */
  43399. export class WebXRExperienceHelper implements IDisposable {
  43400. private scene;
  43401. /**
  43402. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  43403. */
  43404. container: AbstractMesh;
  43405. /**
  43406. * Camera used to render xr content
  43407. */
  43408. camera: WebXRCamera;
  43409. /**
  43410. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43411. */
  43412. state: WebXRState;
  43413. private _setState;
  43414. private static _TmpVector;
  43415. /**
  43416. * Fires when the state of the experience helper has changed
  43417. */
  43418. onStateChangedObservable: Observable<WebXRState>;
  43419. /** Session manager used to keep track of xr session */
  43420. sessionManager: WebXRSessionManager;
  43421. private _nonVRCamera;
  43422. private _originalSceneAutoClear;
  43423. private _supported;
  43424. /**
  43425. * Creates the experience helper
  43426. * @param scene the scene to attach the experience helper to
  43427. * @returns a promise for the experience helper
  43428. */
  43429. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43430. /**
  43431. * Creates a WebXRExperienceHelper
  43432. * @param scene The scene the helper should be created in
  43433. */
  43434. private constructor();
  43435. /**
  43436. * Exits XR mode and returns the scene to its original state
  43437. * @returns promise that resolves after xr mode has exited
  43438. */
  43439. exitXRAsync(): Promise<void>;
  43440. /**
  43441. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43442. * @param sessionMode options for the XR session
  43443. * @param referenceSpaceType frame of reference of the XR session
  43444. * @param renderTarget the output canvas that will be used to enter XR mode
  43445. * @returns promise that resolves after xr mode has entered
  43446. */
  43447. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43448. /**
  43449. * Updates the global position of the camera by moving the camera's container
  43450. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43451. * @param position The desired global position of the camera
  43452. */
  43453. setPositionOfCameraUsingContainer(position: Vector3): void;
  43454. /**
  43455. * Rotates the xr camera by rotating the camera's container around the camera's position
  43456. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43457. * @param rotation the desired quaternion rotation to apply to the camera
  43458. */
  43459. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43460. /**
  43461. * Disposes of the experience helper
  43462. */
  43463. dispose(): void;
  43464. }
  43465. }
  43466. declare module "babylonjs/Cameras/XR/webXRController" {
  43467. import { Nullable } from "babylonjs/types";
  43468. import { Observable } from "babylonjs/Misc/observable";
  43469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43470. import { Ray } from "babylonjs/Culling/ray";
  43471. import { Scene } from "babylonjs/scene";
  43472. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43473. /**
  43474. * Represents an XR input
  43475. */
  43476. export class WebXRController {
  43477. private scene;
  43478. /** The underlying input source for the controller */
  43479. inputSource: XRInputSource;
  43480. private parentContainer;
  43481. /**
  43482. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  43483. */
  43484. grip?: AbstractMesh;
  43485. /**
  43486. * Pointer which can be used to select objects or attach a visible laser to
  43487. */
  43488. pointer: AbstractMesh;
  43489. private _gamepadMode;
  43490. /**
  43491. * If available, this is the gamepad object related to this controller.
  43492. * Using this object it is possible to get click events and trackpad changes of the
  43493. * webxr controller that is currently being used.
  43494. */
  43495. gamepadController?: WebVRController;
  43496. /**
  43497. * Event that fires when the controller is removed/disposed
  43498. */
  43499. onDisposeObservable: Observable<{}>;
  43500. private _tmpQuaternion;
  43501. private _tmpVector;
  43502. /**
  43503. * Creates the controller
  43504. * @see https://doc.babylonjs.com/how_to/webxr
  43505. * @param scene the scene which the controller should be associated to
  43506. * @param inputSource the underlying input source for the controller
  43507. * @param parentContainer parent that the controller meshes should be children of
  43508. */
  43509. constructor(scene: Scene,
  43510. /** The underlying input source for the controller */
  43511. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43512. /**
  43513. * Updates the controller pose based on the given XRFrame
  43514. * @param xrFrame xr frame to update the pose with
  43515. * @param referenceSpace reference space to use
  43516. */
  43517. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43518. /**
  43519. * Gets a world space ray coming from the controller
  43520. * @param result the resulting ray
  43521. */
  43522. getWorldPointerRayToRef(result: Ray): void;
  43523. /**
  43524. * Get the scene associated with this controller
  43525. * @returns the scene object
  43526. */
  43527. getScene(): Scene;
  43528. /**
  43529. * Disposes of the object
  43530. */
  43531. dispose(): void;
  43532. }
  43533. }
  43534. declare module "babylonjs/Cameras/XR/webXRInput" {
  43535. import { Observable } from "babylonjs/Misc/observable";
  43536. import { IDisposable } from "babylonjs/scene";
  43537. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43538. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43539. /**
  43540. * XR input used to track XR inputs such as controllers/rays
  43541. */
  43542. export class WebXRInput implements IDisposable {
  43543. /**
  43544. * Base experience the input listens to
  43545. */
  43546. baseExperience: WebXRExperienceHelper;
  43547. /**
  43548. * XR controllers being tracked
  43549. */
  43550. controllers: Array<WebXRController>;
  43551. private _frameObserver;
  43552. private _stateObserver;
  43553. /**
  43554. * Event when a controller has been connected/added
  43555. */
  43556. onControllerAddedObservable: Observable<WebXRController>;
  43557. /**
  43558. * Event when a controller has been removed/disconnected
  43559. */
  43560. onControllerRemovedObservable: Observable<WebXRController>;
  43561. /**
  43562. * Initializes the WebXRInput
  43563. * @param baseExperience experience helper which the input should be created for
  43564. */
  43565. constructor(
  43566. /**
  43567. * Base experience the input listens to
  43568. */
  43569. baseExperience: WebXRExperienceHelper);
  43570. private _onInputSourcesChange;
  43571. private _addAndRemoveControllers;
  43572. /**
  43573. * Disposes of the object
  43574. */
  43575. dispose(): void;
  43576. }
  43577. }
  43578. declare module "babylonjs/Loading/sceneLoader" {
  43579. import { Observable } from "babylonjs/Misc/observable";
  43580. import { Nullable } from "babylonjs/types";
  43581. import { Scene } from "babylonjs/scene";
  43582. import { Engine } from "babylonjs/Engines/engine";
  43583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43584. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43585. import { AssetContainer } from "babylonjs/assetContainer";
  43586. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43587. import { Skeleton } from "babylonjs/Bones/skeleton";
  43588. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43589. import { WebRequest } from "babylonjs/Misc/webRequest";
  43590. /**
  43591. * Class used to represent data loading progression
  43592. */
  43593. export class SceneLoaderProgressEvent {
  43594. /** defines if data length to load can be evaluated */
  43595. readonly lengthComputable: boolean;
  43596. /** defines the loaded data length */
  43597. readonly loaded: number;
  43598. /** defines the data length to load */
  43599. readonly total: number;
  43600. /**
  43601. * Create a new progress event
  43602. * @param lengthComputable defines if data length to load can be evaluated
  43603. * @param loaded defines the loaded data length
  43604. * @param total defines the data length to load
  43605. */
  43606. constructor(
  43607. /** defines if data length to load can be evaluated */
  43608. lengthComputable: boolean,
  43609. /** defines the loaded data length */
  43610. loaded: number,
  43611. /** defines the data length to load */
  43612. total: number);
  43613. /**
  43614. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43615. * @param event defines the source event
  43616. * @returns a new SceneLoaderProgressEvent
  43617. */
  43618. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43619. }
  43620. /**
  43621. * Interface used by SceneLoader plugins to define supported file extensions
  43622. */
  43623. export interface ISceneLoaderPluginExtensions {
  43624. /**
  43625. * Defines the list of supported extensions
  43626. */
  43627. [extension: string]: {
  43628. isBinary: boolean;
  43629. };
  43630. }
  43631. /**
  43632. * Interface used by SceneLoader plugin factory
  43633. */
  43634. export interface ISceneLoaderPluginFactory {
  43635. /**
  43636. * Defines the name of the factory
  43637. */
  43638. name: string;
  43639. /**
  43640. * Function called to create a new plugin
  43641. * @return the new plugin
  43642. */
  43643. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43644. /**
  43645. * The callback that returns true if the data can be directly loaded.
  43646. * @param data string containing the file data
  43647. * @returns if the data can be loaded directly
  43648. */
  43649. canDirectLoad?(data: string): boolean;
  43650. }
  43651. /**
  43652. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43653. */
  43654. export interface ISceneLoaderPluginBase {
  43655. /**
  43656. * The friendly name of this plugin.
  43657. */
  43658. name: string;
  43659. /**
  43660. * The file extensions supported by this plugin.
  43661. */
  43662. extensions: string | ISceneLoaderPluginExtensions;
  43663. /**
  43664. * The callback called when loading from a url.
  43665. * @param scene scene loading this url
  43666. * @param url url to load
  43667. * @param onSuccess callback called when the file successfully loads
  43668. * @param onProgress callback called while file is loading (if the server supports this mode)
  43669. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43670. * @param onError callback called when the file fails to load
  43671. * @returns a file request object
  43672. */
  43673. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43674. /**
  43675. * The callback called when loading from a file object.
  43676. * @param scene scene loading this file
  43677. * @param file defines the file to load
  43678. * @param onSuccess defines the callback to call when data is loaded
  43679. * @param onProgress defines the callback to call during loading process
  43680. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43681. * @param onError defines the callback to call when an error occurs
  43682. * @returns a file request object
  43683. */
  43684. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43685. /**
  43686. * The callback that returns true if the data can be directly loaded.
  43687. * @param data string containing the file data
  43688. * @returns if the data can be loaded directly
  43689. */
  43690. canDirectLoad?(data: string): boolean;
  43691. /**
  43692. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43693. * @param scene scene loading this data
  43694. * @param data string containing the data
  43695. * @returns data to pass to the plugin
  43696. */
  43697. directLoad?(scene: Scene, data: string): any;
  43698. /**
  43699. * The callback that allows custom handling of the root url based on the response url.
  43700. * @param rootUrl the original root url
  43701. * @param responseURL the response url if available
  43702. * @returns the new root url
  43703. */
  43704. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43705. }
  43706. /**
  43707. * Interface used to define a SceneLoader plugin
  43708. */
  43709. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43710. /**
  43711. * Import meshes into a scene.
  43712. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43713. * @param scene The scene to import into
  43714. * @param data The data to import
  43715. * @param rootUrl The root url for scene and resources
  43716. * @param meshes The meshes array to import into
  43717. * @param particleSystems The particle systems array to import into
  43718. * @param skeletons The skeletons array to import into
  43719. * @param onError The callback when import fails
  43720. * @returns True if successful or false otherwise
  43721. */
  43722. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43723. /**
  43724. * Load into a scene.
  43725. * @param scene The scene to load into
  43726. * @param data The data to import
  43727. * @param rootUrl The root url for scene and resources
  43728. * @param onError The callback when import fails
  43729. * @returns True if successful or false otherwise
  43730. */
  43731. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43732. /**
  43733. * Load into an asset container.
  43734. * @param scene The scene to load into
  43735. * @param data The data to import
  43736. * @param rootUrl The root url for scene and resources
  43737. * @param onError The callback when import fails
  43738. * @returns The loaded asset container
  43739. */
  43740. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43741. }
  43742. /**
  43743. * Interface used to define an async SceneLoader plugin
  43744. */
  43745. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43746. /**
  43747. * Import meshes into a scene.
  43748. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43749. * @param scene The scene to import into
  43750. * @param data The data to import
  43751. * @param rootUrl The root url for scene and resources
  43752. * @param onProgress The callback when the load progresses
  43753. * @param fileName Defines the name of the file to load
  43754. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43755. */
  43756. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43757. meshes: AbstractMesh[];
  43758. particleSystems: IParticleSystem[];
  43759. skeletons: Skeleton[];
  43760. animationGroups: AnimationGroup[];
  43761. }>;
  43762. /**
  43763. * Load into a scene.
  43764. * @param scene The scene to load into
  43765. * @param data The data to import
  43766. * @param rootUrl The root url for scene and resources
  43767. * @param onProgress The callback when the load progresses
  43768. * @param fileName Defines the name of the file to load
  43769. * @returns Nothing
  43770. */
  43771. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43772. /**
  43773. * Load into an asset container.
  43774. * @param scene The scene to load into
  43775. * @param data The data to import
  43776. * @param rootUrl The root url for scene and resources
  43777. * @param onProgress The callback when the load progresses
  43778. * @param fileName Defines the name of the file to load
  43779. * @returns The loaded asset container
  43780. */
  43781. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43782. }
  43783. /**
  43784. * Class used to load scene from various file formats using registered plugins
  43785. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43786. */
  43787. export class SceneLoader {
  43788. /**
  43789. * No logging while loading
  43790. */
  43791. static readonly NO_LOGGING: number;
  43792. /**
  43793. * Minimal logging while loading
  43794. */
  43795. static readonly MINIMAL_LOGGING: number;
  43796. /**
  43797. * Summary logging while loading
  43798. */
  43799. static readonly SUMMARY_LOGGING: number;
  43800. /**
  43801. * Detailled logging while loading
  43802. */
  43803. static readonly DETAILED_LOGGING: number;
  43804. /**
  43805. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43806. */
  43807. static ForceFullSceneLoadingForIncremental: boolean;
  43808. /**
  43809. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43810. */
  43811. static ShowLoadingScreen: boolean;
  43812. /**
  43813. * Defines the current logging level (while loading the scene)
  43814. * @ignorenaming
  43815. */
  43816. static loggingLevel: number;
  43817. /**
  43818. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43819. */
  43820. static CleanBoneMatrixWeights: boolean;
  43821. /**
  43822. * Event raised when a plugin is used to load a scene
  43823. */
  43824. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43825. private static _registeredPlugins;
  43826. private static _getDefaultPlugin;
  43827. private static _getPluginForExtension;
  43828. private static _getPluginForDirectLoad;
  43829. private static _getPluginForFilename;
  43830. private static _getDirectLoad;
  43831. private static _loadData;
  43832. private static _getFileInfo;
  43833. /**
  43834. * Gets a plugin that can load the given extension
  43835. * @param extension defines the extension to load
  43836. * @returns a plugin or null if none works
  43837. */
  43838. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43839. /**
  43840. * Gets a boolean indicating that the given extension can be loaded
  43841. * @param extension defines the extension to load
  43842. * @returns true if the extension is supported
  43843. */
  43844. static IsPluginForExtensionAvailable(extension: string): boolean;
  43845. /**
  43846. * Adds a new plugin to the list of registered plugins
  43847. * @param plugin defines the plugin to add
  43848. */
  43849. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43850. /**
  43851. * Import meshes into a scene
  43852. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43853. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43854. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43855. * @param scene the instance of BABYLON.Scene to append to
  43856. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43857. * @param onProgress a callback with a progress event for each file being loaded
  43858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43859. * @param pluginExtension the extension used to determine the plugin
  43860. * @returns The loaded plugin
  43861. */
  43862. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43863. /**
  43864. * Import meshes into a scene
  43865. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43866. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43867. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43868. * @param scene the instance of BABYLON.Scene to append to
  43869. * @param onProgress a callback with a progress event for each file being loaded
  43870. * @param pluginExtension the extension used to determine the plugin
  43871. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43872. */
  43873. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43874. meshes: AbstractMesh[];
  43875. particleSystems: IParticleSystem[];
  43876. skeletons: Skeleton[];
  43877. animationGroups: AnimationGroup[];
  43878. }>;
  43879. /**
  43880. * Load a scene
  43881. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43882. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43883. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43884. * @param onSuccess a callback with the scene when import succeeds
  43885. * @param onProgress a callback with a progress event for each file being loaded
  43886. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43887. * @param pluginExtension the extension used to determine the plugin
  43888. * @returns The loaded plugin
  43889. */
  43890. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43891. /**
  43892. * Load a scene
  43893. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43894. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43895. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43896. * @param onProgress a callback with a progress event for each file being loaded
  43897. * @param pluginExtension the extension used to determine the plugin
  43898. * @returns The loaded scene
  43899. */
  43900. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43901. /**
  43902. * Append a scene
  43903. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43904. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43905. * @param scene is the instance of BABYLON.Scene to append to
  43906. * @param onSuccess a callback with the scene when import succeeds
  43907. * @param onProgress a callback with a progress event for each file being loaded
  43908. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43909. * @param pluginExtension the extension used to determine the plugin
  43910. * @returns The loaded plugin
  43911. */
  43912. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43913. /**
  43914. * Append a scene
  43915. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43916. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43917. * @param scene is the instance of BABYLON.Scene to append to
  43918. * @param onProgress a callback with a progress event for each file being loaded
  43919. * @param pluginExtension the extension used to determine the plugin
  43920. * @returns The given scene
  43921. */
  43922. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43923. /**
  43924. * Load a scene into an asset container
  43925. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43926. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43927. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43928. * @param onSuccess a callback with the scene when import succeeds
  43929. * @param onProgress a callback with a progress event for each file being loaded
  43930. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43931. * @param pluginExtension the extension used to determine the plugin
  43932. * @returns The loaded plugin
  43933. */
  43934. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43935. /**
  43936. * Load a scene into an asset container
  43937. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43938. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  43939. * @param scene is the instance of Scene to append to
  43940. * @param onProgress a callback with a progress event for each file being loaded
  43941. * @param pluginExtension the extension used to determine the plugin
  43942. * @returns The loaded asset container
  43943. */
  43944. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43945. }
  43946. }
  43947. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43948. import { Scene } from "babylonjs/scene";
  43949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43950. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43951. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43952. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43953. /**
  43954. * Generic Controller
  43955. */
  43956. export class GenericController extends WebVRController {
  43957. /**
  43958. * Base Url for the controller model.
  43959. */
  43960. static readonly MODEL_BASE_URL: string;
  43961. /**
  43962. * File name for the controller model.
  43963. */
  43964. static readonly MODEL_FILENAME: string;
  43965. /**
  43966. * Creates a new GenericController from a gamepad
  43967. * @param vrGamepad the gamepad that the controller should be created from
  43968. */
  43969. constructor(vrGamepad: any);
  43970. /**
  43971. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43972. * @param scene scene in which to add meshes
  43973. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43974. */
  43975. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43976. /**
  43977. * Called once for each button that changed state since the last frame
  43978. * @param buttonIdx Which button index changed
  43979. * @param state New state of the button
  43980. * @param changes Which properties on the state changed since last frame
  43981. */
  43982. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43983. }
  43984. }
  43985. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43986. import { Observable } from "babylonjs/Misc/observable";
  43987. import { Scene } from "babylonjs/scene";
  43988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43989. import { Ray } from "babylonjs/Culling/ray";
  43990. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43991. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43992. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43993. /**
  43994. * Defines the WindowsMotionController object that the state of the windows motion controller
  43995. */
  43996. export class WindowsMotionController extends WebVRController {
  43997. /**
  43998. * The base url used to load the left and right controller models
  43999. */
  44000. static MODEL_BASE_URL: string;
  44001. /**
  44002. * The name of the left controller model file
  44003. */
  44004. static MODEL_LEFT_FILENAME: string;
  44005. /**
  44006. * The name of the right controller model file
  44007. */
  44008. static MODEL_RIGHT_FILENAME: string;
  44009. /**
  44010. * The controller name prefix for this controller type
  44011. */
  44012. static readonly GAMEPAD_ID_PREFIX: string;
  44013. /**
  44014. * The controller id pattern for this controller type
  44015. */
  44016. private static readonly GAMEPAD_ID_PATTERN;
  44017. private _loadedMeshInfo;
  44018. protected readonly _mapping: {
  44019. buttons: string[];
  44020. buttonMeshNames: {
  44021. 'trigger': string;
  44022. 'menu': string;
  44023. 'grip': string;
  44024. 'thumbstick': string;
  44025. 'trackpad': string;
  44026. };
  44027. buttonObservableNames: {
  44028. 'trigger': string;
  44029. 'menu': string;
  44030. 'grip': string;
  44031. 'thumbstick': string;
  44032. 'trackpad': string;
  44033. };
  44034. axisMeshNames: string[];
  44035. pointingPoseMeshName: string;
  44036. };
  44037. /**
  44038. * Fired when the trackpad on this controller is clicked
  44039. */
  44040. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44041. /**
  44042. * Fired when the trackpad on this controller is modified
  44043. */
  44044. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44045. /**
  44046. * The current x and y values of this controller's trackpad
  44047. */
  44048. trackpad: StickValues;
  44049. /**
  44050. * Creates a new WindowsMotionController from a gamepad
  44051. * @param vrGamepad the gamepad that the controller should be created from
  44052. */
  44053. constructor(vrGamepad: any);
  44054. /**
  44055. * Fired when the trigger on this controller is modified
  44056. */
  44057. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44058. /**
  44059. * Fired when the menu button on this controller is modified
  44060. */
  44061. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44062. /**
  44063. * Fired when the grip button on this controller is modified
  44064. */
  44065. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44066. /**
  44067. * Fired when the thumbstick button on this controller is modified
  44068. */
  44069. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44070. /**
  44071. * Fired when the touchpad button on this controller is modified
  44072. */
  44073. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44074. /**
  44075. * Fired when the touchpad values on this controller are modified
  44076. */
  44077. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44078. protected _updateTrackpad(): void;
  44079. /**
  44080. * Called once per frame by the engine.
  44081. */
  44082. update(): void;
  44083. /**
  44084. * Called once for each button that changed state since the last frame
  44085. * @param buttonIdx Which button index changed
  44086. * @param state New state of the button
  44087. * @param changes Which properties on the state changed since last frame
  44088. */
  44089. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44090. /**
  44091. * Moves the buttons on the controller mesh based on their current state
  44092. * @param buttonName the name of the button to move
  44093. * @param buttonValue the value of the button which determines the buttons new position
  44094. */
  44095. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44096. /**
  44097. * Moves the axis on the controller mesh based on its current state
  44098. * @param axis the index of the axis
  44099. * @param axisValue the value of the axis which determines the meshes new position
  44100. * @hidden
  44101. */
  44102. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44103. /**
  44104. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44105. * @param scene scene in which to add meshes
  44106. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44107. */
  44108. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44109. /**
  44110. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44111. * can be transformed by button presses and axes values, based on this._mapping.
  44112. *
  44113. * @param scene scene in which the meshes exist
  44114. * @param meshes list of meshes that make up the controller model to process
  44115. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44116. */
  44117. private processModel;
  44118. private createMeshInfo;
  44119. /**
  44120. * Gets the ray of the controller in the direction the controller is pointing
  44121. * @param length the length the resulting ray should be
  44122. * @returns a ray in the direction the controller is pointing
  44123. */
  44124. getForwardRay(length?: number): Ray;
  44125. /**
  44126. * Disposes of the controller
  44127. */
  44128. dispose(): void;
  44129. }
  44130. /**
  44131. * This class represents a new windows motion controller in XR.
  44132. */
  44133. export class XRWindowsMotionController extends WindowsMotionController {
  44134. /**
  44135. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44136. */
  44137. protected readonly _mapping: {
  44138. buttons: string[];
  44139. buttonMeshNames: {
  44140. 'trigger': string;
  44141. 'menu': string;
  44142. 'grip': string;
  44143. 'thumbstick': string;
  44144. 'trackpad': string;
  44145. };
  44146. buttonObservableNames: {
  44147. 'trigger': string;
  44148. 'menu': string;
  44149. 'grip': string;
  44150. 'thumbstick': string;
  44151. 'trackpad': string;
  44152. };
  44153. axisMeshNames: string[];
  44154. pointingPoseMeshName: string;
  44155. };
  44156. /**
  44157. * Construct a new XR-Based windows motion controller
  44158. *
  44159. * @param gamepadInfo the gamepad object from the browser
  44160. */
  44161. constructor(gamepadInfo: any);
  44162. /**
  44163. * holds the thumbstick values (X,Y)
  44164. */
  44165. thumbstickValues: StickValues;
  44166. /**
  44167. * Fired when the thumbstick on this controller is clicked
  44168. */
  44169. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44170. /**
  44171. * Fired when the thumbstick on this controller is modified
  44172. */
  44173. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44174. /**
  44175. * Fired when the touchpad button on this controller is modified
  44176. */
  44177. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44178. /**
  44179. * Fired when the touchpad values on this controller are modified
  44180. */
  44181. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44182. /**
  44183. * Fired when the thumbstick button on this controller is modified
  44184. * here to prevent breaking changes
  44185. */
  44186. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44187. /**
  44188. * updating the thumbstick(!) and not the trackpad.
  44189. * This is named this way due to the difference between WebVR and XR and to avoid
  44190. * changing the parent class.
  44191. */
  44192. protected _updateTrackpad(): void;
  44193. /**
  44194. * Disposes the class with joy
  44195. */
  44196. dispose(): void;
  44197. }
  44198. }
  44199. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44200. import { Observable } from "babylonjs/Misc/observable";
  44201. import { Scene } from "babylonjs/scene";
  44202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44203. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44204. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44205. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44206. /**
  44207. * Oculus Touch Controller
  44208. */
  44209. export class OculusTouchController extends WebVRController {
  44210. /**
  44211. * Base Url for the controller model.
  44212. */
  44213. static MODEL_BASE_URL: string;
  44214. /**
  44215. * File name for the left controller model.
  44216. */
  44217. static MODEL_LEFT_FILENAME: string;
  44218. /**
  44219. * File name for the right controller model.
  44220. */
  44221. static MODEL_RIGHT_FILENAME: string;
  44222. /**
  44223. * Base Url for the Quest controller model.
  44224. */
  44225. static QUEST_MODEL_BASE_URL: string;
  44226. /**
  44227. * @hidden
  44228. * If the controllers are running on a device that needs the updated Quest controller models
  44229. */
  44230. static _IsQuest: boolean;
  44231. /**
  44232. * Fired when the secondary trigger on this controller is modified
  44233. */
  44234. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44235. /**
  44236. * Fired when the thumb rest on this controller is modified
  44237. */
  44238. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44239. /**
  44240. * Creates a new OculusTouchController from a gamepad
  44241. * @param vrGamepad the gamepad that the controller should be created from
  44242. */
  44243. constructor(vrGamepad: any);
  44244. /**
  44245. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44246. * @param scene scene in which to add meshes
  44247. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44248. */
  44249. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44250. /**
  44251. * Fired when the A button on this controller is modified
  44252. */
  44253. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44254. /**
  44255. * Fired when the B button on this controller is modified
  44256. */
  44257. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44258. /**
  44259. * Fired when the X button on this controller is modified
  44260. */
  44261. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44262. /**
  44263. * Fired when the Y button on this controller is modified
  44264. */
  44265. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44266. /**
  44267. * Called once for each button that changed state since the last frame
  44268. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44269. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44270. * 2) secondary trigger (same)
  44271. * 3) A (right) X (left), touch, pressed = value
  44272. * 4) B / Y
  44273. * 5) thumb rest
  44274. * @param buttonIdx Which button index changed
  44275. * @param state New state of the button
  44276. * @param changes Which properties on the state changed since last frame
  44277. */
  44278. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44279. }
  44280. }
  44281. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44282. import { Scene } from "babylonjs/scene";
  44283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44284. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44285. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44286. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44287. import { Observable } from "babylonjs/Misc/observable";
  44288. /**
  44289. * Vive Controller
  44290. */
  44291. export class ViveController extends WebVRController {
  44292. /**
  44293. * Base Url for the controller model.
  44294. */
  44295. static MODEL_BASE_URL: string;
  44296. /**
  44297. * File name for the controller model.
  44298. */
  44299. static MODEL_FILENAME: string;
  44300. /**
  44301. * Creates a new ViveController from a gamepad
  44302. * @param vrGamepad the gamepad that the controller should be created from
  44303. */
  44304. constructor(vrGamepad: any);
  44305. /**
  44306. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44307. * @param scene scene in which to add meshes
  44308. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44309. */
  44310. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44311. /**
  44312. * Fired when the left button on this controller is modified
  44313. */
  44314. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44315. /**
  44316. * Fired when the right button on this controller is modified
  44317. */
  44318. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44319. /**
  44320. * Fired when the menu button on this controller is modified
  44321. */
  44322. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44323. /**
  44324. * Called once for each button that changed state since the last frame
  44325. * Vive mapping:
  44326. * 0: touchpad
  44327. * 1: trigger
  44328. * 2: left AND right buttons
  44329. * 3: menu button
  44330. * @param buttonIdx Which button index changed
  44331. * @param state New state of the button
  44332. * @param changes Which properties on the state changed since last frame
  44333. */
  44334. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44335. }
  44336. }
  44337. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44338. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44339. import { Observable } from "babylonjs/Misc/observable";
  44340. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44341. /**
  44342. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44343. */
  44344. export class WebXRControllerModelLoader {
  44345. /**
  44346. * an observable that triggers when a new model (the mesh itself) was initialized.
  44347. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44348. */
  44349. onControllerModelLoaded: Observable<WebXRController>;
  44350. /**
  44351. * Creates the WebXRControllerModelLoader
  44352. * @param input xr input that creates the controllers
  44353. */
  44354. constructor(input: WebXRInput);
  44355. }
  44356. }
  44357. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  44358. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44359. /**
  44360. * Handles pointer input automatically for the pointer of XR controllers
  44361. */
  44362. export class WebXRControllerPointerSelection {
  44363. private static _idCounter;
  44364. private _tmpRay;
  44365. /**
  44366. * Creates a WebXRControllerPointerSelection
  44367. * @param input input manager to setup pointer selection
  44368. */
  44369. constructor(input: WebXRInput);
  44370. private _convertNormalToDirectionOfRay;
  44371. private _updatePointerDistance;
  44372. }
  44373. }
  44374. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  44375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44376. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44377. /**
  44378. * Enables teleportation
  44379. */
  44380. export class WebXRControllerTeleportation {
  44381. private _teleportationFillColor;
  44382. private _teleportationBorderColor;
  44383. private _tmpRay;
  44384. private _tmpVector;
  44385. /**
  44386. * Creates a WebXRControllerTeleportation
  44387. * @param input input manager to add teleportation to
  44388. * @param floorMeshes floormeshes which can be teleported to
  44389. */
  44390. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  44391. }
  44392. }
  44393. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  44394. import { Nullable } from "babylonjs/types";
  44395. import { Observable } from "babylonjs/Misc/observable";
  44396. import { IDisposable, Scene } from "babylonjs/scene";
  44397. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44398. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44399. /**
  44400. * Button which can be used to enter a different mode of XR
  44401. */
  44402. export class WebXREnterExitUIButton {
  44403. /** button element */
  44404. element: HTMLElement;
  44405. /** XR initialization options for the button */
  44406. sessionMode: XRSessionMode;
  44407. /** Reference space type */
  44408. referenceSpaceType: XRReferenceSpaceType;
  44409. /**
  44410. * Creates a WebXREnterExitUIButton
  44411. * @param element button element
  44412. * @param sessionMode XR initialization session mode
  44413. * @param referenceSpaceType the type of reference space to be used
  44414. */
  44415. constructor(
  44416. /** button element */
  44417. element: HTMLElement,
  44418. /** XR initialization options for the button */
  44419. sessionMode: XRSessionMode,
  44420. /** Reference space type */
  44421. referenceSpaceType: XRReferenceSpaceType);
  44422. /**
  44423. * Overwritable function which can be used to update the button's visuals when the state changes
  44424. * @param activeButton the current active button in the UI
  44425. */
  44426. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44427. }
  44428. /**
  44429. * Options to create the webXR UI
  44430. */
  44431. export class WebXREnterExitUIOptions {
  44432. /**
  44433. * Context to enter xr with
  44434. */
  44435. renderTarget?: Nullable<WebXRRenderTarget>;
  44436. /**
  44437. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44438. */
  44439. customButtons?: Array<WebXREnterExitUIButton>;
  44440. /**
  44441. * A session mode to use when creating the default button.
  44442. * Default is immersive-vr
  44443. */
  44444. sessionMode?: XRSessionMode;
  44445. /**
  44446. * A reference space type to use when creating the default button.
  44447. * Default is local-floor
  44448. */
  44449. referenceSpaceType?: XRReferenceSpaceType;
  44450. }
  44451. /**
  44452. * UI to allow the user to enter/exit XR mode
  44453. */
  44454. export class WebXREnterExitUI implements IDisposable {
  44455. private scene;
  44456. private _overlay;
  44457. private _buttons;
  44458. private _activeButton;
  44459. /**
  44460. * Fired every time the active button is changed.
  44461. *
  44462. * When xr is entered via a button that launches xr that button will be the callback parameter
  44463. *
  44464. * When exiting xr the callback parameter will be null)
  44465. */
  44466. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44467. /**
  44468. * Creates UI to allow the user to enter/exit XR mode
  44469. * @param scene the scene to add the ui to
  44470. * @param helper the xr experience helper to enter/exit xr with
  44471. * @param options options to configure the UI
  44472. * @returns the created ui
  44473. */
  44474. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44475. private constructor();
  44476. private _updateButtons;
  44477. /**
  44478. * Disposes of the object
  44479. */
  44480. dispose(): void;
  44481. }
  44482. }
  44483. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44484. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44485. import { Scene } from "babylonjs/scene";
  44486. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44487. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44488. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44489. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44490. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44491. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44493. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44494. /**
  44495. * Options for the default xr helper
  44496. */
  44497. export class WebXRDefaultExperienceOptions {
  44498. /**
  44499. * Floor meshes that should be used for teleporting
  44500. */
  44501. floorMeshes: Array<AbstractMesh>;
  44502. /**
  44503. * Enable or disable default UI to enter XR
  44504. */
  44505. disableDefaultUI?: boolean;
  44506. /**
  44507. * optional configuration for the output canvas
  44508. */
  44509. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44510. }
  44511. /**
  44512. * Default experience which provides a similar setup to the previous webVRExperience
  44513. */
  44514. export class WebXRDefaultExperience {
  44515. /**
  44516. * Base experience
  44517. */
  44518. baseExperience: WebXRExperienceHelper;
  44519. /**
  44520. * Input experience extension
  44521. */
  44522. input: WebXRInput;
  44523. /**
  44524. * Loads the controller models
  44525. */
  44526. controllerModelLoader: WebXRControllerModelLoader;
  44527. /**
  44528. * Enables laser pointer and selection
  44529. */
  44530. pointerSelection: WebXRControllerPointerSelection;
  44531. /**
  44532. * Enables teleportation
  44533. */
  44534. teleportation: WebXRControllerTeleportation;
  44535. /**
  44536. * Enables ui for enetering/exiting xr
  44537. */
  44538. enterExitUI: WebXREnterExitUI;
  44539. /**
  44540. * Default target xr should render to
  44541. */
  44542. renderTarget: WebXRRenderTarget;
  44543. /**
  44544. * Creates the default xr experience
  44545. * @param scene scene
  44546. * @param options options for basic configuration
  44547. * @returns resulting WebXRDefaultExperience
  44548. */
  44549. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44550. private constructor();
  44551. /**
  44552. * DIsposes of the experience helper
  44553. */
  44554. dispose(): void;
  44555. }
  44556. }
  44557. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  44558. import { Observable } from "babylonjs/Misc/observable";
  44559. import { Nullable } from "babylonjs/types";
  44560. import { Camera } from "babylonjs/Cameras/camera";
  44561. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44562. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44563. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  44564. import { Scene } from "babylonjs/scene";
  44565. import { Vector3 } from "babylonjs/Maths/math.vector";
  44566. import { Color3 } from "babylonjs/Maths/math.color";
  44567. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44569. import { Mesh } from "babylonjs/Meshes/mesh";
  44570. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44571. import { EasingFunction } from "babylonjs/Animations/easing";
  44572. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44573. import "babylonjs/Meshes/Builders/groundBuilder";
  44574. import "babylonjs/Meshes/Builders/torusBuilder";
  44575. import "babylonjs/Meshes/Builders/cylinderBuilder";
  44576. import "babylonjs/Gamepads/gamepadSceneComponent";
  44577. import "babylonjs/Animations/animatable";
  44578. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44579. /**
  44580. * Options to modify the vr teleportation behavior.
  44581. */
  44582. export interface VRTeleportationOptions {
  44583. /**
  44584. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44585. */
  44586. floorMeshName?: string;
  44587. /**
  44588. * A list of meshes to be used as the teleportation floor. (default: empty)
  44589. */
  44590. floorMeshes?: Mesh[];
  44591. /**
  44592. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44593. */
  44594. teleportationMode?: number;
  44595. /**
  44596. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44597. */
  44598. teleportationTime?: number;
  44599. /**
  44600. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44601. */
  44602. teleportationSpeed?: number;
  44603. /**
  44604. * The easing function used in the animation or null for Linear. (default CircleEase)
  44605. */
  44606. easingFunction?: EasingFunction;
  44607. }
  44608. /**
  44609. * Options to modify the vr experience helper's behavior.
  44610. */
  44611. export interface VRExperienceHelperOptions extends WebVROptions {
  44612. /**
  44613. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44614. */
  44615. createDeviceOrientationCamera?: boolean;
  44616. /**
  44617. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44618. */
  44619. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44620. /**
  44621. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44622. */
  44623. laserToggle?: boolean;
  44624. /**
  44625. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44626. */
  44627. floorMeshes?: Mesh[];
  44628. /**
  44629. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44630. */
  44631. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44632. /**
  44633. * Defines if WebXR should be used instead of WebVR (if available)
  44634. */
  44635. useXR?: boolean;
  44636. }
  44637. /**
  44638. * Event containing information after VR has been entered
  44639. */
  44640. export class OnAfterEnteringVRObservableEvent {
  44641. /**
  44642. * If entering vr was successful
  44643. */
  44644. success: boolean;
  44645. }
  44646. /**
  44647. * Helps to quickly add VR support to an existing scene.
  44648. * See http://doc.babylonjs.com/how_to/webvr_helper
  44649. */
  44650. export class VRExperienceHelper {
  44651. /** Options to modify the vr experience helper's behavior. */
  44652. webVROptions: VRExperienceHelperOptions;
  44653. private _scene;
  44654. private _position;
  44655. private _btnVR;
  44656. private _btnVRDisplayed;
  44657. private _webVRsupported;
  44658. private _webVRready;
  44659. private _webVRrequesting;
  44660. private _webVRpresenting;
  44661. private _hasEnteredVR;
  44662. private _fullscreenVRpresenting;
  44663. private _inputElement;
  44664. private _webVRCamera;
  44665. private _vrDeviceOrientationCamera;
  44666. private _deviceOrientationCamera;
  44667. private _existingCamera;
  44668. private _onKeyDown;
  44669. private _onVrDisplayPresentChange;
  44670. private _onVRDisplayChanged;
  44671. private _onVRRequestPresentStart;
  44672. private _onVRRequestPresentComplete;
  44673. /**
  44674. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  44675. */
  44676. enableGazeEvenWhenNoPointerLock: boolean;
  44677. /**
  44678. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44679. */
  44680. exitVROnDoubleTap: boolean;
  44681. /**
  44682. * Observable raised right before entering VR.
  44683. */
  44684. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44685. /**
  44686. * Observable raised when entering VR has completed.
  44687. */
  44688. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44689. /**
  44690. * Observable raised when exiting VR.
  44691. */
  44692. onExitingVRObservable: Observable<VRExperienceHelper>;
  44693. /**
  44694. * Observable raised when controller mesh is loaded.
  44695. */
  44696. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44697. /** Return this.onEnteringVRObservable
  44698. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44699. */
  44700. readonly onEnteringVR: Observable<VRExperienceHelper>;
  44701. /** Return this.onExitingVRObservable
  44702. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44703. */
  44704. readonly onExitingVR: Observable<VRExperienceHelper>;
  44705. /** Return this.onControllerMeshLoadedObservable
  44706. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44707. */
  44708. readonly onControllerMeshLoaded: Observable<WebVRController>;
  44709. private _rayLength;
  44710. private _useCustomVRButton;
  44711. private _teleportationRequested;
  44712. private _teleportActive;
  44713. private _floorMeshName;
  44714. private _floorMeshesCollection;
  44715. private _teleportationMode;
  44716. private _teleportationTime;
  44717. private _teleportationSpeed;
  44718. private _teleportationEasing;
  44719. private _rotationAllowed;
  44720. private _teleportBackwardsVector;
  44721. private _teleportationTarget;
  44722. private _isDefaultTeleportationTarget;
  44723. private _postProcessMove;
  44724. private _teleportationFillColor;
  44725. private _teleportationBorderColor;
  44726. private _rotationAngle;
  44727. private _haloCenter;
  44728. private _cameraGazer;
  44729. private _padSensibilityUp;
  44730. private _padSensibilityDown;
  44731. private _leftController;
  44732. private _rightController;
  44733. /**
  44734. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44735. */
  44736. onNewMeshSelected: Observable<AbstractMesh>;
  44737. /**
  44738. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44739. * This observable will provide the mesh and the controller used to select the mesh
  44740. */
  44741. onMeshSelectedWithController: Observable<{
  44742. mesh: AbstractMesh;
  44743. controller: WebVRController;
  44744. }>;
  44745. /**
  44746. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44747. */
  44748. onNewMeshPicked: Observable<PickingInfo>;
  44749. private _circleEase;
  44750. /**
  44751. * Observable raised before camera teleportation
  44752. */
  44753. onBeforeCameraTeleport: Observable<Vector3>;
  44754. /**
  44755. * Observable raised after camera teleportation
  44756. */
  44757. onAfterCameraTeleport: Observable<Vector3>;
  44758. /**
  44759. * Observable raised when current selected mesh gets unselected
  44760. */
  44761. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44762. private _raySelectionPredicate;
  44763. /**
  44764. * To be optionaly changed by user to define custom ray selection
  44765. */
  44766. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44767. /**
  44768. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44769. */
  44770. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44771. /**
  44772. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44773. */
  44774. teleportationEnabled: boolean;
  44775. private _defaultHeight;
  44776. private _teleportationInitialized;
  44777. private _interactionsEnabled;
  44778. private _interactionsRequested;
  44779. private _displayGaze;
  44780. private _displayLaserPointer;
  44781. /**
  44782. * The mesh used to display where the user is going to teleport.
  44783. */
  44784. /**
  44785. * Sets the mesh to be used to display where the user is going to teleport.
  44786. */
  44787. teleportationTarget: Mesh;
  44788. /**
  44789. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  44790. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44791. * See http://doc.babylonjs.com/resources/baking_transformations
  44792. */
  44793. gazeTrackerMesh: Mesh;
  44794. /**
  44795. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44796. */
  44797. updateGazeTrackerScale: boolean;
  44798. /**
  44799. * If the gaze trackers color should be updated when selecting meshes
  44800. */
  44801. updateGazeTrackerColor: boolean;
  44802. /**
  44803. * If the controller laser color should be updated when selecting meshes
  44804. */
  44805. updateControllerLaserColor: boolean;
  44806. /**
  44807. * The gaze tracking mesh corresponding to the left controller
  44808. */
  44809. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  44810. /**
  44811. * The gaze tracking mesh corresponding to the right controller
  44812. */
  44813. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  44814. /**
  44815. * If the ray of the gaze should be displayed.
  44816. */
  44817. /**
  44818. * Sets if the ray of the gaze should be displayed.
  44819. */
  44820. displayGaze: boolean;
  44821. /**
  44822. * If the ray of the LaserPointer should be displayed.
  44823. */
  44824. /**
  44825. * Sets if the ray of the LaserPointer should be displayed.
  44826. */
  44827. displayLaserPointer: boolean;
  44828. /**
  44829. * The deviceOrientationCamera used as the camera when not in VR.
  44830. */
  44831. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  44832. /**
  44833. * Based on the current WebVR support, returns the current VR camera used.
  44834. */
  44835. readonly currentVRCamera: Nullable<Camera>;
  44836. /**
  44837. * The webVRCamera which is used when in VR.
  44838. */
  44839. readonly webVRCamera: WebVRFreeCamera;
  44840. /**
  44841. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44842. */
  44843. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  44844. /**
  44845. * The html button that is used to trigger entering into VR.
  44846. */
  44847. readonly vrButton: Nullable<HTMLButtonElement>;
  44848. private readonly _teleportationRequestInitiated;
  44849. /**
  44850. * Defines wether or not Pointer lock should be requested when switching to
  44851. * full screen.
  44852. */
  44853. requestPointerLockOnFullScreen: boolean;
  44854. /**
  44855. * If asking to force XR, this will be populated with the default xr experience
  44856. */
  44857. xr: WebXRDefaultExperience;
  44858. /**
  44859. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44860. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44861. */
  44862. xrTestDone: boolean;
  44863. /**
  44864. * Instantiates a VRExperienceHelper.
  44865. * Helps to quickly add VR support to an existing scene.
  44866. * @param scene The scene the VRExperienceHelper belongs to.
  44867. * @param webVROptions Options to modify the vr experience helper's behavior.
  44868. */
  44869. constructor(scene: Scene,
  44870. /** Options to modify the vr experience helper's behavior. */
  44871. webVROptions?: VRExperienceHelperOptions);
  44872. private completeVRInit;
  44873. private _onDefaultMeshLoaded;
  44874. private _onResize;
  44875. private _onFullscreenChange;
  44876. /**
  44877. * Gets a value indicating if we are currently in VR mode.
  44878. */
  44879. readonly isInVRMode: boolean;
  44880. private onVrDisplayPresentChange;
  44881. private onVRDisplayChanged;
  44882. private moveButtonToBottomRight;
  44883. private displayVRButton;
  44884. private updateButtonVisibility;
  44885. private _cachedAngularSensibility;
  44886. /**
  44887. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44888. * Otherwise, will use the fullscreen API.
  44889. */
  44890. enterVR(): void;
  44891. /**
  44892. * Attempt to exit VR, or fullscreen.
  44893. */
  44894. exitVR(): void;
  44895. /**
  44896. * The position of the vr experience helper.
  44897. */
  44898. /**
  44899. * Sets the position of the vr experience helper.
  44900. */
  44901. position: Vector3;
  44902. /**
  44903. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44904. */
  44905. enableInteractions(): void;
  44906. private readonly _noControllerIsActive;
  44907. private beforeRender;
  44908. private _isTeleportationFloor;
  44909. /**
  44910. * Adds a floor mesh to be used for teleportation.
  44911. * @param floorMesh the mesh to be used for teleportation.
  44912. */
  44913. addFloorMesh(floorMesh: Mesh): void;
  44914. /**
  44915. * Removes a floor mesh from being used for teleportation.
  44916. * @param floorMesh the mesh to be removed.
  44917. */
  44918. removeFloorMesh(floorMesh: Mesh): void;
  44919. /**
  44920. * Enables interactions and teleportation using the VR controllers and gaze.
  44921. * @param vrTeleportationOptions options to modify teleportation behavior.
  44922. */
  44923. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44924. private _onNewGamepadConnected;
  44925. private _tryEnableInteractionOnController;
  44926. private _onNewGamepadDisconnected;
  44927. private _enableInteractionOnController;
  44928. private _checkTeleportWithRay;
  44929. private _checkRotate;
  44930. private _checkTeleportBackwards;
  44931. private _enableTeleportationOnController;
  44932. private _createTeleportationCircles;
  44933. private _displayTeleportationTarget;
  44934. private _hideTeleportationTarget;
  44935. private _rotateCamera;
  44936. private _moveTeleportationSelectorTo;
  44937. private _workingVector;
  44938. private _workingQuaternion;
  44939. private _workingMatrix;
  44940. /**
  44941. * Time Constant Teleportation Mode
  44942. */
  44943. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44944. /**
  44945. * Speed Constant Teleportation Mode
  44946. */
  44947. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44948. /**
  44949. * Teleports the users feet to the desired location
  44950. * @param location The location where the user's feet should be placed
  44951. */
  44952. teleportCamera(location: Vector3): void;
  44953. private _convertNormalToDirectionOfRay;
  44954. private _castRayAndSelectObject;
  44955. private _notifySelectedMeshUnselected;
  44956. /**
  44957. * Sets the color of the laser ray from the vr controllers.
  44958. * @param color new color for the ray.
  44959. */
  44960. changeLaserColor(color: Color3): void;
  44961. /**
  44962. * Sets the color of the ray from the vr headsets gaze.
  44963. * @param color new color for the ray.
  44964. */
  44965. changeGazeColor(color: Color3): void;
  44966. /**
  44967. * Exits VR and disposes of the vr experience helper
  44968. */
  44969. dispose(): void;
  44970. /**
  44971. * Gets the name of the VRExperienceHelper class
  44972. * @returns "VRExperienceHelper"
  44973. */
  44974. getClassName(): string;
  44975. }
  44976. }
  44977. declare module "babylonjs/Cameras/VR/index" {
  44978. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  44979. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  44980. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44981. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  44982. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  44983. export * from "babylonjs/Cameras/VR/webVRCamera";
  44984. }
  44985. declare module "babylonjs/Cameras/XR/index" {
  44986. export * from "babylonjs/Cameras/XR/webXRCamera";
  44987. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44988. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44989. export * from "babylonjs/Cameras/XR/webXRInput";
  44990. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44991. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44992. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44993. export * from "babylonjs/Cameras/XR/webXRController";
  44994. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44995. export * from "babylonjs/Cameras/XR/webXRTypes";
  44996. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44997. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44998. }
  44999. declare module "babylonjs/Cameras/RigModes/index" {
  45000. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  45001. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  45002. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  45003. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  45004. }
  45005. declare module "babylonjs/Cameras/index" {
  45006. export * from "babylonjs/Cameras/Inputs/index";
  45007. export * from "babylonjs/Cameras/cameraInputsManager";
  45008. export * from "babylonjs/Cameras/camera";
  45009. export * from "babylonjs/Cameras/targetCamera";
  45010. export * from "babylonjs/Cameras/freeCamera";
  45011. export * from "babylonjs/Cameras/freeCameraInputsManager";
  45012. export * from "babylonjs/Cameras/touchCamera";
  45013. export * from "babylonjs/Cameras/arcRotateCamera";
  45014. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  45015. export * from "babylonjs/Cameras/deviceOrientationCamera";
  45016. export * from "babylonjs/Cameras/flyCamera";
  45017. export * from "babylonjs/Cameras/flyCameraInputsManager";
  45018. export * from "babylonjs/Cameras/followCamera";
  45019. export * from "babylonjs/Cameras/followCameraInputsManager";
  45020. export * from "babylonjs/Cameras/gamepadCamera";
  45021. export * from "babylonjs/Cameras/Stereoscopic/index";
  45022. export * from "babylonjs/Cameras/universalCamera";
  45023. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  45024. export * from "babylonjs/Cameras/VR/index";
  45025. export * from "babylonjs/Cameras/XR/index";
  45026. export * from "babylonjs/Cameras/RigModes/index";
  45027. }
  45028. declare module "babylonjs/Collisions/index" {
  45029. export * from "babylonjs/Collisions/collider";
  45030. export * from "babylonjs/Collisions/collisionCoordinator";
  45031. export * from "babylonjs/Collisions/pickingInfo";
  45032. export * from "babylonjs/Collisions/intersectionInfo";
  45033. export * from "babylonjs/Collisions/meshCollisionData";
  45034. }
  45035. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  45036. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  45037. import { Vector3 } from "babylonjs/Maths/math.vector";
  45038. import { Ray } from "babylonjs/Culling/ray";
  45039. import { Plane } from "babylonjs/Maths/math.plane";
  45040. /**
  45041. * Contains an array of blocks representing the octree
  45042. */
  45043. export interface IOctreeContainer<T> {
  45044. /**
  45045. * Blocks within the octree
  45046. */
  45047. blocks: Array<OctreeBlock<T>>;
  45048. }
  45049. /**
  45050. * Class used to store a cell in an octree
  45051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45052. */
  45053. export class OctreeBlock<T> {
  45054. /**
  45055. * Gets the content of the current block
  45056. */
  45057. entries: T[];
  45058. /**
  45059. * Gets the list of block children
  45060. */
  45061. blocks: Array<OctreeBlock<T>>;
  45062. private _depth;
  45063. private _maxDepth;
  45064. private _capacity;
  45065. private _minPoint;
  45066. private _maxPoint;
  45067. private _boundingVectors;
  45068. private _creationFunc;
  45069. /**
  45070. * Creates a new block
  45071. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45072. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45073. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45074. * @param depth defines the current depth of this block in the octree
  45075. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45076. * @param creationFunc defines a callback to call when an element is added to the block
  45077. */
  45078. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45079. /**
  45080. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45081. */
  45082. readonly capacity: number;
  45083. /**
  45084. * Gets the minimum vector (in world space) of the block's bounding box
  45085. */
  45086. readonly minPoint: Vector3;
  45087. /**
  45088. * Gets the maximum vector (in world space) of the block's bounding box
  45089. */
  45090. readonly maxPoint: Vector3;
  45091. /**
  45092. * Add a new element to this block
  45093. * @param entry defines the element to add
  45094. */
  45095. addEntry(entry: T): void;
  45096. /**
  45097. * Remove an element from this block
  45098. * @param entry defines the element to remove
  45099. */
  45100. removeEntry(entry: T): void;
  45101. /**
  45102. * Add an array of elements to this block
  45103. * @param entries defines the array of elements to add
  45104. */
  45105. addEntries(entries: T[]): void;
  45106. /**
  45107. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45108. * @param frustumPlanes defines the frustum planes to test
  45109. * @param selection defines the array to store current content if selection is positive
  45110. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45111. */
  45112. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45113. /**
  45114. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45115. * @param sphereCenter defines the bounding sphere center
  45116. * @param sphereRadius defines the bounding sphere radius
  45117. * @param selection defines the array to store current content if selection is positive
  45118. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45119. */
  45120. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45121. /**
  45122. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45123. * @param ray defines the ray to test with
  45124. * @param selection defines the array to store current content if selection is positive
  45125. */
  45126. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45127. /**
  45128. * Subdivide the content into child blocks (this block will then be empty)
  45129. */
  45130. createInnerBlocks(): void;
  45131. /**
  45132. * @hidden
  45133. */
  45134. static _CreateBlocks<T>(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer<T>, creationFunc: (entry: T, block: OctreeBlock<T>) => void): void;
  45135. }
  45136. }
  45137. declare module "babylonjs/Culling/Octrees/octree" {
  45138. import { SmartArray } from "babylonjs/Misc/smartArray";
  45139. import { Vector3 } from "babylonjs/Maths/math.vector";
  45140. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45142. import { Ray } from "babylonjs/Culling/ray";
  45143. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  45144. import { Plane } from "babylonjs/Maths/math.plane";
  45145. /**
  45146. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45147. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45148. */
  45149. export class Octree<T> {
  45150. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  45151. maxDepth: number;
  45152. /**
  45153. * Blocks within the octree containing objects
  45154. */
  45155. blocks: Array<OctreeBlock<T>>;
  45156. /**
  45157. * Content stored in the octree
  45158. */
  45159. dynamicContent: T[];
  45160. private _maxBlockCapacity;
  45161. private _selectionContent;
  45162. private _creationFunc;
  45163. /**
  45164. * Creates a octree
  45165. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45166. * @param creationFunc function to be used to instatiate the octree
  45167. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45168. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  45169. */
  45170. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45171. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  45172. maxDepth?: number);
  45173. /**
  45174. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45175. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  45176. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  45177. * @param entries meshes to be added to the octree blocks
  45178. */
  45179. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45180. /**
  45181. * Adds a mesh to the octree
  45182. * @param entry Mesh to add to the octree
  45183. */
  45184. addMesh(entry: T): void;
  45185. /**
  45186. * Remove an element from the octree
  45187. * @param entry defines the element to remove
  45188. */
  45189. removeMesh(entry: T): void;
  45190. /**
  45191. * Selects an array of meshes within the frustum
  45192. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45193. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45194. * @returns array of meshes within the frustum
  45195. */
  45196. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45197. /**
  45198. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45199. * @param sphereCenter defines the bounding sphere center
  45200. * @param sphereRadius defines the bounding sphere radius
  45201. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45202. * @returns an array of objects that intersect the sphere
  45203. */
  45204. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45205. /**
  45206. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45207. * @param ray defines the ray to test with
  45208. * @returns array of intersected objects
  45209. */
  45210. intersectsRay(ray: Ray): SmartArray<T>;
  45211. /**
  45212. * Adds a mesh into the octree block if it intersects the block
  45213. */
  45214. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45215. /**
  45216. * Adds a submesh into the octree block if it intersects the block
  45217. */
  45218. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45219. }
  45220. }
  45221. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  45222. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  45223. import { Scene } from "babylonjs/scene";
  45224. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45226. import { Ray } from "babylonjs/Culling/ray";
  45227. import { Octree } from "babylonjs/Culling/Octrees/octree";
  45228. import { Collider } from "babylonjs/Collisions/collider";
  45229. module "babylonjs/scene" {
  45230. interface Scene {
  45231. /**
  45232. * @hidden
  45233. * Backing Filed
  45234. */
  45235. _selectionOctree: Octree<AbstractMesh>;
  45236. /**
  45237. * Gets the octree used to boost mesh selection (picking)
  45238. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45239. */
  45240. selectionOctree: Octree<AbstractMesh>;
  45241. /**
  45242. * Creates or updates the octree used to boost selection (picking)
  45243. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45244. * @param maxCapacity defines the maximum capacity per leaf
  45245. * @param maxDepth defines the maximum depth of the octree
  45246. * @returns an octree of AbstractMesh
  45247. */
  45248. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45249. }
  45250. }
  45251. module "babylonjs/Meshes/abstractMesh" {
  45252. interface AbstractMesh {
  45253. /**
  45254. * @hidden
  45255. * Backing Field
  45256. */
  45257. _submeshesOctree: Octree<SubMesh>;
  45258. /**
  45259. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45260. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45261. * @param maxCapacity defines the maximum size of each block (64 by default)
  45262. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45263. * @returns the new octree
  45264. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45266. */
  45267. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45268. }
  45269. }
  45270. /**
  45271. * Defines the octree scene component responsible to manage any octrees
  45272. * in a given scene.
  45273. */
  45274. export class OctreeSceneComponent {
  45275. /**
  45276. * The component name help to identify the component in the list of scene components.
  45277. */
  45278. readonly name: string;
  45279. /**
  45280. * The scene the component belongs to.
  45281. */
  45282. scene: Scene;
  45283. /**
  45284. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45285. */
  45286. readonly checksIsEnabled: boolean;
  45287. /**
  45288. * Creates a new instance of the component for the given scene
  45289. * @param scene Defines the scene to register the component in
  45290. */
  45291. constructor(scene: Scene);
  45292. /**
  45293. * Registers the component in a given scene
  45294. */
  45295. register(): void;
  45296. /**
  45297. * Return the list of active meshes
  45298. * @returns the list of active meshes
  45299. */
  45300. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45301. /**
  45302. * Return the list of active sub meshes
  45303. * @param mesh The mesh to get the candidates sub meshes from
  45304. * @returns the list of active sub meshes
  45305. */
  45306. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45307. private _tempRay;
  45308. /**
  45309. * Return the list of sub meshes intersecting with a given local ray
  45310. * @param mesh defines the mesh to find the submesh for
  45311. * @param localRay defines the ray in local space
  45312. * @returns the list of intersecting sub meshes
  45313. */
  45314. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45315. /**
  45316. * Return the list of sub meshes colliding with a collider
  45317. * @param mesh defines the mesh to find the submesh for
  45318. * @param collider defines the collider to evaluate the collision against
  45319. * @returns the list of colliding sub meshes
  45320. */
  45321. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45322. /**
  45323. * Rebuilds the elements related to this component in case of
  45324. * context lost for instance.
  45325. */
  45326. rebuild(): void;
  45327. /**
  45328. * Disposes the component and the associated ressources.
  45329. */
  45330. dispose(): void;
  45331. }
  45332. }
  45333. declare module "babylonjs/Culling/Octrees/index" {
  45334. export * from "babylonjs/Culling/Octrees/octree";
  45335. export * from "babylonjs/Culling/Octrees/octreeBlock";
  45336. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  45337. }
  45338. declare module "babylonjs/Culling/index" {
  45339. export * from "babylonjs/Culling/boundingBox";
  45340. export * from "babylonjs/Culling/boundingInfo";
  45341. export * from "babylonjs/Culling/boundingSphere";
  45342. export * from "babylonjs/Culling/Octrees/index";
  45343. export * from "babylonjs/Culling/ray";
  45344. }
  45345. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45346. import { IDisposable, Scene } from "babylonjs/scene";
  45347. import { Nullable } from "babylonjs/types";
  45348. import { Observable } from "babylonjs/Misc/observable";
  45349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45350. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45351. import { Camera } from "babylonjs/Cameras/camera";
  45352. /**
  45353. * Renders a layer on top of an existing scene
  45354. */
  45355. export class UtilityLayerRenderer implements IDisposable {
  45356. /** the original scene that will be rendered on top of */
  45357. originalScene: Scene;
  45358. private _pointerCaptures;
  45359. private _lastPointerEvents;
  45360. private static _DefaultUtilityLayer;
  45361. private static _DefaultKeepDepthUtilityLayer;
  45362. private _sharedGizmoLight;
  45363. private _renderCamera;
  45364. /**
  45365. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45366. * @returns the camera that is used when rendering the utility layer
  45367. */
  45368. getRenderCamera(): Nullable<Camera>;
  45369. /**
  45370. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45371. * @param cam the camera that should be used when rendering the utility layer
  45372. */
  45373. setRenderCamera(cam: Nullable<Camera>): void;
  45374. /**
  45375. * @hidden
  45376. * Light which used by gizmos to get light shading
  45377. */
  45378. _getSharedGizmoLight(): HemisphericLight;
  45379. /**
  45380. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45381. */
  45382. pickUtilitySceneFirst: boolean;
  45383. /**
  45384. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  45385. */
  45386. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45387. /**
  45388. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  45389. */
  45390. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45391. /**
  45392. * The scene that is rendered on top of the original scene
  45393. */
  45394. utilityLayerScene: Scene;
  45395. /**
  45396. * If the utility layer should automatically be rendered on top of existing scene
  45397. */
  45398. shouldRender: boolean;
  45399. /**
  45400. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45401. */
  45402. onlyCheckPointerDownEvents: boolean;
  45403. /**
  45404. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45405. */
  45406. processAllEvents: boolean;
  45407. /**
  45408. * Observable raised when the pointer move from the utility layer scene to the main scene
  45409. */
  45410. onPointerOutObservable: Observable<number>;
  45411. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45412. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45413. private _afterRenderObserver;
  45414. private _sceneDisposeObserver;
  45415. private _originalPointerObserver;
  45416. /**
  45417. * Instantiates a UtilityLayerRenderer
  45418. * @param originalScene the original scene that will be rendered on top of
  45419. * @param handleEvents boolean indicating if the utility layer should handle events
  45420. */
  45421. constructor(
  45422. /** the original scene that will be rendered on top of */
  45423. originalScene: Scene, handleEvents?: boolean);
  45424. private _notifyObservers;
  45425. /**
  45426. * Renders the utility layers scene on top of the original scene
  45427. */
  45428. render(): void;
  45429. /**
  45430. * Disposes of the renderer
  45431. */
  45432. dispose(): void;
  45433. private _updateCamera;
  45434. }
  45435. }
  45436. declare module "babylonjs/Gizmos/gizmo" {
  45437. import { Nullable } from "babylonjs/types";
  45438. import { IDisposable } from "babylonjs/scene";
  45439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45440. import { Mesh } from "babylonjs/Meshes/mesh";
  45441. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45442. /**
  45443. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45444. */
  45445. export class Gizmo implements IDisposable {
  45446. /** The utility layer the gizmo will be added to */
  45447. gizmoLayer: UtilityLayerRenderer;
  45448. /**
  45449. * The root mesh of the gizmo
  45450. */
  45451. _rootMesh: Mesh;
  45452. private _attachedMesh;
  45453. /**
  45454. * Ratio for the scale of the gizmo (Default: 1)
  45455. */
  45456. scaleRatio: number;
  45457. /**
  45458. * If a custom mesh has been set (Default: false)
  45459. */
  45460. protected _customMeshSet: boolean;
  45461. /**
  45462. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45463. * * When set, interactions will be enabled
  45464. */
  45465. attachedMesh: Nullable<AbstractMesh>;
  45466. /**
  45467. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45468. * @param mesh The mesh to replace the default mesh of the gizmo
  45469. */
  45470. setCustomMesh(mesh: Mesh): void;
  45471. /**
  45472. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45473. */
  45474. updateGizmoRotationToMatchAttachedMesh: boolean;
  45475. /**
  45476. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45477. */
  45478. updateGizmoPositionToMatchAttachedMesh: boolean;
  45479. /**
  45480. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45481. */
  45482. updateScale: boolean;
  45483. protected _interactionsEnabled: boolean;
  45484. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45485. private _beforeRenderObserver;
  45486. private _tempVector;
  45487. /**
  45488. * Creates a gizmo
  45489. * @param gizmoLayer The utility layer the gizmo will be added to
  45490. */
  45491. constructor(
  45492. /** The utility layer the gizmo will be added to */
  45493. gizmoLayer?: UtilityLayerRenderer);
  45494. /**
  45495. * Updates the gizmo to match the attached mesh's position/rotation
  45496. */
  45497. protected _update(): void;
  45498. /**
  45499. * Disposes of the gizmo
  45500. */
  45501. dispose(): void;
  45502. }
  45503. }
  45504. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45505. import { Observable } from "babylonjs/Misc/observable";
  45506. import { Nullable } from "babylonjs/types";
  45507. import { Vector3 } from "babylonjs/Maths/math.vector";
  45508. import { Color3 } from "babylonjs/Maths/math.color";
  45509. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45511. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45512. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45513. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45514. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45515. import { Scene } from "babylonjs/scene";
  45516. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45517. /**
  45518. * Single plane drag gizmo
  45519. */
  45520. export class PlaneDragGizmo extends Gizmo {
  45521. /**
  45522. * Drag behavior responsible for the gizmos dragging interactions
  45523. */
  45524. dragBehavior: PointerDragBehavior;
  45525. private _pointerObserver;
  45526. /**
  45527. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45528. */
  45529. snapDistance: number;
  45530. /**
  45531. * Event that fires each time the gizmo snaps to a new location.
  45532. * * snapDistance is the the change in distance
  45533. */
  45534. onSnapObservable: Observable<{
  45535. snapDistance: number;
  45536. }>;
  45537. private _plane;
  45538. private _coloredMaterial;
  45539. private _hoverMaterial;
  45540. private _isEnabled;
  45541. private _parent;
  45542. /** @hidden */
  45543. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45544. /** @hidden */
  45545. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45546. /**
  45547. * Creates a PlaneDragGizmo
  45548. * @param gizmoLayer The utility layer the gizmo will be added to
  45549. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45550. * @param color The color of the gizmo
  45551. */
  45552. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45553. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45554. /**
  45555. * If the gizmo is enabled
  45556. */
  45557. isEnabled: boolean;
  45558. /**
  45559. * Disposes of the gizmo
  45560. */
  45561. dispose(): void;
  45562. }
  45563. }
  45564. declare module "babylonjs/Gizmos/positionGizmo" {
  45565. import { Observable } from "babylonjs/Misc/observable";
  45566. import { Nullable } from "babylonjs/types";
  45567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45568. import { Mesh } from "babylonjs/Meshes/mesh";
  45569. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45570. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45571. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45572. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45573. /**
  45574. * Gizmo that enables dragging a mesh along 3 axis
  45575. */
  45576. export class PositionGizmo extends Gizmo {
  45577. /**
  45578. * Internal gizmo used for interactions on the x axis
  45579. */
  45580. xGizmo: AxisDragGizmo;
  45581. /**
  45582. * Internal gizmo used for interactions on the y axis
  45583. */
  45584. yGizmo: AxisDragGizmo;
  45585. /**
  45586. * Internal gizmo used for interactions on the z axis
  45587. */
  45588. zGizmo: AxisDragGizmo;
  45589. /**
  45590. * Internal gizmo used for interactions on the yz plane
  45591. */
  45592. xPlaneGizmo: PlaneDragGizmo;
  45593. /**
  45594. * Internal gizmo used for interactions on the xz plane
  45595. */
  45596. yPlaneGizmo: PlaneDragGizmo;
  45597. /**
  45598. * Internal gizmo used for interactions on the xy plane
  45599. */
  45600. zPlaneGizmo: PlaneDragGizmo;
  45601. /**
  45602. * private variables
  45603. */
  45604. private _meshAttached;
  45605. private _updateGizmoRotationToMatchAttachedMesh;
  45606. private _snapDistance;
  45607. private _scaleRatio;
  45608. /** Fires an event when any of it's sub gizmos are dragged */
  45609. onDragStartObservable: Observable<unknown>;
  45610. /** Fires an event when any of it's sub gizmos are released from dragging */
  45611. onDragEndObservable: Observable<unknown>;
  45612. /**
  45613. * If set to true, planar drag is enabled
  45614. */
  45615. private _planarGizmoEnabled;
  45616. attachedMesh: Nullable<AbstractMesh>;
  45617. /**
  45618. * Creates a PositionGizmo
  45619. * @param gizmoLayer The utility layer the gizmo will be added to
  45620. */
  45621. constructor(gizmoLayer?: UtilityLayerRenderer);
  45622. /**
  45623. * If the planar drag gizmo is enabled
  45624. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45625. */
  45626. planarGizmoEnabled: boolean;
  45627. updateGizmoRotationToMatchAttachedMesh: boolean;
  45628. /**
  45629. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45630. */
  45631. snapDistance: number;
  45632. /**
  45633. * Ratio for the scale of the gizmo (Default: 1)
  45634. */
  45635. scaleRatio: number;
  45636. /**
  45637. * Disposes of the gizmo
  45638. */
  45639. dispose(): void;
  45640. /**
  45641. * CustomMeshes are not supported by this gizmo
  45642. * @param mesh The mesh to replace the default mesh of the gizmo
  45643. */
  45644. setCustomMesh(mesh: Mesh): void;
  45645. }
  45646. }
  45647. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45648. import { Observable } from "babylonjs/Misc/observable";
  45649. import { Nullable } from "babylonjs/types";
  45650. import { Vector3 } from "babylonjs/Maths/math.vector";
  45651. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45653. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45654. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45655. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45656. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45657. import { Scene } from "babylonjs/scene";
  45658. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45659. import { Color3 } from "babylonjs/Maths/math.color";
  45660. /**
  45661. * Single axis drag gizmo
  45662. */
  45663. export class AxisDragGizmo extends Gizmo {
  45664. /**
  45665. * Drag behavior responsible for the gizmos dragging interactions
  45666. */
  45667. dragBehavior: PointerDragBehavior;
  45668. private _pointerObserver;
  45669. /**
  45670. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45671. */
  45672. snapDistance: number;
  45673. /**
  45674. * Event that fires each time the gizmo snaps to a new location.
  45675. * * snapDistance is the the change in distance
  45676. */
  45677. onSnapObservable: Observable<{
  45678. snapDistance: number;
  45679. }>;
  45680. private _isEnabled;
  45681. private _parent;
  45682. private _arrow;
  45683. private _coloredMaterial;
  45684. private _hoverMaterial;
  45685. /** @hidden */
  45686. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45687. /** @hidden */
  45688. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45689. /**
  45690. * Creates an AxisDragGizmo
  45691. * @param gizmoLayer The utility layer the gizmo will be added to
  45692. * @param dragAxis The axis which the gizmo will be able to drag on
  45693. * @param color The color of the gizmo
  45694. */
  45695. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45696. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45697. /**
  45698. * If the gizmo is enabled
  45699. */
  45700. isEnabled: boolean;
  45701. /**
  45702. * Disposes of the gizmo
  45703. */
  45704. dispose(): void;
  45705. }
  45706. }
  45707. declare module "babylonjs/Debug/axesViewer" {
  45708. import { Vector3 } from "babylonjs/Maths/math.vector";
  45709. import { Nullable } from "babylonjs/types";
  45710. import { Scene } from "babylonjs/scene";
  45711. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45712. /**
  45713. * The Axes viewer will show 3 axes in a specific point in space
  45714. */
  45715. export class AxesViewer {
  45716. private _xAxis;
  45717. private _yAxis;
  45718. private _zAxis;
  45719. private _scaleLinesFactor;
  45720. private _instanced;
  45721. /**
  45722. * Gets the hosting scene
  45723. */
  45724. scene: Scene;
  45725. /**
  45726. * Gets or sets a number used to scale line length
  45727. */
  45728. scaleLines: number;
  45729. /** Gets the node hierarchy used to render x-axis */
  45730. readonly xAxis: TransformNode;
  45731. /** Gets the node hierarchy used to render y-axis */
  45732. readonly yAxis: TransformNode;
  45733. /** Gets the node hierarchy used to render z-axis */
  45734. readonly zAxis: TransformNode;
  45735. /**
  45736. * Creates a new AxesViewer
  45737. * @param scene defines the hosting scene
  45738. * @param scaleLines defines a number used to scale line length (1 by default)
  45739. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45740. * @param xAxis defines the node hierarchy used to render the x-axis
  45741. * @param yAxis defines the node hierarchy used to render the y-axis
  45742. * @param zAxis defines the node hierarchy used to render the z-axis
  45743. */
  45744. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45745. /**
  45746. * Force the viewer to update
  45747. * @param position defines the position of the viewer
  45748. * @param xaxis defines the x axis of the viewer
  45749. * @param yaxis defines the y axis of the viewer
  45750. * @param zaxis defines the z axis of the viewer
  45751. */
  45752. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45753. /**
  45754. * Creates an instance of this axes viewer.
  45755. * @returns a new axes viewer with instanced meshes
  45756. */
  45757. createInstance(): AxesViewer;
  45758. /** Releases resources */
  45759. dispose(): void;
  45760. private static _SetRenderingGroupId;
  45761. }
  45762. }
  45763. declare module "babylonjs/Debug/boneAxesViewer" {
  45764. import { Nullable } from "babylonjs/types";
  45765. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45766. import { Vector3 } from "babylonjs/Maths/math.vector";
  45767. import { Mesh } from "babylonjs/Meshes/mesh";
  45768. import { Bone } from "babylonjs/Bones/bone";
  45769. import { Scene } from "babylonjs/scene";
  45770. /**
  45771. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45772. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45773. */
  45774. export class BoneAxesViewer extends AxesViewer {
  45775. /**
  45776. * Gets or sets the target mesh where to display the axes viewer
  45777. */
  45778. mesh: Nullable<Mesh>;
  45779. /**
  45780. * Gets or sets the target bone where to display the axes viewer
  45781. */
  45782. bone: Nullable<Bone>;
  45783. /** Gets current position */
  45784. pos: Vector3;
  45785. /** Gets direction of X axis */
  45786. xaxis: Vector3;
  45787. /** Gets direction of Y axis */
  45788. yaxis: Vector3;
  45789. /** Gets direction of Z axis */
  45790. zaxis: Vector3;
  45791. /**
  45792. * Creates a new BoneAxesViewer
  45793. * @param scene defines the hosting scene
  45794. * @param bone defines the target bone
  45795. * @param mesh defines the target mesh
  45796. * @param scaleLines defines a scaling factor for line length (1 by default)
  45797. */
  45798. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45799. /**
  45800. * Force the viewer to update
  45801. */
  45802. update(): void;
  45803. /** Releases resources */
  45804. dispose(): void;
  45805. }
  45806. }
  45807. declare module "babylonjs/Debug/debugLayer" {
  45808. import { Scene } from "babylonjs/scene";
  45809. /**
  45810. * Interface used to define scene explorer extensibility option
  45811. */
  45812. export interface IExplorerExtensibilityOption {
  45813. /**
  45814. * Define the option label
  45815. */
  45816. label: string;
  45817. /**
  45818. * Defines the action to execute on click
  45819. */
  45820. action: (entity: any) => void;
  45821. }
  45822. /**
  45823. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45824. */
  45825. export interface IExplorerExtensibilityGroup {
  45826. /**
  45827. * Defines a predicate to test if a given type mut be extended
  45828. */
  45829. predicate: (entity: any) => boolean;
  45830. /**
  45831. * Gets the list of options added to a type
  45832. */
  45833. entries: IExplorerExtensibilityOption[];
  45834. }
  45835. /**
  45836. * Interface used to define the options to use to create the Inspector
  45837. */
  45838. export interface IInspectorOptions {
  45839. /**
  45840. * Display in overlay mode (default: false)
  45841. */
  45842. overlay?: boolean;
  45843. /**
  45844. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45845. */
  45846. globalRoot?: HTMLElement;
  45847. /**
  45848. * Display the Scene explorer
  45849. */
  45850. showExplorer?: boolean;
  45851. /**
  45852. * Display the property inspector
  45853. */
  45854. showInspector?: boolean;
  45855. /**
  45856. * Display in embed mode (both panes on the right)
  45857. */
  45858. embedMode?: boolean;
  45859. /**
  45860. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45861. */
  45862. handleResize?: boolean;
  45863. /**
  45864. * Allow the panes to popup (default: true)
  45865. */
  45866. enablePopup?: boolean;
  45867. /**
  45868. * Allow the panes to be closed by users (default: true)
  45869. */
  45870. enableClose?: boolean;
  45871. /**
  45872. * Optional list of extensibility entries
  45873. */
  45874. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45875. /**
  45876. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45877. */
  45878. inspectorURL?: string;
  45879. /**
  45880. * Optional initial tab (default to DebugLayerTab.Properties)
  45881. */
  45882. initialTab?: DebugLayerTab.Properties;
  45883. }
  45884. module "babylonjs/scene" {
  45885. interface Scene {
  45886. /**
  45887. * @hidden
  45888. * Backing field
  45889. */
  45890. _debugLayer: DebugLayer;
  45891. /**
  45892. * Gets the debug layer (aka Inspector) associated with the scene
  45893. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45894. */
  45895. debugLayer: DebugLayer;
  45896. }
  45897. }
  45898. /**
  45899. * Enum of inspector action tab
  45900. */
  45901. export enum DebugLayerTab {
  45902. /**
  45903. * Properties tag (default)
  45904. */
  45905. Properties = 0,
  45906. /**
  45907. * Debug tab
  45908. */
  45909. Debug = 1,
  45910. /**
  45911. * Statistics tab
  45912. */
  45913. Statistics = 2,
  45914. /**
  45915. * Tools tab
  45916. */
  45917. Tools = 3,
  45918. /**
  45919. * Settings tab
  45920. */
  45921. Settings = 4
  45922. }
  45923. /**
  45924. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45925. * what is happening in your scene
  45926. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45927. */
  45928. export class DebugLayer {
  45929. /**
  45930. * Define the url to get the inspector script from.
  45931. * By default it uses the babylonjs CDN.
  45932. * @ignoreNaming
  45933. */
  45934. static InspectorURL: string;
  45935. private _scene;
  45936. private BJSINSPECTOR;
  45937. private _onPropertyChangedObservable?;
  45938. /**
  45939. * Observable triggered when a property is changed through the inspector.
  45940. */
  45941. readonly onPropertyChangedObservable: any;
  45942. /**
  45943. * Instantiates a new debug layer.
  45944. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45945. * what is happening in your scene
  45946. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45947. * @param scene Defines the scene to inspect
  45948. */
  45949. constructor(scene: Scene);
  45950. /** Creates the inspector window. */
  45951. private _createInspector;
  45952. /**
  45953. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45954. * @param entity defines the entity to select
  45955. * @param lineContainerTitle defines the specific block to highlight
  45956. */
  45957. select(entity: any, lineContainerTitle?: string): void;
  45958. /** Get the inspector from bundle or global */
  45959. private _getGlobalInspector;
  45960. /**
  45961. * Get if the inspector is visible or not.
  45962. * @returns true if visible otherwise, false
  45963. */
  45964. isVisible(): boolean;
  45965. /**
  45966. * Hide the inspector and close its window.
  45967. */
  45968. hide(): void;
  45969. /**
  45970. * Launch the debugLayer.
  45971. * @param config Define the configuration of the inspector
  45972. * @return a promise fulfilled when the debug layer is visible
  45973. */
  45974. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45975. }
  45976. }
  45977. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45978. import { Nullable } from "babylonjs/types";
  45979. import { Scene } from "babylonjs/scene";
  45980. import { Vector4 } from "babylonjs/Maths/math.vector";
  45981. import { Color4 } from "babylonjs/Maths/math.color";
  45982. import { Mesh } from "babylonjs/Meshes/mesh";
  45983. /**
  45984. * Class containing static functions to help procedurally build meshes
  45985. */
  45986. export class BoxBuilder {
  45987. /**
  45988. * Creates a box mesh
  45989. * * The parameter `size` sets the size (float) of each box side (default 1)
  45990. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45991. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  45992. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45996. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45997. * @param name defines the name of the mesh
  45998. * @param options defines the options used to create the mesh
  45999. * @param scene defines the hosting scene
  46000. * @returns the box mesh
  46001. */
  46002. static CreateBox(name: string, options: {
  46003. size?: number;
  46004. width?: number;
  46005. height?: number;
  46006. depth?: number;
  46007. faceUV?: Vector4[];
  46008. faceColors?: Color4[];
  46009. sideOrientation?: number;
  46010. frontUVs?: Vector4;
  46011. backUVs?: Vector4;
  46012. wrap?: boolean;
  46013. topBaseAt?: number;
  46014. bottomBaseAt?: number;
  46015. updatable?: boolean;
  46016. }, scene?: Nullable<Scene>): Mesh;
  46017. }
  46018. }
  46019. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46020. import { Vector4 } from "babylonjs/Maths/math.vector";
  46021. import { Mesh } from "babylonjs/Meshes/mesh";
  46022. import { Scene } from "babylonjs/scene";
  46023. import { Nullable } from "babylonjs/types";
  46024. /**
  46025. * Class containing static functions to help procedurally build meshes
  46026. */
  46027. export class SphereBuilder {
  46028. /**
  46029. * Creates a sphere mesh
  46030. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46031. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  46032. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46033. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  46034. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  46035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46038. * @param name defines the name of the mesh
  46039. * @param options defines the options used to create the mesh
  46040. * @param scene defines the hosting scene
  46041. * @returns the sphere mesh
  46042. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46043. */
  46044. static CreateSphere(name: string, options: {
  46045. segments?: number;
  46046. diameter?: number;
  46047. diameterX?: number;
  46048. diameterY?: number;
  46049. diameterZ?: number;
  46050. arc?: number;
  46051. slice?: number;
  46052. sideOrientation?: number;
  46053. frontUVs?: Vector4;
  46054. backUVs?: Vector4;
  46055. updatable?: boolean;
  46056. }, scene?: Nullable<Scene>): Mesh;
  46057. }
  46058. }
  46059. declare module "babylonjs/Debug/physicsViewer" {
  46060. import { Nullable } from "babylonjs/types";
  46061. import { Scene } from "babylonjs/scene";
  46062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46063. import { Mesh } from "babylonjs/Meshes/mesh";
  46064. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46065. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  46066. /**
  46067. * Used to show the physics impostor around the specific mesh
  46068. */
  46069. export class PhysicsViewer {
  46070. /** @hidden */
  46071. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46072. /** @hidden */
  46073. protected _meshes: Array<Nullable<AbstractMesh>>;
  46074. /** @hidden */
  46075. protected _scene: Nullable<Scene>;
  46076. /** @hidden */
  46077. protected _numMeshes: number;
  46078. /** @hidden */
  46079. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46080. private _renderFunction;
  46081. private _utilityLayer;
  46082. private _debugBoxMesh;
  46083. private _debugSphereMesh;
  46084. private _debugCylinderMesh;
  46085. private _debugMaterial;
  46086. private _debugMeshMeshes;
  46087. /**
  46088. * Creates a new PhysicsViewer
  46089. * @param scene defines the hosting scene
  46090. */
  46091. constructor(scene: Scene);
  46092. /** @hidden */
  46093. protected _updateDebugMeshes(): void;
  46094. /**
  46095. * Renders a specified physic impostor
  46096. * @param impostor defines the impostor to render
  46097. * @param targetMesh defines the mesh represented by the impostor
  46098. * @returns the new debug mesh used to render the impostor
  46099. */
  46100. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46101. /**
  46102. * Hides a specified physic impostor
  46103. * @param impostor defines the impostor to hide
  46104. */
  46105. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46106. private _getDebugMaterial;
  46107. private _getDebugBoxMesh;
  46108. private _getDebugSphereMesh;
  46109. private _getDebugCylinderMesh;
  46110. private _getDebugMeshMesh;
  46111. private _getDebugMesh;
  46112. /** Releases all resources */
  46113. dispose(): void;
  46114. }
  46115. }
  46116. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46117. import { Vector3 } from "babylonjs/Maths/math.vector";
  46118. import { Color4 } from "babylonjs/Maths/math.color";
  46119. import { Nullable } from "babylonjs/types";
  46120. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46121. import { Scene } from "babylonjs/scene";
  46122. /**
  46123. * Class containing static functions to help procedurally build meshes
  46124. */
  46125. export class LinesBuilder {
  46126. /**
  46127. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46128. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  46129. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46130. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46131. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46132. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46133. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46134. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  46135. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46138. * @param name defines the name of the new line system
  46139. * @param options defines the options used to create the line system
  46140. * @param scene defines the hosting scene
  46141. * @returns a new line system mesh
  46142. */
  46143. static CreateLineSystem(name: string, options: {
  46144. lines: Vector3[][];
  46145. updatable?: boolean;
  46146. instance?: Nullable<LinesMesh>;
  46147. colors?: Nullable<Color4[][]>;
  46148. useVertexAlpha?: boolean;
  46149. }, scene: Nullable<Scene>): LinesMesh;
  46150. /**
  46151. * Creates a line mesh
  46152. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  46153. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46154. * * The parameter `points` is an array successive Vector3
  46155. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  46156. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46157. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46158. * * When updating an instance, remember that only point positions can change, not the number of points
  46159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46161. * @param name defines the name of the new line system
  46162. * @param options defines the options used to create the line system
  46163. * @param scene defines the hosting scene
  46164. * @returns a new line mesh
  46165. */
  46166. static CreateLines(name: string, options: {
  46167. points: Vector3[];
  46168. updatable?: boolean;
  46169. instance?: Nullable<LinesMesh>;
  46170. colors?: Color4[];
  46171. useVertexAlpha?: boolean;
  46172. }, scene?: Nullable<Scene>): LinesMesh;
  46173. /**
  46174. * Creates a dashed line mesh
  46175. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  46176. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46177. * * The parameter `points` is an array successive Vector3
  46178. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46179. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46180. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46181. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  46182. * * When updating an instance, remember that only point positions can change, not the number of points
  46183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46184. * @param name defines the name of the mesh
  46185. * @param options defines the options used to create the mesh
  46186. * @param scene defines the hosting scene
  46187. * @returns the dashed line mesh
  46188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46189. */
  46190. static CreateDashedLines(name: string, options: {
  46191. points: Vector3[];
  46192. dashSize?: number;
  46193. gapSize?: number;
  46194. dashNb?: number;
  46195. updatable?: boolean;
  46196. instance?: LinesMesh;
  46197. }, scene?: Nullable<Scene>): LinesMesh;
  46198. }
  46199. }
  46200. declare module "babylonjs/Debug/rayHelper" {
  46201. import { Nullable } from "babylonjs/types";
  46202. import { Ray } from "babylonjs/Culling/ray";
  46203. import { Vector3 } from "babylonjs/Maths/math.vector";
  46204. import { Color3 } from "babylonjs/Maths/math.color";
  46205. import { Scene } from "babylonjs/scene";
  46206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46207. import "babylonjs/Meshes/Builders/linesBuilder";
  46208. /**
  46209. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46210. * in order to better appreciate the issue one might have.
  46211. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46212. */
  46213. export class RayHelper {
  46214. /**
  46215. * Defines the ray we are currently tryin to visualize.
  46216. */
  46217. ray: Nullable<Ray>;
  46218. private _renderPoints;
  46219. private _renderLine;
  46220. private _renderFunction;
  46221. private _scene;
  46222. private _updateToMeshFunction;
  46223. private _attachedToMesh;
  46224. private _meshSpaceDirection;
  46225. private _meshSpaceOrigin;
  46226. /**
  46227. * Helper function to create a colored helper in a scene in one line.
  46228. * @param ray Defines the ray we are currently tryin to visualize
  46229. * @param scene Defines the scene the ray is used in
  46230. * @param color Defines the color we want to see the ray in
  46231. * @returns The newly created ray helper.
  46232. */
  46233. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46234. /**
  46235. * Instantiate a new ray helper.
  46236. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46237. * in order to better appreciate the issue one might have.
  46238. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46239. * @param ray Defines the ray we are currently tryin to visualize
  46240. */
  46241. constructor(ray: Ray);
  46242. /**
  46243. * Shows the ray we are willing to debug.
  46244. * @param scene Defines the scene the ray needs to be rendered in
  46245. * @param color Defines the color the ray needs to be rendered in
  46246. */
  46247. show(scene: Scene, color?: Color3): void;
  46248. /**
  46249. * Hides the ray we are debugging.
  46250. */
  46251. hide(): void;
  46252. private _render;
  46253. /**
  46254. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46255. * @param mesh Defines the mesh we want the helper attached to
  46256. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46257. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46258. * @param length Defines the length of the ray
  46259. */
  46260. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46261. /**
  46262. * Detach the ray helper from the mesh it has previously been attached to.
  46263. */
  46264. detachFromMesh(): void;
  46265. private _updateToMesh;
  46266. /**
  46267. * Dispose the helper and release its associated resources.
  46268. */
  46269. dispose(): void;
  46270. }
  46271. }
  46272. declare module "babylonjs/Debug/skeletonViewer" {
  46273. import { Color3 } from "babylonjs/Maths/math.color";
  46274. import { Scene } from "babylonjs/scene";
  46275. import { Nullable } from "babylonjs/types";
  46276. import { Skeleton } from "babylonjs/Bones/skeleton";
  46277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46278. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46279. /**
  46280. * Class used to render a debug view of a given skeleton
  46281. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46282. */
  46283. export class SkeletonViewer {
  46284. /** defines the skeleton to render */
  46285. skeleton: Skeleton;
  46286. /** defines the mesh attached to the skeleton */
  46287. mesh: AbstractMesh;
  46288. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46289. autoUpdateBonesMatrices: boolean;
  46290. /** defines the rendering group id to use with the viewer */
  46291. renderingGroupId: number;
  46292. /** Gets or sets the color used to render the skeleton */
  46293. color: Color3;
  46294. private _scene;
  46295. private _debugLines;
  46296. private _debugMesh;
  46297. private _isEnabled;
  46298. private _renderFunction;
  46299. private _utilityLayer;
  46300. /**
  46301. * Returns the mesh used to render the bones
  46302. */
  46303. readonly debugMesh: Nullable<LinesMesh>;
  46304. /**
  46305. * Creates a new SkeletonViewer
  46306. * @param skeleton defines the skeleton to render
  46307. * @param mesh defines the mesh attached to the skeleton
  46308. * @param scene defines the hosting scene
  46309. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46310. * @param renderingGroupId defines the rendering group id to use with the viewer
  46311. */
  46312. constructor(
  46313. /** defines the skeleton to render */
  46314. skeleton: Skeleton,
  46315. /** defines the mesh attached to the skeleton */
  46316. mesh: AbstractMesh, scene: Scene,
  46317. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46318. autoUpdateBonesMatrices?: boolean,
  46319. /** defines the rendering group id to use with the viewer */
  46320. renderingGroupId?: number);
  46321. /** Gets or sets a boolean indicating if the viewer is enabled */
  46322. isEnabled: boolean;
  46323. private _getBonePosition;
  46324. private _getLinesForBonesWithLength;
  46325. private _getLinesForBonesNoLength;
  46326. /** Update the viewer to sync with current skeleton state */
  46327. update(): void;
  46328. /** Release associated resources */
  46329. dispose(): void;
  46330. }
  46331. }
  46332. declare module "babylonjs/Debug/index" {
  46333. export * from "babylonjs/Debug/axesViewer";
  46334. export * from "babylonjs/Debug/boneAxesViewer";
  46335. export * from "babylonjs/Debug/debugLayer";
  46336. export * from "babylonjs/Debug/physicsViewer";
  46337. export * from "babylonjs/Debug/rayHelper";
  46338. export * from "babylonjs/Debug/skeletonViewer";
  46339. }
  46340. declare module "babylonjs/Engines/nullEngine" {
  46341. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  46342. import { Scene } from "babylonjs/scene";
  46343. import { Engine } from "babylonjs/Engines/engine";
  46344. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46345. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46346. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46347. import { Effect } from "babylonjs/Materials/effect";
  46348. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46349. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46350. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  46351. /**
  46352. * Options to create the null engine
  46353. */
  46354. export class NullEngineOptions {
  46355. /**
  46356. * Render width (Default: 512)
  46357. */
  46358. renderWidth: number;
  46359. /**
  46360. * Render height (Default: 256)
  46361. */
  46362. renderHeight: number;
  46363. /**
  46364. * Texture size (Default: 512)
  46365. */
  46366. textureSize: number;
  46367. /**
  46368. * If delta time between frames should be constant
  46369. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46370. */
  46371. deterministicLockstep: boolean;
  46372. /**
  46373. * Maximum about of steps between frames (Default: 4)
  46374. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46375. */
  46376. lockstepMaxSteps: number;
  46377. }
  46378. /**
  46379. * The null engine class provides support for headless version of babylon.js.
  46380. * This can be used in server side scenario or for testing purposes
  46381. */
  46382. export class NullEngine extends Engine {
  46383. private _options;
  46384. /**
  46385. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46386. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46387. * @returns true if engine is in deterministic lock step mode
  46388. */
  46389. isDeterministicLockStep(): boolean;
  46390. /**
  46391. * Gets the max steps when engine is running in deterministic lock step
  46392. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46393. * @returns the max steps
  46394. */
  46395. getLockstepMaxSteps(): number;
  46396. /**
  46397. * Gets the current hardware scaling level.
  46398. * By default the hardware scaling level is computed from the window device ratio.
  46399. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  46400. * @returns a number indicating the current hardware scaling level
  46401. */
  46402. getHardwareScalingLevel(): number;
  46403. constructor(options?: NullEngineOptions);
  46404. /**
  46405. * Creates a vertex buffer
  46406. * @param vertices the data for the vertex buffer
  46407. * @returns the new WebGL static buffer
  46408. */
  46409. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46410. /**
  46411. * Creates a new index buffer
  46412. * @param indices defines the content of the index buffer
  46413. * @param updatable defines if the index buffer must be updatable
  46414. * @returns a new webGL buffer
  46415. */
  46416. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46417. /**
  46418. * Clear the current render buffer or the current render target (if any is set up)
  46419. * @param color defines the color to use
  46420. * @param backBuffer defines if the back buffer must be cleared
  46421. * @param depth defines if the depth buffer must be cleared
  46422. * @param stencil defines if the stencil buffer must be cleared
  46423. */
  46424. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46425. /**
  46426. * Gets the current render width
  46427. * @param useScreen defines if screen size must be used (or the current render target if any)
  46428. * @returns a number defining the current render width
  46429. */
  46430. getRenderWidth(useScreen?: boolean): number;
  46431. /**
  46432. * Gets the current render height
  46433. * @param useScreen defines if screen size must be used (or the current render target if any)
  46434. * @returns a number defining the current render height
  46435. */
  46436. getRenderHeight(useScreen?: boolean): number;
  46437. /**
  46438. * Set the WebGL's viewport
  46439. * @param viewport defines the viewport element to be used
  46440. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46441. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46442. */
  46443. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46444. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46445. /**
  46446. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46447. * @param pipelineContext defines the pipeline context to use
  46448. * @param uniformsNames defines the list of uniform names
  46449. * @returns an array of webGL uniform locations
  46450. */
  46451. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46452. /**
  46453. * Gets the lsit of active attributes for a given webGL program
  46454. * @param pipelineContext defines the pipeline context to use
  46455. * @param attributesNames defines the list of attribute names to get
  46456. * @returns an array of indices indicating the offset of each attribute
  46457. */
  46458. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46459. /**
  46460. * Binds an effect to the webGL context
  46461. * @param effect defines the effect to bind
  46462. */
  46463. bindSamplers(effect: Effect): void;
  46464. /**
  46465. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46466. * @param effect defines the effect to activate
  46467. */
  46468. enableEffect(effect: Effect): void;
  46469. /**
  46470. * Set various states to the webGL context
  46471. * @param culling defines backface culling state
  46472. * @param zOffset defines the value to apply to zOffset (0 by default)
  46473. * @param force defines if states must be applied even if cache is up to date
  46474. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46475. */
  46476. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46477. /**
  46478. * Set the value of an uniform to an array of int32
  46479. * @param uniform defines the webGL uniform location where to store the value
  46480. * @param array defines the array of int32 to store
  46481. */
  46482. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46483. /**
  46484. * Set the value of an uniform to an array of int32 (stored as vec2)
  46485. * @param uniform defines the webGL uniform location where to store the value
  46486. * @param array defines the array of int32 to store
  46487. */
  46488. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46489. /**
  46490. * Set the value of an uniform to an array of int32 (stored as vec3)
  46491. * @param uniform defines the webGL uniform location where to store the value
  46492. * @param array defines the array of int32 to store
  46493. */
  46494. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46495. /**
  46496. * Set the value of an uniform to an array of int32 (stored as vec4)
  46497. * @param uniform defines the webGL uniform location where to store the value
  46498. * @param array defines the array of int32 to store
  46499. */
  46500. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46501. /**
  46502. * Set the value of an uniform to an array of float32
  46503. * @param uniform defines the webGL uniform location where to store the value
  46504. * @param array defines the array of float32 to store
  46505. */
  46506. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46507. /**
  46508. * Set the value of an uniform to an array of float32 (stored as vec2)
  46509. * @param uniform defines the webGL uniform location where to store the value
  46510. * @param array defines the array of float32 to store
  46511. */
  46512. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46513. /**
  46514. * Set the value of an uniform to an array of float32 (stored as vec3)
  46515. * @param uniform defines the webGL uniform location where to store the value
  46516. * @param array defines the array of float32 to store
  46517. */
  46518. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46519. /**
  46520. * Set the value of an uniform to an array of float32 (stored as vec4)
  46521. * @param uniform defines the webGL uniform location where to store the value
  46522. * @param array defines the array of float32 to store
  46523. */
  46524. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46525. /**
  46526. * Set the value of an uniform to an array of number
  46527. * @param uniform defines the webGL uniform location where to store the value
  46528. * @param array defines the array of number to store
  46529. */
  46530. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46531. /**
  46532. * Set the value of an uniform to an array of number (stored as vec2)
  46533. * @param uniform defines the webGL uniform location where to store the value
  46534. * @param array defines the array of number to store
  46535. */
  46536. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46537. /**
  46538. * Set the value of an uniform to an array of number (stored as vec3)
  46539. * @param uniform defines the webGL uniform location where to store the value
  46540. * @param array defines the array of number to store
  46541. */
  46542. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46543. /**
  46544. * Set the value of an uniform to an array of number (stored as vec4)
  46545. * @param uniform defines the webGL uniform location where to store the value
  46546. * @param array defines the array of number to store
  46547. */
  46548. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46549. /**
  46550. * Set the value of an uniform to an array of float32 (stored as matrices)
  46551. * @param uniform defines the webGL uniform location where to store the value
  46552. * @param matrices defines the array of float32 to store
  46553. */
  46554. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46555. /**
  46556. * Set the value of an uniform to a matrix (3x3)
  46557. * @param uniform defines the webGL uniform location where to store the value
  46558. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46559. */
  46560. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46561. /**
  46562. * Set the value of an uniform to a matrix (2x2)
  46563. * @param uniform defines the webGL uniform location where to store the value
  46564. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46565. */
  46566. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46567. /**
  46568. * Set the value of an uniform to a number (float)
  46569. * @param uniform defines the webGL uniform location where to store the value
  46570. * @param value defines the float number to store
  46571. */
  46572. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46573. /**
  46574. * Set the value of an uniform to a vec2
  46575. * @param uniform defines the webGL uniform location where to store the value
  46576. * @param x defines the 1st component of the value
  46577. * @param y defines the 2nd component of the value
  46578. */
  46579. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46580. /**
  46581. * Set the value of an uniform to a vec3
  46582. * @param uniform defines the webGL uniform location where to store the value
  46583. * @param x defines the 1st component of the value
  46584. * @param y defines the 2nd component of the value
  46585. * @param z defines the 3rd component of the value
  46586. */
  46587. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46588. /**
  46589. * Set the value of an uniform to a boolean
  46590. * @param uniform defines the webGL uniform location where to store the value
  46591. * @param bool defines the boolean to store
  46592. */
  46593. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46594. /**
  46595. * Set the value of an uniform to a vec4
  46596. * @param uniform defines the webGL uniform location where to store the value
  46597. * @param x defines the 1st component of the value
  46598. * @param y defines the 2nd component of the value
  46599. * @param z defines the 3rd component of the value
  46600. * @param w defines the 4th component of the value
  46601. */
  46602. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46603. /**
  46604. * Sets the current alpha mode
  46605. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46606. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46607. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46608. */
  46609. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46610. /**
  46611. * Bind webGl buffers directly to the webGL context
  46612. * @param vertexBuffers defines the vertex buffer to bind
  46613. * @param indexBuffer defines the index buffer to bind
  46614. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46615. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46616. * @param effect defines the effect associated with the vertex buffer
  46617. */
  46618. bindBuffers(vertexBuffers: {
  46619. [key: string]: VertexBuffer;
  46620. }, indexBuffer: DataBuffer, effect: Effect): void;
  46621. /**
  46622. * Force the entire cache to be cleared
  46623. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46624. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46625. */
  46626. wipeCaches(bruteForce?: boolean): void;
  46627. /**
  46628. * Send a draw order
  46629. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46630. * @param indexStart defines the starting index
  46631. * @param indexCount defines the number of index to draw
  46632. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46633. */
  46634. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46635. /**
  46636. * Draw a list of indexed primitives
  46637. * @param fillMode defines the primitive to use
  46638. * @param indexStart defines the starting index
  46639. * @param indexCount defines the number of index to draw
  46640. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46641. */
  46642. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46643. /**
  46644. * Draw a list of unindexed primitives
  46645. * @param fillMode defines the primitive to use
  46646. * @param verticesStart defines the index of first vertex to draw
  46647. * @param verticesCount defines the count of vertices to draw
  46648. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46649. */
  46650. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46651. /** @hidden */
  46652. _createTexture(): WebGLTexture;
  46653. /** @hidden */
  46654. _releaseTexture(texture: InternalTexture): void;
  46655. /**
  46656. * Usually called from Texture.ts.
  46657. * Passed information to create a WebGLTexture
  46658. * @param urlArg defines a value which contains one of the following:
  46659. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46660. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46661. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46662. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46663. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  46664. * @param scene needed for loading to the correct scene
  46665. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46666. * @param onLoad optional callback to be called upon successful completion
  46667. * @param onError optional callback to be called upon failure
  46668. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  46669. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46670. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46671. * @param forcedExtension defines the extension to use to pick the right loader
  46672. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46673. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46674. */
  46675. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  46676. /**
  46677. * Creates a new render target texture
  46678. * @param size defines the size of the texture
  46679. * @param options defines the options used to create the texture
  46680. * @returns a new render target texture stored in an InternalTexture
  46681. */
  46682. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46683. /**
  46684. * Update the sampling mode of a given texture
  46685. * @param samplingMode defines the required sampling mode
  46686. * @param texture defines the texture to update
  46687. */
  46688. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46689. /**
  46690. * Binds the frame buffer to the specified texture.
  46691. * @param texture The texture to render to or null for the default canvas
  46692. * @param faceIndex The face of the texture to render to in case of cube texture
  46693. * @param requiredWidth The width of the target to render to
  46694. * @param requiredHeight The height of the target to render to
  46695. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46696. * @param depthStencilTexture The depth stencil texture to use to render
  46697. * @param lodLevel defines le lod level to bind to the frame buffer
  46698. */
  46699. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46700. /**
  46701. * Unbind the current render target texture from the webGL context
  46702. * @param texture defines the render target texture to unbind
  46703. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46704. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46705. */
  46706. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46707. /**
  46708. * Creates a dynamic vertex buffer
  46709. * @param vertices the data for the dynamic vertex buffer
  46710. * @returns the new WebGL dynamic buffer
  46711. */
  46712. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46713. /**
  46714. * Update the content of a dynamic texture
  46715. * @param texture defines the texture to update
  46716. * @param canvas defines the canvas containing the source
  46717. * @param invertY defines if data must be stored with Y axis inverted
  46718. * @param premulAlpha defines if alpha is stored as premultiplied
  46719. * @param format defines the format of the data
  46720. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46721. */
  46722. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46723. /**
  46724. * Gets a boolean indicating if all created effects are ready
  46725. * @returns true if all effects are ready
  46726. */
  46727. areAllEffectsReady(): boolean;
  46728. /**
  46729. * @hidden
  46730. * Get the current error code of the webGL context
  46731. * @returns the error code
  46732. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46733. */
  46734. getError(): number;
  46735. /** @hidden */
  46736. _getUnpackAlignement(): number;
  46737. /** @hidden */
  46738. _unpackFlipY(value: boolean): void;
  46739. /**
  46740. * Update a dynamic index buffer
  46741. * @param indexBuffer defines the target index buffer
  46742. * @param indices defines the data to update
  46743. * @param offset defines the offset in the target index buffer where update should start
  46744. */
  46745. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46746. /**
  46747. * Updates a dynamic vertex buffer.
  46748. * @param vertexBuffer the vertex buffer to update
  46749. * @param vertices the data used to update the vertex buffer
  46750. * @param byteOffset the byte offset of the data (optional)
  46751. * @param byteLength the byte length of the data (optional)
  46752. */
  46753. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46754. /** @hidden */
  46755. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46756. /** @hidden */
  46757. _bindTexture(channel: number, texture: InternalTexture): void;
  46758. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46759. /**
  46760. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  46761. */
  46762. releaseEffects(): void;
  46763. displayLoadingUI(): void;
  46764. hideLoadingUI(): void;
  46765. /** @hidden */
  46766. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46767. /** @hidden */
  46768. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46769. /** @hidden */
  46770. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46771. /** @hidden */
  46772. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46773. }
  46774. }
  46775. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46776. import { Nullable, int } from "babylonjs/types";
  46777. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46778. /** @hidden */
  46779. export class _OcclusionDataStorage {
  46780. /** @hidden */
  46781. occlusionInternalRetryCounter: number;
  46782. /** @hidden */
  46783. isOcclusionQueryInProgress: boolean;
  46784. /** @hidden */
  46785. isOccluded: boolean;
  46786. /** @hidden */
  46787. occlusionRetryCount: number;
  46788. /** @hidden */
  46789. occlusionType: number;
  46790. /** @hidden */
  46791. occlusionQueryAlgorithmType: number;
  46792. }
  46793. module "babylonjs/Engines/engine" {
  46794. interface Engine {
  46795. /**
  46796. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46797. * @return the new query
  46798. */
  46799. createQuery(): WebGLQuery;
  46800. /**
  46801. * Delete and release a webGL query
  46802. * @param query defines the query to delete
  46803. * @return the current engine
  46804. */
  46805. deleteQuery(query: WebGLQuery): Engine;
  46806. /**
  46807. * Check if a given query has resolved and got its value
  46808. * @param query defines the query to check
  46809. * @returns true if the query got its value
  46810. */
  46811. isQueryResultAvailable(query: WebGLQuery): boolean;
  46812. /**
  46813. * Gets the value of a given query
  46814. * @param query defines the query to check
  46815. * @returns the value of the query
  46816. */
  46817. getQueryResult(query: WebGLQuery): number;
  46818. /**
  46819. * Initiates an occlusion query
  46820. * @param algorithmType defines the algorithm to use
  46821. * @param query defines the query to use
  46822. * @returns the current engine
  46823. * @see http://doc.babylonjs.com/features/occlusionquery
  46824. */
  46825. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46826. /**
  46827. * Ends an occlusion query
  46828. * @see http://doc.babylonjs.com/features/occlusionquery
  46829. * @param algorithmType defines the algorithm to use
  46830. * @returns the current engine
  46831. */
  46832. endOcclusionQuery(algorithmType: number): Engine;
  46833. /**
  46834. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46835. * Please note that only one query can be issued at a time
  46836. * @returns a time token used to track the time span
  46837. */
  46838. startTimeQuery(): Nullable<_TimeToken>;
  46839. /**
  46840. * Ends a time query
  46841. * @param token defines the token used to measure the time span
  46842. * @returns the time spent (in ns)
  46843. */
  46844. endTimeQuery(token: _TimeToken): int;
  46845. /** @hidden */
  46846. _currentNonTimestampToken: Nullable<_TimeToken>;
  46847. /** @hidden */
  46848. _createTimeQuery(): WebGLQuery;
  46849. /** @hidden */
  46850. _deleteTimeQuery(query: WebGLQuery): void;
  46851. /** @hidden */
  46852. _getGlAlgorithmType(algorithmType: number): number;
  46853. /** @hidden */
  46854. _getTimeQueryResult(query: WebGLQuery): any;
  46855. /** @hidden */
  46856. _getTimeQueryAvailability(query: WebGLQuery): any;
  46857. }
  46858. }
  46859. module "babylonjs/Meshes/abstractMesh" {
  46860. interface AbstractMesh {
  46861. /**
  46862. * Backing filed
  46863. * @hidden
  46864. */
  46865. __occlusionDataStorage: _OcclusionDataStorage;
  46866. /**
  46867. * Access property
  46868. * @hidden
  46869. */
  46870. _occlusionDataStorage: _OcclusionDataStorage;
  46871. /**
  46872. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  46873. * The default value is -1 which means don't break the query and wait till the result
  46874. * @see http://doc.babylonjs.com/features/occlusionquery
  46875. */
  46876. occlusionRetryCount: number;
  46877. /**
  46878. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  46879. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46880. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46881. * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  46882. * @see http://doc.babylonjs.com/features/occlusionquery
  46883. */
  46884. occlusionType: number;
  46885. /**
  46886. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46887. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46888. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  46889. * @see http://doc.babylonjs.com/features/occlusionquery
  46890. */
  46891. occlusionQueryAlgorithmType: number;
  46892. /**
  46893. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  46894. * @see http://doc.babylonjs.com/features/occlusionquery
  46895. */
  46896. isOccluded: boolean;
  46897. /**
  46898. * Flag to check the progress status of the query
  46899. * @see http://doc.babylonjs.com/features/occlusionquery
  46900. */
  46901. isOcclusionQueryInProgress: boolean;
  46902. }
  46903. }
  46904. }
  46905. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46906. import { Nullable } from "babylonjs/types";
  46907. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46908. /** @hidden */
  46909. export var _forceTransformFeedbackToBundle: boolean;
  46910. module "babylonjs/Engines/engine" {
  46911. interface Engine {
  46912. /**
  46913. * Creates a webGL transform feedback object
  46914. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46915. * @returns the webGL transform feedback object
  46916. */
  46917. createTransformFeedback(): WebGLTransformFeedback;
  46918. /**
  46919. * Delete a webGL transform feedback object
  46920. * @param value defines the webGL transform feedback object to delete
  46921. */
  46922. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46923. /**
  46924. * Bind a webGL transform feedback object to the webgl context
  46925. * @param value defines the webGL transform feedback object to bind
  46926. */
  46927. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46928. /**
  46929. * Begins a transform feedback operation
  46930. * @param usePoints defines if points or triangles must be used
  46931. */
  46932. beginTransformFeedback(usePoints: boolean): void;
  46933. /**
  46934. * Ends a transform feedback operation
  46935. */
  46936. endTransformFeedback(): void;
  46937. /**
  46938. * Specify the varyings to use with transform feedback
  46939. * @param program defines the associated webGL program
  46940. * @param value defines the list of strings representing the varying names
  46941. */
  46942. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46943. /**
  46944. * Bind a webGL buffer for a transform feedback operation
  46945. * @param value defines the webGL buffer to bind
  46946. */
  46947. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46948. }
  46949. }
  46950. }
  46951. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46952. import { Scene } from "babylonjs/scene";
  46953. import { Engine } from "babylonjs/Engines/engine";
  46954. import { Texture } from "babylonjs/Materials/Textures/texture";
  46955. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46956. import "babylonjs/Engines/Extensions/engine.multiRender";
  46957. /**
  46958. * Creation options of the multi render target texture.
  46959. */
  46960. export interface IMultiRenderTargetOptions {
  46961. /**
  46962. * Define if the texture needs to create mip maps after render.
  46963. */
  46964. generateMipMaps?: boolean;
  46965. /**
  46966. * Define the types of all the draw buffers we want to create
  46967. */
  46968. types?: number[];
  46969. /**
  46970. * Define the sampling modes of all the draw buffers we want to create
  46971. */
  46972. samplingModes?: number[];
  46973. /**
  46974. * Define if a depth buffer is required
  46975. */
  46976. generateDepthBuffer?: boolean;
  46977. /**
  46978. * Define if a stencil buffer is required
  46979. */
  46980. generateStencilBuffer?: boolean;
  46981. /**
  46982. * Define if a depth texture is required instead of a depth buffer
  46983. */
  46984. generateDepthTexture?: boolean;
  46985. /**
  46986. * Define the number of desired draw buffers
  46987. */
  46988. textureCount?: number;
  46989. /**
  46990. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46991. */
  46992. doNotChangeAspectRatio?: boolean;
  46993. /**
  46994. * Define the default type of the buffers we are creating
  46995. */
  46996. defaultType?: number;
  46997. }
  46998. /**
  46999. * A multi render target, like a render target provides the ability to render to a texture.
  47000. * Unlike the render target, it can render to several draw buffers in one draw.
  47001. * This is specially interesting in deferred rendering or for any effects requiring more than
  47002. * just one color from a single pass.
  47003. */
  47004. export class MultiRenderTarget extends RenderTargetTexture {
  47005. private _internalTextures;
  47006. private _textures;
  47007. private _multiRenderTargetOptions;
  47008. /**
  47009. * Get if draw buffers are currently supported by the used hardware and browser.
  47010. */
  47011. readonly isSupported: boolean;
  47012. /**
  47013. * Get the list of textures generated by the multi render target.
  47014. */
  47015. readonly textures: Texture[];
  47016. /**
  47017. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47018. */
  47019. readonly depthTexture: Texture;
  47020. /**
  47021. * Set the wrapping mode on U of all the textures we are rendering to.
  47022. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47023. */
  47024. wrapU: number;
  47025. /**
  47026. * Set the wrapping mode on V of all the textures we are rendering to.
  47027. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47028. */
  47029. wrapV: number;
  47030. /**
  47031. * Instantiate a new multi render target texture.
  47032. * A multi render target, like a render target provides the ability to render to a texture.
  47033. * Unlike the render target, it can render to several draw buffers in one draw.
  47034. * This is specially interesting in deferred rendering or for any effects requiring more than
  47035. * just one color from a single pass.
  47036. * @param name Define the name of the texture
  47037. * @param size Define the size of the buffers to render to
  47038. * @param count Define the number of target we are rendering into
  47039. * @param scene Define the scene the texture belongs to
  47040. * @param options Define the options used to create the multi render target
  47041. */
  47042. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47043. /** @hidden */
  47044. _rebuild(): void;
  47045. private _createInternalTextures;
  47046. private _createTextures;
  47047. /**
  47048. * Define the number of samples used if MSAA is enabled.
  47049. */
  47050. samples: number;
  47051. /**
  47052. * Resize all the textures in the multi render target.
  47053. * Be carrefull as it will recreate all the data in the new texture.
  47054. * @param size Define the new size
  47055. */
  47056. resize(size: any): void;
  47057. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47058. /**
  47059. * Dispose the render targets and their associated resources
  47060. */
  47061. dispose(): void;
  47062. /**
  47063. * Release all the underlying texture used as draw buffers.
  47064. */
  47065. releaseInternalTextures(): void;
  47066. }
  47067. }
  47068. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  47069. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47070. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  47071. import { Nullable } from "babylonjs/types";
  47072. module "babylonjs/Engines/thinEngine" {
  47073. interface ThinEngine {
  47074. /**
  47075. * Unbind a list of render target textures from the webGL context
  47076. * This is used only when drawBuffer extension or webGL2 are active
  47077. * @param textures defines the render target textures to unbind
  47078. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47079. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47080. */
  47081. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47082. /**
  47083. * Create a multi render target texture
  47084. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47085. * @param size defines the size of the texture
  47086. * @param options defines the creation options
  47087. * @returns the cube texture as an InternalTexture
  47088. */
  47089. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47090. /**
  47091. * Update the sample count for a given multiple render target texture
  47092. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47093. * @param textures defines the textures to update
  47094. * @param samples defines the sample count to set
  47095. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47096. */
  47097. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47098. }
  47099. }
  47100. }
  47101. declare module "babylonjs/Engines/Extensions/engine.views" {
  47102. import { Camera } from "babylonjs/Cameras/camera";
  47103. import { Nullable } from "babylonjs/types";
  47104. /**
  47105. * Class used to define an additional view for the engine
  47106. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47107. */
  47108. export class EngineView {
  47109. /** Defines the canvas where to render the view */
  47110. target: HTMLCanvasElement;
  47111. /** Defines an optional camera used to render the view (will use active camera else) */
  47112. camera?: Camera;
  47113. }
  47114. module "babylonjs/Engines/engine" {
  47115. interface Engine {
  47116. /**
  47117. * Gets or sets the HTML element to use for attaching events
  47118. */
  47119. inputElement: Nullable<HTMLElement>;
  47120. /**
  47121. * Gets the current engine view
  47122. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47123. */
  47124. activeView: Nullable<EngineView>;
  47125. /** Gets or sets the list of views */
  47126. views: EngineView[];
  47127. /**
  47128. * Register a new child canvas
  47129. * @param canvas defines the canvas to register
  47130. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47131. * @returns the associated view
  47132. */
  47133. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47134. /**
  47135. * Remove a registered child canvas
  47136. * @param canvas defines the canvas to remove
  47137. * @returns the current engine
  47138. */
  47139. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47140. }
  47141. }
  47142. }
  47143. declare module "babylonjs/Engines/Extensions/index" {
  47144. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  47145. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  47146. export * from "babylonjs/Engines/Extensions/engine.multiview";
  47147. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  47148. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47149. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  47150. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  47151. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  47152. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  47153. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47154. export * from "babylonjs/Engines/Extensions/engine.webVR";
  47155. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  47156. export * from "babylonjs/Engines/Extensions/engine.views";
  47157. }
  47158. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  47159. import { Nullable } from "babylonjs/types";
  47160. /**
  47161. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47162. */
  47163. export interface CubeMapInfo {
  47164. /**
  47165. * The pixel array for the front face.
  47166. * This is stored in format, left to right, up to down format.
  47167. */
  47168. front: Nullable<ArrayBufferView>;
  47169. /**
  47170. * The pixel array for the back face.
  47171. * This is stored in format, left to right, up to down format.
  47172. */
  47173. back: Nullable<ArrayBufferView>;
  47174. /**
  47175. * The pixel array for the left face.
  47176. * This is stored in format, left to right, up to down format.
  47177. */
  47178. left: Nullable<ArrayBufferView>;
  47179. /**
  47180. * The pixel array for the right face.
  47181. * This is stored in format, left to right, up to down format.
  47182. */
  47183. right: Nullable<ArrayBufferView>;
  47184. /**
  47185. * The pixel array for the up face.
  47186. * This is stored in format, left to right, up to down format.
  47187. */
  47188. up: Nullable<ArrayBufferView>;
  47189. /**
  47190. * The pixel array for the down face.
  47191. * This is stored in format, left to right, up to down format.
  47192. */
  47193. down: Nullable<ArrayBufferView>;
  47194. /**
  47195. * The size of the cubemap stored.
  47196. *
  47197. * Each faces will be size * size pixels.
  47198. */
  47199. size: number;
  47200. /**
  47201. * The format of the texture.
  47202. *
  47203. * RGBA, RGB.
  47204. */
  47205. format: number;
  47206. /**
  47207. * The type of the texture data.
  47208. *
  47209. * UNSIGNED_INT, FLOAT.
  47210. */
  47211. type: number;
  47212. /**
  47213. * Specifies whether the texture is in gamma space.
  47214. */
  47215. gammaSpace: boolean;
  47216. }
  47217. /**
  47218. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47219. */
  47220. export class PanoramaToCubeMapTools {
  47221. private static FACE_FRONT;
  47222. private static FACE_BACK;
  47223. private static FACE_RIGHT;
  47224. private static FACE_LEFT;
  47225. private static FACE_DOWN;
  47226. private static FACE_UP;
  47227. /**
  47228. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47229. *
  47230. * @param float32Array The source data.
  47231. * @param inputWidth The width of the input panorama.
  47232. * @param inputHeight The height of the input panorama.
  47233. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47234. * @return The cubemap data
  47235. */
  47236. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47237. private static CreateCubemapTexture;
  47238. private static CalcProjectionSpherical;
  47239. }
  47240. }
  47241. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  47242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47244. import { Nullable } from "babylonjs/types";
  47245. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47246. /**
  47247. * Helper class dealing with the extraction of spherical polynomial dataArray
  47248. * from a cube map.
  47249. */
  47250. export class CubeMapToSphericalPolynomialTools {
  47251. private static FileFaces;
  47252. /**
  47253. * Converts a texture to the according Spherical Polynomial data.
  47254. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47255. *
  47256. * @param texture The texture to extract the information from.
  47257. * @return The Spherical Polynomial data.
  47258. */
  47259. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47260. /**
  47261. * Converts a cubemap to the according Spherical Polynomial data.
  47262. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47263. *
  47264. * @param cubeInfo The Cube map to extract the information from.
  47265. * @return The Spherical Polynomial data.
  47266. */
  47267. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47268. }
  47269. }
  47270. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  47271. import { Nullable } from "babylonjs/types";
  47272. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47273. module "babylonjs/Materials/Textures/baseTexture" {
  47274. interface BaseTexture {
  47275. /**
  47276. * Get the polynomial representation of the texture data.
  47277. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47278. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47279. */
  47280. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47281. }
  47282. }
  47283. }
  47284. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47285. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47286. /** @hidden */
  47287. export var rgbdEncodePixelShader: {
  47288. name: string;
  47289. shader: string;
  47290. };
  47291. }
  47292. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47293. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47294. /** @hidden */
  47295. export var rgbdDecodePixelShader: {
  47296. name: string;
  47297. shader: string;
  47298. };
  47299. }
  47300. declare module "babylonjs/Misc/environmentTextureTools" {
  47301. import { Nullable } from "babylonjs/types";
  47302. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47303. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47304. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47305. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47306. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  47307. import "babylonjs/Shaders/rgbdEncode.fragment";
  47308. import "babylonjs/Shaders/rgbdDecode.fragment";
  47309. /**
  47310. * Raw texture data and descriptor sufficient for WebGL texture upload
  47311. */
  47312. export interface EnvironmentTextureInfo {
  47313. /**
  47314. * Version of the environment map
  47315. */
  47316. version: number;
  47317. /**
  47318. * Width of image
  47319. */
  47320. width: number;
  47321. /**
  47322. * Irradiance information stored in the file.
  47323. */
  47324. irradiance: any;
  47325. /**
  47326. * Specular information stored in the file.
  47327. */
  47328. specular: any;
  47329. }
  47330. /**
  47331. * Defines One Image in the file. It requires only the position in the file
  47332. * as well as the length.
  47333. */
  47334. interface BufferImageData {
  47335. /**
  47336. * Length of the image data.
  47337. */
  47338. length: number;
  47339. /**
  47340. * Position of the data from the null terminator delimiting the end of the JSON.
  47341. */
  47342. position: number;
  47343. }
  47344. /**
  47345. * Defines the specular data enclosed in the file.
  47346. * This corresponds to the version 1 of the data.
  47347. */
  47348. export interface EnvironmentTextureSpecularInfoV1 {
  47349. /**
  47350. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47351. */
  47352. specularDataPosition?: number;
  47353. /**
  47354. * This contains all the images data needed to reconstruct the cubemap.
  47355. */
  47356. mipmaps: Array<BufferImageData>;
  47357. /**
  47358. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47359. */
  47360. lodGenerationScale: number;
  47361. }
  47362. /**
  47363. * Sets of helpers addressing the serialization and deserialization of environment texture
  47364. * stored in a BabylonJS env file.
  47365. * Those files are usually stored as .env files.
  47366. */
  47367. export class EnvironmentTextureTools {
  47368. /**
  47369. * Magic number identifying the env file.
  47370. */
  47371. private static _MagicBytes;
  47372. /**
  47373. * Gets the environment info from an env file.
  47374. * @param data The array buffer containing the .env bytes.
  47375. * @returns the environment file info (the json header) if successfully parsed.
  47376. */
  47377. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47378. /**
  47379. * Creates an environment texture from a loaded cube texture.
  47380. * @param texture defines the cube texture to convert in env file
  47381. * @return a promise containing the environment data if succesfull.
  47382. */
  47383. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47384. /**
  47385. * Creates a JSON representation of the spherical data.
  47386. * @param texture defines the texture containing the polynomials
  47387. * @return the JSON representation of the spherical info
  47388. */
  47389. private static _CreateEnvTextureIrradiance;
  47390. /**
  47391. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47392. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47393. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47394. * @return the views described by info providing access to the underlying buffer
  47395. */
  47396. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47397. /**
  47398. * Uploads the texture info contained in the env file to the GPU.
  47399. * @param texture defines the internal texture to upload to
  47400. * @param arrayBuffer defines the buffer cotaining the data to load
  47401. * @param info defines the texture info retrieved through the GetEnvInfo method
  47402. * @returns a promise
  47403. */
  47404. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47405. private static _OnImageReadyAsync;
  47406. /**
  47407. * Uploads the levels of image data to the GPU.
  47408. * @param texture defines the internal texture to upload to
  47409. * @param imageData defines the array buffer views of image data [mipmap][face]
  47410. * @returns a promise
  47411. */
  47412. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47413. /**
  47414. * Uploads spherical polynomials information to the texture.
  47415. * @param texture defines the texture we are trying to upload the information to
  47416. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47417. */
  47418. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47419. /** @hidden */
  47420. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47421. }
  47422. }
  47423. declare module "babylonjs/Maths/math.vertexFormat" {
  47424. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47425. /**
  47426. * Contains position and normal vectors for a vertex
  47427. */
  47428. export class PositionNormalVertex {
  47429. /** the position of the vertex (defaut: 0,0,0) */
  47430. position: Vector3;
  47431. /** the normal of the vertex (defaut: 0,1,0) */
  47432. normal: Vector3;
  47433. /**
  47434. * Creates a PositionNormalVertex
  47435. * @param position the position of the vertex (defaut: 0,0,0)
  47436. * @param normal the normal of the vertex (defaut: 0,1,0)
  47437. */
  47438. constructor(
  47439. /** the position of the vertex (defaut: 0,0,0) */
  47440. position?: Vector3,
  47441. /** the normal of the vertex (defaut: 0,1,0) */
  47442. normal?: Vector3);
  47443. /**
  47444. * Clones the PositionNormalVertex
  47445. * @returns the cloned PositionNormalVertex
  47446. */
  47447. clone(): PositionNormalVertex;
  47448. }
  47449. /**
  47450. * Contains position, normal and uv vectors for a vertex
  47451. */
  47452. export class PositionNormalTextureVertex {
  47453. /** the position of the vertex (defaut: 0,0,0) */
  47454. position: Vector3;
  47455. /** the normal of the vertex (defaut: 0,1,0) */
  47456. normal: Vector3;
  47457. /** the uv of the vertex (default: 0,0) */
  47458. uv: Vector2;
  47459. /**
  47460. * Creates a PositionNormalTextureVertex
  47461. * @param position the position of the vertex (defaut: 0,0,0)
  47462. * @param normal the normal of the vertex (defaut: 0,1,0)
  47463. * @param uv the uv of the vertex (default: 0,0)
  47464. */
  47465. constructor(
  47466. /** the position of the vertex (defaut: 0,0,0) */
  47467. position?: Vector3,
  47468. /** the normal of the vertex (defaut: 0,1,0) */
  47469. normal?: Vector3,
  47470. /** the uv of the vertex (default: 0,0) */
  47471. uv?: Vector2);
  47472. /**
  47473. * Clones the PositionNormalTextureVertex
  47474. * @returns the cloned PositionNormalTextureVertex
  47475. */
  47476. clone(): PositionNormalTextureVertex;
  47477. }
  47478. }
  47479. declare module "babylonjs/Maths/math" {
  47480. export * from "babylonjs/Maths/math.axis";
  47481. export * from "babylonjs/Maths/math.color";
  47482. export * from "babylonjs/Maths/math.constants";
  47483. export * from "babylonjs/Maths/math.frustum";
  47484. export * from "babylonjs/Maths/math.path";
  47485. export * from "babylonjs/Maths/math.plane";
  47486. export * from "babylonjs/Maths/math.size";
  47487. export * from "babylonjs/Maths/math.vector";
  47488. export * from "babylonjs/Maths/math.vertexFormat";
  47489. export * from "babylonjs/Maths/math.viewport";
  47490. }
  47491. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47492. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47493. /** @hidden */
  47494. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47495. private _genericAttributeLocation;
  47496. private _varyingLocationCount;
  47497. private _varyingLocationMap;
  47498. private _replacements;
  47499. private _textureCount;
  47500. private _uniforms;
  47501. lineProcessor(line: string): string;
  47502. attributeProcessor(attribute: string): string;
  47503. varyingProcessor(varying: string, isFragment: boolean): string;
  47504. uniformProcessor(uniform: string): string;
  47505. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47506. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47507. }
  47508. }
  47509. declare module "babylonjs/Engines/nativeEngine" {
  47510. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47511. import { Engine } from "babylonjs/Engines/engine";
  47512. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47515. import { Effect } from "babylonjs/Materials/effect";
  47516. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47517. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47518. import { IColor4Like } from "babylonjs/Maths/math.like";
  47519. import { Scene } from "babylonjs/scene";
  47520. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47521. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47522. /**
  47523. * Container for accessors for natively-stored mesh data buffers.
  47524. */
  47525. class NativeDataBuffer extends DataBuffer {
  47526. /**
  47527. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47528. */
  47529. nativeIndexBuffer?: any;
  47530. /**
  47531. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47532. */
  47533. nativeVertexBuffer?: any;
  47534. }
  47535. /** @hidden */
  47536. class NativeTexture extends InternalTexture {
  47537. getInternalTexture(): InternalTexture;
  47538. getViewCount(): number;
  47539. }
  47540. /** @hidden */
  47541. export class NativeEngine extends Engine {
  47542. private readonly _native;
  47543. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47544. private readonly INVALID_HANDLE;
  47545. getHardwareScalingLevel(): number;
  47546. constructor();
  47547. /**
  47548. * Can be used to override the current requestAnimationFrame requester.
  47549. * @hidden
  47550. */
  47551. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47552. /**
  47553. * Override default engine behavior.
  47554. * @param color
  47555. * @param backBuffer
  47556. * @param depth
  47557. * @param stencil
  47558. */
  47559. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47560. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47561. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47562. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47563. recordVertexArrayObject(vertexBuffers: {
  47564. [key: string]: VertexBuffer;
  47565. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47566. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47567. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47568. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47569. /**
  47570. * Draw a list of indexed primitives
  47571. * @param fillMode defines the primitive to use
  47572. * @param indexStart defines the starting index
  47573. * @param indexCount defines the number of index to draw
  47574. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47575. */
  47576. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47577. /**
  47578. * Draw a list of unindexed primitives
  47579. * @param fillMode defines the primitive to use
  47580. * @param verticesStart defines the index of first vertex to draw
  47581. * @param verticesCount defines the count of vertices to draw
  47582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47583. */
  47584. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47585. createPipelineContext(): IPipelineContext;
  47586. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47587. /** @hidden */
  47588. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47589. /** @hidden */
  47590. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47591. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47592. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47593. protected _setProgram(program: WebGLProgram): void;
  47594. _releaseEffect(effect: Effect): void;
  47595. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47596. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47597. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47598. bindSamplers(effect: Effect): void;
  47599. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47600. getRenderWidth(useScreen?: boolean): number;
  47601. getRenderHeight(useScreen?: boolean): number;
  47602. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47603. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47604. /**
  47605. * Set the z offset to apply to current rendering
  47606. * @param value defines the offset to apply
  47607. */
  47608. setZOffset(value: number): void;
  47609. /**
  47610. * Gets the current value of the zOffset
  47611. * @returns the current zOffset state
  47612. */
  47613. getZOffset(): number;
  47614. /**
  47615. * Enable or disable depth buffering
  47616. * @param enable defines the state to set
  47617. */
  47618. setDepthBuffer(enable: boolean): void;
  47619. /**
  47620. * Gets a boolean indicating if depth writing is enabled
  47621. * @returns the current depth writing state
  47622. */
  47623. getDepthWrite(): boolean;
  47624. /**
  47625. * Enable or disable depth writing
  47626. * @param enable defines the state to set
  47627. */
  47628. setDepthWrite(enable: boolean): void;
  47629. /**
  47630. * Enable or disable color writing
  47631. * @param enable defines the state to set
  47632. */
  47633. setColorWrite(enable: boolean): void;
  47634. /**
  47635. * Gets a boolean indicating if color writing is enabled
  47636. * @returns the current color writing state
  47637. */
  47638. getColorWrite(): boolean;
  47639. /**
  47640. * Sets alpha constants used by some alpha blending modes
  47641. * @param r defines the red component
  47642. * @param g defines the green component
  47643. * @param b defines the blue component
  47644. * @param a defines the alpha component
  47645. */
  47646. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47647. /**
  47648. * Sets the current alpha mode
  47649. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47650. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47651. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47652. */
  47653. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47654. /**
  47655. * Gets the current alpha mode
  47656. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47657. * @returns the current alpha mode
  47658. */
  47659. getAlphaMode(): number;
  47660. setInt(uniform: WebGLUniformLocation, int: number): void;
  47661. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47662. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47663. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47664. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47665. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47666. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47667. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47668. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47669. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47670. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47671. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47672. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47673. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47674. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47675. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47676. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47677. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47678. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47679. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47680. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47681. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47682. wipeCaches(bruteForce?: boolean): void;
  47683. _createTexture(): WebGLTexture;
  47684. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47685. /**
  47686. * Usually called from BABYLON.Texture.ts.
  47687. * Passed information to create a WebGLTexture
  47688. * @param urlArg defines a value which contains one of the following:
  47689. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47690. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47691. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47692. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47693. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47694. * @param scene needed for loading to the correct scene
  47695. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47696. * @param onLoad optional callback to be called upon successful completion
  47697. * @param onError optional callback to be called upon failure
  47698. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47699. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47700. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47701. * @param forcedExtension defines the extension to use to pick the right loader
  47702. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47703. */
  47704. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  47705. /**
  47706. * Creates a cube texture
  47707. * @param rootUrl defines the url where the files to load is located
  47708. * @param scene defines the current scene
  47709. * @param files defines the list of files to load (1 per face)
  47710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47711. * @param onLoad defines an optional callback raised when the texture is loaded
  47712. * @param onError defines an optional callback raised if there is an issue to load the texture
  47713. * @param format defines the format of the data
  47714. * @param forcedExtension defines the extension to use to pick the right loader
  47715. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47718. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47719. * @returns the cube texture as an InternalTexture
  47720. */
  47721. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  47722. private _getSamplingFilter;
  47723. private static _GetNativeTextureFormat;
  47724. createRenderTargetTexture(size: number | {
  47725. width: number;
  47726. height: number;
  47727. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47728. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47729. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47730. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47731. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47732. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47733. /**
  47734. * Updates a dynamic vertex buffer.
  47735. * @param vertexBuffer the vertex buffer to update
  47736. * @param data the data used to update the vertex buffer
  47737. * @param byteOffset the byte offset of the data (optional)
  47738. * @param byteLength the byte length of the data (optional)
  47739. */
  47740. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47741. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47742. private _updateAnisotropicLevel;
  47743. private _getAddressMode;
  47744. /** @hidden */
  47745. _bindTexture(channel: number, texture: InternalTexture): void;
  47746. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47747. releaseEffects(): void;
  47748. /** @hidden */
  47749. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47750. /** @hidden */
  47751. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47752. /** @hidden */
  47753. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47754. /** @hidden */
  47755. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47756. }
  47757. }
  47758. declare module "babylonjs/Engines/index" {
  47759. export * from "babylonjs/Engines/constants";
  47760. export * from "babylonjs/Engines/engineCapabilities";
  47761. export * from "babylonjs/Engines/instancingAttributeInfo";
  47762. export * from "babylonjs/Engines/thinEngine";
  47763. export * from "babylonjs/Engines/engine";
  47764. export * from "babylonjs/Engines/engineStore";
  47765. export * from "babylonjs/Engines/nullEngine";
  47766. export * from "babylonjs/Engines/Extensions/index";
  47767. export * from "babylonjs/Engines/IPipelineContext";
  47768. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47769. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47770. export * from "babylonjs/Engines/nativeEngine";
  47771. }
  47772. declare module "babylonjs/Events/clipboardEvents" {
  47773. /**
  47774. * Gather the list of clipboard event types as constants.
  47775. */
  47776. export class ClipboardEventTypes {
  47777. /**
  47778. * The clipboard event is fired when a copy command is active (pressed).
  47779. */
  47780. static readonly COPY: number;
  47781. /**
  47782. * The clipboard event is fired when a cut command is active (pressed).
  47783. */
  47784. static readonly CUT: number;
  47785. /**
  47786. * The clipboard event is fired when a paste command is active (pressed).
  47787. */
  47788. static readonly PASTE: number;
  47789. }
  47790. /**
  47791. * This class is used to store clipboard related info for the onClipboardObservable event.
  47792. */
  47793. export class ClipboardInfo {
  47794. /**
  47795. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47796. */
  47797. type: number;
  47798. /**
  47799. * Defines the related dom event
  47800. */
  47801. event: ClipboardEvent;
  47802. /**
  47803. *Creates an instance of ClipboardInfo.
  47804. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47805. * @param event Defines the related dom event
  47806. */
  47807. constructor(
  47808. /**
  47809. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47810. */
  47811. type: number,
  47812. /**
  47813. * Defines the related dom event
  47814. */
  47815. event: ClipboardEvent);
  47816. /**
  47817. * Get the clipboard event's type from the keycode.
  47818. * @param keyCode Defines the keyCode for the current keyboard event.
  47819. * @return {number}
  47820. */
  47821. static GetTypeFromCharacter(keyCode: number): number;
  47822. }
  47823. }
  47824. declare module "babylonjs/Events/index" {
  47825. export * from "babylonjs/Events/keyboardEvents";
  47826. export * from "babylonjs/Events/pointerEvents";
  47827. export * from "babylonjs/Events/clipboardEvents";
  47828. }
  47829. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47830. import { Scene } from "babylonjs/scene";
  47831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47832. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47833. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47834. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47835. /**
  47836. * Google Daydream controller
  47837. */
  47838. export class DaydreamController extends WebVRController {
  47839. /**
  47840. * Base Url for the controller model.
  47841. */
  47842. static MODEL_BASE_URL: string;
  47843. /**
  47844. * File name for the controller model.
  47845. */
  47846. static MODEL_FILENAME: string;
  47847. /**
  47848. * Gamepad Id prefix used to identify Daydream Controller.
  47849. */
  47850. static readonly GAMEPAD_ID_PREFIX: string;
  47851. /**
  47852. * Creates a new DaydreamController from a gamepad
  47853. * @param vrGamepad the gamepad that the controller should be created from
  47854. */
  47855. constructor(vrGamepad: any);
  47856. /**
  47857. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47858. * @param scene scene in which to add meshes
  47859. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47860. */
  47861. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47862. /**
  47863. * Called once for each button that changed state since the last frame
  47864. * @param buttonIdx Which button index changed
  47865. * @param state New state of the button
  47866. * @param changes Which properties on the state changed since last frame
  47867. */
  47868. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47869. }
  47870. }
  47871. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47872. import { Scene } from "babylonjs/scene";
  47873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47874. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47875. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47876. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47877. /**
  47878. * Gear VR Controller
  47879. */
  47880. export class GearVRController extends WebVRController {
  47881. /**
  47882. * Base Url for the controller model.
  47883. */
  47884. static MODEL_BASE_URL: string;
  47885. /**
  47886. * File name for the controller model.
  47887. */
  47888. static MODEL_FILENAME: string;
  47889. /**
  47890. * Gamepad Id prefix used to identify this controller.
  47891. */
  47892. static readonly GAMEPAD_ID_PREFIX: string;
  47893. private readonly _buttonIndexToObservableNameMap;
  47894. /**
  47895. * Creates a new GearVRController from a gamepad
  47896. * @param vrGamepad the gamepad that the controller should be created from
  47897. */
  47898. constructor(vrGamepad: any);
  47899. /**
  47900. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47901. * @param scene scene in which to add meshes
  47902. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47903. */
  47904. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47905. /**
  47906. * Called once for each button that changed state since the last frame
  47907. * @param buttonIdx Which button index changed
  47908. * @param state New state of the button
  47909. * @param changes Which properties on the state changed since last frame
  47910. */
  47911. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47912. }
  47913. }
  47914. declare module "babylonjs/Gamepads/Controllers/index" {
  47915. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47916. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47917. export * from "babylonjs/Gamepads/Controllers/genericController";
  47918. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47919. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47920. export * from "babylonjs/Gamepads/Controllers/viveController";
  47921. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47922. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47923. }
  47924. declare module "babylonjs/Gamepads/index" {
  47925. export * from "babylonjs/Gamepads/Controllers/index";
  47926. export * from "babylonjs/Gamepads/gamepad";
  47927. export * from "babylonjs/Gamepads/gamepadManager";
  47928. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47929. export * from "babylonjs/Gamepads/xboxGamepad";
  47930. export * from "babylonjs/Gamepads/dualShockGamepad";
  47931. }
  47932. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47933. import { Scene } from "babylonjs/scene";
  47934. import { Vector4 } from "babylonjs/Maths/math.vector";
  47935. import { Color4 } from "babylonjs/Maths/math.color";
  47936. import { Mesh } from "babylonjs/Meshes/mesh";
  47937. import { Nullable } from "babylonjs/types";
  47938. /**
  47939. * Class containing static functions to help procedurally build meshes
  47940. */
  47941. export class PolyhedronBuilder {
  47942. /**
  47943. * Creates a polyhedron mesh
  47944. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  47945. * * The parameter `size` (positive float, default 1) sets the polygon size
  47946. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47947. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  47948. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  47949. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  47950. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47951. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  47952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47955. * @param name defines the name of the mesh
  47956. * @param options defines the options used to create the mesh
  47957. * @param scene defines the hosting scene
  47958. * @returns the polyhedron mesh
  47959. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47960. */
  47961. static CreatePolyhedron(name: string, options: {
  47962. type?: number;
  47963. size?: number;
  47964. sizeX?: number;
  47965. sizeY?: number;
  47966. sizeZ?: number;
  47967. custom?: any;
  47968. faceUV?: Vector4[];
  47969. faceColors?: Color4[];
  47970. flat?: boolean;
  47971. updatable?: boolean;
  47972. sideOrientation?: number;
  47973. frontUVs?: Vector4;
  47974. backUVs?: Vector4;
  47975. }, scene?: Nullable<Scene>): Mesh;
  47976. }
  47977. }
  47978. declare module "babylonjs/Gizmos/scaleGizmo" {
  47979. import { Observable } from "babylonjs/Misc/observable";
  47980. import { Nullable } from "babylonjs/types";
  47981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47982. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47983. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47984. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47985. /**
  47986. * Gizmo that enables scaling a mesh along 3 axis
  47987. */
  47988. export class ScaleGizmo extends Gizmo {
  47989. /**
  47990. * Internal gizmo used for interactions on the x axis
  47991. */
  47992. xGizmo: AxisScaleGizmo;
  47993. /**
  47994. * Internal gizmo used for interactions on the y axis
  47995. */
  47996. yGizmo: AxisScaleGizmo;
  47997. /**
  47998. * Internal gizmo used for interactions on the z axis
  47999. */
  48000. zGizmo: AxisScaleGizmo;
  48001. /**
  48002. * Internal gizmo used to scale all axis equally
  48003. */
  48004. uniformScaleGizmo: AxisScaleGizmo;
  48005. private _meshAttached;
  48006. private _updateGizmoRotationToMatchAttachedMesh;
  48007. private _snapDistance;
  48008. private _scaleRatio;
  48009. private _uniformScalingMesh;
  48010. private _octahedron;
  48011. private _sensitivity;
  48012. /** Fires an event when any of it's sub gizmos are dragged */
  48013. onDragStartObservable: Observable<unknown>;
  48014. /** Fires an event when any of it's sub gizmos are released from dragging */
  48015. onDragEndObservable: Observable<unknown>;
  48016. attachedMesh: Nullable<AbstractMesh>;
  48017. /**
  48018. * Creates a ScaleGizmo
  48019. * @param gizmoLayer The utility layer the gizmo will be added to
  48020. */
  48021. constructor(gizmoLayer?: UtilityLayerRenderer);
  48022. updateGizmoRotationToMatchAttachedMesh: boolean;
  48023. /**
  48024. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48025. */
  48026. snapDistance: number;
  48027. /**
  48028. * Ratio for the scale of the gizmo (Default: 1)
  48029. */
  48030. scaleRatio: number;
  48031. /**
  48032. * Sensitivity factor for dragging (Default: 1)
  48033. */
  48034. sensitivity: number;
  48035. /**
  48036. * Disposes of the gizmo
  48037. */
  48038. dispose(): void;
  48039. }
  48040. }
  48041. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  48042. import { Observable } from "babylonjs/Misc/observable";
  48043. import { Nullable } from "babylonjs/types";
  48044. import { Vector3 } from "babylonjs/Maths/math.vector";
  48045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48046. import { Mesh } from "babylonjs/Meshes/mesh";
  48047. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48048. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48049. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48050. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48051. import { Color3 } from "babylonjs/Maths/math.color";
  48052. /**
  48053. * Single axis scale gizmo
  48054. */
  48055. export class AxisScaleGizmo extends Gizmo {
  48056. /**
  48057. * Drag behavior responsible for the gizmos dragging interactions
  48058. */
  48059. dragBehavior: PointerDragBehavior;
  48060. private _pointerObserver;
  48061. /**
  48062. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48063. */
  48064. snapDistance: number;
  48065. /**
  48066. * Event that fires each time the gizmo snaps to a new location.
  48067. * * snapDistance is the the change in distance
  48068. */
  48069. onSnapObservable: Observable<{
  48070. snapDistance: number;
  48071. }>;
  48072. /**
  48073. * If the scaling operation should be done on all axis (default: false)
  48074. */
  48075. uniformScaling: boolean;
  48076. /**
  48077. * Custom sensitivity value for the drag strength
  48078. */
  48079. sensitivity: number;
  48080. private _isEnabled;
  48081. private _parent;
  48082. private _arrow;
  48083. private _coloredMaterial;
  48084. private _hoverMaterial;
  48085. /**
  48086. * Creates an AxisScaleGizmo
  48087. * @param gizmoLayer The utility layer the gizmo will be added to
  48088. * @param dragAxis The axis which the gizmo will be able to scale on
  48089. * @param color The color of the gizmo
  48090. */
  48091. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48092. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48093. /**
  48094. * If the gizmo is enabled
  48095. */
  48096. isEnabled: boolean;
  48097. /**
  48098. * Disposes of the gizmo
  48099. */
  48100. dispose(): void;
  48101. /**
  48102. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48103. * @param mesh The mesh to replace the default mesh of the gizmo
  48104. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48105. */
  48106. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48107. }
  48108. }
  48109. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  48110. import { Observable } from "babylonjs/Misc/observable";
  48111. import { Nullable } from "babylonjs/types";
  48112. import { Vector3 } from "babylonjs/Maths/math.vector";
  48113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48114. import { Mesh } from "babylonjs/Meshes/mesh";
  48115. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48116. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48117. import { Color3 } from "babylonjs/Maths/math.color";
  48118. import "babylonjs/Meshes/Builders/boxBuilder";
  48119. /**
  48120. * Bounding box gizmo
  48121. */
  48122. export class BoundingBoxGizmo extends Gizmo {
  48123. private _lineBoundingBox;
  48124. private _rotateSpheresParent;
  48125. private _scaleBoxesParent;
  48126. private _boundingDimensions;
  48127. private _renderObserver;
  48128. private _pointerObserver;
  48129. private _scaleDragSpeed;
  48130. private _tmpQuaternion;
  48131. private _tmpVector;
  48132. private _tmpRotationMatrix;
  48133. /**
  48134. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  48135. */
  48136. ignoreChildren: boolean;
  48137. /**
  48138. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  48139. */
  48140. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48141. /**
  48142. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48143. */
  48144. rotationSphereSize: number;
  48145. /**
  48146. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48147. */
  48148. scaleBoxSize: number;
  48149. /**
  48150. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  48151. */
  48152. fixedDragMeshScreenSize: boolean;
  48153. /**
  48154. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48155. */
  48156. fixedDragMeshScreenSizeDistanceFactor: number;
  48157. /**
  48158. * Fired when a rotation sphere or scale box is dragged
  48159. */
  48160. onDragStartObservable: Observable<{}>;
  48161. /**
  48162. * Fired when a scale box is dragged
  48163. */
  48164. onScaleBoxDragObservable: Observable<{}>;
  48165. /**
  48166. * Fired when a scale box drag is ended
  48167. */
  48168. onScaleBoxDragEndObservable: Observable<{}>;
  48169. /**
  48170. * Fired when a rotation sphere is dragged
  48171. */
  48172. onRotationSphereDragObservable: Observable<{}>;
  48173. /**
  48174. * Fired when a rotation sphere drag is ended
  48175. */
  48176. onRotationSphereDragEndObservable: Observable<{}>;
  48177. /**
  48178. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  48179. */
  48180. scalePivot: Nullable<Vector3>;
  48181. /**
  48182. * Mesh used as a pivot to rotate the attached mesh
  48183. */
  48184. private _anchorMesh;
  48185. private _existingMeshScale;
  48186. private _dragMesh;
  48187. private pointerDragBehavior;
  48188. private coloredMaterial;
  48189. private hoverColoredMaterial;
  48190. /**
  48191. * Sets the color of the bounding box gizmo
  48192. * @param color the color to set
  48193. */
  48194. setColor(color: Color3): void;
  48195. /**
  48196. * Creates an BoundingBoxGizmo
  48197. * @param gizmoLayer The utility layer the gizmo will be added to
  48198. * @param color The color of the gizmo
  48199. */
  48200. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48201. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48202. private _selectNode;
  48203. /**
  48204. * Updates the bounding box information for the Gizmo
  48205. */
  48206. updateBoundingBox(): void;
  48207. private _updateRotationSpheres;
  48208. private _updateScaleBoxes;
  48209. /**
  48210. * Enables rotation on the specified axis and disables rotation on the others
  48211. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48212. */
  48213. setEnabledRotationAxis(axis: string): void;
  48214. /**
  48215. * Enables/disables scaling
  48216. * @param enable if scaling should be enabled
  48217. */
  48218. setEnabledScaling(enable: boolean): void;
  48219. private _updateDummy;
  48220. /**
  48221. * Enables a pointer drag behavior on the bounding box of the gizmo
  48222. */
  48223. enableDragBehavior(): void;
  48224. /**
  48225. * Disposes of the gizmo
  48226. */
  48227. dispose(): void;
  48228. /**
  48229. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  48230. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48231. * @returns the bounding box mesh with the passed in mesh as a child
  48232. */
  48233. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48234. /**
  48235. * CustomMeshes are not supported by this gizmo
  48236. * @param mesh The mesh to replace the default mesh of the gizmo
  48237. */
  48238. setCustomMesh(mesh: Mesh): void;
  48239. }
  48240. }
  48241. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  48242. import { Observable } from "babylonjs/Misc/observable";
  48243. import { Nullable } from "babylonjs/types";
  48244. import { Vector3 } from "babylonjs/Maths/math.vector";
  48245. import { Color3 } from "babylonjs/Maths/math.color";
  48246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48247. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48248. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48249. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48250. import "babylonjs/Meshes/Builders/linesBuilder";
  48251. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48252. /**
  48253. * Single plane rotation gizmo
  48254. */
  48255. export class PlaneRotationGizmo extends Gizmo {
  48256. /**
  48257. * Drag behavior responsible for the gizmos dragging interactions
  48258. */
  48259. dragBehavior: PointerDragBehavior;
  48260. private _pointerObserver;
  48261. /**
  48262. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48263. */
  48264. snapDistance: number;
  48265. /**
  48266. * Event that fires each time the gizmo snaps to a new location.
  48267. * * snapDistance is the the change in distance
  48268. */
  48269. onSnapObservable: Observable<{
  48270. snapDistance: number;
  48271. }>;
  48272. private _isEnabled;
  48273. private _parent;
  48274. /**
  48275. * Creates a PlaneRotationGizmo
  48276. * @param gizmoLayer The utility layer the gizmo will be added to
  48277. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48278. * @param color The color of the gizmo
  48279. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48280. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48281. */
  48282. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48283. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48284. /**
  48285. * If the gizmo is enabled
  48286. */
  48287. isEnabled: boolean;
  48288. /**
  48289. * Disposes of the gizmo
  48290. */
  48291. dispose(): void;
  48292. }
  48293. }
  48294. declare module "babylonjs/Gizmos/rotationGizmo" {
  48295. import { Observable } from "babylonjs/Misc/observable";
  48296. import { Nullable } from "babylonjs/types";
  48297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48298. import { Mesh } from "babylonjs/Meshes/mesh";
  48299. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48300. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  48301. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48302. /**
  48303. * Gizmo that enables rotating a mesh along 3 axis
  48304. */
  48305. export class RotationGizmo extends Gizmo {
  48306. /**
  48307. * Internal gizmo used for interactions on the x axis
  48308. */
  48309. xGizmo: PlaneRotationGizmo;
  48310. /**
  48311. * Internal gizmo used for interactions on the y axis
  48312. */
  48313. yGizmo: PlaneRotationGizmo;
  48314. /**
  48315. * Internal gizmo used for interactions on the z axis
  48316. */
  48317. zGizmo: PlaneRotationGizmo;
  48318. /** Fires an event when any of it's sub gizmos are dragged */
  48319. onDragStartObservable: Observable<unknown>;
  48320. /** Fires an event when any of it's sub gizmos are released from dragging */
  48321. onDragEndObservable: Observable<unknown>;
  48322. private _meshAttached;
  48323. attachedMesh: Nullable<AbstractMesh>;
  48324. /**
  48325. * Creates a RotationGizmo
  48326. * @param gizmoLayer The utility layer the gizmo will be added to
  48327. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48328. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48329. */
  48330. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48331. updateGizmoRotationToMatchAttachedMesh: boolean;
  48332. /**
  48333. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48334. */
  48335. snapDistance: number;
  48336. /**
  48337. * Ratio for the scale of the gizmo (Default: 1)
  48338. */
  48339. scaleRatio: number;
  48340. /**
  48341. * Disposes of the gizmo
  48342. */
  48343. dispose(): void;
  48344. /**
  48345. * CustomMeshes are not supported by this gizmo
  48346. * @param mesh The mesh to replace the default mesh of the gizmo
  48347. */
  48348. setCustomMesh(mesh: Mesh): void;
  48349. }
  48350. }
  48351. declare module "babylonjs/Gizmos/gizmoManager" {
  48352. import { Observable } from "babylonjs/Misc/observable";
  48353. import { Nullable } from "babylonjs/types";
  48354. import { Scene, IDisposable } from "babylonjs/scene";
  48355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48356. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48357. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48358. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48359. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48360. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48361. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  48362. /**
  48363. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48364. */
  48365. export class GizmoManager implements IDisposable {
  48366. private scene;
  48367. /**
  48368. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48369. */
  48370. gizmos: {
  48371. positionGizmo: Nullable<PositionGizmo>;
  48372. rotationGizmo: Nullable<RotationGizmo>;
  48373. scaleGizmo: Nullable<ScaleGizmo>;
  48374. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48375. };
  48376. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48377. clearGizmoOnEmptyPointerEvent: boolean;
  48378. /** Fires an event when the manager is attached to a mesh */
  48379. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48380. private _gizmosEnabled;
  48381. private _pointerObserver;
  48382. private _attachedMesh;
  48383. private _boundingBoxColor;
  48384. private _defaultUtilityLayer;
  48385. private _defaultKeepDepthUtilityLayer;
  48386. /**
  48387. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48388. */
  48389. boundingBoxDragBehavior: SixDofDragBehavior;
  48390. /**
  48391. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48392. */
  48393. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48394. /**
  48395. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48396. */
  48397. usePointerToAttachGizmos: boolean;
  48398. /**
  48399. * Utility layer that the bounding box gizmo belongs to
  48400. */
  48401. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48402. /**
  48403. * Utility layer that all gizmos besides bounding box belong to
  48404. */
  48405. readonly utilityLayer: UtilityLayerRenderer;
  48406. /**
  48407. * Instatiates a gizmo manager
  48408. * @param scene the scene to overlay the gizmos on top of
  48409. */
  48410. constructor(scene: Scene);
  48411. /**
  48412. * Attaches a set of gizmos to the specified mesh
  48413. * @param mesh The mesh the gizmo's should be attached to
  48414. */
  48415. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48416. /**
  48417. * If the position gizmo is enabled
  48418. */
  48419. positionGizmoEnabled: boolean;
  48420. /**
  48421. * If the rotation gizmo is enabled
  48422. */
  48423. rotationGizmoEnabled: boolean;
  48424. /**
  48425. * If the scale gizmo is enabled
  48426. */
  48427. scaleGizmoEnabled: boolean;
  48428. /**
  48429. * If the boundingBox gizmo is enabled
  48430. */
  48431. boundingBoxGizmoEnabled: boolean;
  48432. /**
  48433. * Disposes of the gizmo manager
  48434. */
  48435. dispose(): void;
  48436. }
  48437. }
  48438. declare module "babylonjs/Lights/directionalLight" {
  48439. import { Camera } from "babylonjs/Cameras/camera";
  48440. import { Scene } from "babylonjs/scene";
  48441. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48443. import { Light } from "babylonjs/Lights/light";
  48444. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48445. import { Effect } from "babylonjs/Materials/effect";
  48446. /**
  48447. * A directional light is defined by a direction (what a surprise!).
  48448. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48449. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  48450. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48451. */
  48452. export class DirectionalLight extends ShadowLight {
  48453. private _shadowFrustumSize;
  48454. /**
  48455. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48456. */
  48457. /**
  48458. * Specifies a fix frustum size for the shadow generation.
  48459. */
  48460. shadowFrustumSize: number;
  48461. private _shadowOrthoScale;
  48462. /**
  48463. * Gets the shadow projection scale against the optimal computed one.
  48464. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48465. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48466. */
  48467. /**
  48468. * Sets the shadow projection scale against the optimal computed one.
  48469. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48470. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48471. */
  48472. shadowOrthoScale: number;
  48473. /**
  48474. * Automatically compute the projection matrix to best fit (including all the casters)
  48475. * on each frame.
  48476. */
  48477. autoUpdateExtends: boolean;
  48478. private _orthoLeft;
  48479. private _orthoRight;
  48480. private _orthoTop;
  48481. private _orthoBottom;
  48482. /**
  48483. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48484. * The directional light is emitted from everywhere in the given direction.
  48485. * It can cast shadows.
  48486. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48487. * @param name The friendly name of the light
  48488. * @param direction The direction of the light
  48489. * @param scene The scene the light belongs to
  48490. */
  48491. constructor(name: string, direction: Vector3, scene: Scene);
  48492. /**
  48493. * Returns the string "DirectionalLight".
  48494. * @return The class name
  48495. */
  48496. getClassName(): string;
  48497. /**
  48498. * Returns the integer 1.
  48499. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48500. */
  48501. getTypeID(): number;
  48502. /**
  48503. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48504. * Returns the DirectionalLight Shadow projection matrix.
  48505. */
  48506. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48507. /**
  48508. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48509. * Returns the DirectionalLight Shadow projection matrix.
  48510. */
  48511. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48512. /**
  48513. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48514. * Returns the DirectionalLight Shadow projection matrix.
  48515. */
  48516. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48517. protected _buildUniformLayout(): void;
  48518. /**
  48519. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48520. * @param effect The effect to update
  48521. * @param lightIndex The index of the light in the effect to update
  48522. * @returns The directional light
  48523. */
  48524. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48525. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48526. /**
  48527. * Gets the minZ used for shadow according to both the scene and the light.
  48528. *
  48529. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48530. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48531. * @param activeCamera The camera we are returning the min for
  48532. * @returns the depth min z
  48533. */
  48534. getDepthMinZ(activeCamera: Camera): number;
  48535. /**
  48536. * Gets the maxZ used for shadow according to both the scene and the light.
  48537. *
  48538. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48539. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48540. * @param activeCamera The camera we are returning the max for
  48541. * @returns the depth max z
  48542. */
  48543. getDepthMaxZ(activeCamera: Camera): number;
  48544. /**
  48545. * Prepares the list of defines specific to the light type.
  48546. * @param defines the list of defines
  48547. * @param lightIndex defines the index of the light for the effect
  48548. */
  48549. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48550. }
  48551. }
  48552. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48553. import { Mesh } from "babylonjs/Meshes/mesh";
  48554. /**
  48555. * Class containing static functions to help procedurally build meshes
  48556. */
  48557. export class HemisphereBuilder {
  48558. /**
  48559. * Creates a hemisphere mesh
  48560. * @param name defines the name of the mesh
  48561. * @param options defines the options used to create the mesh
  48562. * @param scene defines the hosting scene
  48563. * @returns the hemisphere mesh
  48564. */
  48565. static CreateHemisphere(name: string, options: {
  48566. segments?: number;
  48567. diameter?: number;
  48568. sideOrientation?: number;
  48569. }, scene: any): Mesh;
  48570. }
  48571. }
  48572. declare module "babylonjs/Lights/spotLight" {
  48573. import { Nullable } from "babylonjs/types";
  48574. import { Scene } from "babylonjs/scene";
  48575. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48577. import { Effect } from "babylonjs/Materials/effect";
  48578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48579. import { Light } from "babylonjs/Lights/light";
  48580. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48581. /**
  48582. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48583. * These values define a cone of light starting from the position, emitting toward the direction.
  48584. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48585. * and the exponent defines the speed of the decay of the light with distance (reach).
  48586. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48587. */
  48588. export class SpotLight extends ShadowLight {
  48589. private _angle;
  48590. private _innerAngle;
  48591. private _cosHalfAngle;
  48592. private _lightAngleScale;
  48593. private _lightAngleOffset;
  48594. /**
  48595. * Gets the cone angle of the spot light in Radians.
  48596. */
  48597. /**
  48598. * Sets the cone angle of the spot light in Radians.
  48599. */
  48600. angle: number;
  48601. /**
  48602. * Only used in gltf falloff mode, this defines the angle where
  48603. * the directional falloff will start before cutting at angle which could be seen
  48604. * as outer angle.
  48605. */
  48606. /**
  48607. * Only used in gltf falloff mode, this defines the angle where
  48608. * the directional falloff will start before cutting at angle which could be seen
  48609. * as outer angle.
  48610. */
  48611. innerAngle: number;
  48612. private _shadowAngleScale;
  48613. /**
  48614. * Allows scaling the angle of the light for shadow generation only.
  48615. */
  48616. /**
  48617. * Allows scaling the angle of the light for shadow generation only.
  48618. */
  48619. shadowAngleScale: number;
  48620. /**
  48621. * The light decay speed with the distance from the emission spot.
  48622. */
  48623. exponent: number;
  48624. private _projectionTextureMatrix;
  48625. /**
  48626. * Allows reading the projecton texture
  48627. */
  48628. readonly projectionTextureMatrix: Matrix;
  48629. protected _projectionTextureLightNear: number;
  48630. /**
  48631. * Gets the near clip of the Spotlight for texture projection.
  48632. */
  48633. /**
  48634. * Sets the near clip of the Spotlight for texture projection.
  48635. */
  48636. projectionTextureLightNear: number;
  48637. protected _projectionTextureLightFar: number;
  48638. /**
  48639. * Gets the far clip of the Spotlight for texture projection.
  48640. */
  48641. /**
  48642. * Sets the far clip of the Spotlight for texture projection.
  48643. */
  48644. projectionTextureLightFar: number;
  48645. protected _projectionTextureUpDirection: Vector3;
  48646. /**
  48647. * Gets the Up vector of the Spotlight for texture projection.
  48648. */
  48649. /**
  48650. * Sets the Up vector of the Spotlight for texture projection.
  48651. */
  48652. projectionTextureUpDirection: Vector3;
  48653. private _projectionTexture;
  48654. /**
  48655. * Gets the projection texture of the light.
  48656. */
  48657. /**
  48658. * Sets the projection texture of the light.
  48659. */
  48660. projectionTexture: Nullable<BaseTexture>;
  48661. private _projectionTextureViewLightDirty;
  48662. private _projectionTextureProjectionLightDirty;
  48663. private _projectionTextureDirty;
  48664. private _projectionTextureViewTargetVector;
  48665. private _projectionTextureViewLightMatrix;
  48666. private _projectionTextureProjectionLightMatrix;
  48667. private _projectionTextureScalingMatrix;
  48668. /**
  48669. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48670. * It can cast shadows.
  48671. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48672. * @param name The light friendly name
  48673. * @param position The position of the spot light in the scene
  48674. * @param direction The direction of the light in the scene
  48675. * @param angle The cone angle of the light in Radians
  48676. * @param exponent The light decay speed with the distance from the emission spot
  48677. * @param scene The scene the lights belongs to
  48678. */
  48679. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48680. /**
  48681. * Returns the string "SpotLight".
  48682. * @returns the class name
  48683. */
  48684. getClassName(): string;
  48685. /**
  48686. * Returns the integer 2.
  48687. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48688. */
  48689. getTypeID(): number;
  48690. /**
  48691. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48692. */
  48693. protected _setDirection(value: Vector3): void;
  48694. /**
  48695. * Overrides the position setter to recompute the projection texture view light Matrix.
  48696. */
  48697. protected _setPosition(value: Vector3): void;
  48698. /**
  48699. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  48700. * Returns the SpotLight.
  48701. */
  48702. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48703. protected _computeProjectionTextureViewLightMatrix(): void;
  48704. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48705. /**
  48706. * Main function for light texture projection matrix computing.
  48707. */
  48708. protected _computeProjectionTextureMatrix(): void;
  48709. protected _buildUniformLayout(): void;
  48710. private _computeAngleValues;
  48711. /**
  48712. * Sets the passed Effect "effect" with the Light textures.
  48713. * @param effect The effect to update
  48714. * @param lightIndex The index of the light in the effect to update
  48715. * @returns The light
  48716. */
  48717. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48718. /**
  48719. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48720. * @param effect The effect to update
  48721. * @param lightIndex The index of the light in the effect to update
  48722. * @returns The spot light
  48723. */
  48724. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48725. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48726. /**
  48727. * Disposes the light and the associated resources.
  48728. */
  48729. dispose(): void;
  48730. /**
  48731. * Prepares the list of defines specific to the light type.
  48732. * @param defines the list of defines
  48733. * @param lightIndex defines the index of the light for the effect
  48734. */
  48735. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48736. }
  48737. }
  48738. declare module "babylonjs/Gizmos/lightGizmo" {
  48739. import { Nullable } from "babylonjs/types";
  48740. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48741. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48742. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48743. import { Light } from "babylonjs/Lights/light";
  48744. /**
  48745. * Gizmo that enables viewing a light
  48746. */
  48747. export class LightGizmo extends Gizmo {
  48748. private _lightMesh;
  48749. private _material;
  48750. private _cachedPosition;
  48751. private _cachedForward;
  48752. private _attachedMeshParent;
  48753. /**
  48754. * Creates a LightGizmo
  48755. * @param gizmoLayer The utility layer the gizmo will be added to
  48756. */
  48757. constructor(gizmoLayer?: UtilityLayerRenderer);
  48758. private _light;
  48759. /**
  48760. * The light that the gizmo is attached to
  48761. */
  48762. light: Nullable<Light>;
  48763. /**
  48764. * Gets the material used to render the light gizmo
  48765. */
  48766. readonly material: StandardMaterial;
  48767. /**
  48768. * @hidden
  48769. * Updates the gizmo to match the attached mesh's position/rotation
  48770. */
  48771. protected _update(): void;
  48772. private static _Scale;
  48773. /**
  48774. * Creates the lines for a light mesh
  48775. */
  48776. private static _CreateLightLines;
  48777. /**
  48778. * Disposes of the light gizmo
  48779. */
  48780. dispose(): void;
  48781. private static _CreateHemisphericLightMesh;
  48782. private static _CreatePointLightMesh;
  48783. private static _CreateSpotLightMesh;
  48784. private static _CreateDirectionalLightMesh;
  48785. }
  48786. }
  48787. declare module "babylonjs/Gizmos/index" {
  48788. export * from "babylonjs/Gizmos/axisDragGizmo";
  48789. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48790. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48791. export * from "babylonjs/Gizmos/gizmo";
  48792. export * from "babylonjs/Gizmos/gizmoManager";
  48793. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48794. export * from "babylonjs/Gizmos/positionGizmo";
  48795. export * from "babylonjs/Gizmos/rotationGizmo";
  48796. export * from "babylonjs/Gizmos/scaleGizmo";
  48797. export * from "babylonjs/Gizmos/lightGizmo";
  48798. export * from "babylonjs/Gizmos/planeDragGizmo";
  48799. }
  48800. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48801. /** @hidden */
  48802. export var backgroundFragmentDeclaration: {
  48803. name: string;
  48804. shader: string;
  48805. };
  48806. }
  48807. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48808. /** @hidden */
  48809. export var backgroundUboDeclaration: {
  48810. name: string;
  48811. shader: string;
  48812. };
  48813. }
  48814. declare module "babylonjs/Shaders/background.fragment" {
  48815. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48816. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48817. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48818. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48819. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48820. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48821. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48822. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48823. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48824. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48825. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48826. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48827. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48828. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48829. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48830. /** @hidden */
  48831. export var backgroundPixelShader: {
  48832. name: string;
  48833. shader: string;
  48834. };
  48835. }
  48836. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48837. /** @hidden */
  48838. export var backgroundVertexDeclaration: {
  48839. name: string;
  48840. shader: string;
  48841. };
  48842. }
  48843. declare module "babylonjs/Shaders/background.vertex" {
  48844. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48845. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48846. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48847. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48848. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48849. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48850. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48851. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48852. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48853. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48854. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48855. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48856. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48857. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48858. /** @hidden */
  48859. export var backgroundVertexShader: {
  48860. name: string;
  48861. shader: string;
  48862. };
  48863. }
  48864. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48865. import { Nullable, int, float } from "babylonjs/types";
  48866. import { Scene } from "babylonjs/scene";
  48867. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48868. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48870. import { Mesh } from "babylonjs/Meshes/mesh";
  48871. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48872. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48873. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48874. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48875. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48876. import { Color3 } from "babylonjs/Maths/math.color";
  48877. import "babylonjs/Shaders/background.fragment";
  48878. import "babylonjs/Shaders/background.vertex";
  48879. /**
  48880. * Background material used to create an efficient environement around your scene.
  48881. */
  48882. export class BackgroundMaterial extends PushMaterial {
  48883. /**
  48884. * Standard reflectance value at parallel view angle.
  48885. */
  48886. static StandardReflectance0: number;
  48887. /**
  48888. * Standard reflectance value at grazing angle.
  48889. */
  48890. static StandardReflectance90: number;
  48891. protected _primaryColor: Color3;
  48892. /**
  48893. * Key light Color (multiply against the environement texture)
  48894. */
  48895. primaryColor: Color3;
  48896. protected __perceptualColor: Nullable<Color3>;
  48897. /**
  48898. * Experimental Internal Use Only.
  48899. *
  48900. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48901. * This acts as a helper to set the primary color to a more "human friendly" value.
  48902. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48903. * output color as close as possible from the chosen value.
  48904. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48905. * part of lighting setup.)
  48906. */
  48907. _perceptualColor: Nullable<Color3>;
  48908. protected _primaryColorShadowLevel: float;
  48909. /**
  48910. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48911. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48912. */
  48913. primaryColorShadowLevel: float;
  48914. protected _primaryColorHighlightLevel: float;
  48915. /**
  48916. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48917. * The primary color is used at the level chosen to define what the white area would look.
  48918. */
  48919. primaryColorHighlightLevel: float;
  48920. protected _reflectionTexture: Nullable<BaseTexture>;
  48921. /**
  48922. * Reflection Texture used in the material.
  48923. * Should be author in a specific way for the best result (refer to the documentation).
  48924. */
  48925. reflectionTexture: Nullable<BaseTexture>;
  48926. protected _reflectionBlur: float;
  48927. /**
  48928. * Reflection Texture level of blur.
  48929. *
  48930. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48931. * texture twice.
  48932. */
  48933. reflectionBlur: float;
  48934. protected _diffuseTexture: Nullable<BaseTexture>;
  48935. /**
  48936. * Diffuse Texture used in the material.
  48937. * Should be author in a specific way for the best result (refer to the documentation).
  48938. */
  48939. diffuseTexture: Nullable<BaseTexture>;
  48940. protected _shadowLights: Nullable<IShadowLight[]>;
  48941. /**
  48942. * Specify the list of lights casting shadow on the material.
  48943. * All scene shadow lights will be included if null.
  48944. */
  48945. shadowLights: Nullable<IShadowLight[]>;
  48946. protected _shadowLevel: float;
  48947. /**
  48948. * Helps adjusting the shadow to a softer level if required.
  48949. * 0 means black shadows and 1 means no shadows.
  48950. */
  48951. shadowLevel: float;
  48952. protected _sceneCenter: Vector3;
  48953. /**
  48954. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48955. * It is usually zero but might be interesting to modify according to your setup.
  48956. */
  48957. sceneCenter: Vector3;
  48958. protected _opacityFresnel: boolean;
  48959. /**
  48960. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48961. * This helps ensuring a nice transition when the camera goes under the ground.
  48962. */
  48963. opacityFresnel: boolean;
  48964. protected _reflectionFresnel: boolean;
  48965. /**
  48966. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48967. * This helps adding a mirror texture on the ground.
  48968. */
  48969. reflectionFresnel: boolean;
  48970. protected _reflectionFalloffDistance: number;
  48971. /**
  48972. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48973. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48974. */
  48975. reflectionFalloffDistance: number;
  48976. protected _reflectionAmount: number;
  48977. /**
  48978. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48979. */
  48980. reflectionAmount: number;
  48981. protected _reflectionReflectance0: number;
  48982. /**
  48983. * This specifies the weight of the reflection at grazing angle.
  48984. */
  48985. reflectionReflectance0: number;
  48986. protected _reflectionReflectance90: number;
  48987. /**
  48988. * This specifies the weight of the reflection at a perpendicular point of view.
  48989. */
  48990. reflectionReflectance90: number;
  48991. /**
  48992. * Sets the reflection reflectance fresnel values according to the default standard
  48993. * empirically know to work well :-)
  48994. */
  48995. reflectionStandardFresnelWeight: number;
  48996. protected _useRGBColor: boolean;
  48997. /**
  48998. * Helps to directly use the maps channels instead of their level.
  48999. */
  49000. useRGBColor: boolean;
  49001. protected _enableNoise: boolean;
  49002. /**
  49003. * This helps reducing the banding effect that could occur on the background.
  49004. */
  49005. enableNoise: boolean;
  49006. /**
  49007. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49008. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49009. * Recommended to be keep at 1.0 except for special cases.
  49010. */
  49011. fovMultiplier: number;
  49012. private _fovMultiplier;
  49013. /**
  49014. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49015. */
  49016. useEquirectangularFOV: boolean;
  49017. private _maxSimultaneousLights;
  49018. /**
  49019. * Number of Simultaneous lights allowed on the material.
  49020. */
  49021. maxSimultaneousLights: int;
  49022. /**
  49023. * Default configuration related to image processing available in the Background Material.
  49024. */
  49025. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49026. /**
  49027. * Keep track of the image processing observer to allow dispose and replace.
  49028. */
  49029. private _imageProcessingObserver;
  49030. /**
  49031. * Attaches a new image processing configuration to the PBR Material.
  49032. * @param configuration (if null the scene configuration will be use)
  49033. */
  49034. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49035. /**
  49036. * Gets the image processing configuration used either in this material.
  49037. */
  49038. /**
  49039. * Sets the Default image processing configuration used either in the this material.
  49040. *
  49041. * If sets to null, the scene one is in use.
  49042. */
  49043. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  49044. /**
  49045. * Gets wether the color curves effect is enabled.
  49046. */
  49047. /**
  49048. * Sets wether the color curves effect is enabled.
  49049. */
  49050. cameraColorCurvesEnabled: boolean;
  49051. /**
  49052. * Gets wether the color grading effect is enabled.
  49053. */
  49054. /**
  49055. * Gets wether the color grading effect is enabled.
  49056. */
  49057. cameraColorGradingEnabled: boolean;
  49058. /**
  49059. * Gets wether tonemapping is enabled or not.
  49060. */
  49061. /**
  49062. * Sets wether tonemapping is enabled or not
  49063. */
  49064. cameraToneMappingEnabled: boolean;
  49065. /**
  49066. * The camera exposure used on this material.
  49067. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49068. * This corresponds to a photographic exposure.
  49069. */
  49070. /**
  49071. * The camera exposure used on this material.
  49072. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49073. * This corresponds to a photographic exposure.
  49074. */
  49075. cameraExposure: float;
  49076. /**
  49077. * Gets The camera contrast used on this material.
  49078. */
  49079. /**
  49080. * Sets The camera contrast used on this material.
  49081. */
  49082. cameraContrast: float;
  49083. /**
  49084. * Gets the Color Grading 2D Lookup Texture.
  49085. */
  49086. /**
  49087. * Sets the Color Grading 2D Lookup Texture.
  49088. */
  49089. cameraColorGradingTexture: Nullable<BaseTexture>;
  49090. /**
  49091. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49092. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49093. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  49094. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49095. */
  49096. /**
  49097. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49098. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49099. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  49100. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49101. */
  49102. cameraColorCurves: Nullable<ColorCurves>;
  49103. /**
  49104. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49105. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49106. */
  49107. switchToBGR: boolean;
  49108. private _renderTargets;
  49109. private _reflectionControls;
  49110. private _white;
  49111. private _primaryShadowColor;
  49112. private _primaryHighlightColor;
  49113. /**
  49114. * Instantiates a Background Material in the given scene
  49115. * @param name The friendly name of the material
  49116. * @param scene The scene to add the material to
  49117. */
  49118. constructor(name: string, scene: Scene);
  49119. /**
  49120. * Gets a boolean indicating that current material needs to register RTT
  49121. */
  49122. readonly hasRenderTargetTextures: boolean;
  49123. /**
  49124. * The entire material has been created in order to prevent overdraw.
  49125. * @returns false
  49126. */
  49127. needAlphaTesting(): boolean;
  49128. /**
  49129. * The entire material has been created in order to prevent overdraw.
  49130. * @returns true if blending is enable
  49131. */
  49132. needAlphaBlending(): boolean;
  49133. /**
  49134. * Checks wether the material is ready to be rendered for a given mesh.
  49135. * @param mesh The mesh to render
  49136. * @param subMesh The submesh to check against
  49137. * @param useInstances Specify wether or not the material is used with instances
  49138. * @returns true if all the dependencies are ready (Textures, Effects...)
  49139. */
  49140. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49141. /**
  49142. * Compute the primary color according to the chosen perceptual color.
  49143. */
  49144. private _computePrimaryColorFromPerceptualColor;
  49145. /**
  49146. * Compute the highlights and shadow colors according to their chosen levels.
  49147. */
  49148. private _computePrimaryColors;
  49149. /**
  49150. * Build the uniform buffer used in the material.
  49151. */
  49152. buildUniformLayout(): void;
  49153. /**
  49154. * Unbind the material.
  49155. */
  49156. unbind(): void;
  49157. /**
  49158. * Bind only the world matrix to the material.
  49159. * @param world The world matrix to bind.
  49160. */
  49161. bindOnlyWorldMatrix(world: Matrix): void;
  49162. /**
  49163. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49164. * @param world The world matrix to bind.
  49165. * @param subMesh The submesh to bind for.
  49166. */
  49167. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49168. /**
  49169. * Checks to see if a texture is used in the material.
  49170. * @param texture - Base texture to use.
  49171. * @returns - Boolean specifying if a texture is used in the material.
  49172. */
  49173. hasTexture(texture: BaseTexture): boolean;
  49174. /**
  49175. * Dispose the material.
  49176. * @param forceDisposeEffect Force disposal of the associated effect.
  49177. * @param forceDisposeTextures Force disposal of the associated textures.
  49178. */
  49179. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49180. /**
  49181. * Clones the material.
  49182. * @param name The cloned name.
  49183. * @returns The cloned material.
  49184. */
  49185. clone(name: string): BackgroundMaterial;
  49186. /**
  49187. * Serializes the current material to its JSON representation.
  49188. * @returns The JSON representation.
  49189. */
  49190. serialize(): any;
  49191. /**
  49192. * Gets the class name of the material
  49193. * @returns "BackgroundMaterial"
  49194. */
  49195. getClassName(): string;
  49196. /**
  49197. * Parse a JSON input to create back a background material.
  49198. * @param source The JSON data to parse
  49199. * @param scene The scene to create the parsed material in
  49200. * @param rootUrl The root url of the assets the material depends upon
  49201. * @returns the instantiated BackgroundMaterial.
  49202. */
  49203. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49204. }
  49205. }
  49206. declare module "babylonjs/Helpers/environmentHelper" {
  49207. import { Observable } from "babylonjs/Misc/observable";
  49208. import { Nullable } from "babylonjs/types";
  49209. import { Scene } from "babylonjs/scene";
  49210. import { Vector3 } from "babylonjs/Maths/math.vector";
  49211. import { Color3 } from "babylonjs/Maths/math.color";
  49212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49213. import { Mesh } from "babylonjs/Meshes/mesh";
  49214. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49215. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  49216. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49217. import "babylonjs/Meshes/Builders/planeBuilder";
  49218. import "babylonjs/Meshes/Builders/boxBuilder";
  49219. /**
  49220. * Represents the different options available during the creation of
  49221. * a Environment helper.
  49222. *
  49223. * This can control the default ground, skybox and image processing setup of your scene.
  49224. */
  49225. export interface IEnvironmentHelperOptions {
  49226. /**
  49227. * Specifies wether or not to create a ground.
  49228. * True by default.
  49229. */
  49230. createGround: boolean;
  49231. /**
  49232. * Specifies the ground size.
  49233. * 15 by default.
  49234. */
  49235. groundSize: number;
  49236. /**
  49237. * The texture used on the ground for the main color.
  49238. * Comes from the BabylonJS CDN by default.
  49239. *
  49240. * Remarks: Can be either a texture or a url.
  49241. */
  49242. groundTexture: string | BaseTexture;
  49243. /**
  49244. * The color mixed in the ground texture by default.
  49245. * BabylonJS clearColor by default.
  49246. */
  49247. groundColor: Color3;
  49248. /**
  49249. * Specifies the ground opacity.
  49250. * 1 by default.
  49251. */
  49252. groundOpacity: number;
  49253. /**
  49254. * Enables the ground to receive shadows.
  49255. * True by default.
  49256. */
  49257. enableGroundShadow: boolean;
  49258. /**
  49259. * Helps preventing the shadow to be fully black on the ground.
  49260. * 0.5 by default.
  49261. */
  49262. groundShadowLevel: number;
  49263. /**
  49264. * Creates a mirror texture attach to the ground.
  49265. * false by default.
  49266. */
  49267. enableGroundMirror: boolean;
  49268. /**
  49269. * Specifies the ground mirror size ratio.
  49270. * 0.3 by default as the default kernel is 64.
  49271. */
  49272. groundMirrorSizeRatio: number;
  49273. /**
  49274. * Specifies the ground mirror blur kernel size.
  49275. * 64 by default.
  49276. */
  49277. groundMirrorBlurKernel: number;
  49278. /**
  49279. * Specifies the ground mirror visibility amount.
  49280. * 1 by default
  49281. */
  49282. groundMirrorAmount: number;
  49283. /**
  49284. * Specifies the ground mirror reflectance weight.
  49285. * This uses the standard weight of the background material to setup the fresnel effect
  49286. * of the mirror.
  49287. * 1 by default.
  49288. */
  49289. groundMirrorFresnelWeight: number;
  49290. /**
  49291. * Specifies the ground mirror Falloff distance.
  49292. * This can helps reducing the size of the reflection.
  49293. * 0 by Default.
  49294. */
  49295. groundMirrorFallOffDistance: number;
  49296. /**
  49297. * Specifies the ground mirror texture type.
  49298. * Unsigned Int by Default.
  49299. */
  49300. groundMirrorTextureType: number;
  49301. /**
  49302. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49303. * the shown objects.
  49304. */
  49305. groundYBias: number;
  49306. /**
  49307. * Specifies wether or not to create a skybox.
  49308. * True by default.
  49309. */
  49310. createSkybox: boolean;
  49311. /**
  49312. * Specifies the skybox size.
  49313. * 20 by default.
  49314. */
  49315. skyboxSize: number;
  49316. /**
  49317. * The texture used on the skybox for the main color.
  49318. * Comes from the BabylonJS CDN by default.
  49319. *
  49320. * Remarks: Can be either a texture or a url.
  49321. */
  49322. skyboxTexture: string | BaseTexture;
  49323. /**
  49324. * The color mixed in the skybox texture by default.
  49325. * BabylonJS clearColor by default.
  49326. */
  49327. skyboxColor: Color3;
  49328. /**
  49329. * The background rotation around the Y axis of the scene.
  49330. * This helps aligning the key lights of your scene with the background.
  49331. * 0 by default.
  49332. */
  49333. backgroundYRotation: number;
  49334. /**
  49335. * Compute automatically the size of the elements to best fit with the scene.
  49336. */
  49337. sizeAuto: boolean;
  49338. /**
  49339. * Default position of the rootMesh if autoSize is not true.
  49340. */
  49341. rootPosition: Vector3;
  49342. /**
  49343. * Sets up the image processing in the scene.
  49344. * true by default.
  49345. */
  49346. setupImageProcessing: boolean;
  49347. /**
  49348. * The texture used as your environment texture in the scene.
  49349. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49350. *
  49351. * Remarks: Can be either a texture or a url.
  49352. */
  49353. environmentTexture: string | BaseTexture;
  49354. /**
  49355. * The value of the exposure to apply to the scene.
  49356. * 0.6 by default if setupImageProcessing is true.
  49357. */
  49358. cameraExposure: number;
  49359. /**
  49360. * The value of the contrast to apply to the scene.
  49361. * 1.6 by default if setupImageProcessing is true.
  49362. */
  49363. cameraContrast: number;
  49364. /**
  49365. * Specifies wether or not tonemapping should be enabled in the scene.
  49366. * true by default if setupImageProcessing is true.
  49367. */
  49368. toneMappingEnabled: boolean;
  49369. }
  49370. /**
  49371. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49372. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49373. * It also helps with the default setup of your imageProcessing configuration.
  49374. */
  49375. export class EnvironmentHelper {
  49376. /**
  49377. * Default ground texture URL.
  49378. */
  49379. private static _groundTextureCDNUrl;
  49380. /**
  49381. * Default skybox texture URL.
  49382. */
  49383. private static _skyboxTextureCDNUrl;
  49384. /**
  49385. * Default environment texture URL.
  49386. */
  49387. private static _environmentTextureCDNUrl;
  49388. /**
  49389. * Creates the default options for the helper.
  49390. */
  49391. private static _getDefaultOptions;
  49392. private _rootMesh;
  49393. /**
  49394. * Gets the root mesh created by the helper.
  49395. */
  49396. readonly rootMesh: Mesh;
  49397. private _skybox;
  49398. /**
  49399. * Gets the skybox created by the helper.
  49400. */
  49401. readonly skybox: Nullable<Mesh>;
  49402. private _skyboxTexture;
  49403. /**
  49404. * Gets the skybox texture created by the helper.
  49405. */
  49406. readonly skyboxTexture: Nullable<BaseTexture>;
  49407. private _skyboxMaterial;
  49408. /**
  49409. * Gets the skybox material created by the helper.
  49410. */
  49411. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49412. private _ground;
  49413. /**
  49414. * Gets the ground mesh created by the helper.
  49415. */
  49416. readonly ground: Nullable<Mesh>;
  49417. private _groundTexture;
  49418. /**
  49419. * Gets the ground texture created by the helper.
  49420. */
  49421. readonly groundTexture: Nullable<BaseTexture>;
  49422. private _groundMirror;
  49423. /**
  49424. * Gets the ground mirror created by the helper.
  49425. */
  49426. readonly groundMirror: Nullable<MirrorTexture>;
  49427. /**
  49428. * Gets the ground mirror render list to helps pushing the meshes
  49429. * you wish in the ground reflection.
  49430. */
  49431. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49432. private _groundMaterial;
  49433. /**
  49434. * Gets the ground material created by the helper.
  49435. */
  49436. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49437. /**
  49438. * Stores the creation options.
  49439. */
  49440. private readonly _scene;
  49441. private _options;
  49442. /**
  49443. * This observable will be notified with any error during the creation of the environment,
  49444. * mainly texture creation errors.
  49445. */
  49446. onErrorObservable: Observable<{
  49447. message?: string;
  49448. exception?: any;
  49449. }>;
  49450. /**
  49451. * constructor
  49452. * @param options Defines the options we want to customize the helper
  49453. * @param scene The scene to add the material to
  49454. */
  49455. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49456. /**
  49457. * Updates the background according to the new options
  49458. * @param options
  49459. */
  49460. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49461. /**
  49462. * Sets the primary color of all the available elements.
  49463. * @param color the main color to affect to the ground and the background
  49464. */
  49465. setMainColor(color: Color3): void;
  49466. /**
  49467. * Setup the image processing according to the specified options.
  49468. */
  49469. private _setupImageProcessing;
  49470. /**
  49471. * Setup the environment texture according to the specified options.
  49472. */
  49473. private _setupEnvironmentTexture;
  49474. /**
  49475. * Setup the background according to the specified options.
  49476. */
  49477. private _setupBackground;
  49478. /**
  49479. * Get the scene sizes according to the setup.
  49480. */
  49481. private _getSceneSize;
  49482. /**
  49483. * Setup the ground according to the specified options.
  49484. */
  49485. private _setupGround;
  49486. /**
  49487. * Setup the ground material according to the specified options.
  49488. */
  49489. private _setupGroundMaterial;
  49490. /**
  49491. * Setup the ground diffuse texture according to the specified options.
  49492. */
  49493. private _setupGroundDiffuseTexture;
  49494. /**
  49495. * Setup the ground mirror texture according to the specified options.
  49496. */
  49497. private _setupGroundMirrorTexture;
  49498. /**
  49499. * Setup the ground to receive the mirror texture.
  49500. */
  49501. private _setupMirrorInGroundMaterial;
  49502. /**
  49503. * Setup the skybox according to the specified options.
  49504. */
  49505. private _setupSkybox;
  49506. /**
  49507. * Setup the skybox material according to the specified options.
  49508. */
  49509. private _setupSkyboxMaterial;
  49510. /**
  49511. * Setup the skybox reflection texture according to the specified options.
  49512. */
  49513. private _setupSkyboxReflectionTexture;
  49514. private _errorHandler;
  49515. /**
  49516. * Dispose all the elements created by the Helper.
  49517. */
  49518. dispose(): void;
  49519. }
  49520. }
  49521. declare module "babylonjs/Helpers/photoDome" {
  49522. import { Observable } from "babylonjs/Misc/observable";
  49523. import { Nullable } from "babylonjs/types";
  49524. import { Scene } from "babylonjs/scene";
  49525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49526. import { Mesh } from "babylonjs/Meshes/mesh";
  49527. import { Texture } from "babylonjs/Materials/Textures/texture";
  49528. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49529. import "babylonjs/Meshes/Builders/sphereBuilder";
  49530. /**
  49531. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49532. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49533. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49534. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49535. */
  49536. export class PhotoDome extends TransformNode {
  49537. /**
  49538. * Define the image as a Monoscopic panoramic 360 image.
  49539. */
  49540. static readonly MODE_MONOSCOPIC: number;
  49541. /**
  49542. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49543. */
  49544. static readonly MODE_TOPBOTTOM: number;
  49545. /**
  49546. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49547. */
  49548. static readonly MODE_SIDEBYSIDE: number;
  49549. private _useDirectMapping;
  49550. /**
  49551. * The texture being displayed on the sphere
  49552. */
  49553. protected _photoTexture: Texture;
  49554. /**
  49555. * Gets or sets the texture being displayed on the sphere
  49556. */
  49557. photoTexture: Texture;
  49558. /**
  49559. * Observable raised when an error occured while loading the 360 image
  49560. */
  49561. onLoadErrorObservable: Observable<string>;
  49562. /**
  49563. * The skybox material
  49564. */
  49565. protected _material: BackgroundMaterial;
  49566. /**
  49567. * The surface used for the skybox
  49568. */
  49569. protected _mesh: Mesh;
  49570. /**
  49571. * Gets the mesh used for the skybox.
  49572. */
  49573. readonly mesh: Mesh;
  49574. /**
  49575. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49576. * Also see the options.resolution property.
  49577. */
  49578. fovMultiplier: number;
  49579. private _imageMode;
  49580. /**
  49581. * Gets or set the current video mode for the video. It can be:
  49582. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49583. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49584. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49585. */
  49586. imageMode: number;
  49587. /**
  49588. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49589. * @param name Element's name, child elements will append suffixes for their own names.
  49590. * @param urlsOfPhoto defines the url of the photo to display
  49591. * @param options defines an object containing optional or exposed sub element properties
  49592. * @param onError defines a callback called when an error occured while loading the texture
  49593. */
  49594. constructor(name: string, urlOfPhoto: string, options: {
  49595. resolution?: number;
  49596. size?: number;
  49597. useDirectMapping?: boolean;
  49598. faceForward?: boolean;
  49599. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49600. private _onBeforeCameraRenderObserver;
  49601. private _changeImageMode;
  49602. /**
  49603. * Releases resources associated with this node.
  49604. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49605. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49606. */
  49607. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49608. }
  49609. }
  49610. declare module "babylonjs/Misc/rgbdTextureTools" {
  49611. import "babylonjs/Shaders/rgbdDecode.fragment";
  49612. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49613. import { Texture } from "babylonjs/Materials/Textures/texture";
  49614. /**
  49615. * Class used to host RGBD texture specific utilities
  49616. */
  49617. export class RGBDTextureTools {
  49618. /**
  49619. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49620. * @param texture the texture to expand.
  49621. */
  49622. static ExpandRGBDTexture(texture: Texture): void;
  49623. }
  49624. }
  49625. declare module "babylonjs/Misc/brdfTextureTools" {
  49626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49627. import { Scene } from "babylonjs/scene";
  49628. /**
  49629. * Class used to host texture specific utilities
  49630. */
  49631. export class BRDFTextureTools {
  49632. /**
  49633. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49634. * @param scene defines the hosting scene
  49635. * @returns the environment BRDF texture
  49636. */
  49637. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49638. private static _environmentBRDFBase64Texture;
  49639. }
  49640. }
  49641. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49642. import { Nullable } from "babylonjs/types";
  49643. import { Color3 } from "babylonjs/Maths/math.color";
  49644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49645. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49646. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49647. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49648. import { Engine } from "babylonjs/Engines/engine";
  49649. import { Scene } from "babylonjs/scene";
  49650. /**
  49651. * @hidden
  49652. */
  49653. export interface IMaterialClearCoatDefines {
  49654. CLEARCOAT: boolean;
  49655. CLEARCOAT_DEFAULTIOR: boolean;
  49656. CLEARCOAT_TEXTURE: boolean;
  49657. CLEARCOAT_TEXTUREDIRECTUV: number;
  49658. CLEARCOAT_BUMP: boolean;
  49659. CLEARCOAT_BUMPDIRECTUV: number;
  49660. CLEARCOAT_TINT: boolean;
  49661. CLEARCOAT_TINT_TEXTURE: boolean;
  49662. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49663. /** @hidden */
  49664. _areTexturesDirty: boolean;
  49665. }
  49666. /**
  49667. * Define the code related to the clear coat parameters of the pbr material.
  49668. */
  49669. export class PBRClearCoatConfiguration {
  49670. /**
  49671. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49672. * The default fits with a polyurethane material.
  49673. */
  49674. private static readonly _DefaultIndexOfRefraction;
  49675. private _isEnabled;
  49676. /**
  49677. * Defines if the clear coat is enabled in the material.
  49678. */
  49679. isEnabled: boolean;
  49680. /**
  49681. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49682. */
  49683. intensity: number;
  49684. /**
  49685. * Defines the clear coat layer roughness.
  49686. */
  49687. roughness: number;
  49688. private _indexOfRefraction;
  49689. /**
  49690. * Defines the index of refraction of the clear coat.
  49691. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49692. * The default fits with a polyurethane material.
  49693. * Changing the default value is more performance intensive.
  49694. */
  49695. indexOfRefraction: number;
  49696. private _texture;
  49697. /**
  49698. * Stores the clear coat values in a texture.
  49699. */
  49700. texture: Nullable<BaseTexture>;
  49701. private _bumpTexture;
  49702. /**
  49703. * Define the clear coat specific bump texture.
  49704. */
  49705. bumpTexture: Nullable<BaseTexture>;
  49706. private _isTintEnabled;
  49707. /**
  49708. * Defines if the clear coat tint is enabled in the material.
  49709. */
  49710. isTintEnabled: boolean;
  49711. /**
  49712. * Defines the clear coat tint of the material.
  49713. * This is only use if tint is enabled
  49714. */
  49715. tintColor: Color3;
  49716. /**
  49717. * Defines the distance at which the tint color should be found in the
  49718. * clear coat media.
  49719. * This is only use if tint is enabled
  49720. */
  49721. tintColorAtDistance: number;
  49722. /**
  49723. * Defines the clear coat layer thickness.
  49724. * This is only use if tint is enabled
  49725. */
  49726. tintThickness: number;
  49727. private _tintTexture;
  49728. /**
  49729. * Stores the clear tint values in a texture.
  49730. * rgb is tint
  49731. * a is a thickness factor
  49732. */
  49733. tintTexture: Nullable<BaseTexture>;
  49734. /** @hidden */
  49735. private _internalMarkAllSubMeshesAsTexturesDirty;
  49736. /** @hidden */
  49737. _markAllSubMeshesAsTexturesDirty(): void;
  49738. /**
  49739. * Instantiate a new istance of clear coat configuration.
  49740. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49741. */
  49742. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49743. /**
  49744. * Gets wehter the submesh is ready to be used or not.
  49745. * @param defines the list of "defines" to update.
  49746. * @param scene defines the scene the material belongs to.
  49747. * @param engine defines the engine the material belongs to.
  49748. * @param disableBumpMap defines wether the material disables bump or not.
  49749. * @returns - boolean indicating that the submesh is ready or not.
  49750. */
  49751. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49752. /**
  49753. * Checks to see if a texture is used in the material.
  49754. * @param defines the list of "defines" to update.
  49755. * @param scene defines the scene to the material belongs to.
  49756. */
  49757. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49758. /**
  49759. * Binds the material data.
  49760. * @param uniformBuffer defines the Uniform buffer to fill in.
  49761. * @param scene defines the scene the material belongs to.
  49762. * @param engine defines the engine the material belongs to.
  49763. * @param disableBumpMap defines wether the material disables bump or not.
  49764. * @param isFrozen defines wether the material is frozen or not.
  49765. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49766. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49767. */
  49768. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49769. /**
  49770. * Checks to see if a texture is used in the material.
  49771. * @param texture - Base texture to use.
  49772. * @returns - Boolean specifying if a texture is used in the material.
  49773. */
  49774. hasTexture(texture: BaseTexture): boolean;
  49775. /**
  49776. * Returns an array of the actively used textures.
  49777. * @param activeTextures Array of BaseTextures
  49778. */
  49779. getActiveTextures(activeTextures: BaseTexture[]): void;
  49780. /**
  49781. * Returns the animatable textures.
  49782. * @param animatables Array of animatable textures.
  49783. */
  49784. getAnimatables(animatables: IAnimatable[]): void;
  49785. /**
  49786. * Disposes the resources of the material.
  49787. * @param forceDisposeTextures - Forces the disposal of all textures.
  49788. */
  49789. dispose(forceDisposeTextures?: boolean): void;
  49790. /**
  49791. * Get the current class name of the texture useful for serialization or dynamic coding.
  49792. * @returns "PBRClearCoatConfiguration"
  49793. */
  49794. getClassName(): string;
  49795. /**
  49796. * Add fallbacks to the effect fallbacks list.
  49797. * @param defines defines the Base texture to use.
  49798. * @param fallbacks defines the current fallback list.
  49799. * @param currentRank defines the current fallback rank.
  49800. * @returns the new fallback rank.
  49801. */
  49802. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49803. /**
  49804. * Add the required uniforms to the current list.
  49805. * @param uniforms defines the current uniform list.
  49806. */
  49807. static AddUniforms(uniforms: string[]): void;
  49808. /**
  49809. * Add the required samplers to the current list.
  49810. * @param samplers defines the current sampler list.
  49811. */
  49812. static AddSamplers(samplers: string[]): void;
  49813. /**
  49814. * Add the required uniforms to the current buffer.
  49815. * @param uniformBuffer defines the current uniform buffer.
  49816. */
  49817. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49818. /**
  49819. * Makes a duplicate of the current configuration into another one.
  49820. * @param clearCoatConfiguration define the config where to copy the info
  49821. */
  49822. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49823. /**
  49824. * Serializes this clear coat configuration.
  49825. * @returns - An object with the serialized config.
  49826. */
  49827. serialize(): any;
  49828. /**
  49829. * Parses a anisotropy Configuration from a serialized object.
  49830. * @param source - Serialized object.
  49831. * @param scene Defines the scene we are parsing for
  49832. * @param rootUrl Defines the rootUrl to load from
  49833. */
  49834. parse(source: any, scene: Scene, rootUrl: string): void;
  49835. }
  49836. }
  49837. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49838. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49840. import { Vector2 } from "babylonjs/Maths/math.vector";
  49841. import { Scene } from "babylonjs/scene";
  49842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49843. import { Nullable } from "babylonjs/types";
  49844. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49845. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49846. /**
  49847. * @hidden
  49848. */
  49849. export interface IMaterialAnisotropicDefines {
  49850. ANISOTROPIC: boolean;
  49851. ANISOTROPIC_TEXTURE: boolean;
  49852. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49853. MAINUV1: boolean;
  49854. _areTexturesDirty: boolean;
  49855. _needUVs: boolean;
  49856. }
  49857. /**
  49858. * Define the code related to the anisotropic parameters of the pbr material.
  49859. */
  49860. export class PBRAnisotropicConfiguration {
  49861. private _isEnabled;
  49862. /**
  49863. * Defines if the anisotropy is enabled in the material.
  49864. */
  49865. isEnabled: boolean;
  49866. /**
  49867. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49868. */
  49869. intensity: number;
  49870. /**
  49871. * Defines if the effect is along the tangents, bitangents or in between.
  49872. * By default, the effect is "strectching" the highlights along the tangents.
  49873. */
  49874. direction: Vector2;
  49875. private _texture;
  49876. /**
  49877. * Stores the anisotropy values in a texture.
  49878. * rg is direction (like normal from -1 to 1)
  49879. * b is a intensity
  49880. */
  49881. texture: Nullable<BaseTexture>;
  49882. /** @hidden */
  49883. private _internalMarkAllSubMeshesAsTexturesDirty;
  49884. /** @hidden */
  49885. _markAllSubMeshesAsTexturesDirty(): void;
  49886. /**
  49887. * Instantiate a new istance of anisotropy configuration.
  49888. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49889. */
  49890. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49891. /**
  49892. * Specifies that the submesh is ready to be used.
  49893. * @param defines the list of "defines" to update.
  49894. * @param scene defines the scene the material belongs to.
  49895. * @returns - boolean indicating that the submesh is ready or not.
  49896. */
  49897. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49898. /**
  49899. * Checks to see if a texture is used in the material.
  49900. * @param defines the list of "defines" to update.
  49901. * @param mesh the mesh we are preparing the defines for.
  49902. * @param scene defines the scene the material belongs to.
  49903. */
  49904. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49905. /**
  49906. * Binds the material data.
  49907. * @param uniformBuffer defines the Uniform buffer to fill in.
  49908. * @param scene defines the scene the material belongs to.
  49909. * @param isFrozen defines wether the material is frozen or not.
  49910. */
  49911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49912. /**
  49913. * Checks to see if a texture is used in the material.
  49914. * @param texture - Base texture to use.
  49915. * @returns - Boolean specifying if a texture is used in the material.
  49916. */
  49917. hasTexture(texture: BaseTexture): boolean;
  49918. /**
  49919. * Returns an array of the actively used textures.
  49920. * @param activeTextures Array of BaseTextures
  49921. */
  49922. getActiveTextures(activeTextures: BaseTexture[]): void;
  49923. /**
  49924. * Returns the animatable textures.
  49925. * @param animatables Array of animatable textures.
  49926. */
  49927. getAnimatables(animatables: IAnimatable[]): void;
  49928. /**
  49929. * Disposes the resources of the material.
  49930. * @param forceDisposeTextures - Forces the disposal of all textures.
  49931. */
  49932. dispose(forceDisposeTextures?: boolean): void;
  49933. /**
  49934. * Get the current class name of the texture useful for serialization or dynamic coding.
  49935. * @returns "PBRAnisotropicConfiguration"
  49936. */
  49937. getClassName(): string;
  49938. /**
  49939. * Add fallbacks to the effect fallbacks list.
  49940. * @param defines defines the Base texture to use.
  49941. * @param fallbacks defines the current fallback list.
  49942. * @param currentRank defines the current fallback rank.
  49943. * @returns the new fallback rank.
  49944. */
  49945. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49946. /**
  49947. * Add the required uniforms to the current list.
  49948. * @param uniforms defines the current uniform list.
  49949. */
  49950. static AddUniforms(uniforms: string[]): void;
  49951. /**
  49952. * Add the required uniforms to the current buffer.
  49953. * @param uniformBuffer defines the current uniform buffer.
  49954. */
  49955. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49956. /**
  49957. * Add the required samplers to the current list.
  49958. * @param samplers defines the current sampler list.
  49959. */
  49960. static AddSamplers(samplers: string[]): void;
  49961. /**
  49962. * Makes a duplicate of the current configuration into another one.
  49963. * @param anisotropicConfiguration define the config where to copy the info
  49964. */
  49965. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49966. /**
  49967. * Serializes this anisotropy configuration.
  49968. * @returns - An object with the serialized config.
  49969. */
  49970. serialize(): any;
  49971. /**
  49972. * Parses a anisotropy Configuration from a serialized object.
  49973. * @param source - Serialized object.
  49974. * @param scene Defines the scene we are parsing for
  49975. * @param rootUrl Defines the rootUrl to load from
  49976. */
  49977. parse(source: any, scene: Scene, rootUrl: string): void;
  49978. }
  49979. }
  49980. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49981. import { Scene } from "babylonjs/scene";
  49982. /**
  49983. * @hidden
  49984. */
  49985. export interface IMaterialBRDFDefines {
  49986. BRDF_V_HEIGHT_CORRELATED: boolean;
  49987. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49988. SPHERICAL_HARMONICS: boolean;
  49989. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49990. /** @hidden */
  49991. _areMiscDirty: boolean;
  49992. }
  49993. /**
  49994. * Define the code related to the BRDF parameters of the pbr material.
  49995. */
  49996. export class PBRBRDFConfiguration {
  49997. /**
  49998. * Default value used for the energy conservation.
  49999. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50000. */
  50001. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50002. /**
  50003. * Default value used for the Smith Visibility Height Correlated mode.
  50004. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50005. */
  50006. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50007. /**
  50008. * Default value used for the IBL diffuse part.
  50009. * This can help switching back to the polynomials mode globally which is a tiny bit
  50010. * less GPU intensive at the drawback of a lower quality.
  50011. */
  50012. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50013. /**
  50014. * Default value used for activating energy conservation for the specular workflow.
  50015. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50016. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50017. */
  50018. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50019. private _useEnergyConservation;
  50020. /**
  50021. * Defines if the material uses energy conservation.
  50022. */
  50023. useEnergyConservation: boolean;
  50024. private _useSmithVisibilityHeightCorrelated;
  50025. /**
  50026. * LEGACY Mode set to false
  50027. * Defines if the material uses height smith correlated visibility term.
  50028. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50029. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50030. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50031. * Not relying on height correlated will also disable energy conservation.
  50032. */
  50033. useSmithVisibilityHeightCorrelated: boolean;
  50034. private _useSphericalHarmonics;
  50035. /**
  50036. * LEGACY Mode set to false
  50037. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50038. * diffuse part of the IBL.
  50039. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50040. * to the ground truth.
  50041. */
  50042. useSphericalHarmonics: boolean;
  50043. private _useSpecularGlossinessInputEnergyConservation;
  50044. /**
  50045. * Defines if the material uses energy conservation, when the specular workflow is active.
  50046. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50047. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50048. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50049. */
  50050. useSpecularGlossinessInputEnergyConservation: boolean;
  50051. /** @hidden */
  50052. private _internalMarkAllSubMeshesAsMiscDirty;
  50053. /** @hidden */
  50054. _markAllSubMeshesAsMiscDirty(): void;
  50055. /**
  50056. * Instantiate a new istance of clear coat configuration.
  50057. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50058. */
  50059. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50060. /**
  50061. * Checks to see if a texture is used in the material.
  50062. * @param defines the list of "defines" to update.
  50063. */
  50064. prepareDefines(defines: IMaterialBRDFDefines): void;
  50065. /**
  50066. * Get the current class name of the texture useful for serialization or dynamic coding.
  50067. * @returns "PBRClearCoatConfiguration"
  50068. */
  50069. getClassName(): string;
  50070. /**
  50071. * Makes a duplicate of the current configuration into another one.
  50072. * @param brdfConfiguration define the config where to copy the info
  50073. */
  50074. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50075. /**
  50076. * Serializes this BRDF configuration.
  50077. * @returns - An object with the serialized config.
  50078. */
  50079. serialize(): any;
  50080. /**
  50081. * Parses a anisotropy Configuration from a serialized object.
  50082. * @param source - Serialized object.
  50083. * @param scene Defines the scene we are parsing for
  50084. * @param rootUrl Defines the rootUrl to load from
  50085. */
  50086. parse(source: any, scene: Scene, rootUrl: string): void;
  50087. }
  50088. }
  50089. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  50090. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50091. import { Color3 } from "babylonjs/Maths/math.color";
  50092. import { Scene } from "babylonjs/scene";
  50093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50094. import { Nullable } from "babylonjs/types";
  50095. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50096. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50097. /**
  50098. * @hidden
  50099. */
  50100. export interface IMaterialSheenDefines {
  50101. SHEEN: boolean;
  50102. SHEEN_TEXTURE: boolean;
  50103. SHEEN_TEXTUREDIRECTUV: number;
  50104. SHEEN_LINKWITHALBEDO: boolean;
  50105. /** @hidden */
  50106. _areTexturesDirty: boolean;
  50107. }
  50108. /**
  50109. * Define the code related to the Sheen parameters of the pbr material.
  50110. */
  50111. export class PBRSheenConfiguration {
  50112. private _isEnabled;
  50113. /**
  50114. * Defines if the material uses sheen.
  50115. */
  50116. isEnabled: boolean;
  50117. private _linkSheenWithAlbedo;
  50118. /**
  50119. * Defines if the sheen is linked to the sheen color.
  50120. */
  50121. linkSheenWithAlbedo: boolean;
  50122. /**
  50123. * Defines the sheen intensity.
  50124. */
  50125. intensity: number;
  50126. /**
  50127. * Defines the sheen color.
  50128. */
  50129. color: Color3;
  50130. private _texture;
  50131. /**
  50132. * Stores the sheen tint values in a texture.
  50133. * rgb is tint
  50134. * a is a intensity
  50135. */
  50136. texture: Nullable<BaseTexture>;
  50137. /** @hidden */
  50138. private _internalMarkAllSubMeshesAsTexturesDirty;
  50139. /** @hidden */
  50140. _markAllSubMeshesAsTexturesDirty(): void;
  50141. /**
  50142. * Instantiate a new istance of clear coat configuration.
  50143. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50144. */
  50145. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50146. /**
  50147. * Specifies that the submesh is ready to be used.
  50148. * @param defines the list of "defines" to update.
  50149. * @param scene defines the scene the material belongs to.
  50150. * @returns - boolean indicating that the submesh is ready or not.
  50151. */
  50152. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50153. /**
  50154. * Checks to see if a texture is used in the material.
  50155. * @param defines the list of "defines" to update.
  50156. * @param scene defines the scene the material belongs to.
  50157. */
  50158. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50159. /**
  50160. * Binds the material data.
  50161. * @param uniformBuffer defines the Uniform buffer to fill in.
  50162. * @param scene defines the scene the material belongs to.
  50163. * @param isFrozen defines wether the material is frozen or not.
  50164. */
  50165. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50166. /**
  50167. * Checks to see if a texture is used in the material.
  50168. * @param texture - Base texture to use.
  50169. * @returns - Boolean specifying if a texture is used in the material.
  50170. */
  50171. hasTexture(texture: BaseTexture): boolean;
  50172. /**
  50173. * Returns an array of the actively used textures.
  50174. * @param activeTextures Array of BaseTextures
  50175. */
  50176. getActiveTextures(activeTextures: BaseTexture[]): void;
  50177. /**
  50178. * Returns the animatable textures.
  50179. * @param animatables Array of animatable textures.
  50180. */
  50181. getAnimatables(animatables: IAnimatable[]): void;
  50182. /**
  50183. * Disposes the resources of the material.
  50184. * @param forceDisposeTextures - Forces the disposal of all textures.
  50185. */
  50186. dispose(forceDisposeTextures?: boolean): void;
  50187. /**
  50188. * Get the current class name of the texture useful for serialization or dynamic coding.
  50189. * @returns "PBRSheenConfiguration"
  50190. */
  50191. getClassName(): string;
  50192. /**
  50193. * Add fallbacks to the effect fallbacks list.
  50194. * @param defines defines the Base texture to use.
  50195. * @param fallbacks defines the current fallback list.
  50196. * @param currentRank defines the current fallback rank.
  50197. * @returns the new fallback rank.
  50198. */
  50199. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50200. /**
  50201. * Add the required uniforms to the current list.
  50202. * @param uniforms defines the current uniform list.
  50203. */
  50204. static AddUniforms(uniforms: string[]): void;
  50205. /**
  50206. * Add the required uniforms to the current buffer.
  50207. * @param uniformBuffer defines the current uniform buffer.
  50208. */
  50209. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50210. /**
  50211. * Add the required samplers to the current list.
  50212. * @param samplers defines the current sampler list.
  50213. */
  50214. static AddSamplers(samplers: string[]): void;
  50215. /**
  50216. * Makes a duplicate of the current configuration into another one.
  50217. * @param sheenConfiguration define the config where to copy the info
  50218. */
  50219. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50220. /**
  50221. * Serializes this BRDF configuration.
  50222. * @returns - An object with the serialized config.
  50223. */
  50224. serialize(): any;
  50225. /**
  50226. * Parses a anisotropy Configuration from a serialized object.
  50227. * @param source - Serialized object.
  50228. * @param scene Defines the scene we are parsing for
  50229. * @param rootUrl Defines the rootUrl to load from
  50230. */
  50231. parse(source: any, scene: Scene, rootUrl: string): void;
  50232. }
  50233. }
  50234. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  50235. import { Nullable } from "babylonjs/types";
  50236. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50237. import { Color3 } from "babylonjs/Maths/math.color";
  50238. import { SmartArray } from "babylonjs/Misc/smartArray";
  50239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50240. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50241. import { Effect } from "babylonjs/Materials/effect";
  50242. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50243. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50244. import { Engine } from "babylonjs/Engines/engine";
  50245. import { Scene } from "babylonjs/scene";
  50246. /**
  50247. * @hidden
  50248. */
  50249. export interface IMaterialSubSurfaceDefines {
  50250. SUBSURFACE: boolean;
  50251. SS_REFRACTION: boolean;
  50252. SS_TRANSLUCENCY: boolean;
  50253. SS_SCATERRING: boolean;
  50254. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50255. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50256. SS_REFRACTIONMAP_3D: boolean;
  50257. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50258. SS_LODINREFRACTIONALPHA: boolean;
  50259. SS_GAMMAREFRACTION: boolean;
  50260. SS_RGBDREFRACTION: boolean;
  50261. SS_LINEARSPECULARREFRACTION: boolean;
  50262. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50263. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50264. /** @hidden */
  50265. _areTexturesDirty: boolean;
  50266. }
  50267. /**
  50268. * Define the code related to the sub surface parameters of the pbr material.
  50269. */
  50270. export class PBRSubSurfaceConfiguration {
  50271. private _isRefractionEnabled;
  50272. /**
  50273. * Defines if the refraction is enabled in the material.
  50274. */
  50275. isRefractionEnabled: boolean;
  50276. private _isTranslucencyEnabled;
  50277. /**
  50278. * Defines if the translucency is enabled in the material.
  50279. */
  50280. isTranslucencyEnabled: boolean;
  50281. private _isScatteringEnabled;
  50282. /**
  50283. * Defines the refraction intensity of the material.
  50284. * The refraction when enabled replaces the Diffuse part of the material.
  50285. * The intensity helps transitionning between diffuse and refraction.
  50286. */
  50287. refractionIntensity: number;
  50288. /**
  50289. * Defines the translucency intensity of the material.
  50290. * When translucency has been enabled, this defines how much of the "translucency"
  50291. * is addded to the diffuse part of the material.
  50292. */
  50293. translucencyIntensity: number;
  50294. /**
  50295. * Defines the scattering intensity of the material.
  50296. * When scattering has been enabled, this defines how much of the "scattered light"
  50297. * is addded to the diffuse part of the material.
  50298. */
  50299. scatteringIntensity: number;
  50300. private _thicknessTexture;
  50301. /**
  50302. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50303. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50304. * 0 would mean minimumThickness
  50305. * 1 would mean maximumThickness
  50306. * The other channels might be use as a mask to vary the different effects intensity.
  50307. */
  50308. thicknessTexture: Nullable<BaseTexture>;
  50309. private _refractionTexture;
  50310. /**
  50311. * Defines the texture to use for refraction.
  50312. */
  50313. refractionTexture: Nullable<BaseTexture>;
  50314. private _indexOfRefraction;
  50315. /**
  50316. * Defines the index of refraction used in the material.
  50317. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50318. */
  50319. indexOfRefraction: number;
  50320. private _invertRefractionY;
  50321. /**
  50322. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50323. */
  50324. invertRefractionY: boolean;
  50325. private _linkRefractionWithTransparency;
  50326. /**
  50327. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50328. * Materials half opaque for instance using refraction could benefit from this control.
  50329. */
  50330. linkRefractionWithTransparency: boolean;
  50331. /**
  50332. * Defines the minimum thickness stored in the thickness map.
  50333. * If no thickness map is defined, this value will be used to simulate thickness.
  50334. */
  50335. minimumThickness: number;
  50336. /**
  50337. * Defines the maximum thickness stored in the thickness map.
  50338. */
  50339. maximumThickness: number;
  50340. /**
  50341. * Defines the volume tint of the material.
  50342. * This is used for both translucency and scattering.
  50343. */
  50344. tintColor: Color3;
  50345. /**
  50346. * Defines the distance at which the tint color should be found in the media.
  50347. * This is used for refraction only.
  50348. */
  50349. tintColorAtDistance: number;
  50350. /**
  50351. * Defines how far each channel transmit through the media.
  50352. * It is defined as a color to simplify it selection.
  50353. */
  50354. diffusionDistance: Color3;
  50355. private _useMaskFromThicknessTexture;
  50356. /**
  50357. * Stores the intensity of the different subsurface effects in the thickness texture.
  50358. * * the green channel is the translucency intensity.
  50359. * * the blue channel is the scattering intensity.
  50360. * * the alpha channel is the refraction intensity.
  50361. */
  50362. useMaskFromThicknessTexture: boolean;
  50363. /** @hidden */
  50364. private _internalMarkAllSubMeshesAsTexturesDirty;
  50365. /** @hidden */
  50366. _markAllSubMeshesAsTexturesDirty(): void;
  50367. /**
  50368. * Instantiate a new istance of sub surface configuration.
  50369. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50370. */
  50371. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50372. /**
  50373. * Gets wehter the submesh is ready to be used or not.
  50374. * @param defines the list of "defines" to update.
  50375. * @param scene defines the scene the material belongs to.
  50376. * @returns - boolean indicating that the submesh is ready or not.
  50377. */
  50378. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50379. /**
  50380. * Checks to see if a texture is used in the material.
  50381. * @param defines the list of "defines" to update.
  50382. * @param scene defines the scene to the material belongs to.
  50383. */
  50384. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50385. /**
  50386. * Binds the material data.
  50387. * @param uniformBuffer defines the Uniform buffer to fill in.
  50388. * @param scene defines the scene the material belongs to.
  50389. * @param engine defines the engine the material belongs to.
  50390. * @param isFrozen defines wether the material is frozen or not.
  50391. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50392. */
  50393. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50394. /**
  50395. * Unbinds the material from the mesh.
  50396. * @param activeEffect defines the effect that should be unbound from.
  50397. * @returns true if unbound, otherwise false
  50398. */
  50399. unbind(activeEffect: Effect): boolean;
  50400. /**
  50401. * Returns the texture used for refraction or null if none is used.
  50402. * @param scene defines the scene the material belongs to.
  50403. * @returns - Refraction texture if present. If no refraction texture and refraction
  50404. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50405. */
  50406. private _getRefractionTexture;
  50407. /**
  50408. * Returns true if alpha blending should be disabled.
  50409. */
  50410. readonly disableAlphaBlending: boolean;
  50411. /**
  50412. * Fills the list of render target textures.
  50413. * @param renderTargets the list of render targets to update
  50414. */
  50415. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50416. /**
  50417. * Checks to see if a texture is used in the material.
  50418. * @param texture - Base texture to use.
  50419. * @returns - Boolean specifying if a texture is used in the material.
  50420. */
  50421. hasTexture(texture: BaseTexture): boolean;
  50422. /**
  50423. * Gets a boolean indicating that current material needs to register RTT
  50424. * @returns true if this uses a render target otherwise false.
  50425. */
  50426. hasRenderTargetTextures(): boolean;
  50427. /**
  50428. * Returns an array of the actively used textures.
  50429. * @param activeTextures Array of BaseTextures
  50430. */
  50431. getActiveTextures(activeTextures: BaseTexture[]): void;
  50432. /**
  50433. * Returns the animatable textures.
  50434. * @param animatables Array of animatable textures.
  50435. */
  50436. getAnimatables(animatables: IAnimatable[]): void;
  50437. /**
  50438. * Disposes the resources of the material.
  50439. * @param forceDisposeTextures - Forces the disposal of all textures.
  50440. */
  50441. dispose(forceDisposeTextures?: boolean): void;
  50442. /**
  50443. * Get the current class name of the texture useful for serialization or dynamic coding.
  50444. * @returns "PBRSubSurfaceConfiguration"
  50445. */
  50446. getClassName(): string;
  50447. /**
  50448. * Add fallbacks to the effect fallbacks list.
  50449. * @param defines defines the Base texture to use.
  50450. * @param fallbacks defines the current fallback list.
  50451. * @param currentRank defines the current fallback rank.
  50452. * @returns the new fallback rank.
  50453. */
  50454. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50455. /**
  50456. * Add the required uniforms to the current list.
  50457. * @param uniforms defines the current uniform list.
  50458. */
  50459. static AddUniforms(uniforms: string[]): void;
  50460. /**
  50461. * Add the required samplers to the current list.
  50462. * @param samplers defines the current sampler list.
  50463. */
  50464. static AddSamplers(samplers: string[]): void;
  50465. /**
  50466. * Add the required uniforms to the current buffer.
  50467. * @param uniformBuffer defines the current uniform buffer.
  50468. */
  50469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50470. /**
  50471. * Makes a duplicate of the current configuration into another one.
  50472. * @param configuration define the config where to copy the info
  50473. */
  50474. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50475. /**
  50476. * Serializes this Sub Surface configuration.
  50477. * @returns - An object with the serialized config.
  50478. */
  50479. serialize(): any;
  50480. /**
  50481. * Parses a anisotropy Configuration from a serialized object.
  50482. * @param source - Serialized object.
  50483. * @param scene Defines the scene we are parsing for
  50484. * @param rootUrl Defines the rootUrl to load from
  50485. */
  50486. parse(source: any, scene: Scene, rootUrl: string): void;
  50487. }
  50488. }
  50489. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50490. /** @hidden */
  50491. export var pbrFragmentDeclaration: {
  50492. name: string;
  50493. shader: string;
  50494. };
  50495. }
  50496. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50497. /** @hidden */
  50498. export var pbrUboDeclaration: {
  50499. name: string;
  50500. shader: string;
  50501. };
  50502. }
  50503. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50504. /** @hidden */
  50505. export var pbrFragmentExtraDeclaration: {
  50506. name: string;
  50507. shader: string;
  50508. };
  50509. }
  50510. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50511. /** @hidden */
  50512. export var pbrFragmentSamplersDeclaration: {
  50513. name: string;
  50514. shader: string;
  50515. };
  50516. }
  50517. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50518. /** @hidden */
  50519. export var pbrHelperFunctions: {
  50520. name: string;
  50521. shader: string;
  50522. };
  50523. }
  50524. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50525. /** @hidden */
  50526. export var harmonicsFunctions: {
  50527. name: string;
  50528. shader: string;
  50529. };
  50530. }
  50531. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50532. /** @hidden */
  50533. export var pbrDirectLightingSetupFunctions: {
  50534. name: string;
  50535. shader: string;
  50536. };
  50537. }
  50538. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50539. /** @hidden */
  50540. export var pbrDirectLightingFalloffFunctions: {
  50541. name: string;
  50542. shader: string;
  50543. };
  50544. }
  50545. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50546. /** @hidden */
  50547. export var pbrBRDFFunctions: {
  50548. name: string;
  50549. shader: string;
  50550. };
  50551. }
  50552. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50553. /** @hidden */
  50554. export var pbrDirectLightingFunctions: {
  50555. name: string;
  50556. shader: string;
  50557. };
  50558. }
  50559. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50560. /** @hidden */
  50561. export var pbrIBLFunctions: {
  50562. name: string;
  50563. shader: string;
  50564. };
  50565. }
  50566. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50567. /** @hidden */
  50568. export var pbrDebug: {
  50569. name: string;
  50570. shader: string;
  50571. };
  50572. }
  50573. declare module "babylonjs/Shaders/pbr.fragment" {
  50574. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50575. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50576. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50577. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50578. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50579. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50580. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50581. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50582. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50583. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50584. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50585. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50586. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50587. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50588. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50589. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50590. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50591. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50592. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50593. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50594. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50595. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50596. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50597. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50598. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50599. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50600. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50601. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50602. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50603. /** @hidden */
  50604. export var pbrPixelShader: {
  50605. name: string;
  50606. shader: string;
  50607. };
  50608. }
  50609. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50610. /** @hidden */
  50611. export var pbrVertexDeclaration: {
  50612. name: string;
  50613. shader: string;
  50614. };
  50615. }
  50616. declare module "babylonjs/Shaders/pbr.vertex" {
  50617. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50618. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50619. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50620. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50621. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50622. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50623. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50624. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50625. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50626. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50627. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50629. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50630. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50631. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50632. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50633. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50634. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50635. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50636. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50637. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50638. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50639. /** @hidden */
  50640. export var pbrVertexShader: {
  50641. name: string;
  50642. shader: string;
  50643. };
  50644. }
  50645. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50646. import { Nullable } from "babylonjs/types";
  50647. import { Scene } from "babylonjs/scene";
  50648. import { Matrix } from "babylonjs/Maths/math.vector";
  50649. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50651. import { Mesh } from "babylonjs/Meshes/mesh";
  50652. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50653. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50654. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50655. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50656. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50657. import { Color3 } from "babylonjs/Maths/math.color";
  50658. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50659. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50660. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50661. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50662. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50663. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50664. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50665. import "babylonjs/Shaders/pbr.fragment";
  50666. import "babylonjs/Shaders/pbr.vertex";
  50667. /**
  50668. * Manages the defines for the PBR Material.
  50669. * @hidden
  50670. */
  50671. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50672. PBR: boolean;
  50673. MAINUV1: boolean;
  50674. MAINUV2: boolean;
  50675. UV1: boolean;
  50676. UV2: boolean;
  50677. ALBEDO: boolean;
  50678. ALBEDODIRECTUV: number;
  50679. VERTEXCOLOR: boolean;
  50680. AMBIENT: boolean;
  50681. AMBIENTDIRECTUV: number;
  50682. AMBIENTINGRAYSCALE: boolean;
  50683. OPACITY: boolean;
  50684. VERTEXALPHA: boolean;
  50685. OPACITYDIRECTUV: number;
  50686. OPACITYRGB: boolean;
  50687. ALPHATEST: boolean;
  50688. DEPTHPREPASS: boolean;
  50689. ALPHABLEND: boolean;
  50690. ALPHAFROMALBEDO: boolean;
  50691. ALPHATESTVALUE: string;
  50692. SPECULAROVERALPHA: boolean;
  50693. RADIANCEOVERALPHA: boolean;
  50694. ALPHAFRESNEL: boolean;
  50695. LINEARALPHAFRESNEL: boolean;
  50696. PREMULTIPLYALPHA: boolean;
  50697. EMISSIVE: boolean;
  50698. EMISSIVEDIRECTUV: number;
  50699. REFLECTIVITY: boolean;
  50700. REFLECTIVITYDIRECTUV: number;
  50701. SPECULARTERM: boolean;
  50702. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50703. MICROSURFACEAUTOMATIC: boolean;
  50704. LODBASEDMICROSFURACE: boolean;
  50705. MICROSURFACEMAP: boolean;
  50706. MICROSURFACEMAPDIRECTUV: number;
  50707. METALLICWORKFLOW: boolean;
  50708. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50709. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50710. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50711. AOSTOREINMETALMAPRED: boolean;
  50712. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50713. ENVIRONMENTBRDF: boolean;
  50714. ENVIRONMENTBRDF_RGBD: boolean;
  50715. NORMAL: boolean;
  50716. TANGENT: boolean;
  50717. BUMP: boolean;
  50718. BUMPDIRECTUV: number;
  50719. OBJECTSPACE_NORMALMAP: boolean;
  50720. PARALLAX: boolean;
  50721. PARALLAXOCCLUSION: boolean;
  50722. NORMALXYSCALE: boolean;
  50723. LIGHTMAP: boolean;
  50724. LIGHTMAPDIRECTUV: number;
  50725. USELIGHTMAPASSHADOWMAP: boolean;
  50726. GAMMALIGHTMAP: boolean;
  50727. RGBDLIGHTMAP: boolean;
  50728. REFLECTION: boolean;
  50729. REFLECTIONMAP_3D: boolean;
  50730. REFLECTIONMAP_SPHERICAL: boolean;
  50731. REFLECTIONMAP_PLANAR: boolean;
  50732. REFLECTIONMAP_CUBIC: boolean;
  50733. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50734. REFLECTIONMAP_PROJECTION: boolean;
  50735. REFLECTIONMAP_SKYBOX: boolean;
  50736. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50737. REFLECTIONMAP_EXPLICIT: boolean;
  50738. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50739. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50740. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50741. INVERTCUBICMAP: boolean;
  50742. USESPHERICALFROMREFLECTIONMAP: boolean;
  50743. USEIRRADIANCEMAP: boolean;
  50744. SPHERICAL_HARMONICS: boolean;
  50745. USESPHERICALINVERTEX: boolean;
  50746. REFLECTIONMAP_OPPOSITEZ: boolean;
  50747. LODINREFLECTIONALPHA: boolean;
  50748. GAMMAREFLECTION: boolean;
  50749. RGBDREFLECTION: boolean;
  50750. LINEARSPECULARREFLECTION: boolean;
  50751. RADIANCEOCCLUSION: boolean;
  50752. HORIZONOCCLUSION: boolean;
  50753. INSTANCES: boolean;
  50754. NUM_BONE_INFLUENCERS: number;
  50755. BonesPerMesh: number;
  50756. BONETEXTURE: boolean;
  50757. NONUNIFORMSCALING: boolean;
  50758. MORPHTARGETS: boolean;
  50759. MORPHTARGETS_NORMAL: boolean;
  50760. MORPHTARGETS_TANGENT: boolean;
  50761. MORPHTARGETS_UV: boolean;
  50762. NUM_MORPH_INFLUENCERS: number;
  50763. IMAGEPROCESSING: boolean;
  50764. VIGNETTE: boolean;
  50765. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50766. VIGNETTEBLENDMODEOPAQUE: boolean;
  50767. TONEMAPPING: boolean;
  50768. TONEMAPPING_ACES: boolean;
  50769. CONTRAST: boolean;
  50770. COLORCURVES: boolean;
  50771. COLORGRADING: boolean;
  50772. COLORGRADING3D: boolean;
  50773. SAMPLER3DGREENDEPTH: boolean;
  50774. SAMPLER3DBGRMAP: boolean;
  50775. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50776. EXPOSURE: boolean;
  50777. MULTIVIEW: boolean;
  50778. USEPHYSICALLIGHTFALLOFF: boolean;
  50779. USEGLTFLIGHTFALLOFF: boolean;
  50780. TWOSIDEDLIGHTING: boolean;
  50781. SHADOWFLOAT: boolean;
  50782. CLIPPLANE: boolean;
  50783. CLIPPLANE2: boolean;
  50784. CLIPPLANE3: boolean;
  50785. CLIPPLANE4: boolean;
  50786. POINTSIZE: boolean;
  50787. FOG: boolean;
  50788. LOGARITHMICDEPTH: boolean;
  50789. FORCENORMALFORWARD: boolean;
  50790. SPECULARAA: boolean;
  50791. CLEARCOAT: boolean;
  50792. CLEARCOAT_DEFAULTIOR: boolean;
  50793. CLEARCOAT_TEXTURE: boolean;
  50794. CLEARCOAT_TEXTUREDIRECTUV: number;
  50795. CLEARCOAT_BUMP: boolean;
  50796. CLEARCOAT_BUMPDIRECTUV: number;
  50797. CLEARCOAT_TINT: boolean;
  50798. CLEARCOAT_TINT_TEXTURE: boolean;
  50799. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50800. ANISOTROPIC: boolean;
  50801. ANISOTROPIC_TEXTURE: boolean;
  50802. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50803. BRDF_V_HEIGHT_CORRELATED: boolean;
  50804. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50805. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50806. SHEEN: boolean;
  50807. SHEEN_TEXTURE: boolean;
  50808. SHEEN_TEXTUREDIRECTUV: number;
  50809. SHEEN_LINKWITHALBEDO: boolean;
  50810. SUBSURFACE: boolean;
  50811. SS_REFRACTION: boolean;
  50812. SS_TRANSLUCENCY: boolean;
  50813. SS_SCATERRING: boolean;
  50814. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50815. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50816. SS_REFRACTIONMAP_3D: boolean;
  50817. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50818. SS_LODINREFRACTIONALPHA: boolean;
  50819. SS_GAMMAREFRACTION: boolean;
  50820. SS_RGBDREFRACTION: boolean;
  50821. SS_LINEARSPECULARREFRACTION: boolean;
  50822. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50823. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50824. UNLIT: boolean;
  50825. DEBUGMODE: number;
  50826. /**
  50827. * Initializes the PBR Material defines.
  50828. */
  50829. constructor();
  50830. /**
  50831. * Resets the PBR Material defines.
  50832. */
  50833. reset(): void;
  50834. }
  50835. /**
  50836. * The Physically based material base class of BJS.
  50837. *
  50838. * This offers the main features of a standard PBR material.
  50839. * For more information, please refer to the documentation :
  50840. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50841. */
  50842. export abstract class PBRBaseMaterial extends PushMaterial {
  50843. /**
  50844. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50845. */
  50846. static readonly PBRMATERIAL_OPAQUE: number;
  50847. /**
  50848. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50849. */
  50850. static readonly PBRMATERIAL_ALPHATEST: number;
  50851. /**
  50852. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50853. */
  50854. static readonly PBRMATERIAL_ALPHABLEND: number;
  50855. /**
  50856. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50857. * They are also discarded below the alpha cutoff threshold to improve performances.
  50858. */
  50859. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50860. /**
  50861. * Defines the default value of how much AO map is occluding the analytical lights
  50862. * (point spot...).
  50863. */
  50864. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50865. /**
  50866. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50867. */
  50868. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50869. /**
  50870. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50871. * to enhance interoperability with other engines.
  50872. */
  50873. static readonly LIGHTFALLOFF_GLTF: number;
  50874. /**
  50875. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50876. * to enhance interoperability with other materials.
  50877. */
  50878. static readonly LIGHTFALLOFF_STANDARD: number;
  50879. /**
  50880. * Intensity of the direct lights e.g. the four lights available in your scene.
  50881. * This impacts both the direct diffuse and specular highlights.
  50882. */
  50883. protected _directIntensity: number;
  50884. /**
  50885. * Intensity of the emissive part of the material.
  50886. * This helps controlling the emissive effect without modifying the emissive color.
  50887. */
  50888. protected _emissiveIntensity: number;
  50889. /**
  50890. * Intensity of the environment e.g. how much the environment will light the object
  50891. * either through harmonics for rough material or through the refelction for shiny ones.
  50892. */
  50893. protected _environmentIntensity: number;
  50894. /**
  50895. * This is a special control allowing the reduction of the specular highlights coming from the
  50896. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50897. */
  50898. protected _specularIntensity: number;
  50899. /**
  50900. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50901. */
  50902. private _lightingInfos;
  50903. /**
  50904. * Debug Control allowing disabling the bump map on this material.
  50905. */
  50906. protected _disableBumpMap: boolean;
  50907. /**
  50908. * AKA Diffuse Texture in standard nomenclature.
  50909. */
  50910. protected _albedoTexture: Nullable<BaseTexture>;
  50911. /**
  50912. * AKA Occlusion Texture in other nomenclature.
  50913. */
  50914. protected _ambientTexture: Nullable<BaseTexture>;
  50915. /**
  50916. * AKA Occlusion Texture Intensity in other nomenclature.
  50917. */
  50918. protected _ambientTextureStrength: number;
  50919. /**
  50920. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50921. * 1 means it completely occludes it
  50922. * 0 mean it has no impact
  50923. */
  50924. protected _ambientTextureImpactOnAnalyticalLights: number;
  50925. /**
  50926. * Stores the alpha values in a texture.
  50927. */
  50928. protected _opacityTexture: Nullable<BaseTexture>;
  50929. /**
  50930. * Stores the reflection values in a texture.
  50931. */
  50932. protected _reflectionTexture: Nullable<BaseTexture>;
  50933. /**
  50934. * Stores the emissive values in a texture.
  50935. */
  50936. protected _emissiveTexture: Nullable<BaseTexture>;
  50937. /**
  50938. * AKA Specular texture in other nomenclature.
  50939. */
  50940. protected _reflectivityTexture: Nullable<BaseTexture>;
  50941. /**
  50942. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50943. */
  50944. protected _metallicTexture: Nullable<BaseTexture>;
  50945. /**
  50946. * Specifies the metallic scalar of the metallic/roughness workflow.
  50947. * Can also be used to scale the metalness values of the metallic texture.
  50948. */
  50949. protected _metallic: Nullable<number>;
  50950. /**
  50951. * Specifies the roughness scalar of the metallic/roughness workflow.
  50952. * Can also be used to scale the roughness values of the metallic texture.
  50953. */
  50954. protected _roughness: Nullable<number>;
  50955. /**
  50956. * Specifies the an F0 factor to help configuring the material F0.
  50957. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50958. * to 0.5 the previously hard coded value stays the same.
  50959. * Can also be used to scale the F0 values of the metallic texture.
  50960. */
  50961. protected _metallicF0Factor: number;
  50962. /**
  50963. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50964. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50965. * your expectation as it multiplies with the texture data.
  50966. */
  50967. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50968. /**
  50969. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50970. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50971. */
  50972. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50973. /**
  50974. * Stores surface normal data used to displace a mesh in a texture.
  50975. */
  50976. protected _bumpTexture: Nullable<BaseTexture>;
  50977. /**
  50978. * Stores the pre-calculated light information of a mesh in a texture.
  50979. */
  50980. protected _lightmapTexture: Nullable<BaseTexture>;
  50981. /**
  50982. * The color of a material in ambient lighting.
  50983. */
  50984. protected _ambientColor: Color3;
  50985. /**
  50986. * AKA Diffuse Color in other nomenclature.
  50987. */
  50988. protected _albedoColor: Color3;
  50989. /**
  50990. * AKA Specular Color in other nomenclature.
  50991. */
  50992. protected _reflectivityColor: Color3;
  50993. /**
  50994. * The color applied when light is reflected from a material.
  50995. */
  50996. protected _reflectionColor: Color3;
  50997. /**
  50998. * The color applied when light is emitted from a material.
  50999. */
  51000. protected _emissiveColor: Color3;
  51001. /**
  51002. * AKA Glossiness in other nomenclature.
  51003. */
  51004. protected _microSurface: number;
  51005. /**
  51006. * Specifies that the material will use the light map as a show map.
  51007. */
  51008. protected _useLightmapAsShadowmap: boolean;
  51009. /**
  51010. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51011. * makes the reflect vector face the model (under horizon).
  51012. */
  51013. protected _useHorizonOcclusion: boolean;
  51014. /**
  51015. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51016. * too much the area relying on ambient texture to define their ambient occlusion.
  51017. */
  51018. protected _useRadianceOcclusion: boolean;
  51019. /**
  51020. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51021. */
  51022. protected _useAlphaFromAlbedoTexture: boolean;
  51023. /**
  51024. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51025. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51026. */
  51027. protected _useSpecularOverAlpha: boolean;
  51028. /**
  51029. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51030. */
  51031. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51032. /**
  51033. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51034. */
  51035. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51036. /**
  51037. * Specifies if the metallic texture contains the roughness information in its green channel.
  51038. */
  51039. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51040. /**
  51041. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51042. */
  51043. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51044. /**
  51045. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51046. */
  51047. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51048. /**
  51049. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51050. */
  51051. protected _useAmbientInGrayScale: boolean;
  51052. /**
  51053. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51054. * The material will try to infer what glossiness each pixel should be.
  51055. */
  51056. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51057. /**
  51058. * Defines the falloff type used in this material.
  51059. * It by default is Physical.
  51060. */
  51061. protected _lightFalloff: number;
  51062. /**
  51063. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51064. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51065. */
  51066. protected _useRadianceOverAlpha: boolean;
  51067. /**
  51068. * Allows using an object space normal map (instead of tangent space).
  51069. */
  51070. protected _useObjectSpaceNormalMap: boolean;
  51071. /**
  51072. * Allows using the bump map in parallax mode.
  51073. */
  51074. protected _useParallax: boolean;
  51075. /**
  51076. * Allows using the bump map in parallax occlusion mode.
  51077. */
  51078. protected _useParallaxOcclusion: boolean;
  51079. /**
  51080. * Controls the scale bias of the parallax mode.
  51081. */
  51082. protected _parallaxScaleBias: number;
  51083. /**
  51084. * If sets to true, disables all the lights affecting the material.
  51085. */
  51086. protected _disableLighting: boolean;
  51087. /**
  51088. * Number of Simultaneous lights allowed on the material.
  51089. */
  51090. protected _maxSimultaneousLights: number;
  51091. /**
  51092. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51093. */
  51094. protected _invertNormalMapX: boolean;
  51095. /**
  51096. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51097. */
  51098. protected _invertNormalMapY: boolean;
  51099. /**
  51100. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51101. */
  51102. protected _twoSidedLighting: boolean;
  51103. /**
  51104. * Defines the alpha limits in alpha test mode.
  51105. */
  51106. protected _alphaCutOff: number;
  51107. /**
  51108. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51109. */
  51110. protected _forceAlphaTest: boolean;
  51111. /**
  51112. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51113. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51114. */
  51115. protected _useAlphaFresnel: boolean;
  51116. /**
  51117. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51118. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51119. */
  51120. protected _useLinearAlphaFresnel: boolean;
  51121. /**
  51122. * The transparency mode of the material.
  51123. */
  51124. protected _transparencyMode: Nullable<number>;
  51125. /**
  51126. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51127. * from cos thetav and roughness:
  51128. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51129. */
  51130. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51131. /**
  51132. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51133. */
  51134. protected _forceIrradianceInFragment: boolean;
  51135. /**
  51136. * Force normal to face away from face.
  51137. */
  51138. protected _forceNormalForward: boolean;
  51139. /**
  51140. * Enables specular anti aliasing in the PBR shader.
  51141. * It will both interacts on the Geometry for analytical and IBL lighting.
  51142. * It also prefilter the roughness map based on the bump values.
  51143. */
  51144. protected _enableSpecularAntiAliasing: boolean;
  51145. /**
  51146. * Default configuration related to image processing available in the PBR Material.
  51147. */
  51148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51149. /**
  51150. * Keep track of the image processing observer to allow dispose and replace.
  51151. */
  51152. private _imageProcessingObserver;
  51153. /**
  51154. * Attaches a new image processing configuration to the PBR Material.
  51155. * @param configuration
  51156. */
  51157. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51158. /**
  51159. * Stores the available render targets.
  51160. */
  51161. private _renderTargets;
  51162. /**
  51163. * Sets the global ambient color for the material used in lighting calculations.
  51164. */
  51165. private _globalAmbientColor;
  51166. /**
  51167. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51168. */
  51169. private _useLogarithmicDepth;
  51170. /**
  51171. * If set to true, no lighting calculations will be applied.
  51172. */
  51173. private _unlit;
  51174. private _debugMode;
  51175. /**
  51176. * @hidden
  51177. * This is reserved for the inspector.
  51178. * Defines the material debug mode.
  51179. * It helps seeing only some components of the material while troubleshooting.
  51180. */
  51181. debugMode: number;
  51182. /**
  51183. * @hidden
  51184. * This is reserved for the inspector.
  51185. * Specify from where on screen the debug mode should start.
  51186. * The value goes from -1 (full screen) to 1 (not visible)
  51187. * It helps with side by side comparison against the final render
  51188. * This defaults to -1
  51189. */
  51190. private debugLimit;
  51191. /**
  51192. * @hidden
  51193. * This is reserved for the inspector.
  51194. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51195. * You can use the factor to better multiply the final value.
  51196. */
  51197. private debugFactor;
  51198. /**
  51199. * Defines the clear coat layer parameters for the material.
  51200. */
  51201. readonly clearCoat: PBRClearCoatConfiguration;
  51202. /**
  51203. * Defines the anisotropic parameters for the material.
  51204. */
  51205. readonly anisotropy: PBRAnisotropicConfiguration;
  51206. /**
  51207. * Defines the BRDF parameters for the material.
  51208. */
  51209. readonly brdf: PBRBRDFConfiguration;
  51210. /**
  51211. * Defines the Sheen parameters for the material.
  51212. */
  51213. readonly sheen: PBRSheenConfiguration;
  51214. /**
  51215. * Defines the SubSurface parameters for the material.
  51216. */
  51217. readonly subSurface: PBRSubSurfaceConfiguration;
  51218. /**
  51219. * Custom callback helping to override the default shader used in the material.
  51220. */
  51221. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51222. protected _rebuildInParallel: boolean;
  51223. /**
  51224. * Instantiates a new PBRMaterial instance.
  51225. *
  51226. * @param name The material name
  51227. * @param scene The scene the material will be use in.
  51228. */
  51229. constructor(name: string, scene: Scene);
  51230. /**
  51231. * Gets a boolean indicating that current material needs to register RTT
  51232. */
  51233. readonly hasRenderTargetTextures: boolean;
  51234. /**
  51235. * Gets the name of the material class.
  51236. */
  51237. getClassName(): string;
  51238. /**
  51239. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51240. */
  51241. /**
  51242. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51243. */
  51244. useLogarithmicDepth: boolean;
  51245. /**
  51246. * Gets the current transparency mode.
  51247. */
  51248. /**
  51249. * Sets the transparency mode of the material.
  51250. *
  51251. * | Value | Type | Description |
  51252. * | ----- | ----------------------------------- | ----------- |
  51253. * | 0 | OPAQUE | |
  51254. * | 1 | ALPHATEST | |
  51255. * | 2 | ALPHABLEND | |
  51256. * | 3 | ALPHATESTANDBLEND | |
  51257. *
  51258. */
  51259. transparencyMode: Nullable<number>;
  51260. /**
  51261. * Returns true if alpha blending should be disabled.
  51262. */
  51263. private readonly _disableAlphaBlending;
  51264. /**
  51265. * Specifies whether or not this material should be rendered in alpha blend mode.
  51266. */
  51267. needAlphaBlending(): boolean;
  51268. /**
  51269. * Specifies if the mesh will require alpha blending.
  51270. * @param mesh - BJS mesh.
  51271. */
  51272. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51273. /**
  51274. * Specifies whether or not this material should be rendered in alpha test mode.
  51275. */
  51276. needAlphaTesting(): boolean;
  51277. /**
  51278. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51279. */
  51280. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51281. /**
  51282. * Gets the texture used for the alpha test.
  51283. */
  51284. getAlphaTestTexture(): Nullable<BaseTexture>;
  51285. /**
  51286. * Specifies that the submesh is ready to be used.
  51287. * @param mesh - BJS mesh.
  51288. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51289. * @param useInstances - Specifies that instances should be used.
  51290. * @returns - boolean indicating that the submesh is ready or not.
  51291. */
  51292. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51293. /**
  51294. * Specifies if the material uses metallic roughness workflow.
  51295. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51296. */
  51297. isMetallicWorkflow(): boolean;
  51298. private _prepareEffect;
  51299. private _prepareDefines;
  51300. /**
  51301. * Force shader compilation
  51302. */
  51303. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51304. /**
  51305. * Initializes the uniform buffer layout for the shader.
  51306. */
  51307. buildUniformLayout(): void;
  51308. /**
  51309. * Unbinds the material from the mesh
  51310. */
  51311. unbind(): void;
  51312. /**
  51313. * Binds the submesh data.
  51314. * @param world - The world matrix.
  51315. * @param mesh - The BJS mesh.
  51316. * @param subMesh - A submesh of the BJS mesh.
  51317. */
  51318. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51319. /**
  51320. * Returns the animatable textures.
  51321. * @returns - Array of animatable textures.
  51322. */
  51323. getAnimatables(): IAnimatable[];
  51324. /**
  51325. * Returns the texture used for reflections.
  51326. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51327. */
  51328. private _getReflectionTexture;
  51329. /**
  51330. * Returns an array of the actively used textures.
  51331. * @returns - Array of BaseTextures
  51332. */
  51333. getActiveTextures(): BaseTexture[];
  51334. /**
  51335. * Checks to see if a texture is used in the material.
  51336. * @param texture - Base texture to use.
  51337. * @returns - Boolean specifying if a texture is used in the material.
  51338. */
  51339. hasTexture(texture: BaseTexture): boolean;
  51340. /**
  51341. * Disposes the resources of the material.
  51342. * @param forceDisposeEffect - Forces the disposal of effects.
  51343. * @param forceDisposeTextures - Forces the disposal of all textures.
  51344. */
  51345. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51346. }
  51347. }
  51348. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  51349. import { Nullable } from "babylonjs/types";
  51350. import { Scene } from "babylonjs/scene";
  51351. import { Color3 } from "babylonjs/Maths/math.color";
  51352. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51353. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51354. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51355. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51356. /**
  51357. * The Physically based material of BJS.
  51358. *
  51359. * This offers the main features of a standard PBR material.
  51360. * For more information, please refer to the documentation :
  51361. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51362. */
  51363. export class PBRMaterial extends PBRBaseMaterial {
  51364. /**
  51365. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51366. */
  51367. static readonly PBRMATERIAL_OPAQUE: number;
  51368. /**
  51369. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51370. */
  51371. static readonly PBRMATERIAL_ALPHATEST: number;
  51372. /**
  51373. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51374. */
  51375. static readonly PBRMATERIAL_ALPHABLEND: number;
  51376. /**
  51377. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51378. * They are also discarded below the alpha cutoff threshold to improve performances.
  51379. */
  51380. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51381. /**
  51382. * Defines the default value of how much AO map is occluding the analytical lights
  51383. * (point spot...).
  51384. */
  51385. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51386. /**
  51387. * Intensity of the direct lights e.g. the four lights available in your scene.
  51388. * This impacts both the direct diffuse and specular highlights.
  51389. */
  51390. directIntensity: number;
  51391. /**
  51392. * Intensity of the emissive part of the material.
  51393. * This helps controlling the emissive effect without modifying the emissive color.
  51394. */
  51395. emissiveIntensity: number;
  51396. /**
  51397. * Intensity of the environment e.g. how much the environment will light the object
  51398. * either through harmonics for rough material or through the refelction for shiny ones.
  51399. */
  51400. environmentIntensity: number;
  51401. /**
  51402. * This is a special control allowing the reduction of the specular highlights coming from the
  51403. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51404. */
  51405. specularIntensity: number;
  51406. /**
  51407. * Debug Control allowing disabling the bump map on this material.
  51408. */
  51409. disableBumpMap: boolean;
  51410. /**
  51411. * AKA Diffuse Texture in standard nomenclature.
  51412. */
  51413. albedoTexture: BaseTexture;
  51414. /**
  51415. * AKA Occlusion Texture in other nomenclature.
  51416. */
  51417. ambientTexture: BaseTexture;
  51418. /**
  51419. * AKA Occlusion Texture Intensity in other nomenclature.
  51420. */
  51421. ambientTextureStrength: number;
  51422. /**
  51423. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51424. * 1 means it completely occludes it
  51425. * 0 mean it has no impact
  51426. */
  51427. ambientTextureImpactOnAnalyticalLights: number;
  51428. /**
  51429. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51430. */
  51431. opacityTexture: BaseTexture;
  51432. /**
  51433. * Stores the reflection values in a texture.
  51434. */
  51435. reflectionTexture: Nullable<BaseTexture>;
  51436. /**
  51437. * Stores the emissive values in a texture.
  51438. */
  51439. emissiveTexture: BaseTexture;
  51440. /**
  51441. * AKA Specular texture in other nomenclature.
  51442. */
  51443. reflectivityTexture: BaseTexture;
  51444. /**
  51445. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51446. */
  51447. metallicTexture: BaseTexture;
  51448. /**
  51449. * Specifies the metallic scalar of the metallic/roughness workflow.
  51450. * Can also be used to scale the metalness values of the metallic texture.
  51451. */
  51452. metallic: Nullable<number>;
  51453. /**
  51454. * Specifies the roughness scalar of the metallic/roughness workflow.
  51455. * Can also be used to scale the roughness values of the metallic texture.
  51456. */
  51457. roughness: Nullable<number>;
  51458. /**
  51459. * Specifies the an F0 factor to help configuring the material F0.
  51460. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51461. * to 0.5 the previously hard coded value stays the same.
  51462. * Can also be used to scale the F0 values of the metallic texture.
  51463. */
  51464. metallicF0Factor: number;
  51465. /**
  51466. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51467. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51468. * your expectation as it multiplies with the texture data.
  51469. */
  51470. useMetallicF0FactorFromMetallicTexture: boolean;
  51471. /**
  51472. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51473. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51474. */
  51475. microSurfaceTexture: BaseTexture;
  51476. /**
  51477. * Stores surface normal data used to displace a mesh in a texture.
  51478. */
  51479. bumpTexture: BaseTexture;
  51480. /**
  51481. * Stores the pre-calculated light information of a mesh in a texture.
  51482. */
  51483. lightmapTexture: BaseTexture;
  51484. /**
  51485. * Stores the refracted light information in a texture.
  51486. */
  51487. refractionTexture: Nullable<BaseTexture>;
  51488. /**
  51489. * The color of a material in ambient lighting.
  51490. */
  51491. ambientColor: Color3;
  51492. /**
  51493. * AKA Diffuse Color in other nomenclature.
  51494. */
  51495. albedoColor: Color3;
  51496. /**
  51497. * AKA Specular Color in other nomenclature.
  51498. */
  51499. reflectivityColor: Color3;
  51500. /**
  51501. * The color reflected from the material.
  51502. */
  51503. reflectionColor: Color3;
  51504. /**
  51505. * The color emitted from the material.
  51506. */
  51507. emissiveColor: Color3;
  51508. /**
  51509. * AKA Glossiness in other nomenclature.
  51510. */
  51511. microSurface: number;
  51512. /**
  51513. * source material index of refraction (IOR)' / 'destination material IOR.
  51514. */
  51515. indexOfRefraction: number;
  51516. /**
  51517. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51518. */
  51519. invertRefractionY: boolean;
  51520. /**
  51521. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51522. * Materials half opaque for instance using refraction could benefit from this control.
  51523. */
  51524. linkRefractionWithTransparency: boolean;
  51525. /**
  51526. * If true, the light map contains occlusion information instead of lighting info.
  51527. */
  51528. useLightmapAsShadowmap: boolean;
  51529. /**
  51530. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51531. */
  51532. useAlphaFromAlbedoTexture: boolean;
  51533. /**
  51534. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51535. */
  51536. forceAlphaTest: boolean;
  51537. /**
  51538. * Defines the alpha limits in alpha test mode.
  51539. */
  51540. alphaCutOff: number;
  51541. /**
  51542. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51543. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51544. */
  51545. useSpecularOverAlpha: boolean;
  51546. /**
  51547. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51548. */
  51549. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51550. /**
  51551. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51552. */
  51553. useRoughnessFromMetallicTextureAlpha: boolean;
  51554. /**
  51555. * Specifies if the metallic texture contains the roughness information in its green channel.
  51556. */
  51557. useRoughnessFromMetallicTextureGreen: boolean;
  51558. /**
  51559. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51560. */
  51561. useMetallnessFromMetallicTextureBlue: boolean;
  51562. /**
  51563. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51564. */
  51565. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51566. /**
  51567. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51568. */
  51569. useAmbientInGrayScale: boolean;
  51570. /**
  51571. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51572. * The material will try to infer what glossiness each pixel should be.
  51573. */
  51574. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51575. /**
  51576. * BJS is using an harcoded light falloff based on a manually sets up range.
  51577. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51578. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51579. */
  51580. /**
  51581. * BJS is using an harcoded light falloff based on a manually sets up range.
  51582. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51583. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51584. */
  51585. usePhysicalLightFalloff: boolean;
  51586. /**
  51587. * In order to support the falloff compatibility with gltf, a special mode has been added
  51588. * to reproduce the gltf light falloff.
  51589. */
  51590. /**
  51591. * In order to support the falloff compatibility with gltf, a special mode has been added
  51592. * to reproduce the gltf light falloff.
  51593. */
  51594. useGLTFLightFalloff: boolean;
  51595. /**
  51596. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51597. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51598. */
  51599. useRadianceOverAlpha: boolean;
  51600. /**
  51601. * Allows using an object space normal map (instead of tangent space).
  51602. */
  51603. useObjectSpaceNormalMap: boolean;
  51604. /**
  51605. * Allows using the bump map in parallax mode.
  51606. */
  51607. useParallax: boolean;
  51608. /**
  51609. * Allows using the bump map in parallax occlusion mode.
  51610. */
  51611. useParallaxOcclusion: boolean;
  51612. /**
  51613. * Controls the scale bias of the parallax mode.
  51614. */
  51615. parallaxScaleBias: number;
  51616. /**
  51617. * If sets to true, disables all the lights affecting the material.
  51618. */
  51619. disableLighting: boolean;
  51620. /**
  51621. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51622. */
  51623. forceIrradianceInFragment: boolean;
  51624. /**
  51625. * Number of Simultaneous lights allowed on the material.
  51626. */
  51627. maxSimultaneousLights: number;
  51628. /**
  51629. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51630. */
  51631. invertNormalMapX: boolean;
  51632. /**
  51633. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51634. */
  51635. invertNormalMapY: boolean;
  51636. /**
  51637. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51638. */
  51639. twoSidedLighting: boolean;
  51640. /**
  51641. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51642. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51643. */
  51644. useAlphaFresnel: boolean;
  51645. /**
  51646. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51647. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51648. */
  51649. useLinearAlphaFresnel: boolean;
  51650. /**
  51651. * Let user defines the brdf lookup texture used for IBL.
  51652. * A default 8bit version is embedded but you could point at :
  51653. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51654. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51655. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51656. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51657. */
  51658. environmentBRDFTexture: Nullable<BaseTexture>;
  51659. /**
  51660. * Force normal to face away from face.
  51661. */
  51662. forceNormalForward: boolean;
  51663. /**
  51664. * Enables specular anti aliasing in the PBR shader.
  51665. * It will both interacts on the Geometry for analytical and IBL lighting.
  51666. * It also prefilter the roughness map based on the bump values.
  51667. */
  51668. enableSpecularAntiAliasing: boolean;
  51669. /**
  51670. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51671. * makes the reflect vector face the model (under horizon).
  51672. */
  51673. useHorizonOcclusion: boolean;
  51674. /**
  51675. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51676. * too much the area relying on ambient texture to define their ambient occlusion.
  51677. */
  51678. useRadianceOcclusion: boolean;
  51679. /**
  51680. * If set to true, no lighting calculations will be applied.
  51681. */
  51682. unlit: boolean;
  51683. /**
  51684. * Gets the image processing configuration used either in this material.
  51685. */
  51686. /**
  51687. * Sets the Default image processing configuration used either in the this material.
  51688. *
  51689. * If sets to null, the scene one is in use.
  51690. */
  51691. imageProcessingConfiguration: ImageProcessingConfiguration;
  51692. /**
  51693. * Gets wether the color curves effect is enabled.
  51694. */
  51695. /**
  51696. * Sets wether the color curves effect is enabled.
  51697. */
  51698. cameraColorCurvesEnabled: boolean;
  51699. /**
  51700. * Gets wether the color grading effect is enabled.
  51701. */
  51702. /**
  51703. * Gets wether the color grading effect is enabled.
  51704. */
  51705. cameraColorGradingEnabled: boolean;
  51706. /**
  51707. * Gets wether tonemapping is enabled or not.
  51708. */
  51709. /**
  51710. * Sets wether tonemapping is enabled or not
  51711. */
  51712. cameraToneMappingEnabled: boolean;
  51713. /**
  51714. * The camera exposure used on this material.
  51715. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51716. * This corresponds to a photographic exposure.
  51717. */
  51718. /**
  51719. * The camera exposure used on this material.
  51720. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51721. * This corresponds to a photographic exposure.
  51722. */
  51723. cameraExposure: number;
  51724. /**
  51725. * Gets The camera contrast used on this material.
  51726. */
  51727. /**
  51728. * Sets The camera contrast used on this material.
  51729. */
  51730. cameraContrast: number;
  51731. /**
  51732. * Gets the Color Grading 2D Lookup Texture.
  51733. */
  51734. /**
  51735. * Sets the Color Grading 2D Lookup Texture.
  51736. */
  51737. cameraColorGradingTexture: Nullable<BaseTexture>;
  51738. /**
  51739. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51740. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51741. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  51742. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51743. */
  51744. /**
  51745. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51746. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51747. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  51748. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51749. */
  51750. cameraColorCurves: Nullable<ColorCurves>;
  51751. /**
  51752. * Instantiates a new PBRMaterial instance.
  51753. *
  51754. * @param name The material name
  51755. * @param scene The scene the material will be use in.
  51756. */
  51757. constructor(name: string, scene: Scene);
  51758. /**
  51759. * Returns the name of this material class.
  51760. */
  51761. getClassName(): string;
  51762. /**
  51763. * Makes a duplicate of the current material.
  51764. * @param name - name to use for the new material.
  51765. */
  51766. clone(name: string): PBRMaterial;
  51767. /**
  51768. * Serializes this PBR Material.
  51769. * @returns - An object with the serialized material.
  51770. */
  51771. serialize(): any;
  51772. /**
  51773. * Parses a PBR Material from a serialized object.
  51774. * @param source - Serialized object.
  51775. * @param scene - BJS scene instance.
  51776. * @param rootUrl - url for the scene object
  51777. * @returns - PBRMaterial
  51778. */
  51779. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51780. }
  51781. }
  51782. declare module "babylonjs/Misc/dds" {
  51783. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51784. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51785. import { Nullable } from "babylonjs/types";
  51786. import { Scene } from "babylonjs/scene";
  51787. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51788. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51789. /**
  51790. * Direct draw surface info
  51791. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51792. */
  51793. export interface DDSInfo {
  51794. /**
  51795. * Width of the texture
  51796. */
  51797. width: number;
  51798. /**
  51799. * Width of the texture
  51800. */
  51801. height: number;
  51802. /**
  51803. * Number of Mipmaps for the texture
  51804. * @see https://en.wikipedia.org/wiki/Mipmap
  51805. */
  51806. mipmapCount: number;
  51807. /**
  51808. * If the textures format is a known fourCC format
  51809. * @see https://www.fourcc.org/
  51810. */
  51811. isFourCC: boolean;
  51812. /**
  51813. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51814. */
  51815. isRGB: boolean;
  51816. /**
  51817. * If the texture is a lumincance format
  51818. */
  51819. isLuminance: boolean;
  51820. /**
  51821. * If this is a cube texture
  51822. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51823. */
  51824. isCube: boolean;
  51825. /**
  51826. * If the texture is a compressed format eg. FOURCC_DXT1
  51827. */
  51828. isCompressed: boolean;
  51829. /**
  51830. * The dxgiFormat of the texture
  51831. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51832. */
  51833. dxgiFormat: number;
  51834. /**
  51835. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51836. */
  51837. textureType: number;
  51838. /**
  51839. * Sphericle polynomial created for the dds texture
  51840. */
  51841. sphericalPolynomial?: SphericalPolynomial;
  51842. }
  51843. /**
  51844. * Class used to provide DDS decompression tools
  51845. */
  51846. export class DDSTools {
  51847. /**
  51848. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51849. */
  51850. static StoreLODInAlphaChannel: boolean;
  51851. /**
  51852. * Gets DDS information from an array buffer
  51853. * @param arrayBuffer defines the array buffer to read data from
  51854. * @returns the DDS information
  51855. */
  51856. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51857. private static _FloatView;
  51858. private static _Int32View;
  51859. private static _ToHalfFloat;
  51860. private static _FromHalfFloat;
  51861. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51862. private static _GetHalfFloatRGBAArrayBuffer;
  51863. private static _GetFloatRGBAArrayBuffer;
  51864. private static _GetFloatAsUIntRGBAArrayBuffer;
  51865. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51866. private static _GetRGBAArrayBuffer;
  51867. private static _ExtractLongWordOrder;
  51868. private static _GetRGBArrayBuffer;
  51869. private static _GetLuminanceArrayBuffer;
  51870. /**
  51871. * Uploads DDS Levels to a Babylon Texture
  51872. * @hidden
  51873. */
  51874. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51875. }
  51876. module "babylonjs/Engines/thinEngine" {
  51877. interface ThinEngine {
  51878. /**
  51879. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51880. * @param rootUrl defines the url where the file to load is located
  51881. * @param scene defines the current scene
  51882. * @param lodScale defines scale to apply to the mip map selection
  51883. * @param lodOffset defines offset to apply to the mip map selection
  51884. * @param onLoad defines an optional callback raised when the texture is loaded
  51885. * @param onError defines an optional callback raised if there is an issue to load the texture
  51886. * @param format defines the format of the data
  51887. * @param forcedExtension defines the extension to use to pick the right loader
  51888. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51889. * @returns the cube texture as an InternalTexture
  51890. */
  51891. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  51892. }
  51893. }
  51894. }
  51895. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51896. import { Nullable } from "babylonjs/types";
  51897. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51898. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51899. /**
  51900. * Implementation of the DDS Texture Loader.
  51901. * @hidden
  51902. */
  51903. export class _DDSTextureLoader implements IInternalTextureLoader {
  51904. /**
  51905. * Defines wether the loader supports cascade loading the different faces.
  51906. */
  51907. readonly supportCascades: boolean;
  51908. /**
  51909. * This returns if the loader support the current file information.
  51910. * @param extension defines the file extension of the file being loaded
  51911. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51912. * @param fallback defines the fallback internal texture if any
  51913. * @param isBase64 defines whether the texture is encoded as a base64
  51914. * @param isBuffer defines whether the texture data are stored as a buffer
  51915. * @returns true if the loader can load the specified file
  51916. */
  51917. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51918. /**
  51919. * Transform the url before loading if required.
  51920. * @param rootUrl the url of the texture
  51921. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51922. * @returns the transformed texture
  51923. */
  51924. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51925. /**
  51926. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51927. * @param rootUrl the url of the texture
  51928. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51929. * @returns the fallback texture
  51930. */
  51931. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51932. /**
  51933. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51934. * @param data contains the texture data
  51935. * @param texture defines the BabylonJS internal texture
  51936. * @param createPolynomials will be true if polynomials have been requested
  51937. * @param onLoad defines the callback to trigger once the texture is ready
  51938. * @param onError defines the callback to trigger in case of error
  51939. */
  51940. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51941. /**
  51942. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51943. * @param data contains the texture data
  51944. * @param texture defines the BabylonJS internal texture
  51945. * @param callback defines the method to call once ready to upload
  51946. */
  51947. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51948. }
  51949. }
  51950. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51951. import { Nullable } from "babylonjs/types";
  51952. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51953. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51954. /**
  51955. * Implementation of the ENV Texture Loader.
  51956. * @hidden
  51957. */
  51958. export class _ENVTextureLoader implements IInternalTextureLoader {
  51959. /**
  51960. * Defines wether the loader supports cascade loading the different faces.
  51961. */
  51962. readonly supportCascades: boolean;
  51963. /**
  51964. * This returns if the loader support the current file information.
  51965. * @param extension defines the file extension of the file being loaded
  51966. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51967. * @param fallback defines the fallback internal texture if any
  51968. * @param isBase64 defines whether the texture is encoded as a base64
  51969. * @param isBuffer defines whether the texture data are stored as a buffer
  51970. * @returns true if the loader can load the specified file
  51971. */
  51972. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51973. /**
  51974. * Transform the url before loading if required.
  51975. * @param rootUrl the url of the texture
  51976. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51977. * @returns the transformed texture
  51978. */
  51979. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51980. /**
  51981. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51982. * @param rootUrl the url of the texture
  51983. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51984. * @returns the fallback texture
  51985. */
  51986. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51987. /**
  51988. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51989. * @param data contains the texture data
  51990. * @param texture defines the BabylonJS internal texture
  51991. * @param createPolynomials will be true if polynomials have been requested
  51992. * @param onLoad defines the callback to trigger once the texture is ready
  51993. * @param onError defines the callback to trigger in case of error
  51994. */
  51995. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51996. /**
  51997. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51998. * @param data contains the texture data
  51999. * @param texture defines the BabylonJS internal texture
  52000. * @param callback defines the method to call once ready to upload
  52001. */
  52002. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52003. }
  52004. }
  52005. declare module "babylonjs/Misc/khronosTextureContainer" {
  52006. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52007. /**
  52008. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52009. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52010. */
  52011. export class KhronosTextureContainer {
  52012. /** contents of the KTX container file */
  52013. arrayBuffer: any;
  52014. private static HEADER_LEN;
  52015. private static COMPRESSED_2D;
  52016. private static COMPRESSED_3D;
  52017. private static TEX_2D;
  52018. private static TEX_3D;
  52019. /**
  52020. * Gets the openGL type
  52021. */
  52022. glType: number;
  52023. /**
  52024. * Gets the openGL type size
  52025. */
  52026. glTypeSize: number;
  52027. /**
  52028. * Gets the openGL format
  52029. */
  52030. glFormat: number;
  52031. /**
  52032. * Gets the openGL internal format
  52033. */
  52034. glInternalFormat: number;
  52035. /**
  52036. * Gets the base internal format
  52037. */
  52038. glBaseInternalFormat: number;
  52039. /**
  52040. * Gets image width in pixel
  52041. */
  52042. pixelWidth: number;
  52043. /**
  52044. * Gets image height in pixel
  52045. */
  52046. pixelHeight: number;
  52047. /**
  52048. * Gets image depth in pixels
  52049. */
  52050. pixelDepth: number;
  52051. /**
  52052. * Gets the number of array elements
  52053. */
  52054. numberOfArrayElements: number;
  52055. /**
  52056. * Gets the number of faces
  52057. */
  52058. numberOfFaces: number;
  52059. /**
  52060. * Gets the number of mipmap levels
  52061. */
  52062. numberOfMipmapLevels: number;
  52063. /**
  52064. * Gets the bytes of key value data
  52065. */
  52066. bytesOfKeyValueData: number;
  52067. /**
  52068. * Gets the load type
  52069. */
  52070. loadType: number;
  52071. /**
  52072. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52073. */
  52074. isInvalid: boolean;
  52075. /**
  52076. * Creates a new KhronosTextureContainer
  52077. * @param arrayBuffer contents of the KTX container file
  52078. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52079. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52080. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52081. */
  52082. constructor(
  52083. /** contents of the KTX container file */
  52084. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52085. /**
  52086. * Uploads KTX content to a Babylon Texture.
  52087. * It is assumed that the texture has already been created & is currently bound
  52088. * @hidden
  52089. */
  52090. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52091. private _upload2DCompressedLevels;
  52092. }
  52093. }
  52094. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  52095. import { Nullable } from "babylonjs/types";
  52096. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52097. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52098. /**
  52099. * Implementation of the KTX Texture Loader.
  52100. * @hidden
  52101. */
  52102. export class _KTXTextureLoader implements IInternalTextureLoader {
  52103. /**
  52104. * Defines wether the loader supports cascade loading the different faces.
  52105. */
  52106. readonly supportCascades: boolean;
  52107. /**
  52108. * This returns if the loader support the current file information.
  52109. * @param extension defines the file extension of the file being loaded
  52110. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52111. * @param fallback defines the fallback internal texture if any
  52112. * @param isBase64 defines whether the texture is encoded as a base64
  52113. * @param isBuffer defines whether the texture data are stored as a buffer
  52114. * @returns true if the loader can load the specified file
  52115. */
  52116. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52117. /**
  52118. * Transform the url before loading if required.
  52119. * @param rootUrl the url of the texture
  52120. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52121. * @returns the transformed texture
  52122. */
  52123. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52124. /**
  52125. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52126. * @param rootUrl the url of the texture
  52127. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52128. * @returns the fallback texture
  52129. */
  52130. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52131. /**
  52132. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52133. * @param data contains the texture data
  52134. * @param texture defines the BabylonJS internal texture
  52135. * @param createPolynomials will be true if polynomials have been requested
  52136. * @param onLoad defines the callback to trigger once the texture is ready
  52137. * @param onError defines the callback to trigger in case of error
  52138. */
  52139. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52140. /**
  52141. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52142. * @param data contains the texture data
  52143. * @param texture defines the BabylonJS internal texture
  52144. * @param callback defines the method to call once ready to upload
  52145. */
  52146. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52147. }
  52148. }
  52149. declare module "babylonjs/Helpers/sceneHelpers" {
  52150. import { Nullable } from "babylonjs/types";
  52151. import { Mesh } from "babylonjs/Meshes/mesh";
  52152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52153. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  52154. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  52155. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52156. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52157. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52158. import "babylonjs/Meshes/Builders/boxBuilder";
  52159. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  52160. /** @hidden */
  52161. export var _forceSceneHelpersToBundle: boolean;
  52162. module "babylonjs/scene" {
  52163. interface Scene {
  52164. /**
  52165. * Creates a default light for the scene.
  52166. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52167. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52168. */
  52169. createDefaultLight(replace?: boolean): void;
  52170. /**
  52171. * Creates a default camera for the scene.
  52172. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52173. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52174. * @param replace has default false, when true replaces the active camera in the scene
  52175. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52176. */
  52177. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52178. /**
  52179. * Creates a default camera and a default light.
  52180. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52181. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52182. * @param replace has the default false, when true replaces the active camera/light in the scene
  52183. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52184. */
  52185. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52186. /**
  52187. * Creates a new sky box
  52188. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52189. * @param environmentTexture defines the texture to use as environment texture
  52190. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52191. * @param scale defines the overall scale of the skybox
  52192. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52193. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52194. * @returns a new mesh holding the sky box
  52195. */
  52196. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52197. /**
  52198. * Creates a new environment
  52199. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52200. * @param options defines the options you can use to configure the environment
  52201. * @returns the new EnvironmentHelper
  52202. */
  52203. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52204. /**
  52205. * Creates a new VREXperienceHelper
  52206. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52207. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52208. * @returns a new VREXperienceHelper
  52209. */
  52210. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52211. /**
  52212. * Creates a new WebXRDefaultExperience
  52213. * @see http://doc.babylonjs.com/how_to/webxr
  52214. * @param options experience options
  52215. * @returns a promise for a new WebXRDefaultExperience
  52216. */
  52217. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52218. }
  52219. }
  52220. }
  52221. declare module "babylonjs/Helpers/videoDome" {
  52222. import { Scene } from "babylonjs/scene";
  52223. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52224. import { Mesh } from "babylonjs/Meshes/mesh";
  52225. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  52226. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52227. import "babylonjs/Meshes/Builders/sphereBuilder";
  52228. /**
  52229. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52230. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52231. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52232. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52233. */
  52234. export class VideoDome extends TransformNode {
  52235. /**
  52236. * Define the video source as a Monoscopic panoramic 360 video.
  52237. */
  52238. static readonly MODE_MONOSCOPIC: number;
  52239. /**
  52240. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52241. */
  52242. static readonly MODE_TOPBOTTOM: number;
  52243. /**
  52244. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52245. */
  52246. static readonly MODE_SIDEBYSIDE: number;
  52247. private _halfDome;
  52248. private _useDirectMapping;
  52249. /**
  52250. * The video texture being displayed on the sphere
  52251. */
  52252. protected _videoTexture: VideoTexture;
  52253. /**
  52254. * Gets the video texture being displayed on the sphere
  52255. */
  52256. readonly videoTexture: VideoTexture;
  52257. /**
  52258. * The skybox material
  52259. */
  52260. protected _material: BackgroundMaterial;
  52261. /**
  52262. * The surface used for the skybox
  52263. */
  52264. protected _mesh: Mesh;
  52265. /**
  52266. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52267. */
  52268. private _halfDomeMask;
  52269. /**
  52270. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52271. * Also see the options.resolution property.
  52272. */
  52273. fovMultiplier: number;
  52274. private _videoMode;
  52275. /**
  52276. * Gets or set the current video mode for the video. It can be:
  52277. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52278. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52279. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52280. */
  52281. videoMode: number;
  52282. /**
  52283. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52284. *
  52285. */
  52286. /**
  52287. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52288. */
  52289. halfDome: boolean;
  52290. /**
  52291. * Oberserver used in Stereoscopic VR Mode.
  52292. */
  52293. private _onBeforeCameraRenderObserver;
  52294. /**
  52295. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52296. * @param name Element's name, child elements will append suffixes for their own names.
  52297. * @param urlsOrVideo defines the url(s) or the video element to use
  52298. * @param options An object containing optional or exposed sub element properties
  52299. */
  52300. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52301. resolution?: number;
  52302. clickToPlay?: boolean;
  52303. autoPlay?: boolean;
  52304. loop?: boolean;
  52305. size?: number;
  52306. poster?: string;
  52307. faceForward?: boolean;
  52308. useDirectMapping?: boolean;
  52309. halfDomeMode?: boolean;
  52310. }, scene: Scene);
  52311. private _changeVideoMode;
  52312. /**
  52313. * Releases resources associated with this node.
  52314. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52315. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52316. */
  52317. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52318. }
  52319. }
  52320. declare module "babylonjs/Helpers/index" {
  52321. export * from "babylonjs/Helpers/environmentHelper";
  52322. export * from "babylonjs/Helpers/photoDome";
  52323. export * from "babylonjs/Helpers/sceneHelpers";
  52324. export * from "babylonjs/Helpers/videoDome";
  52325. }
  52326. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  52327. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52328. import { IDisposable } from "babylonjs/scene";
  52329. import { Engine } from "babylonjs/Engines/engine";
  52330. /**
  52331. * This class can be used to get instrumentation data from a Babylon engine
  52332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52333. */
  52334. export class EngineInstrumentation implements IDisposable {
  52335. /**
  52336. * Define the instrumented engine.
  52337. */
  52338. engine: Engine;
  52339. private _captureGPUFrameTime;
  52340. private _gpuFrameTimeToken;
  52341. private _gpuFrameTime;
  52342. private _captureShaderCompilationTime;
  52343. private _shaderCompilationTime;
  52344. private _onBeginFrameObserver;
  52345. private _onEndFrameObserver;
  52346. private _onBeforeShaderCompilationObserver;
  52347. private _onAfterShaderCompilationObserver;
  52348. /**
  52349. * Gets the perf counter used for GPU frame time
  52350. */
  52351. readonly gpuFrameTimeCounter: PerfCounter;
  52352. /**
  52353. * Gets the GPU frame time capture status
  52354. */
  52355. /**
  52356. * Enable or disable the GPU frame time capture
  52357. */
  52358. captureGPUFrameTime: boolean;
  52359. /**
  52360. * Gets the perf counter used for shader compilation time
  52361. */
  52362. readonly shaderCompilationTimeCounter: PerfCounter;
  52363. /**
  52364. * Gets the shader compilation time capture status
  52365. */
  52366. /**
  52367. * Enable or disable the shader compilation time capture
  52368. */
  52369. captureShaderCompilationTime: boolean;
  52370. /**
  52371. * Instantiates a new engine instrumentation.
  52372. * This class can be used to get instrumentation data from a Babylon engine
  52373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52374. * @param engine Defines the engine to instrument
  52375. */
  52376. constructor(
  52377. /**
  52378. * Define the instrumented engine.
  52379. */
  52380. engine: Engine);
  52381. /**
  52382. * Dispose and release associated resources.
  52383. */
  52384. dispose(): void;
  52385. }
  52386. }
  52387. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  52388. import { Scene, IDisposable } from "babylonjs/scene";
  52389. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52390. /**
  52391. * This class can be used to get instrumentation data from a Babylon engine
  52392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52393. */
  52394. export class SceneInstrumentation implements IDisposable {
  52395. /**
  52396. * Defines the scene to instrument
  52397. */
  52398. scene: Scene;
  52399. private _captureActiveMeshesEvaluationTime;
  52400. private _activeMeshesEvaluationTime;
  52401. private _captureRenderTargetsRenderTime;
  52402. private _renderTargetsRenderTime;
  52403. private _captureFrameTime;
  52404. private _frameTime;
  52405. private _captureRenderTime;
  52406. private _renderTime;
  52407. private _captureInterFrameTime;
  52408. private _interFrameTime;
  52409. private _captureParticlesRenderTime;
  52410. private _particlesRenderTime;
  52411. private _captureSpritesRenderTime;
  52412. private _spritesRenderTime;
  52413. private _capturePhysicsTime;
  52414. private _physicsTime;
  52415. private _captureAnimationsTime;
  52416. private _animationsTime;
  52417. private _captureCameraRenderTime;
  52418. private _cameraRenderTime;
  52419. private _onBeforeActiveMeshesEvaluationObserver;
  52420. private _onAfterActiveMeshesEvaluationObserver;
  52421. private _onBeforeRenderTargetsRenderObserver;
  52422. private _onAfterRenderTargetsRenderObserver;
  52423. private _onAfterRenderObserver;
  52424. private _onBeforeDrawPhaseObserver;
  52425. private _onAfterDrawPhaseObserver;
  52426. private _onBeforeAnimationsObserver;
  52427. private _onBeforeParticlesRenderingObserver;
  52428. private _onAfterParticlesRenderingObserver;
  52429. private _onBeforeSpritesRenderingObserver;
  52430. private _onAfterSpritesRenderingObserver;
  52431. private _onBeforePhysicsObserver;
  52432. private _onAfterPhysicsObserver;
  52433. private _onAfterAnimationsObserver;
  52434. private _onBeforeCameraRenderObserver;
  52435. private _onAfterCameraRenderObserver;
  52436. /**
  52437. * Gets the perf counter used for active meshes evaluation time
  52438. */
  52439. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52440. /**
  52441. * Gets the active meshes evaluation time capture status
  52442. */
  52443. /**
  52444. * Enable or disable the active meshes evaluation time capture
  52445. */
  52446. captureActiveMeshesEvaluationTime: boolean;
  52447. /**
  52448. * Gets the perf counter used for render targets render time
  52449. */
  52450. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52451. /**
  52452. * Gets the render targets render time capture status
  52453. */
  52454. /**
  52455. * Enable or disable the render targets render time capture
  52456. */
  52457. captureRenderTargetsRenderTime: boolean;
  52458. /**
  52459. * Gets the perf counter used for particles render time
  52460. */
  52461. readonly particlesRenderTimeCounter: PerfCounter;
  52462. /**
  52463. * Gets the particles render time capture status
  52464. */
  52465. /**
  52466. * Enable or disable the particles render time capture
  52467. */
  52468. captureParticlesRenderTime: boolean;
  52469. /**
  52470. * Gets the perf counter used for sprites render time
  52471. */
  52472. readonly spritesRenderTimeCounter: PerfCounter;
  52473. /**
  52474. * Gets the sprites render time capture status
  52475. */
  52476. /**
  52477. * Enable or disable the sprites render time capture
  52478. */
  52479. captureSpritesRenderTime: boolean;
  52480. /**
  52481. * Gets the perf counter used for physics time
  52482. */
  52483. readonly physicsTimeCounter: PerfCounter;
  52484. /**
  52485. * Gets the physics time capture status
  52486. */
  52487. /**
  52488. * Enable or disable the physics time capture
  52489. */
  52490. capturePhysicsTime: boolean;
  52491. /**
  52492. * Gets the perf counter used for animations time
  52493. */
  52494. readonly animationsTimeCounter: PerfCounter;
  52495. /**
  52496. * Gets the animations time capture status
  52497. */
  52498. /**
  52499. * Enable or disable the animations time capture
  52500. */
  52501. captureAnimationsTime: boolean;
  52502. /**
  52503. * Gets the perf counter used for frame time capture
  52504. */
  52505. readonly frameTimeCounter: PerfCounter;
  52506. /**
  52507. * Gets the frame time capture status
  52508. */
  52509. /**
  52510. * Enable or disable the frame time capture
  52511. */
  52512. captureFrameTime: boolean;
  52513. /**
  52514. * Gets the perf counter used for inter-frames time capture
  52515. */
  52516. readonly interFrameTimeCounter: PerfCounter;
  52517. /**
  52518. * Gets the inter-frames time capture status
  52519. */
  52520. /**
  52521. * Enable or disable the inter-frames time capture
  52522. */
  52523. captureInterFrameTime: boolean;
  52524. /**
  52525. * Gets the perf counter used for render time capture
  52526. */
  52527. readonly renderTimeCounter: PerfCounter;
  52528. /**
  52529. * Gets the render time capture status
  52530. */
  52531. /**
  52532. * Enable or disable the render time capture
  52533. */
  52534. captureRenderTime: boolean;
  52535. /**
  52536. * Gets the perf counter used for camera render time capture
  52537. */
  52538. readonly cameraRenderTimeCounter: PerfCounter;
  52539. /**
  52540. * Gets the camera render time capture status
  52541. */
  52542. /**
  52543. * Enable or disable the camera render time capture
  52544. */
  52545. captureCameraRenderTime: boolean;
  52546. /**
  52547. * Gets the perf counter used for draw calls
  52548. */
  52549. readonly drawCallsCounter: PerfCounter;
  52550. /**
  52551. * Instantiates a new scene instrumentation.
  52552. * This class can be used to get instrumentation data from a Babylon engine
  52553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52554. * @param scene Defines the scene to instrument
  52555. */
  52556. constructor(
  52557. /**
  52558. * Defines the scene to instrument
  52559. */
  52560. scene: Scene);
  52561. /**
  52562. * Dispose and release associated resources.
  52563. */
  52564. dispose(): void;
  52565. }
  52566. }
  52567. declare module "babylonjs/Instrumentation/index" {
  52568. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52569. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52570. export * from "babylonjs/Instrumentation/timeToken";
  52571. }
  52572. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52573. /** @hidden */
  52574. export var glowMapGenerationPixelShader: {
  52575. name: string;
  52576. shader: string;
  52577. };
  52578. }
  52579. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52580. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52581. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52582. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52583. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52584. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52585. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52586. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52587. /** @hidden */
  52588. export var glowMapGenerationVertexShader: {
  52589. name: string;
  52590. shader: string;
  52591. };
  52592. }
  52593. declare module "babylonjs/Layers/effectLayer" {
  52594. import { Observable } from "babylonjs/Misc/observable";
  52595. import { Nullable } from "babylonjs/types";
  52596. import { Camera } from "babylonjs/Cameras/camera";
  52597. import { Scene } from "babylonjs/scene";
  52598. import { ISize } from "babylonjs/Maths/math.size";
  52599. import { Color4 } from "babylonjs/Maths/math.color";
  52600. import { Engine } from "babylonjs/Engines/engine";
  52601. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52603. import { Mesh } from "babylonjs/Meshes/mesh";
  52604. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52606. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52607. import { Effect } from "babylonjs/Materials/effect";
  52608. import { Material } from "babylonjs/Materials/material";
  52609. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52610. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52611. /**
  52612. * Effect layer options. This helps customizing the behaviour
  52613. * of the effect layer.
  52614. */
  52615. export interface IEffectLayerOptions {
  52616. /**
  52617. * Multiplication factor apply to the canvas size to compute the render target size
  52618. * used to generated the objects (the smaller the faster).
  52619. */
  52620. mainTextureRatio: number;
  52621. /**
  52622. * Enforces a fixed size texture to ensure effect stability across devices.
  52623. */
  52624. mainTextureFixedSize?: number;
  52625. /**
  52626. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52627. */
  52628. alphaBlendingMode: number;
  52629. /**
  52630. * The camera attached to the layer.
  52631. */
  52632. camera: Nullable<Camera>;
  52633. /**
  52634. * The rendering group to draw the layer in.
  52635. */
  52636. renderingGroupId: number;
  52637. }
  52638. /**
  52639. * The effect layer Helps adding post process effect blended with the main pass.
  52640. *
  52641. * This can be for instance use to generate glow or higlight effects on the scene.
  52642. *
  52643. * The effect layer class can not be used directly and is intented to inherited from to be
  52644. * customized per effects.
  52645. */
  52646. export abstract class EffectLayer {
  52647. private _vertexBuffers;
  52648. private _indexBuffer;
  52649. private _cachedDefines;
  52650. private _effectLayerMapGenerationEffect;
  52651. private _effectLayerOptions;
  52652. private _mergeEffect;
  52653. protected _scene: Scene;
  52654. protected _engine: Engine;
  52655. protected _maxSize: number;
  52656. protected _mainTextureDesiredSize: ISize;
  52657. protected _mainTexture: RenderTargetTexture;
  52658. protected _shouldRender: boolean;
  52659. protected _postProcesses: PostProcess[];
  52660. protected _textures: BaseTexture[];
  52661. protected _emissiveTextureAndColor: {
  52662. texture: Nullable<BaseTexture>;
  52663. color: Color4;
  52664. };
  52665. /**
  52666. * The name of the layer
  52667. */
  52668. name: string;
  52669. /**
  52670. * The clear color of the texture used to generate the glow map.
  52671. */
  52672. neutralColor: Color4;
  52673. /**
  52674. * Specifies wether the highlight layer is enabled or not.
  52675. */
  52676. isEnabled: boolean;
  52677. /**
  52678. * Gets the camera attached to the layer.
  52679. */
  52680. readonly camera: Nullable<Camera>;
  52681. /**
  52682. * Gets the rendering group id the layer should render in.
  52683. */
  52684. renderingGroupId: number;
  52685. /**
  52686. * An event triggered when the effect layer has been disposed.
  52687. */
  52688. onDisposeObservable: Observable<EffectLayer>;
  52689. /**
  52690. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52691. */
  52692. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52693. /**
  52694. * An event triggered when the generated texture is being merged in the scene.
  52695. */
  52696. onBeforeComposeObservable: Observable<EffectLayer>;
  52697. /**
  52698. * An event triggered when the mesh is rendered into the effect render target.
  52699. */
  52700. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52701. /**
  52702. * An event triggered after the mesh has been rendered into the effect render target.
  52703. */
  52704. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52705. /**
  52706. * An event triggered when the generated texture has been merged in the scene.
  52707. */
  52708. onAfterComposeObservable: Observable<EffectLayer>;
  52709. /**
  52710. * An event triggered when the efffect layer changes its size.
  52711. */
  52712. onSizeChangedObservable: Observable<EffectLayer>;
  52713. /** @hidden */
  52714. static _SceneComponentInitialization: (scene: Scene) => void;
  52715. /**
  52716. * Instantiates a new effect Layer and references it in the scene.
  52717. * @param name The name of the layer
  52718. * @param scene The scene to use the layer in
  52719. */
  52720. constructor(
  52721. /** The Friendly of the effect in the scene */
  52722. name: string, scene: Scene);
  52723. /**
  52724. * Get the effect name of the layer.
  52725. * @return The effect name
  52726. */
  52727. abstract getEffectName(): string;
  52728. /**
  52729. * Checks for the readiness of the element composing the layer.
  52730. * @param subMesh the mesh to check for
  52731. * @param useInstances specify wether or not to use instances to render the mesh
  52732. * @return true if ready otherwise, false
  52733. */
  52734. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52735. /**
  52736. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52737. * @returns true if the effect requires stencil during the main canvas render pass.
  52738. */
  52739. abstract needStencil(): boolean;
  52740. /**
  52741. * Create the merge effect. This is the shader use to blit the information back
  52742. * to the main canvas at the end of the scene rendering.
  52743. * @returns The effect containing the shader used to merge the effect on the main canvas
  52744. */
  52745. protected abstract _createMergeEffect(): Effect;
  52746. /**
  52747. * Creates the render target textures and post processes used in the effect layer.
  52748. */
  52749. protected abstract _createTextureAndPostProcesses(): void;
  52750. /**
  52751. * Implementation specific of rendering the generating effect on the main canvas.
  52752. * @param effect The effect used to render through
  52753. */
  52754. protected abstract _internalRender(effect: Effect): void;
  52755. /**
  52756. * Sets the required values for both the emissive texture and and the main color.
  52757. */
  52758. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52759. /**
  52760. * Free any resources and references associated to a mesh.
  52761. * Internal use
  52762. * @param mesh The mesh to free.
  52763. */
  52764. abstract _disposeMesh(mesh: Mesh): void;
  52765. /**
  52766. * Serializes this layer (Glow or Highlight for example)
  52767. * @returns a serialized layer object
  52768. */
  52769. abstract serialize?(): any;
  52770. /**
  52771. * Initializes the effect layer with the required options.
  52772. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52773. */
  52774. protected _init(options: Partial<IEffectLayerOptions>): void;
  52775. /**
  52776. * Generates the index buffer of the full screen quad blending to the main canvas.
  52777. */
  52778. private _generateIndexBuffer;
  52779. /**
  52780. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52781. */
  52782. private _generateVertexBuffer;
  52783. /**
  52784. * Sets the main texture desired size which is the closest power of two
  52785. * of the engine canvas size.
  52786. */
  52787. private _setMainTextureSize;
  52788. /**
  52789. * Creates the main texture for the effect layer.
  52790. */
  52791. protected _createMainTexture(): void;
  52792. /**
  52793. * Adds specific effects defines.
  52794. * @param defines The defines to add specifics to.
  52795. */
  52796. protected _addCustomEffectDefines(defines: string[]): void;
  52797. /**
  52798. * Checks for the readiness of the element composing the layer.
  52799. * @param subMesh the mesh to check for
  52800. * @param useInstances specify wether or not to use instances to render the mesh
  52801. * @param emissiveTexture the associated emissive texture used to generate the glow
  52802. * @return true if ready otherwise, false
  52803. */
  52804. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52805. /**
  52806. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52807. */
  52808. render(): void;
  52809. /**
  52810. * Determine if a given mesh will be used in the current effect.
  52811. * @param mesh mesh to test
  52812. * @returns true if the mesh will be used
  52813. */
  52814. hasMesh(mesh: AbstractMesh): boolean;
  52815. /**
  52816. * Returns true if the layer contains information to display, otherwise false.
  52817. * @returns true if the glow layer should be rendered
  52818. */
  52819. shouldRender(): boolean;
  52820. /**
  52821. * Returns true if the mesh should render, otherwise false.
  52822. * @param mesh The mesh to render
  52823. * @returns true if it should render otherwise false
  52824. */
  52825. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52826. /**
  52827. * Returns true if the mesh can be rendered, otherwise false.
  52828. * @param mesh The mesh to render
  52829. * @param material The material used on the mesh
  52830. * @returns true if it can be rendered otherwise false
  52831. */
  52832. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52833. /**
  52834. * Returns true if the mesh should render, otherwise false.
  52835. * @param mesh The mesh to render
  52836. * @returns true if it should render otherwise false
  52837. */
  52838. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52839. /**
  52840. * Renders the submesh passed in parameter to the generation map.
  52841. */
  52842. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52843. /**
  52844. * Defines wether the current material of the mesh should be use to render the effect.
  52845. * @param mesh defines the current mesh to render
  52846. */
  52847. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52848. /**
  52849. * Rebuild the required buffers.
  52850. * @hidden Internal use only.
  52851. */
  52852. _rebuild(): void;
  52853. /**
  52854. * Dispose only the render target textures and post process.
  52855. */
  52856. private _disposeTextureAndPostProcesses;
  52857. /**
  52858. * Dispose the highlight layer and free resources.
  52859. */
  52860. dispose(): void;
  52861. /**
  52862. * Gets the class name of the effect layer
  52863. * @returns the string with the class name of the effect layer
  52864. */
  52865. getClassName(): string;
  52866. /**
  52867. * Creates an effect layer from parsed effect layer data
  52868. * @param parsedEffectLayer defines effect layer data
  52869. * @param scene defines the current scene
  52870. * @param rootUrl defines the root URL containing the effect layer information
  52871. * @returns a parsed effect Layer
  52872. */
  52873. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52874. }
  52875. }
  52876. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52877. import { Scene } from "babylonjs/scene";
  52878. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52879. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52880. import { AbstractScene } from "babylonjs/abstractScene";
  52881. module "babylonjs/abstractScene" {
  52882. interface AbstractScene {
  52883. /**
  52884. * The list of effect layers (highlights/glow) added to the scene
  52885. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52886. * @see http://doc.babylonjs.com/how_to/glow_layer
  52887. */
  52888. effectLayers: Array<EffectLayer>;
  52889. /**
  52890. * Removes the given effect layer from this scene.
  52891. * @param toRemove defines the effect layer to remove
  52892. * @returns the index of the removed effect layer
  52893. */
  52894. removeEffectLayer(toRemove: EffectLayer): number;
  52895. /**
  52896. * Adds the given effect layer to this scene
  52897. * @param newEffectLayer defines the effect layer to add
  52898. */
  52899. addEffectLayer(newEffectLayer: EffectLayer): void;
  52900. }
  52901. }
  52902. /**
  52903. * Defines the layer scene component responsible to manage any effect layers
  52904. * in a given scene.
  52905. */
  52906. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52907. /**
  52908. * The component name helpfull to identify the component in the list of scene components.
  52909. */
  52910. readonly name: string;
  52911. /**
  52912. * The scene the component belongs to.
  52913. */
  52914. scene: Scene;
  52915. private _engine;
  52916. private _renderEffects;
  52917. private _needStencil;
  52918. private _previousStencilState;
  52919. /**
  52920. * Creates a new instance of the component for the given scene
  52921. * @param scene Defines the scene to register the component in
  52922. */
  52923. constructor(scene: Scene);
  52924. /**
  52925. * Registers the component in a given scene
  52926. */
  52927. register(): void;
  52928. /**
  52929. * Rebuilds the elements related to this component in case of
  52930. * context lost for instance.
  52931. */
  52932. rebuild(): void;
  52933. /**
  52934. * Serializes the component data to the specified json object
  52935. * @param serializationObject The object to serialize to
  52936. */
  52937. serialize(serializationObject: any): void;
  52938. /**
  52939. * Adds all the elements from the container to the scene
  52940. * @param container the container holding the elements
  52941. */
  52942. addFromContainer(container: AbstractScene): void;
  52943. /**
  52944. * Removes all the elements in the container from the scene
  52945. * @param container contains the elements to remove
  52946. * @param dispose if the removed element should be disposed (default: false)
  52947. */
  52948. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52949. /**
  52950. * Disposes the component and the associated ressources.
  52951. */
  52952. dispose(): void;
  52953. private _isReadyForMesh;
  52954. private _renderMainTexture;
  52955. private _setStencil;
  52956. private _setStencilBack;
  52957. private _draw;
  52958. private _drawCamera;
  52959. private _drawRenderingGroup;
  52960. }
  52961. }
  52962. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52963. /** @hidden */
  52964. export var glowMapMergePixelShader: {
  52965. name: string;
  52966. shader: string;
  52967. };
  52968. }
  52969. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52970. /** @hidden */
  52971. export var glowMapMergeVertexShader: {
  52972. name: string;
  52973. shader: string;
  52974. };
  52975. }
  52976. declare module "babylonjs/Layers/glowLayer" {
  52977. import { Nullable } from "babylonjs/types";
  52978. import { Camera } from "babylonjs/Cameras/camera";
  52979. import { Scene } from "babylonjs/scene";
  52980. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52982. import { Mesh } from "babylonjs/Meshes/mesh";
  52983. import { Texture } from "babylonjs/Materials/Textures/texture";
  52984. import { Effect } from "babylonjs/Materials/effect";
  52985. import { Material } from "babylonjs/Materials/material";
  52986. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52987. import { Color4 } from "babylonjs/Maths/math.color";
  52988. import "babylonjs/Shaders/glowMapMerge.fragment";
  52989. import "babylonjs/Shaders/glowMapMerge.vertex";
  52990. import "babylonjs/Layers/effectLayerSceneComponent";
  52991. module "babylonjs/abstractScene" {
  52992. interface AbstractScene {
  52993. /**
  52994. * Return a the first highlight layer of the scene with a given name.
  52995. * @param name The name of the highlight layer to look for.
  52996. * @return The highlight layer if found otherwise null.
  52997. */
  52998. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52999. }
  53000. }
  53001. /**
  53002. * Glow layer options. This helps customizing the behaviour
  53003. * of the glow layer.
  53004. */
  53005. export interface IGlowLayerOptions {
  53006. /**
  53007. * Multiplication factor apply to the canvas size to compute the render target size
  53008. * used to generated the glowing objects (the smaller the faster).
  53009. */
  53010. mainTextureRatio: number;
  53011. /**
  53012. * Enforces a fixed size texture to ensure resize independant blur.
  53013. */
  53014. mainTextureFixedSize?: number;
  53015. /**
  53016. * How big is the kernel of the blur texture.
  53017. */
  53018. blurKernelSize: number;
  53019. /**
  53020. * The camera attached to the layer.
  53021. */
  53022. camera: Nullable<Camera>;
  53023. /**
  53024. * Enable MSAA by chosing the number of samples.
  53025. */
  53026. mainTextureSamples?: number;
  53027. /**
  53028. * The rendering group to draw the layer in.
  53029. */
  53030. renderingGroupId: number;
  53031. }
  53032. /**
  53033. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53034. *
  53035. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53036. *
  53037. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53038. */
  53039. export class GlowLayer extends EffectLayer {
  53040. /**
  53041. * Effect Name of the layer.
  53042. */
  53043. static readonly EffectName: string;
  53044. /**
  53045. * The default blur kernel size used for the glow.
  53046. */
  53047. static DefaultBlurKernelSize: number;
  53048. /**
  53049. * The default texture size ratio used for the glow.
  53050. */
  53051. static DefaultTextureRatio: number;
  53052. /**
  53053. * Sets the kernel size of the blur.
  53054. */
  53055. /**
  53056. * Gets the kernel size of the blur.
  53057. */
  53058. blurKernelSize: number;
  53059. /**
  53060. * Sets the glow intensity.
  53061. */
  53062. /**
  53063. * Gets the glow intensity.
  53064. */
  53065. intensity: number;
  53066. private _options;
  53067. private _intensity;
  53068. private _horizontalBlurPostprocess1;
  53069. private _verticalBlurPostprocess1;
  53070. private _horizontalBlurPostprocess2;
  53071. private _verticalBlurPostprocess2;
  53072. private _blurTexture1;
  53073. private _blurTexture2;
  53074. private _postProcesses1;
  53075. private _postProcesses2;
  53076. private _includedOnlyMeshes;
  53077. private _excludedMeshes;
  53078. private _meshesUsingTheirOwnMaterials;
  53079. /**
  53080. * Callback used to let the user override the color selection on a per mesh basis
  53081. */
  53082. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53083. /**
  53084. * Callback used to let the user override the texture selection on a per mesh basis
  53085. */
  53086. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53087. /**
  53088. * Instantiates a new glow Layer and references it to the scene.
  53089. * @param name The name of the layer
  53090. * @param scene The scene to use the layer in
  53091. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53092. */
  53093. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53094. /**
  53095. * Get the effect name of the layer.
  53096. * @return The effect name
  53097. */
  53098. getEffectName(): string;
  53099. /**
  53100. * Create the merge effect. This is the shader use to blit the information back
  53101. * to the main canvas at the end of the scene rendering.
  53102. */
  53103. protected _createMergeEffect(): Effect;
  53104. /**
  53105. * Creates the render target textures and post processes used in the glow layer.
  53106. */
  53107. protected _createTextureAndPostProcesses(): void;
  53108. /**
  53109. * Checks for the readiness of the element composing the layer.
  53110. * @param subMesh the mesh to check for
  53111. * @param useInstances specify wether or not to use instances to render the mesh
  53112. * @param emissiveTexture the associated emissive texture used to generate the glow
  53113. * @return true if ready otherwise, false
  53114. */
  53115. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53116. /**
  53117. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53118. */
  53119. needStencil(): boolean;
  53120. /**
  53121. * Returns true if the mesh can be rendered, otherwise false.
  53122. * @param mesh The mesh to render
  53123. * @param material The material used on the mesh
  53124. * @returns true if it can be rendered otherwise false
  53125. */
  53126. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53127. /**
  53128. * Implementation specific of rendering the generating effect on the main canvas.
  53129. * @param effect The effect used to render through
  53130. */
  53131. protected _internalRender(effect: Effect): void;
  53132. /**
  53133. * Sets the required values for both the emissive texture and and the main color.
  53134. */
  53135. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53136. /**
  53137. * Returns true if the mesh should render, otherwise false.
  53138. * @param mesh The mesh to render
  53139. * @returns true if it should render otherwise false
  53140. */
  53141. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53142. /**
  53143. * Adds specific effects defines.
  53144. * @param defines The defines to add specifics to.
  53145. */
  53146. protected _addCustomEffectDefines(defines: string[]): void;
  53147. /**
  53148. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53149. * @param mesh The mesh to exclude from the glow layer
  53150. */
  53151. addExcludedMesh(mesh: Mesh): void;
  53152. /**
  53153. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53154. * @param mesh The mesh to remove
  53155. */
  53156. removeExcludedMesh(mesh: Mesh): void;
  53157. /**
  53158. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53159. * @param mesh The mesh to include in the glow layer
  53160. */
  53161. addIncludedOnlyMesh(mesh: Mesh): void;
  53162. /**
  53163. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53164. * @param mesh The mesh to remove
  53165. */
  53166. removeIncludedOnlyMesh(mesh: Mesh): void;
  53167. /**
  53168. * Determine if a given mesh will be used in the glow layer
  53169. * @param mesh The mesh to test
  53170. * @returns true if the mesh will be highlighted by the current glow layer
  53171. */
  53172. hasMesh(mesh: AbstractMesh): boolean;
  53173. /**
  53174. * Defines wether the current material of the mesh should be use to render the effect.
  53175. * @param mesh defines the current mesh to render
  53176. */
  53177. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53178. /**
  53179. * Add a mesh to be rendered through its own material and not with emissive only.
  53180. * @param mesh The mesh for which we need to use its material
  53181. */
  53182. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53183. /**
  53184. * Remove a mesh from being rendered through its own material and not with emissive only.
  53185. * @param mesh The mesh for which we need to not use its material
  53186. */
  53187. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53188. /**
  53189. * Free any resources and references associated to a mesh.
  53190. * Internal use
  53191. * @param mesh The mesh to free.
  53192. * @hidden
  53193. */
  53194. _disposeMesh(mesh: Mesh): void;
  53195. /**
  53196. * Gets the class name of the effect layer
  53197. * @returns the string with the class name of the effect layer
  53198. */
  53199. getClassName(): string;
  53200. /**
  53201. * Serializes this glow layer
  53202. * @returns a serialized glow layer object
  53203. */
  53204. serialize(): any;
  53205. /**
  53206. * Creates a Glow Layer from parsed glow layer data
  53207. * @param parsedGlowLayer defines glow layer data
  53208. * @param scene defines the current scene
  53209. * @param rootUrl defines the root URL containing the glow layer information
  53210. * @returns a parsed Glow Layer
  53211. */
  53212. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53213. }
  53214. }
  53215. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  53216. /** @hidden */
  53217. export var glowBlurPostProcessPixelShader: {
  53218. name: string;
  53219. shader: string;
  53220. };
  53221. }
  53222. declare module "babylonjs/Layers/highlightLayer" {
  53223. import { Observable } from "babylonjs/Misc/observable";
  53224. import { Nullable } from "babylonjs/types";
  53225. import { Camera } from "babylonjs/Cameras/camera";
  53226. import { Scene } from "babylonjs/scene";
  53227. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53229. import { Mesh } from "babylonjs/Meshes/mesh";
  53230. import { Effect } from "babylonjs/Materials/effect";
  53231. import { Material } from "babylonjs/Materials/material";
  53232. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53233. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  53234. import "babylonjs/Shaders/glowMapMerge.fragment";
  53235. import "babylonjs/Shaders/glowMapMerge.vertex";
  53236. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  53237. module "babylonjs/abstractScene" {
  53238. interface AbstractScene {
  53239. /**
  53240. * Return a the first highlight layer of the scene with a given name.
  53241. * @param name The name of the highlight layer to look for.
  53242. * @return The highlight layer if found otherwise null.
  53243. */
  53244. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53245. }
  53246. }
  53247. /**
  53248. * Highlight layer options. This helps customizing the behaviour
  53249. * of the highlight layer.
  53250. */
  53251. export interface IHighlightLayerOptions {
  53252. /**
  53253. * Multiplication factor apply to the canvas size to compute the render target size
  53254. * used to generated the glowing objects (the smaller the faster).
  53255. */
  53256. mainTextureRatio: number;
  53257. /**
  53258. * Enforces a fixed size texture to ensure resize independant blur.
  53259. */
  53260. mainTextureFixedSize?: number;
  53261. /**
  53262. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53263. * of the picture to blur (the smaller the faster).
  53264. */
  53265. blurTextureSizeRatio: number;
  53266. /**
  53267. * How big in texel of the blur texture is the vertical blur.
  53268. */
  53269. blurVerticalSize: number;
  53270. /**
  53271. * How big in texel of the blur texture is the horizontal blur.
  53272. */
  53273. blurHorizontalSize: number;
  53274. /**
  53275. * Alpha blending mode used to apply the blur. Default is combine.
  53276. */
  53277. alphaBlendingMode: number;
  53278. /**
  53279. * The camera attached to the layer.
  53280. */
  53281. camera: Nullable<Camera>;
  53282. /**
  53283. * Should we display highlight as a solid stroke?
  53284. */
  53285. isStroke?: boolean;
  53286. /**
  53287. * The rendering group to draw the layer in.
  53288. */
  53289. renderingGroupId: number;
  53290. }
  53291. /**
  53292. * The highlight layer Helps adding a glow effect around a mesh.
  53293. *
  53294. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53295. * glowy meshes to your scene.
  53296. *
  53297. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53298. */
  53299. export class HighlightLayer extends EffectLayer {
  53300. name: string;
  53301. /**
  53302. * Effect Name of the highlight layer.
  53303. */
  53304. static readonly EffectName: string;
  53305. /**
  53306. * The neutral color used during the preparation of the glow effect.
  53307. * This is black by default as the blend operation is a blend operation.
  53308. */
  53309. static NeutralColor: Color4;
  53310. /**
  53311. * Stencil value used for glowing meshes.
  53312. */
  53313. static GlowingMeshStencilReference: number;
  53314. /**
  53315. * Stencil value used for the other meshes in the scene.
  53316. */
  53317. static NormalMeshStencilReference: number;
  53318. /**
  53319. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53320. */
  53321. innerGlow: boolean;
  53322. /**
  53323. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53324. */
  53325. outerGlow: boolean;
  53326. /**
  53327. * Specifies the horizontal size of the blur.
  53328. */
  53329. /**
  53330. * Gets the horizontal size of the blur.
  53331. */
  53332. blurHorizontalSize: number;
  53333. /**
  53334. * Specifies the vertical size of the blur.
  53335. */
  53336. /**
  53337. * Gets the vertical size of the blur.
  53338. */
  53339. blurVerticalSize: number;
  53340. /**
  53341. * An event triggered when the highlight layer is being blurred.
  53342. */
  53343. onBeforeBlurObservable: Observable<HighlightLayer>;
  53344. /**
  53345. * An event triggered when the highlight layer has been blurred.
  53346. */
  53347. onAfterBlurObservable: Observable<HighlightLayer>;
  53348. private _instanceGlowingMeshStencilReference;
  53349. private _options;
  53350. private _downSamplePostprocess;
  53351. private _horizontalBlurPostprocess;
  53352. private _verticalBlurPostprocess;
  53353. private _blurTexture;
  53354. private _meshes;
  53355. private _excludedMeshes;
  53356. /**
  53357. * Instantiates a new highlight Layer and references it to the scene..
  53358. * @param name The name of the layer
  53359. * @param scene The scene to use the layer in
  53360. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53361. */
  53362. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53363. /**
  53364. * Get the effect name of the layer.
  53365. * @return The effect name
  53366. */
  53367. getEffectName(): string;
  53368. /**
  53369. * Create the merge effect. This is the shader use to blit the information back
  53370. * to the main canvas at the end of the scene rendering.
  53371. */
  53372. protected _createMergeEffect(): Effect;
  53373. /**
  53374. * Creates the render target textures and post processes used in the highlight layer.
  53375. */
  53376. protected _createTextureAndPostProcesses(): void;
  53377. /**
  53378. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53379. */
  53380. needStencil(): boolean;
  53381. /**
  53382. * Checks for the readiness of the element composing the layer.
  53383. * @param subMesh the mesh to check for
  53384. * @param useInstances specify wether or not to use instances to render the mesh
  53385. * @param emissiveTexture the associated emissive texture used to generate the glow
  53386. * @return true if ready otherwise, false
  53387. */
  53388. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53389. /**
  53390. * Implementation specific of rendering the generating effect on the main canvas.
  53391. * @param effect The effect used to render through
  53392. */
  53393. protected _internalRender(effect: Effect): void;
  53394. /**
  53395. * Returns true if the layer contains information to display, otherwise false.
  53396. */
  53397. shouldRender(): boolean;
  53398. /**
  53399. * Returns true if the mesh should render, otherwise false.
  53400. * @param mesh The mesh to render
  53401. * @returns true if it should render otherwise false
  53402. */
  53403. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53404. /**
  53405. * Sets the required values for both the emissive texture and and the main color.
  53406. */
  53407. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53408. /**
  53409. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53410. * @param mesh The mesh to exclude from the highlight layer
  53411. */
  53412. addExcludedMesh(mesh: Mesh): void;
  53413. /**
  53414. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53415. * @param mesh The mesh to highlight
  53416. */
  53417. removeExcludedMesh(mesh: Mesh): void;
  53418. /**
  53419. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53420. * @param mesh mesh to test
  53421. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53422. */
  53423. hasMesh(mesh: AbstractMesh): boolean;
  53424. /**
  53425. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53426. * @param mesh The mesh to highlight
  53427. * @param color The color of the highlight
  53428. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53429. */
  53430. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53431. /**
  53432. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53433. * @param mesh The mesh to highlight
  53434. */
  53435. removeMesh(mesh: Mesh): void;
  53436. /**
  53437. * Force the stencil to the normal expected value for none glowing parts
  53438. */
  53439. private _defaultStencilReference;
  53440. /**
  53441. * Free any resources and references associated to a mesh.
  53442. * Internal use
  53443. * @param mesh The mesh to free.
  53444. * @hidden
  53445. */
  53446. _disposeMesh(mesh: Mesh): void;
  53447. /**
  53448. * Dispose the highlight layer and free resources.
  53449. */
  53450. dispose(): void;
  53451. /**
  53452. * Gets the class name of the effect layer
  53453. * @returns the string with the class name of the effect layer
  53454. */
  53455. getClassName(): string;
  53456. /**
  53457. * Serializes this Highlight layer
  53458. * @returns a serialized Highlight layer object
  53459. */
  53460. serialize(): any;
  53461. /**
  53462. * Creates a Highlight layer from parsed Highlight layer data
  53463. * @param parsedHightlightLayer defines the Highlight layer data
  53464. * @param scene defines the current scene
  53465. * @param rootUrl defines the root URL containing the Highlight layer information
  53466. * @returns a parsed Highlight layer
  53467. */
  53468. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53469. }
  53470. }
  53471. declare module "babylonjs/Layers/layerSceneComponent" {
  53472. import { Scene } from "babylonjs/scene";
  53473. import { ISceneComponent } from "babylonjs/sceneComponent";
  53474. import { Layer } from "babylonjs/Layers/layer";
  53475. import { AbstractScene } from "babylonjs/abstractScene";
  53476. module "babylonjs/abstractScene" {
  53477. interface AbstractScene {
  53478. /**
  53479. * The list of layers (background and foreground) of the scene
  53480. */
  53481. layers: Array<Layer>;
  53482. }
  53483. }
  53484. /**
  53485. * Defines the layer scene component responsible to manage any layers
  53486. * in a given scene.
  53487. */
  53488. export class LayerSceneComponent implements ISceneComponent {
  53489. /**
  53490. * The component name helpfull to identify the component in the list of scene components.
  53491. */
  53492. readonly name: string;
  53493. /**
  53494. * The scene the component belongs to.
  53495. */
  53496. scene: Scene;
  53497. private _engine;
  53498. /**
  53499. * Creates a new instance of the component for the given scene
  53500. * @param scene Defines the scene to register the component in
  53501. */
  53502. constructor(scene: Scene);
  53503. /**
  53504. * Registers the component in a given scene
  53505. */
  53506. register(): void;
  53507. /**
  53508. * Rebuilds the elements related to this component in case of
  53509. * context lost for instance.
  53510. */
  53511. rebuild(): void;
  53512. /**
  53513. * Disposes the component and the associated ressources.
  53514. */
  53515. dispose(): void;
  53516. private _draw;
  53517. private _drawCameraPredicate;
  53518. private _drawCameraBackground;
  53519. private _drawCameraForeground;
  53520. private _drawRenderTargetPredicate;
  53521. private _drawRenderTargetBackground;
  53522. private _drawRenderTargetForeground;
  53523. /**
  53524. * Adds all the elements from the container to the scene
  53525. * @param container the container holding the elements
  53526. */
  53527. addFromContainer(container: AbstractScene): void;
  53528. /**
  53529. * Removes all the elements in the container from the scene
  53530. * @param container contains the elements to remove
  53531. * @param dispose if the removed element should be disposed (default: false)
  53532. */
  53533. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53534. }
  53535. }
  53536. declare module "babylonjs/Shaders/layer.fragment" {
  53537. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53538. /** @hidden */
  53539. export var layerPixelShader: {
  53540. name: string;
  53541. shader: string;
  53542. };
  53543. }
  53544. declare module "babylonjs/Shaders/layer.vertex" {
  53545. /** @hidden */
  53546. export var layerVertexShader: {
  53547. name: string;
  53548. shader: string;
  53549. };
  53550. }
  53551. declare module "babylonjs/Layers/layer" {
  53552. import { Observable } from "babylonjs/Misc/observable";
  53553. import { Nullable } from "babylonjs/types";
  53554. import { Scene } from "babylonjs/scene";
  53555. import { Vector2 } from "babylonjs/Maths/math.vector";
  53556. import { Color4 } from "babylonjs/Maths/math.color";
  53557. import { Texture } from "babylonjs/Materials/Textures/texture";
  53558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53559. import "babylonjs/Shaders/layer.fragment";
  53560. import "babylonjs/Shaders/layer.vertex";
  53561. /**
  53562. * This represents a full screen 2d layer.
  53563. * This can be useful to display a picture in the background of your scene for instance.
  53564. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53565. */
  53566. export class Layer {
  53567. /**
  53568. * Define the name of the layer.
  53569. */
  53570. name: string;
  53571. /**
  53572. * Define the texture the layer should display.
  53573. */
  53574. texture: Nullable<Texture>;
  53575. /**
  53576. * Is the layer in background or foreground.
  53577. */
  53578. isBackground: boolean;
  53579. /**
  53580. * Define the color of the layer (instead of texture).
  53581. */
  53582. color: Color4;
  53583. /**
  53584. * Define the scale of the layer in order to zoom in out of the texture.
  53585. */
  53586. scale: Vector2;
  53587. /**
  53588. * Define an offset for the layer in order to shift the texture.
  53589. */
  53590. offset: Vector2;
  53591. /**
  53592. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53593. */
  53594. alphaBlendingMode: number;
  53595. /**
  53596. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53597. * Alpha test will not mix with the background color in case of transparency.
  53598. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53599. */
  53600. alphaTest: boolean;
  53601. /**
  53602. * Define a mask to restrict the layer to only some of the scene cameras.
  53603. */
  53604. layerMask: number;
  53605. /**
  53606. * Define the list of render target the layer is visible into.
  53607. */
  53608. renderTargetTextures: RenderTargetTexture[];
  53609. /**
  53610. * Define if the layer is only used in renderTarget or if it also
  53611. * renders in the main frame buffer of the canvas.
  53612. */
  53613. renderOnlyInRenderTargetTextures: boolean;
  53614. private _scene;
  53615. private _vertexBuffers;
  53616. private _indexBuffer;
  53617. private _effect;
  53618. private _previousDefines;
  53619. /**
  53620. * An event triggered when the layer is disposed.
  53621. */
  53622. onDisposeObservable: Observable<Layer>;
  53623. private _onDisposeObserver;
  53624. /**
  53625. * Back compatibility with callback before the onDisposeObservable existed.
  53626. * The set callback will be triggered when the layer has been disposed.
  53627. */
  53628. onDispose: () => void;
  53629. /**
  53630. * An event triggered before rendering the scene
  53631. */
  53632. onBeforeRenderObservable: Observable<Layer>;
  53633. private _onBeforeRenderObserver;
  53634. /**
  53635. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53636. * The set callback will be triggered just before rendering the layer.
  53637. */
  53638. onBeforeRender: () => void;
  53639. /**
  53640. * An event triggered after rendering the scene
  53641. */
  53642. onAfterRenderObservable: Observable<Layer>;
  53643. private _onAfterRenderObserver;
  53644. /**
  53645. * Back compatibility with callback before the onAfterRenderObservable existed.
  53646. * The set callback will be triggered just after rendering the layer.
  53647. */
  53648. onAfterRender: () => void;
  53649. /**
  53650. * Instantiates a new layer.
  53651. * This represents a full screen 2d layer.
  53652. * This can be useful to display a picture in the background of your scene for instance.
  53653. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53654. * @param name Define the name of the layer in the scene
  53655. * @param imgUrl Define the url of the texture to display in the layer
  53656. * @param scene Define the scene the layer belongs to
  53657. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53658. * @param color Defines a color for the layer
  53659. */
  53660. constructor(
  53661. /**
  53662. * Define the name of the layer.
  53663. */
  53664. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53665. private _createIndexBuffer;
  53666. /** @hidden */
  53667. _rebuild(): void;
  53668. /**
  53669. * Renders the layer in the scene.
  53670. */
  53671. render(): void;
  53672. /**
  53673. * Disposes and releases the associated ressources.
  53674. */
  53675. dispose(): void;
  53676. }
  53677. }
  53678. declare module "babylonjs/Layers/index" {
  53679. export * from "babylonjs/Layers/effectLayer";
  53680. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53681. export * from "babylonjs/Layers/glowLayer";
  53682. export * from "babylonjs/Layers/highlightLayer";
  53683. export * from "babylonjs/Layers/layer";
  53684. export * from "babylonjs/Layers/layerSceneComponent";
  53685. }
  53686. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53687. /** @hidden */
  53688. export var lensFlarePixelShader: {
  53689. name: string;
  53690. shader: string;
  53691. };
  53692. }
  53693. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53694. /** @hidden */
  53695. export var lensFlareVertexShader: {
  53696. name: string;
  53697. shader: string;
  53698. };
  53699. }
  53700. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53701. import { Scene } from "babylonjs/scene";
  53702. import { Vector3 } from "babylonjs/Maths/math.vector";
  53703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53704. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53705. import "babylonjs/Shaders/lensFlare.fragment";
  53706. import "babylonjs/Shaders/lensFlare.vertex";
  53707. import { Viewport } from "babylonjs/Maths/math.viewport";
  53708. /**
  53709. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53710. * It is usually composed of several `lensFlare`.
  53711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53712. */
  53713. export class LensFlareSystem {
  53714. /**
  53715. * Define the name of the lens flare system
  53716. */
  53717. name: string;
  53718. /**
  53719. * List of lens flares used in this system.
  53720. */
  53721. lensFlares: LensFlare[];
  53722. /**
  53723. * Define a limit from the border the lens flare can be visible.
  53724. */
  53725. borderLimit: number;
  53726. /**
  53727. * Define a viewport border we do not want to see the lens flare in.
  53728. */
  53729. viewportBorder: number;
  53730. /**
  53731. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53732. */
  53733. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53734. /**
  53735. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53736. */
  53737. layerMask: number;
  53738. /**
  53739. * Define the id of the lens flare system in the scene.
  53740. * (equal to name by default)
  53741. */
  53742. id: string;
  53743. private _scene;
  53744. private _emitter;
  53745. private _vertexBuffers;
  53746. private _indexBuffer;
  53747. private _effect;
  53748. private _positionX;
  53749. private _positionY;
  53750. private _isEnabled;
  53751. /** @hidden */
  53752. static _SceneComponentInitialization: (scene: Scene) => void;
  53753. /**
  53754. * Instantiates a lens flare system.
  53755. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53756. * It is usually composed of several `lensFlare`.
  53757. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53758. * @param name Define the name of the lens flare system in the scene
  53759. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53760. * @param scene Define the scene the lens flare system belongs to
  53761. */
  53762. constructor(
  53763. /**
  53764. * Define the name of the lens flare system
  53765. */
  53766. name: string, emitter: any, scene: Scene);
  53767. /**
  53768. * Define if the lens flare system is enabled.
  53769. */
  53770. isEnabled: boolean;
  53771. /**
  53772. * Get the scene the effects belongs to.
  53773. * @returns the scene holding the lens flare system
  53774. */
  53775. getScene(): Scene;
  53776. /**
  53777. * Get the emitter of the lens flare system.
  53778. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53779. * @returns the emitter of the lens flare system
  53780. */
  53781. getEmitter(): any;
  53782. /**
  53783. * Set the emitter of the lens flare system.
  53784. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53785. * @param newEmitter Define the new emitter of the system
  53786. */
  53787. setEmitter(newEmitter: any): void;
  53788. /**
  53789. * Get the lens flare system emitter position.
  53790. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53791. * @returns the position
  53792. */
  53793. getEmitterPosition(): Vector3;
  53794. /**
  53795. * @hidden
  53796. */
  53797. computeEffectivePosition(globalViewport: Viewport): boolean;
  53798. /** @hidden */
  53799. _isVisible(): boolean;
  53800. /**
  53801. * @hidden
  53802. */
  53803. render(): boolean;
  53804. /**
  53805. * Dispose and release the lens flare with its associated resources.
  53806. */
  53807. dispose(): void;
  53808. /**
  53809. * Parse a lens flare system from a JSON repressentation
  53810. * @param parsedLensFlareSystem Define the JSON to parse
  53811. * @param scene Define the scene the parsed system should be instantiated in
  53812. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53813. * @returns the parsed system
  53814. */
  53815. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53816. /**
  53817. * Serialize the current Lens Flare System into a JSON representation.
  53818. * @returns the serialized JSON
  53819. */
  53820. serialize(): any;
  53821. }
  53822. }
  53823. declare module "babylonjs/LensFlares/lensFlare" {
  53824. import { Nullable } from "babylonjs/types";
  53825. import { Color3 } from "babylonjs/Maths/math.color";
  53826. import { Texture } from "babylonjs/Materials/Textures/texture";
  53827. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53828. /**
  53829. * This represents one of the lens effect in a `lensFlareSystem`.
  53830. * It controls one of the indiviual texture used in the effect.
  53831. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53832. */
  53833. export class LensFlare {
  53834. /**
  53835. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53836. */
  53837. size: number;
  53838. /**
  53839. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  53840. */
  53841. position: number;
  53842. /**
  53843. * Define the lens color.
  53844. */
  53845. color: Color3;
  53846. /**
  53847. * Define the lens texture.
  53848. */
  53849. texture: Nullable<Texture>;
  53850. /**
  53851. * Define the alpha mode to render this particular lens.
  53852. */
  53853. alphaMode: number;
  53854. private _system;
  53855. /**
  53856. * Creates a new Lens Flare.
  53857. * This represents one of the lens effect in a `lensFlareSystem`.
  53858. * It controls one of the indiviual texture used in the effect.
  53859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53860. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53861. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  53862. * @param color Define the lens color
  53863. * @param imgUrl Define the lens texture url
  53864. * @param system Define the `lensFlareSystem` this flare is part of
  53865. * @returns The newly created Lens Flare
  53866. */
  53867. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53868. /**
  53869. * Instantiates a new Lens Flare.
  53870. * This represents one of the lens effect in a `lensFlareSystem`.
  53871. * It controls one of the indiviual texture used in the effect.
  53872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53873. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53874. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  53875. * @param color Define the lens color
  53876. * @param imgUrl Define the lens texture url
  53877. * @param system Define the `lensFlareSystem` this flare is part of
  53878. */
  53879. constructor(
  53880. /**
  53881. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53882. */
  53883. size: number,
  53884. /**
  53885. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  53886. */
  53887. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53888. /**
  53889. * Dispose and release the lens flare with its associated resources.
  53890. */
  53891. dispose(): void;
  53892. }
  53893. }
  53894. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53895. import { Nullable } from "babylonjs/types";
  53896. import { Scene } from "babylonjs/scene";
  53897. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53898. import { AbstractScene } from "babylonjs/abstractScene";
  53899. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53900. module "babylonjs/abstractScene" {
  53901. interface AbstractScene {
  53902. /**
  53903. * The list of lens flare system added to the scene
  53904. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53905. */
  53906. lensFlareSystems: Array<LensFlareSystem>;
  53907. /**
  53908. * Removes the given lens flare system from this scene.
  53909. * @param toRemove The lens flare system to remove
  53910. * @returns The index of the removed lens flare system
  53911. */
  53912. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53913. /**
  53914. * Adds the given lens flare system to this scene
  53915. * @param newLensFlareSystem The lens flare system to add
  53916. */
  53917. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53918. /**
  53919. * Gets a lens flare system using its name
  53920. * @param name defines the name to look for
  53921. * @returns the lens flare system or null if not found
  53922. */
  53923. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53924. /**
  53925. * Gets a lens flare system using its id
  53926. * @param id defines the id to look for
  53927. * @returns the lens flare system or null if not found
  53928. */
  53929. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53930. }
  53931. }
  53932. /**
  53933. * Defines the lens flare scene component responsible to manage any lens flares
  53934. * in a given scene.
  53935. */
  53936. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53937. /**
  53938. * The component name helpfull to identify the component in the list of scene components.
  53939. */
  53940. readonly name: string;
  53941. /**
  53942. * The scene the component belongs to.
  53943. */
  53944. scene: Scene;
  53945. /**
  53946. * Creates a new instance of the component for the given scene
  53947. * @param scene Defines the scene to register the component in
  53948. */
  53949. constructor(scene: Scene);
  53950. /**
  53951. * Registers the component in a given scene
  53952. */
  53953. register(): void;
  53954. /**
  53955. * Rebuilds the elements related to this component in case of
  53956. * context lost for instance.
  53957. */
  53958. rebuild(): void;
  53959. /**
  53960. * Adds all the elements from the container to the scene
  53961. * @param container the container holding the elements
  53962. */
  53963. addFromContainer(container: AbstractScene): void;
  53964. /**
  53965. * Removes all the elements in the container from the scene
  53966. * @param container contains the elements to remove
  53967. * @param dispose if the removed element should be disposed (default: false)
  53968. */
  53969. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53970. /**
  53971. * Serializes the component data to the specified json object
  53972. * @param serializationObject The object to serialize to
  53973. */
  53974. serialize(serializationObject: any): void;
  53975. /**
  53976. * Disposes the component and the associated ressources.
  53977. */
  53978. dispose(): void;
  53979. private _draw;
  53980. }
  53981. }
  53982. declare module "babylonjs/LensFlares/index" {
  53983. export * from "babylonjs/LensFlares/lensFlare";
  53984. export * from "babylonjs/LensFlares/lensFlareSystem";
  53985. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53986. }
  53987. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53988. import { Scene } from "babylonjs/scene";
  53989. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53990. import { AbstractScene } from "babylonjs/abstractScene";
  53991. /**
  53992. * Defines the shadow generator component responsible to manage any shadow generators
  53993. * in a given scene.
  53994. */
  53995. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53996. /**
  53997. * The component name helpfull to identify the component in the list of scene components.
  53998. */
  53999. readonly name: string;
  54000. /**
  54001. * The scene the component belongs to.
  54002. */
  54003. scene: Scene;
  54004. /**
  54005. * Creates a new instance of the component for the given scene
  54006. * @param scene Defines the scene to register the component in
  54007. */
  54008. constructor(scene: Scene);
  54009. /**
  54010. * Registers the component in a given scene
  54011. */
  54012. register(): void;
  54013. /**
  54014. * Rebuilds the elements related to this component in case of
  54015. * context lost for instance.
  54016. */
  54017. rebuild(): void;
  54018. /**
  54019. * Serializes the component data to the specified json object
  54020. * @param serializationObject The object to serialize to
  54021. */
  54022. serialize(serializationObject: any): void;
  54023. /**
  54024. * Adds all the elements from the container to the scene
  54025. * @param container the container holding the elements
  54026. */
  54027. addFromContainer(container: AbstractScene): void;
  54028. /**
  54029. * Removes all the elements in the container from the scene
  54030. * @param container contains the elements to remove
  54031. * @param dispose if the removed element should be disposed (default: false)
  54032. */
  54033. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54034. /**
  54035. * Rebuilds the elements related to this component in case of
  54036. * context lost for instance.
  54037. */
  54038. dispose(): void;
  54039. private _gatherRenderTargets;
  54040. }
  54041. }
  54042. declare module "babylonjs/Lights/Shadows/index" {
  54043. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  54044. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  54045. }
  54046. declare module "babylonjs/Lights/pointLight" {
  54047. import { Scene } from "babylonjs/scene";
  54048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54050. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54051. import { Effect } from "babylonjs/Materials/effect";
  54052. /**
  54053. * A point light is a light defined by an unique point in world space.
  54054. * The light is emitted in every direction from this point.
  54055. * A good example of a point light is a standard light bulb.
  54056. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54057. */
  54058. export class PointLight extends ShadowLight {
  54059. private _shadowAngle;
  54060. /**
  54061. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54062. * This specifies what angle the shadow will use to be created.
  54063. *
  54064. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54065. */
  54066. /**
  54067. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54068. * This specifies what angle the shadow will use to be created.
  54069. *
  54070. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54071. */
  54072. shadowAngle: number;
  54073. /**
  54074. * Gets the direction if it has been set.
  54075. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54076. */
  54077. /**
  54078. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54079. */
  54080. direction: Vector3;
  54081. /**
  54082. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54083. * A PointLight emits the light in every direction.
  54084. * It can cast shadows.
  54085. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54086. * ```javascript
  54087. * var pointLight = new PointLight("pl", camera.position, scene);
  54088. * ```
  54089. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54090. * @param name The light friendly name
  54091. * @param position The position of the point light in the scene
  54092. * @param scene The scene the lights belongs to
  54093. */
  54094. constructor(name: string, position: Vector3, scene: Scene);
  54095. /**
  54096. * Returns the string "PointLight"
  54097. * @returns the class name
  54098. */
  54099. getClassName(): string;
  54100. /**
  54101. * Returns the integer 0.
  54102. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54103. */
  54104. getTypeID(): number;
  54105. /**
  54106. * Specifies wether or not the shadowmap should be a cube texture.
  54107. * @returns true if the shadowmap needs to be a cube texture.
  54108. */
  54109. needCube(): boolean;
  54110. /**
  54111. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54112. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54113. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54114. */
  54115. getShadowDirection(faceIndex?: number): Vector3;
  54116. /**
  54117. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54118. * - fov = PI / 2
  54119. * - aspect ratio : 1.0
  54120. * - z-near and far equal to the active camera minZ and maxZ.
  54121. * Returns the PointLight.
  54122. */
  54123. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54124. protected _buildUniformLayout(): void;
  54125. /**
  54126. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54127. * @param effect The effect to update
  54128. * @param lightIndex The index of the light in the effect to update
  54129. * @returns The point light
  54130. */
  54131. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54132. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54133. /**
  54134. * Prepares the list of defines specific to the light type.
  54135. * @param defines the list of defines
  54136. * @param lightIndex defines the index of the light for the effect
  54137. */
  54138. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54139. }
  54140. }
  54141. declare module "babylonjs/Lights/index" {
  54142. export * from "babylonjs/Lights/light";
  54143. export * from "babylonjs/Lights/shadowLight";
  54144. export * from "babylonjs/Lights/Shadows/index";
  54145. export * from "babylonjs/Lights/directionalLight";
  54146. export * from "babylonjs/Lights/hemisphericLight";
  54147. export * from "babylonjs/Lights/pointLight";
  54148. export * from "babylonjs/Lights/spotLight";
  54149. }
  54150. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  54151. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54152. /**
  54153. * Header information of HDR texture files.
  54154. */
  54155. export interface HDRInfo {
  54156. /**
  54157. * The height of the texture in pixels.
  54158. */
  54159. height: number;
  54160. /**
  54161. * The width of the texture in pixels.
  54162. */
  54163. width: number;
  54164. /**
  54165. * The index of the beginning of the data in the binary file.
  54166. */
  54167. dataPosition: number;
  54168. }
  54169. /**
  54170. * This groups tools to convert HDR texture to native colors array.
  54171. */
  54172. export class HDRTools {
  54173. private static Ldexp;
  54174. private static Rgbe2float;
  54175. private static readStringLine;
  54176. /**
  54177. * Reads header information from an RGBE texture stored in a native array.
  54178. * More information on this format are available here:
  54179. * https://en.wikipedia.org/wiki/RGBE_image_format
  54180. *
  54181. * @param uint8array The binary file stored in native array.
  54182. * @return The header information.
  54183. */
  54184. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54185. /**
  54186. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54187. * This RGBE texture needs to store the information as a panorama.
  54188. *
  54189. * More information on this format are available here:
  54190. * https://en.wikipedia.org/wiki/RGBE_image_format
  54191. *
  54192. * @param buffer The binary file stored in an array buffer.
  54193. * @param size The expected size of the extracted cubemap.
  54194. * @return The Cube Map information.
  54195. */
  54196. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54197. /**
  54198. * Returns the pixels data extracted from an RGBE texture.
  54199. * This pixels will be stored left to right up to down in the R G B order in one array.
  54200. *
  54201. * More information on this format are available here:
  54202. * https://en.wikipedia.org/wiki/RGBE_image_format
  54203. *
  54204. * @param uint8array The binary file stored in an array buffer.
  54205. * @param hdrInfo The header information of the file.
  54206. * @return The pixels data in RGB right to left up to down order.
  54207. */
  54208. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54209. private static RGBE_ReadPixels_RLE;
  54210. }
  54211. }
  54212. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  54213. import { Nullable } from "babylonjs/types";
  54214. import { Scene } from "babylonjs/scene";
  54215. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54216. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54217. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54218. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54219. /**
  54220. * This represents a texture coming from an HDR input.
  54221. *
  54222. * The only supported format is currently panorama picture stored in RGBE format.
  54223. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54224. */
  54225. export class HDRCubeTexture extends BaseTexture {
  54226. private static _facesMapping;
  54227. private _generateHarmonics;
  54228. private _noMipmap;
  54229. private _textureMatrix;
  54230. private _size;
  54231. private _onLoad;
  54232. private _onError;
  54233. /**
  54234. * The texture URL.
  54235. */
  54236. url: string;
  54237. /**
  54238. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54239. */
  54240. coordinatesMode: number;
  54241. protected _isBlocking: boolean;
  54242. /**
  54243. * Sets wether or not the texture is blocking during loading.
  54244. */
  54245. /**
  54246. * Gets wether or not the texture is blocking during loading.
  54247. */
  54248. isBlocking: boolean;
  54249. protected _rotationY: number;
  54250. /**
  54251. * Sets texture matrix rotation angle around Y axis in radians.
  54252. */
  54253. /**
  54254. * Gets texture matrix rotation angle around Y axis radians.
  54255. */
  54256. rotationY: number;
  54257. /**
  54258. * Gets or sets the center of the bounding box associated with the cube texture
  54259. * It must define where the camera used to render the texture was set
  54260. */
  54261. boundingBoxPosition: Vector3;
  54262. private _boundingBoxSize;
  54263. /**
  54264. * Gets or sets the size of the bounding box associated with the cube texture
  54265. * When defined, the cubemap will switch to local mode
  54266. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54267. * @example https://www.babylonjs-playground.com/#RNASML
  54268. */
  54269. boundingBoxSize: Vector3;
  54270. /**
  54271. * Instantiates an HDRTexture from the following parameters.
  54272. *
  54273. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54274. * @param scene The scene the texture will be used in
  54275. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54276. * @param noMipmap Forces to not generate the mipmap if true
  54277. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54278. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54279. * @param reserved Reserved flag for internal use.
  54280. */
  54281. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54282. /**
  54283. * Get the current class name of the texture useful for serialization or dynamic coding.
  54284. * @returns "HDRCubeTexture"
  54285. */
  54286. getClassName(): string;
  54287. /**
  54288. * Occurs when the file is raw .hdr file.
  54289. */
  54290. private loadTexture;
  54291. clone(): HDRCubeTexture;
  54292. delayLoad(): void;
  54293. /**
  54294. * Get the texture reflection matrix used to rotate/transform the reflection.
  54295. * @returns the reflection matrix
  54296. */
  54297. getReflectionTextureMatrix(): Matrix;
  54298. /**
  54299. * Set the texture reflection matrix used to rotate/transform the reflection.
  54300. * @param value Define the reflection matrix to set
  54301. */
  54302. setReflectionTextureMatrix(value: Matrix): void;
  54303. /**
  54304. * Parses a JSON representation of an HDR Texture in order to create the texture
  54305. * @param parsedTexture Define the JSON representation
  54306. * @param scene Define the scene the texture should be created in
  54307. * @param rootUrl Define the root url in case we need to load relative dependencies
  54308. * @returns the newly created texture after parsing
  54309. */
  54310. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54311. serialize(): any;
  54312. }
  54313. }
  54314. declare module "babylonjs/Physics/physicsEngine" {
  54315. import { Nullable } from "babylonjs/types";
  54316. import { Vector3 } from "babylonjs/Maths/math.vector";
  54317. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54318. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  54319. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  54320. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54321. /**
  54322. * Class used to control physics engine
  54323. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54324. */
  54325. export class PhysicsEngine implements IPhysicsEngine {
  54326. private _physicsPlugin;
  54327. /**
  54328. * Global value used to control the smallest number supported by the simulation
  54329. */
  54330. static Epsilon: number;
  54331. private _impostors;
  54332. private _joints;
  54333. private _subTimeStep;
  54334. /**
  54335. * Gets the gravity vector used by the simulation
  54336. */
  54337. gravity: Vector3;
  54338. /**
  54339. * Factory used to create the default physics plugin.
  54340. * @returns The default physics plugin
  54341. */
  54342. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54343. /**
  54344. * Creates a new Physics Engine
  54345. * @param gravity defines the gravity vector used by the simulation
  54346. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54347. */
  54348. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54349. /**
  54350. * Sets the gravity vector used by the simulation
  54351. * @param gravity defines the gravity vector to use
  54352. */
  54353. setGravity(gravity: Vector3): void;
  54354. /**
  54355. * Set the time step of the physics engine.
  54356. * Default is 1/60.
  54357. * To slow it down, enter 1/600 for example.
  54358. * To speed it up, 1/30
  54359. * @param newTimeStep defines the new timestep to apply to this world.
  54360. */
  54361. setTimeStep(newTimeStep?: number): void;
  54362. /**
  54363. * Get the time step of the physics engine.
  54364. * @returns the current time step
  54365. */
  54366. getTimeStep(): number;
  54367. /**
  54368. * Set the sub time step of the physics engine.
  54369. * Default is 0 meaning there is no sub steps
  54370. * To increase physics resolution precision, set a small value (like 1 ms)
  54371. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54372. */
  54373. setSubTimeStep(subTimeStep?: number): void;
  54374. /**
  54375. * Get the sub time step of the physics engine.
  54376. * @returns the current sub time step
  54377. */
  54378. getSubTimeStep(): number;
  54379. /**
  54380. * Release all resources
  54381. */
  54382. dispose(): void;
  54383. /**
  54384. * Gets the name of the current physics plugin
  54385. * @returns the name of the plugin
  54386. */
  54387. getPhysicsPluginName(): string;
  54388. /**
  54389. * Adding a new impostor for the impostor tracking.
  54390. * This will be done by the impostor itself.
  54391. * @param impostor the impostor to add
  54392. */
  54393. addImpostor(impostor: PhysicsImpostor): void;
  54394. /**
  54395. * Remove an impostor from the engine.
  54396. * This impostor and its mesh will not longer be updated by the physics engine.
  54397. * @param impostor the impostor to remove
  54398. */
  54399. removeImpostor(impostor: PhysicsImpostor): void;
  54400. /**
  54401. * Add a joint to the physics engine
  54402. * @param mainImpostor defines the main impostor to which the joint is added.
  54403. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54404. * @param joint defines the joint that will connect both impostors.
  54405. */
  54406. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54407. /**
  54408. * Removes a joint from the simulation
  54409. * @param mainImpostor defines the impostor used with the joint
  54410. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54411. * @param joint defines the joint to remove
  54412. */
  54413. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54414. /**
  54415. * Called by the scene. No need to call it.
  54416. * @param delta defines the timespam between frames
  54417. */
  54418. _step(delta: number): void;
  54419. /**
  54420. * Gets the current plugin used to run the simulation
  54421. * @returns current plugin
  54422. */
  54423. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54424. /**
  54425. * Gets the list of physic impostors
  54426. * @returns an array of PhysicsImpostor
  54427. */
  54428. getImpostors(): Array<PhysicsImpostor>;
  54429. /**
  54430. * Gets the impostor for a physics enabled object
  54431. * @param object defines the object impersonated by the impostor
  54432. * @returns the PhysicsImpostor or null if not found
  54433. */
  54434. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54435. /**
  54436. * Gets the impostor for a physics body object
  54437. * @param body defines physics body used by the impostor
  54438. * @returns the PhysicsImpostor or null if not found
  54439. */
  54440. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54441. /**
  54442. * Does a raycast in the physics world
  54443. * @param from when should the ray start?
  54444. * @param to when should the ray end?
  54445. * @returns PhysicsRaycastResult
  54446. */
  54447. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54448. }
  54449. }
  54450. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54451. import { Nullable } from "babylonjs/types";
  54452. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54454. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54455. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54456. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54457. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54458. /** @hidden */
  54459. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54460. private _useDeltaForWorldStep;
  54461. world: any;
  54462. name: string;
  54463. private _physicsMaterials;
  54464. private _fixedTimeStep;
  54465. private _cannonRaycastResult;
  54466. private _raycastResult;
  54467. private _physicsBodysToRemoveAfterStep;
  54468. BJSCANNON: any;
  54469. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54470. setGravity(gravity: Vector3): void;
  54471. setTimeStep(timeStep: number): void;
  54472. getTimeStep(): number;
  54473. executeStep(delta: number): void;
  54474. private _removeMarkedPhysicsBodiesFromWorld;
  54475. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54476. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54477. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54478. private _processChildMeshes;
  54479. removePhysicsBody(impostor: PhysicsImpostor): void;
  54480. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54481. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54482. private _addMaterial;
  54483. private _checkWithEpsilon;
  54484. private _createShape;
  54485. private _createHeightmap;
  54486. private _minus90X;
  54487. private _plus90X;
  54488. private _tmpPosition;
  54489. private _tmpDeltaPosition;
  54490. private _tmpUnityRotation;
  54491. private _updatePhysicsBodyTransformation;
  54492. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54493. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54494. isSupported(): boolean;
  54495. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54496. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54497. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54498. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54499. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54500. getBodyMass(impostor: PhysicsImpostor): number;
  54501. getBodyFriction(impostor: PhysicsImpostor): number;
  54502. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54503. getBodyRestitution(impostor: PhysicsImpostor): number;
  54504. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54505. sleepBody(impostor: PhysicsImpostor): void;
  54506. wakeUpBody(impostor: PhysicsImpostor): void;
  54507. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54508. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54509. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54510. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54511. getRadius(impostor: PhysicsImpostor): number;
  54512. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54513. dispose(): void;
  54514. private _extendNamespace;
  54515. /**
  54516. * Does a raycast in the physics world
  54517. * @param from when should the ray start?
  54518. * @param to when should the ray end?
  54519. * @returns PhysicsRaycastResult
  54520. */
  54521. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54522. }
  54523. }
  54524. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54525. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54526. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54527. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54529. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54530. import { Nullable } from "babylonjs/types";
  54531. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54532. /** @hidden */
  54533. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54534. world: any;
  54535. name: string;
  54536. BJSOIMO: any;
  54537. private _raycastResult;
  54538. constructor(iterations?: number, oimoInjection?: any);
  54539. setGravity(gravity: Vector3): void;
  54540. setTimeStep(timeStep: number): void;
  54541. getTimeStep(): number;
  54542. private _tmpImpostorsArray;
  54543. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54544. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54545. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54546. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54547. private _tmpPositionVector;
  54548. removePhysicsBody(impostor: PhysicsImpostor): void;
  54549. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54550. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54551. isSupported(): boolean;
  54552. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54553. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54554. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54555. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54556. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54557. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54558. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54559. getBodyMass(impostor: PhysicsImpostor): number;
  54560. getBodyFriction(impostor: PhysicsImpostor): number;
  54561. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54562. getBodyRestitution(impostor: PhysicsImpostor): number;
  54563. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54564. sleepBody(impostor: PhysicsImpostor): void;
  54565. wakeUpBody(impostor: PhysicsImpostor): void;
  54566. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54567. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54568. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54569. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54570. getRadius(impostor: PhysicsImpostor): number;
  54571. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54572. dispose(): void;
  54573. /**
  54574. * Does a raycast in the physics world
  54575. * @param from when should the ray start?
  54576. * @param to when should the ray end?
  54577. * @returns PhysicsRaycastResult
  54578. */
  54579. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54580. }
  54581. }
  54582. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54583. import { Nullable } from "babylonjs/types";
  54584. import { Scene } from "babylonjs/scene";
  54585. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54586. import { Color4 } from "babylonjs/Maths/math.color";
  54587. import { Mesh } from "babylonjs/Meshes/mesh";
  54588. /**
  54589. * Class containing static functions to help procedurally build meshes
  54590. */
  54591. export class RibbonBuilder {
  54592. /**
  54593. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54594. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54595. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54596. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54597. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  54598. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  54599. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  54600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54603. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  54604. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54605. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  54606. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54608. * @param name defines the name of the mesh
  54609. * @param options defines the options used to create the mesh
  54610. * @param scene defines the hosting scene
  54611. * @returns the ribbon mesh
  54612. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54614. */
  54615. static CreateRibbon(name: string, options: {
  54616. pathArray: Vector3[][];
  54617. closeArray?: boolean;
  54618. closePath?: boolean;
  54619. offset?: number;
  54620. updatable?: boolean;
  54621. sideOrientation?: number;
  54622. frontUVs?: Vector4;
  54623. backUVs?: Vector4;
  54624. instance?: Mesh;
  54625. invertUV?: boolean;
  54626. uvs?: Vector2[];
  54627. colors?: Color4[];
  54628. }, scene?: Nullable<Scene>): Mesh;
  54629. }
  54630. }
  54631. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54632. import { Nullable } from "babylonjs/types";
  54633. import { Scene } from "babylonjs/scene";
  54634. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54635. import { Mesh } from "babylonjs/Meshes/mesh";
  54636. /**
  54637. * Class containing static functions to help procedurally build meshes
  54638. */
  54639. export class ShapeBuilder {
  54640. /**
  54641. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54642. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  54643. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54644. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  54645. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54646. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  54647. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  54648. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54651. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54653. * @param name defines the name of the mesh
  54654. * @param options defines the options used to create the mesh
  54655. * @param scene defines the hosting scene
  54656. * @returns the extruded shape mesh
  54657. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54659. */
  54660. static ExtrudeShape(name: string, options: {
  54661. shape: Vector3[];
  54662. path: Vector3[];
  54663. scale?: number;
  54664. rotation?: number;
  54665. cap?: number;
  54666. updatable?: boolean;
  54667. sideOrientation?: number;
  54668. frontUVs?: Vector4;
  54669. backUVs?: Vector4;
  54670. instance?: Mesh;
  54671. invertUV?: boolean;
  54672. }, scene?: Nullable<Scene>): Mesh;
  54673. /**
  54674. * Creates an custom extruded shape mesh.
  54675. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54676. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  54677. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54678. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  54679. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54680. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  54681. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54682. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54683. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54684. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  54685. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  54686. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54689. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54691. * @param name defines the name of the mesh
  54692. * @param options defines the options used to create the mesh
  54693. * @param scene defines the hosting scene
  54694. * @returns the custom extruded shape mesh
  54695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54696. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54698. */
  54699. static ExtrudeShapeCustom(name: string, options: {
  54700. shape: Vector3[];
  54701. path: Vector3[];
  54702. scaleFunction?: any;
  54703. rotationFunction?: any;
  54704. ribbonCloseArray?: boolean;
  54705. ribbonClosePath?: boolean;
  54706. cap?: number;
  54707. updatable?: boolean;
  54708. sideOrientation?: number;
  54709. frontUVs?: Vector4;
  54710. backUVs?: Vector4;
  54711. instance?: Mesh;
  54712. invertUV?: boolean;
  54713. }, scene?: Nullable<Scene>): Mesh;
  54714. private static _ExtrudeShapeGeneric;
  54715. }
  54716. }
  54717. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54718. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54719. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54720. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54721. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54722. import { Nullable } from "babylonjs/types";
  54723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54724. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54725. /**
  54726. * AmmoJS Physics plugin
  54727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54728. * @see https://github.com/kripken/ammo.js/
  54729. */
  54730. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54731. private _useDeltaForWorldStep;
  54732. /**
  54733. * Reference to the Ammo library
  54734. */
  54735. bjsAMMO: any;
  54736. /**
  54737. * Created ammoJS world which physics bodies are added to
  54738. */
  54739. world: any;
  54740. /**
  54741. * Name of the plugin
  54742. */
  54743. name: string;
  54744. private _timeStep;
  54745. private _fixedTimeStep;
  54746. private _maxSteps;
  54747. private _tmpQuaternion;
  54748. private _tmpAmmoTransform;
  54749. private _tmpAmmoQuaternion;
  54750. private _tmpAmmoConcreteContactResultCallback;
  54751. private _collisionConfiguration;
  54752. private _dispatcher;
  54753. private _overlappingPairCache;
  54754. private _solver;
  54755. private _softBodySolver;
  54756. private _tmpAmmoVectorA;
  54757. private _tmpAmmoVectorB;
  54758. private _tmpAmmoVectorC;
  54759. private _tmpAmmoVectorD;
  54760. private _tmpContactCallbackResult;
  54761. private _tmpAmmoVectorRCA;
  54762. private _tmpAmmoVectorRCB;
  54763. private _raycastResult;
  54764. private static readonly DISABLE_COLLISION_FLAG;
  54765. private static readonly KINEMATIC_FLAG;
  54766. private static readonly DISABLE_DEACTIVATION_FLAG;
  54767. /**
  54768. * Initializes the ammoJS plugin
  54769. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54770. * @param ammoInjection can be used to inject your own ammo reference
  54771. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54772. */
  54773. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54774. /**
  54775. * Sets the gravity of the physics world (m/(s^2))
  54776. * @param gravity Gravity to set
  54777. */
  54778. setGravity(gravity: Vector3): void;
  54779. /**
  54780. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54781. * @param timeStep timestep to use in seconds
  54782. */
  54783. setTimeStep(timeStep: number): void;
  54784. /**
  54785. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  54786. * @param fixedTimeStep fixedTimeStep to use in seconds
  54787. */
  54788. setFixedTimeStep(fixedTimeStep: number): void;
  54789. /**
  54790. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54791. * @param maxSteps the maximum number of steps by the physics engine per frame
  54792. */
  54793. setMaxSteps(maxSteps: number): void;
  54794. /**
  54795. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54796. * @returns the current timestep in seconds
  54797. */
  54798. getTimeStep(): number;
  54799. /**
  54800. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  54801. */
  54802. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  54803. private _isImpostorInContact;
  54804. private _isImpostorPairInContact;
  54805. private _stepSimulation;
  54806. /**
  54807. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54808. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54809. * After the step the babylon meshes are set to the position of the physics imposters
  54810. * @param delta amount of time to step forward
  54811. * @param impostors array of imposters to update before/after the step
  54812. */
  54813. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54814. /**
  54815. * Update babylon mesh to match physics world object
  54816. * @param impostor imposter to match
  54817. */
  54818. private _afterSoftStep;
  54819. /**
  54820. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54821. * @param impostor imposter to match
  54822. */
  54823. private _ropeStep;
  54824. /**
  54825. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54826. * @param impostor imposter to match
  54827. */
  54828. private _softbodyOrClothStep;
  54829. private _tmpVector;
  54830. private _tmpMatrix;
  54831. /**
  54832. * Applies an impulse on the imposter
  54833. * @param impostor imposter to apply impulse to
  54834. * @param force amount of force to be applied to the imposter
  54835. * @param contactPoint the location to apply the impulse on the imposter
  54836. */
  54837. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54838. /**
  54839. * Applies a force on the imposter
  54840. * @param impostor imposter to apply force
  54841. * @param force amount of force to be applied to the imposter
  54842. * @param contactPoint the location to apply the force on the imposter
  54843. */
  54844. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54845. /**
  54846. * Creates a physics body using the plugin
  54847. * @param impostor the imposter to create the physics body on
  54848. */
  54849. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54850. /**
  54851. * Removes the physics body from the imposter and disposes of the body's memory
  54852. * @param impostor imposter to remove the physics body from
  54853. */
  54854. removePhysicsBody(impostor: PhysicsImpostor): void;
  54855. /**
  54856. * Generates a joint
  54857. * @param impostorJoint the imposter joint to create the joint with
  54858. */
  54859. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54860. /**
  54861. * Removes a joint
  54862. * @param impostorJoint the imposter joint to remove the joint from
  54863. */
  54864. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54865. private _addMeshVerts;
  54866. /**
  54867. * Initialise the soft body vertices to match its object's (mesh) vertices
  54868. * Softbody vertices (nodes) are in world space and to match this
  54869. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54870. * @param impostor to create the softbody for
  54871. */
  54872. private _softVertexData;
  54873. /**
  54874. * Create an impostor's soft body
  54875. * @param impostor to create the softbody for
  54876. */
  54877. private _createSoftbody;
  54878. /**
  54879. * Create cloth for an impostor
  54880. * @param impostor to create the softbody for
  54881. */
  54882. private _createCloth;
  54883. /**
  54884. * Create rope for an impostor
  54885. * @param impostor to create the softbody for
  54886. */
  54887. private _createRope;
  54888. /**
  54889. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  54890. * @param impostor to create the custom physics shape for
  54891. */
  54892. private _createCustom;
  54893. private _addHullVerts;
  54894. private _createShape;
  54895. /**
  54896. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54897. * @param impostor imposter containing the physics body and babylon object
  54898. */
  54899. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54900. /**
  54901. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54902. * @param impostor imposter containing the physics body and babylon object
  54903. * @param newPosition new position
  54904. * @param newRotation new rotation
  54905. */
  54906. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54907. /**
  54908. * If this plugin is supported
  54909. * @returns true if its supported
  54910. */
  54911. isSupported(): boolean;
  54912. /**
  54913. * Sets the linear velocity of the physics body
  54914. * @param impostor imposter to set the velocity on
  54915. * @param velocity velocity to set
  54916. */
  54917. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54918. /**
  54919. * Sets the angular velocity of the physics body
  54920. * @param impostor imposter to set the velocity on
  54921. * @param velocity velocity to set
  54922. */
  54923. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54924. /**
  54925. * gets the linear velocity
  54926. * @param impostor imposter to get linear velocity from
  54927. * @returns linear velocity
  54928. */
  54929. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54930. /**
  54931. * gets the angular velocity
  54932. * @param impostor imposter to get angular velocity from
  54933. * @returns angular velocity
  54934. */
  54935. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54936. /**
  54937. * Sets the mass of physics body
  54938. * @param impostor imposter to set the mass on
  54939. * @param mass mass to set
  54940. */
  54941. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54942. /**
  54943. * Gets the mass of the physics body
  54944. * @param impostor imposter to get the mass from
  54945. * @returns mass
  54946. */
  54947. getBodyMass(impostor: PhysicsImpostor): number;
  54948. /**
  54949. * Gets friction of the impostor
  54950. * @param impostor impostor to get friction from
  54951. * @returns friction value
  54952. */
  54953. getBodyFriction(impostor: PhysicsImpostor): number;
  54954. /**
  54955. * Sets friction of the impostor
  54956. * @param impostor impostor to set friction on
  54957. * @param friction friction value
  54958. */
  54959. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54960. /**
  54961. * Gets restitution of the impostor
  54962. * @param impostor impostor to get restitution from
  54963. * @returns restitution value
  54964. */
  54965. getBodyRestitution(impostor: PhysicsImpostor): number;
  54966. /**
  54967. * Sets resitution of the impostor
  54968. * @param impostor impostor to set resitution on
  54969. * @param restitution resitution value
  54970. */
  54971. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54972. /**
  54973. * Gets pressure inside the impostor
  54974. * @param impostor impostor to get pressure from
  54975. * @returns pressure value
  54976. */
  54977. getBodyPressure(impostor: PhysicsImpostor): number;
  54978. /**
  54979. * Sets pressure inside a soft body impostor
  54980. * Cloth and rope must remain 0 pressure
  54981. * @param impostor impostor to set pressure on
  54982. * @param pressure pressure value
  54983. */
  54984. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54985. /**
  54986. * Gets stiffness of the impostor
  54987. * @param impostor impostor to get stiffness from
  54988. * @returns pressure value
  54989. */
  54990. getBodyStiffness(impostor: PhysicsImpostor): number;
  54991. /**
  54992. * Sets stiffness of the impostor
  54993. * @param impostor impostor to set stiffness on
  54994. * @param stiffness stiffness value from 0 to 1
  54995. */
  54996. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54997. /**
  54998. * Gets velocityIterations of the impostor
  54999. * @param impostor impostor to get velocity iterations from
  55000. * @returns velocityIterations value
  55001. */
  55002. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55003. /**
  55004. * Sets velocityIterations of the impostor
  55005. * @param impostor impostor to set velocity iterations on
  55006. * @param velocityIterations velocityIterations value
  55007. */
  55008. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55009. /**
  55010. * Gets positionIterations of the impostor
  55011. * @param impostor impostor to get position iterations from
  55012. * @returns positionIterations value
  55013. */
  55014. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55015. /**
  55016. * Sets positionIterations of the impostor
  55017. * @param impostor impostor to set position on
  55018. * @param positionIterations positionIterations value
  55019. */
  55020. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55021. /**
  55022. * Append an anchor to a cloth object
  55023. * @param impostor is the cloth impostor to add anchor to
  55024. * @param otherImpostor is the rigid impostor to anchor to
  55025. * @param width ratio across width from 0 to 1
  55026. * @param height ratio up height from 0 to 1
  55027. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55028. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55029. */
  55030. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55031. /**
  55032. * Append an hook to a rope object
  55033. * @param impostor is the rope impostor to add hook to
  55034. * @param otherImpostor is the rigid impostor to hook to
  55035. * @param length ratio along the rope from 0 to 1
  55036. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55037. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55038. */
  55039. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55040. /**
  55041. * Sleeps the physics body and stops it from being active
  55042. * @param impostor impostor to sleep
  55043. */
  55044. sleepBody(impostor: PhysicsImpostor): void;
  55045. /**
  55046. * Activates the physics body
  55047. * @param impostor impostor to activate
  55048. */
  55049. wakeUpBody(impostor: PhysicsImpostor): void;
  55050. /**
  55051. * Updates the distance parameters of the joint
  55052. * @param joint joint to update
  55053. * @param maxDistance maximum distance of the joint
  55054. * @param minDistance minimum distance of the joint
  55055. */
  55056. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55057. /**
  55058. * Sets a motor on the joint
  55059. * @param joint joint to set motor on
  55060. * @param speed speed of the motor
  55061. * @param maxForce maximum force of the motor
  55062. * @param motorIndex index of the motor
  55063. */
  55064. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55065. /**
  55066. * Sets the motors limit
  55067. * @param joint joint to set limit on
  55068. * @param upperLimit upper limit
  55069. * @param lowerLimit lower limit
  55070. */
  55071. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55072. /**
  55073. * Syncs the position and rotation of a mesh with the impostor
  55074. * @param mesh mesh to sync
  55075. * @param impostor impostor to update the mesh with
  55076. */
  55077. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55078. /**
  55079. * Gets the radius of the impostor
  55080. * @param impostor impostor to get radius from
  55081. * @returns the radius
  55082. */
  55083. getRadius(impostor: PhysicsImpostor): number;
  55084. /**
  55085. * Gets the box size of the impostor
  55086. * @param impostor impostor to get box size from
  55087. * @param result the resulting box size
  55088. */
  55089. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55090. /**
  55091. * Disposes of the impostor
  55092. */
  55093. dispose(): void;
  55094. /**
  55095. * Does a raycast in the physics world
  55096. * @param from when should the ray start?
  55097. * @param to when should the ray end?
  55098. * @returns PhysicsRaycastResult
  55099. */
  55100. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55101. }
  55102. }
  55103. declare module "babylonjs/Probes/reflectionProbe" {
  55104. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55105. import { Vector3 } from "babylonjs/Maths/math.vector";
  55106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55107. import { Nullable } from "babylonjs/types";
  55108. import { Scene } from "babylonjs/scene";
  55109. module "babylonjs/abstractScene" {
  55110. interface AbstractScene {
  55111. /**
  55112. * The list of reflection probes added to the scene
  55113. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55114. */
  55115. reflectionProbes: Array<ReflectionProbe>;
  55116. /**
  55117. * Removes the given reflection probe from this scene.
  55118. * @param toRemove The reflection probe to remove
  55119. * @returns The index of the removed reflection probe
  55120. */
  55121. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55122. /**
  55123. * Adds the given reflection probe to this scene.
  55124. * @param newReflectionProbe The reflection probe to add
  55125. */
  55126. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55127. }
  55128. }
  55129. /**
  55130. * Class used to generate realtime reflection / refraction cube textures
  55131. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55132. */
  55133. export class ReflectionProbe {
  55134. /** defines the name of the probe */
  55135. name: string;
  55136. private _scene;
  55137. private _renderTargetTexture;
  55138. private _projectionMatrix;
  55139. private _viewMatrix;
  55140. private _target;
  55141. private _add;
  55142. private _attachedMesh;
  55143. private _invertYAxis;
  55144. /** Gets or sets probe position (center of the cube map) */
  55145. position: Vector3;
  55146. /**
  55147. * Creates a new reflection probe
  55148. * @param name defines the name of the probe
  55149. * @param size defines the texture resolution (for each face)
  55150. * @param scene defines the hosting scene
  55151. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55152. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55153. */
  55154. constructor(
  55155. /** defines the name of the probe */
  55156. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55157. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55158. samples: number;
  55159. /** Gets or sets the refresh rate to use (on every frame by default) */
  55160. refreshRate: number;
  55161. /**
  55162. * Gets the hosting scene
  55163. * @returns a Scene
  55164. */
  55165. getScene(): Scene;
  55166. /** Gets the internal CubeTexture used to render to */
  55167. readonly cubeTexture: RenderTargetTexture;
  55168. /** Gets the list of meshes to render */
  55169. readonly renderList: Nullable<AbstractMesh[]>;
  55170. /**
  55171. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55172. * @param mesh defines the mesh to attach to
  55173. */
  55174. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55175. /**
  55176. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55177. * @param renderingGroupId The rendering group id corresponding to its index
  55178. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55179. */
  55180. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55181. /**
  55182. * Clean all associated resources
  55183. */
  55184. dispose(): void;
  55185. /**
  55186. * Converts the reflection probe information to a readable string for debug purpose.
  55187. * @param fullDetails Supports for multiple levels of logging within scene loading
  55188. * @returns the human readable reflection probe info
  55189. */
  55190. toString(fullDetails?: boolean): string;
  55191. /**
  55192. * Get the class name of the relfection probe.
  55193. * @returns "ReflectionProbe"
  55194. */
  55195. getClassName(): string;
  55196. /**
  55197. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55198. * @returns The JSON representation of the texture
  55199. */
  55200. serialize(): any;
  55201. /**
  55202. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55203. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55204. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55205. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55206. * @returns The parsed reflection probe if successful
  55207. */
  55208. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55209. }
  55210. }
  55211. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  55212. /** @hidden */
  55213. export var _BabylonLoaderRegistered: boolean;
  55214. /**
  55215. * Helps setting up some configuration for the babylon file loader.
  55216. */
  55217. export class BabylonFileLoaderConfiguration {
  55218. /**
  55219. * The loader does not allow injecting custom physix engine into the plugins.
  55220. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55221. * So you could set this variable to your engine import to make it work.
  55222. */
  55223. static LoaderInjectedPhysicsEngine: any;
  55224. }
  55225. }
  55226. declare module "babylonjs/Loading/Plugins/index" {
  55227. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  55228. }
  55229. declare module "babylonjs/Loading/index" {
  55230. export * from "babylonjs/Loading/loadingScreen";
  55231. export * from "babylonjs/Loading/Plugins/index";
  55232. export * from "babylonjs/Loading/sceneLoader";
  55233. export * from "babylonjs/Loading/sceneLoaderFlags";
  55234. }
  55235. declare module "babylonjs/Materials/Background/index" {
  55236. export * from "babylonjs/Materials/Background/backgroundMaterial";
  55237. }
  55238. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  55239. import { Scene } from "babylonjs/scene";
  55240. import { Color3 } from "babylonjs/Maths/math.color";
  55241. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55243. /**
  55244. * The Physically based simple base material of BJS.
  55245. *
  55246. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55247. * It is used as the base class for both the specGloss and metalRough conventions.
  55248. */
  55249. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55250. /**
  55251. * Number of Simultaneous lights allowed on the material.
  55252. */
  55253. maxSimultaneousLights: number;
  55254. /**
  55255. * If sets to true, disables all the lights affecting the material.
  55256. */
  55257. disableLighting: boolean;
  55258. /**
  55259. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55260. */
  55261. environmentTexture: BaseTexture;
  55262. /**
  55263. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55264. */
  55265. invertNormalMapX: boolean;
  55266. /**
  55267. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55268. */
  55269. invertNormalMapY: boolean;
  55270. /**
  55271. * Normal map used in the model.
  55272. */
  55273. normalTexture: BaseTexture;
  55274. /**
  55275. * Emissivie color used to self-illuminate the model.
  55276. */
  55277. emissiveColor: Color3;
  55278. /**
  55279. * Emissivie texture used to self-illuminate the model.
  55280. */
  55281. emissiveTexture: BaseTexture;
  55282. /**
  55283. * Occlusion Channel Strenght.
  55284. */
  55285. occlusionStrength: number;
  55286. /**
  55287. * Occlusion Texture of the material (adding extra occlusion effects).
  55288. */
  55289. occlusionTexture: BaseTexture;
  55290. /**
  55291. * Defines the alpha limits in alpha test mode.
  55292. */
  55293. alphaCutOff: number;
  55294. /**
  55295. * Gets the current double sided mode.
  55296. */
  55297. /**
  55298. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55299. */
  55300. doubleSided: boolean;
  55301. /**
  55302. * Stores the pre-calculated light information of a mesh in a texture.
  55303. */
  55304. lightmapTexture: BaseTexture;
  55305. /**
  55306. * If true, the light map contains occlusion information instead of lighting info.
  55307. */
  55308. useLightmapAsShadowmap: boolean;
  55309. /**
  55310. * Instantiates a new PBRMaterial instance.
  55311. *
  55312. * @param name The material name
  55313. * @param scene The scene the material will be use in.
  55314. */
  55315. constructor(name: string, scene: Scene);
  55316. getClassName(): string;
  55317. }
  55318. }
  55319. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  55320. import { Scene } from "babylonjs/scene";
  55321. import { Color3 } from "babylonjs/Maths/math.color";
  55322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55323. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55324. /**
  55325. * The PBR material of BJS following the metal roughness convention.
  55326. *
  55327. * This fits to the PBR convention in the GLTF definition:
  55328. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55329. */
  55330. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55331. /**
  55332. * The base color has two different interpretations depending on the value of metalness.
  55333. * When the material is a metal, the base color is the specific measured reflectance value
  55334. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55335. * of the material.
  55336. */
  55337. baseColor: Color3;
  55338. /**
  55339. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55340. * well as opacity information in the alpha channel.
  55341. */
  55342. baseTexture: BaseTexture;
  55343. /**
  55344. * Specifies the metallic scalar value of the material.
  55345. * Can also be used to scale the metalness values of the metallic texture.
  55346. */
  55347. metallic: number;
  55348. /**
  55349. * Specifies the roughness scalar value of the material.
  55350. * Can also be used to scale the roughness values of the metallic texture.
  55351. */
  55352. roughness: number;
  55353. /**
  55354. * Texture containing both the metallic value in the B channel and the
  55355. * roughness value in the G channel to keep better precision.
  55356. */
  55357. metallicRoughnessTexture: BaseTexture;
  55358. /**
  55359. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55360. *
  55361. * @param name The material name
  55362. * @param scene The scene the material will be use in.
  55363. */
  55364. constructor(name: string, scene: Scene);
  55365. /**
  55366. * Return the currrent class name of the material.
  55367. */
  55368. getClassName(): string;
  55369. /**
  55370. * Makes a duplicate of the current material.
  55371. * @param name - name to use for the new material.
  55372. */
  55373. clone(name: string): PBRMetallicRoughnessMaterial;
  55374. /**
  55375. * Serialize the material to a parsable JSON object.
  55376. */
  55377. serialize(): any;
  55378. /**
  55379. * Parses a JSON object correponding to the serialize function.
  55380. */
  55381. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55382. }
  55383. }
  55384. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  55385. import { Scene } from "babylonjs/scene";
  55386. import { Color3 } from "babylonjs/Maths/math.color";
  55387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55388. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55389. /**
  55390. * The PBR material of BJS following the specular glossiness convention.
  55391. *
  55392. * This fits to the PBR convention in the GLTF definition:
  55393. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55394. */
  55395. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55396. /**
  55397. * Specifies the diffuse color of the material.
  55398. */
  55399. diffuseColor: Color3;
  55400. /**
  55401. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55402. * channel.
  55403. */
  55404. diffuseTexture: BaseTexture;
  55405. /**
  55406. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55407. */
  55408. specularColor: Color3;
  55409. /**
  55410. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55411. */
  55412. glossiness: number;
  55413. /**
  55414. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55415. */
  55416. specularGlossinessTexture: BaseTexture;
  55417. /**
  55418. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55419. *
  55420. * @param name The material name
  55421. * @param scene The scene the material will be use in.
  55422. */
  55423. constructor(name: string, scene: Scene);
  55424. /**
  55425. * Return the currrent class name of the material.
  55426. */
  55427. getClassName(): string;
  55428. /**
  55429. * Makes a duplicate of the current material.
  55430. * @param name - name to use for the new material.
  55431. */
  55432. clone(name: string): PBRSpecularGlossinessMaterial;
  55433. /**
  55434. * Serialize the material to a parsable JSON object.
  55435. */
  55436. serialize(): any;
  55437. /**
  55438. * Parses a JSON object correponding to the serialize function.
  55439. */
  55440. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55441. }
  55442. }
  55443. declare module "babylonjs/Materials/PBR/index" {
  55444. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55445. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55446. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55447. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55448. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55449. }
  55450. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55451. import { Nullable } from "babylonjs/types";
  55452. import { Scene } from "babylonjs/scene";
  55453. import { Matrix } from "babylonjs/Maths/math.vector";
  55454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55455. /**
  55456. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55457. * It can help converting any input color in a desired output one. This can then be used to create effects
  55458. * from sepia, black and white to sixties or futuristic rendering...
  55459. *
  55460. * The only supported format is currently 3dl.
  55461. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55462. */
  55463. export class ColorGradingTexture extends BaseTexture {
  55464. /**
  55465. * The current texture matrix. (will always be identity in color grading texture)
  55466. */
  55467. private _textureMatrix;
  55468. /**
  55469. * The texture URL.
  55470. */
  55471. url: string;
  55472. /**
  55473. * Empty line regex stored for GC.
  55474. */
  55475. private static _noneEmptyLineRegex;
  55476. private _engine;
  55477. /**
  55478. * Instantiates a ColorGradingTexture from the following parameters.
  55479. *
  55480. * @param url The location of the color gradind data (currently only supporting 3dl)
  55481. * @param scene The scene the texture will be used in
  55482. */
  55483. constructor(url: string, scene: Scene);
  55484. /**
  55485. * Returns the texture matrix used in most of the material.
  55486. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55487. */
  55488. getTextureMatrix(): Matrix;
  55489. /**
  55490. * Occurs when the file being loaded is a .3dl LUT file.
  55491. */
  55492. private load3dlTexture;
  55493. /**
  55494. * Starts the loading process of the texture.
  55495. */
  55496. private loadTexture;
  55497. /**
  55498. * Clones the color gradind texture.
  55499. */
  55500. clone(): ColorGradingTexture;
  55501. /**
  55502. * Called during delayed load for textures.
  55503. */
  55504. delayLoad(): void;
  55505. /**
  55506. * Parses a color grading texture serialized by Babylon.
  55507. * @param parsedTexture The texture information being parsedTexture
  55508. * @param scene The scene to load the texture in
  55509. * @param rootUrl The root url of the data assets to load
  55510. * @return A color gradind texture
  55511. */
  55512. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55513. /**
  55514. * Serializes the LUT texture to json format.
  55515. */
  55516. serialize(): any;
  55517. }
  55518. }
  55519. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55521. import { Scene } from "babylonjs/scene";
  55522. import { Nullable } from "babylonjs/types";
  55523. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55524. /**
  55525. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55526. */
  55527. export class EquiRectangularCubeTexture extends BaseTexture {
  55528. /** The six faces of the cube. */
  55529. private static _FacesMapping;
  55530. private _noMipmap;
  55531. private _onLoad;
  55532. private _onError;
  55533. /** The size of the cubemap. */
  55534. private _size;
  55535. /** The buffer of the image. */
  55536. private _buffer;
  55537. /** The width of the input image. */
  55538. private _width;
  55539. /** The height of the input image. */
  55540. private _height;
  55541. /** The URL to the image. */
  55542. url: string;
  55543. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55544. coordinatesMode: number;
  55545. /**
  55546. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55547. * @param url The location of the image
  55548. * @param scene The scene the texture will be used in
  55549. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55550. * @param noMipmap Forces to not generate the mipmap if true
  55551. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55552. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55553. * @param onLoad — defines a callback called when texture is loaded
  55554. * @param onError — defines a callback called if there is an error
  55555. */
  55556. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55557. /**
  55558. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55559. */
  55560. private loadImage;
  55561. /**
  55562. * Convert the image buffer into a cubemap and create a CubeTexture.
  55563. */
  55564. private loadTexture;
  55565. /**
  55566. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55567. * @param buffer The ArrayBuffer that should be converted.
  55568. * @returns The buffer as Float32Array.
  55569. */
  55570. private getFloat32ArrayFromArrayBuffer;
  55571. /**
  55572. * Get the current class name of the texture useful for serialization or dynamic coding.
  55573. * @returns "EquiRectangularCubeTexture"
  55574. */
  55575. getClassName(): string;
  55576. /**
  55577. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55578. * @returns A clone of the current EquiRectangularCubeTexture.
  55579. */
  55580. clone(): EquiRectangularCubeTexture;
  55581. }
  55582. }
  55583. declare module "babylonjs/Misc/tga" {
  55584. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55585. /**
  55586. * Based on jsTGALoader - Javascript loader for TGA file
  55587. * By Vincent Thibault
  55588. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55589. */
  55590. export class TGATools {
  55591. private static _TYPE_INDEXED;
  55592. private static _TYPE_RGB;
  55593. private static _TYPE_GREY;
  55594. private static _TYPE_RLE_INDEXED;
  55595. private static _TYPE_RLE_RGB;
  55596. private static _TYPE_RLE_GREY;
  55597. private static _ORIGIN_MASK;
  55598. private static _ORIGIN_SHIFT;
  55599. private static _ORIGIN_BL;
  55600. private static _ORIGIN_BR;
  55601. private static _ORIGIN_UL;
  55602. private static _ORIGIN_UR;
  55603. /**
  55604. * Gets the header of a TGA file
  55605. * @param data defines the TGA data
  55606. * @returns the header
  55607. */
  55608. static GetTGAHeader(data: Uint8Array): any;
  55609. /**
  55610. * Uploads TGA content to a Babylon Texture
  55611. * @hidden
  55612. */
  55613. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55614. /** @hidden */
  55615. static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55616. /** @hidden */
  55617. static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55618. /** @hidden */
  55619. static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55620. /** @hidden */
  55621. static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55622. /** @hidden */
  55623. static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55624. /** @hidden */
  55625. static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55626. }
  55627. }
  55628. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55629. import { Nullable } from "babylonjs/types";
  55630. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55631. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55632. /**
  55633. * Implementation of the TGA Texture Loader.
  55634. * @hidden
  55635. */
  55636. export class _TGATextureLoader implements IInternalTextureLoader {
  55637. /**
  55638. * Defines wether the loader supports cascade loading the different faces.
  55639. */
  55640. readonly supportCascades: boolean;
  55641. /**
  55642. * This returns if the loader support the current file information.
  55643. * @param extension defines the file extension of the file being loaded
  55644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55645. * @param fallback defines the fallback internal texture if any
  55646. * @param isBase64 defines whether the texture is encoded as a base64
  55647. * @param isBuffer defines whether the texture data are stored as a buffer
  55648. * @returns true if the loader can load the specified file
  55649. */
  55650. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55651. /**
  55652. * Transform the url before loading if required.
  55653. * @param rootUrl the url of the texture
  55654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55655. * @returns the transformed texture
  55656. */
  55657. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55658. /**
  55659. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55660. * @param rootUrl the url of the texture
  55661. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55662. * @returns the fallback texture
  55663. */
  55664. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55665. /**
  55666. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55667. * @param data contains the texture data
  55668. * @param texture defines the BabylonJS internal texture
  55669. * @param createPolynomials will be true if polynomials have been requested
  55670. * @param onLoad defines the callback to trigger once the texture is ready
  55671. * @param onError defines the callback to trigger in case of error
  55672. */
  55673. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55674. /**
  55675. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55676. * @param data contains the texture data
  55677. * @param texture defines the BabylonJS internal texture
  55678. * @param callback defines the method to call once ready to upload
  55679. */
  55680. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55681. }
  55682. }
  55683. declare module "babylonjs/Misc/basis" {
  55684. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55685. /**
  55686. * Info about the .basis files
  55687. */
  55688. class BasisFileInfo {
  55689. /**
  55690. * If the file has alpha
  55691. */
  55692. hasAlpha: boolean;
  55693. /**
  55694. * Info about each image of the basis file
  55695. */
  55696. images: Array<{
  55697. levels: Array<{
  55698. width: number;
  55699. height: number;
  55700. transcodedPixels: ArrayBufferView;
  55701. }>;
  55702. }>;
  55703. }
  55704. /**
  55705. * Result of transcoding a basis file
  55706. */
  55707. class TranscodeResult {
  55708. /**
  55709. * Info about the .basis file
  55710. */
  55711. fileInfo: BasisFileInfo;
  55712. /**
  55713. * Format to use when loading the file
  55714. */
  55715. format: number;
  55716. }
  55717. /**
  55718. * Configuration options for the Basis transcoder
  55719. */
  55720. export class BasisTranscodeConfiguration {
  55721. /**
  55722. * Supported compression formats used to determine the supported output format of the transcoder
  55723. */
  55724. supportedCompressionFormats?: {
  55725. /**
  55726. * etc1 compression format
  55727. */
  55728. etc1?: boolean;
  55729. /**
  55730. * s3tc compression format
  55731. */
  55732. s3tc?: boolean;
  55733. /**
  55734. * pvrtc compression format
  55735. */
  55736. pvrtc?: boolean;
  55737. /**
  55738. * etc2 compression format
  55739. */
  55740. etc2?: boolean;
  55741. };
  55742. /**
  55743. * If mipmap levels should be loaded for transcoded images (Default: true)
  55744. */
  55745. loadMipmapLevels?: boolean;
  55746. /**
  55747. * Index of a single image to load (Default: all images)
  55748. */
  55749. loadSingleImage?: number;
  55750. }
  55751. /**
  55752. * Used to load .Basis files
  55753. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55754. */
  55755. export class BasisTools {
  55756. private static _IgnoreSupportedFormats;
  55757. /**
  55758. * URL to use when loading the basis transcoder
  55759. */
  55760. static JSModuleURL: string;
  55761. /**
  55762. * URL to use when loading the wasm module for the transcoder
  55763. */
  55764. static WasmModuleURL: string;
  55765. /**
  55766. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55767. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55768. * @returns internal format corresponding to the Basis format
  55769. */
  55770. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55771. private static _WorkerPromise;
  55772. private static _Worker;
  55773. private static _actionId;
  55774. private static _CreateWorkerAsync;
  55775. /**
  55776. * Transcodes a loaded image file to compressed pixel data
  55777. * @param imageData image data to transcode
  55778. * @param config configuration options for the transcoding
  55779. * @returns a promise resulting in the transcoded image
  55780. */
  55781. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55782. /**
  55783. * Loads a texture from the transcode result
  55784. * @param texture texture load to
  55785. * @param transcodeResult the result of transcoding the basis file to load from
  55786. */
  55787. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55788. }
  55789. }
  55790. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55791. import { Nullable } from "babylonjs/types";
  55792. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55793. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55794. /**
  55795. * Loader for .basis file format
  55796. */
  55797. export class _BasisTextureLoader implements IInternalTextureLoader {
  55798. /**
  55799. * Defines whether the loader supports cascade loading the different faces.
  55800. */
  55801. readonly supportCascades: boolean;
  55802. /**
  55803. * This returns if the loader support the current file information.
  55804. * @param extension defines the file extension of the file being loaded
  55805. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55806. * @param fallback defines the fallback internal texture if any
  55807. * @param isBase64 defines whether the texture is encoded as a base64
  55808. * @param isBuffer defines whether the texture data are stored as a buffer
  55809. * @returns true if the loader can load the specified file
  55810. */
  55811. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55812. /**
  55813. * Transform the url before loading if required.
  55814. * @param rootUrl the url of the texture
  55815. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55816. * @returns the transformed texture
  55817. */
  55818. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55819. /**
  55820. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55821. * @param rootUrl the url of the texture
  55822. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55823. * @returns the fallback texture
  55824. */
  55825. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55826. /**
  55827. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55828. * @param data contains the texture data
  55829. * @param texture defines the BabylonJS internal texture
  55830. * @param createPolynomials will be true if polynomials have been requested
  55831. * @param onLoad defines the callback to trigger once the texture is ready
  55832. * @param onError defines the callback to trigger in case of error
  55833. */
  55834. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55835. /**
  55836. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55837. * @param data contains the texture data
  55838. * @param texture defines the BabylonJS internal texture
  55839. * @param callback defines the method to call once ready to upload
  55840. */
  55841. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55842. }
  55843. }
  55844. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55845. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55846. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55847. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55848. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55849. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55850. }
  55851. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55852. import { Scene } from "babylonjs/scene";
  55853. import { Texture } from "babylonjs/Materials/Textures/texture";
  55854. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55855. /**
  55856. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  55857. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55858. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55859. */
  55860. export class CustomProceduralTexture extends ProceduralTexture {
  55861. private _animate;
  55862. private _time;
  55863. private _config;
  55864. private _texturePath;
  55865. /**
  55866. * Instantiates a new Custom Procedural Texture.
  55867. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  55868. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55869. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55870. * @param name Define the name of the texture
  55871. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55872. * @param size Define the size of the texture to create
  55873. * @param scene Define the scene the texture belongs to
  55874. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55875. * @param generateMipMaps Define if the texture should creates mip maps or not
  55876. */
  55877. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55878. private _loadJson;
  55879. /**
  55880. * Is the texture ready to be used ? (rendered at least once)
  55881. * @returns true if ready, otherwise, false.
  55882. */
  55883. isReady(): boolean;
  55884. /**
  55885. * Render the texture to its associated render target.
  55886. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55887. */
  55888. render(useCameraPostProcess?: boolean): void;
  55889. /**
  55890. * Update the list of dependant textures samplers in the shader.
  55891. */
  55892. updateTextures(): void;
  55893. /**
  55894. * Update the uniform values of the procedural texture in the shader.
  55895. */
  55896. updateShaderUniforms(): void;
  55897. /**
  55898. * Define if the texture animates or not.
  55899. */
  55900. animate: boolean;
  55901. }
  55902. }
  55903. declare module "babylonjs/Shaders/noise.fragment" {
  55904. /** @hidden */
  55905. export var noisePixelShader: {
  55906. name: string;
  55907. shader: string;
  55908. };
  55909. }
  55910. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55911. import { Nullable } from "babylonjs/types";
  55912. import { Scene } from "babylonjs/scene";
  55913. import { Texture } from "babylonjs/Materials/Textures/texture";
  55914. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55915. import "babylonjs/Shaders/noise.fragment";
  55916. /**
  55917. * Class used to generate noise procedural textures
  55918. */
  55919. export class NoiseProceduralTexture extends ProceduralTexture {
  55920. private _time;
  55921. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55922. brightness: number;
  55923. /** Defines the number of octaves to process */
  55924. octaves: number;
  55925. /** Defines the level of persistence (0.8 by default) */
  55926. persistence: number;
  55927. /** Gets or sets animation speed factor (default is 1) */
  55928. animationSpeedFactor: number;
  55929. /**
  55930. * Creates a new NoiseProceduralTexture
  55931. * @param name defines the name fo the texture
  55932. * @param size defines the size of the texture (default is 256)
  55933. * @param scene defines the hosting scene
  55934. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55935. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55936. */
  55937. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55938. private _updateShaderUniforms;
  55939. protected _getDefines(): string;
  55940. /** Generate the current state of the procedural texture */
  55941. render(useCameraPostProcess?: boolean): void;
  55942. /**
  55943. * Serializes this noise procedural texture
  55944. * @returns a serialized noise procedural texture object
  55945. */
  55946. serialize(): any;
  55947. /**
  55948. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55949. * @param parsedTexture defines parsed texture data
  55950. * @param scene defines the current scene
  55951. * @param rootUrl defines the root URL containing noise procedural texture information
  55952. * @returns a parsed NoiseProceduralTexture
  55953. */
  55954. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55955. }
  55956. }
  55957. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55958. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55959. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55960. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55961. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55962. }
  55963. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55964. import { Nullable } from "babylonjs/types";
  55965. import { Scene } from "babylonjs/scene";
  55966. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55968. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55969. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55970. /**
  55971. * Raw cube texture where the raw buffers are passed in
  55972. */
  55973. export class RawCubeTexture extends CubeTexture {
  55974. /**
  55975. * Creates a cube texture where the raw buffers are passed in.
  55976. * @param scene defines the scene the texture is attached to
  55977. * @param data defines the array of data to use to create each face
  55978. * @param size defines the size of the textures
  55979. * @param format defines the format of the data
  55980. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55981. * @param generateMipMaps defines if the engine should generate the mip levels
  55982. * @param invertY defines if data must be stored with Y axis inverted
  55983. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55984. * @param compression defines the compression used (null by default)
  55985. */
  55986. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55987. /**
  55988. * Updates the raw cube texture.
  55989. * @param data defines the data to store
  55990. * @param format defines the data format
  55991. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55992. * @param invertY defines if data must be stored with Y axis inverted
  55993. * @param compression defines the compression used (null by default)
  55994. * @param level defines which level of the texture to update
  55995. */
  55996. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55997. /**
  55998. * Updates a raw cube texture with RGBD encoded data.
  55999. * @param data defines the array of data [mipmap][face] to use to create each face
  56000. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56001. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56002. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56003. * @returns a promsie that resolves when the operation is complete
  56004. */
  56005. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56006. /**
  56007. * Clones the raw cube texture.
  56008. * @return a new cube texture
  56009. */
  56010. clone(): CubeTexture;
  56011. /** @hidden */
  56012. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56013. }
  56014. }
  56015. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  56016. import { Scene } from "babylonjs/scene";
  56017. import { Texture } from "babylonjs/Materials/Textures/texture";
  56018. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56019. /**
  56020. * Class used to store 3D textures containing user data
  56021. */
  56022. export class RawTexture3D extends Texture {
  56023. /** Gets or sets the texture format to use */
  56024. format: number;
  56025. private _engine;
  56026. /**
  56027. * Create a new RawTexture3D
  56028. * @param data defines the data of the texture
  56029. * @param width defines the width of the texture
  56030. * @param height defines the height of the texture
  56031. * @param depth defines the depth of the texture
  56032. * @param format defines the texture format to use
  56033. * @param scene defines the hosting scene
  56034. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56035. * @param invertY defines if texture must be stored with Y axis inverted
  56036. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56037. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56038. */
  56039. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56040. /** Gets or sets the texture format to use */
  56041. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56042. /**
  56043. * Update the texture with new data
  56044. * @param data defines the data to store in the texture
  56045. */
  56046. update(data: ArrayBufferView): void;
  56047. }
  56048. }
  56049. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  56050. import { Scene } from "babylonjs/scene";
  56051. import { Texture } from "babylonjs/Materials/Textures/texture";
  56052. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56053. /**
  56054. * Class used to store 2D array textures containing user data
  56055. */
  56056. export class RawTexture2DArray extends Texture {
  56057. /** Gets or sets the texture format to use */
  56058. format: number;
  56059. private _engine;
  56060. /**
  56061. * Create a new RawTexture2DArray
  56062. * @param data defines the data of the texture
  56063. * @param width defines the width of the texture
  56064. * @param height defines the height of the texture
  56065. * @param depth defines the number of layers of the texture
  56066. * @param format defines the texture format to use
  56067. * @param scene defines the hosting scene
  56068. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56069. * @param invertY defines if texture must be stored with Y axis inverted
  56070. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56071. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56072. */
  56073. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56074. /** Gets or sets the texture format to use */
  56075. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56076. /**
  56077. * Update the texture with new data
  56078. * @param data defines the data to store in the texture
  56079. */
  56080. update(data: ArrayBufferView): void;
  56081. }
  56082. }
  56083. declare module "babylonjs/Materials/Textures/refractionTexture" {
  56084. import { Scene } from "babylonjs/scene";
  56085. import { Plane } from "babylonjs/Maths/math.plane";
  56086. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56087. /**
  56088. * Creates a refraction texture used by refraction channel of the standard material.
  56089. * It is like a mirror but to see through a material.
  56090. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56091. */
  56092. export class RefractionTexture extends RenderTargetTexture {
  56093. /**
  56094. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56095. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  56096. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56097. */
  56098. refractionPlane: Plane;
  56099. /**
  56100. * Define how deep under the surface we should see.
  56101. */
  56102. depth: number;
  56103. /**
  56104. * Creates a refraction texture used by refraction channel of the standard material.
  56105. * It is like a mirror but to see through a material.
  56106. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56107. * @param name Define the texture name
  56108. * @param size Define the size of the underlying texture
  56109. * @param scene Define the scene the refraction belongs to
  56110. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56111. */
  56112. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56113. /**
  56114. * Clone the refraction texture.
  56115. * @returns the cloned texture
  56116. */
  56117. clone(): RefractionTexture;
  56118. /**
  56119. * Serialize the texture to a JSON representation you could use in Parse later on
  56120. * @returns the serialized JSON representation
  56121. */
  56122. serialize(): any;
  56123. }
  56124. }
  56125. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  56126. import { Nullable } from "babylonjs/types";
  56127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56128. import { Matrix } from "babylonjs/Maths/math.vector";
  56129. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  56130. import "babylonjs/Engines/Extensions/engine.videoTexture";
  56131. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  56132. import { Scene } from "babylonjs/scene";
  56133. /**
  56134. * Defines the options related to the creation of an HtmlElementTexture
  56135. */
  56136. export interface IHtmlElementTextureOptions {
  56137. /**
  56138. * Defines wether mip maps should be created or not.
  56139. */
  56140. generateMipMaps?: boolean;
  56141. /**
  56142. * Defines the sampling mode of the texture.
  56143. */
  56144. samplingMode?: number;
  56145. /**
  56146. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56147. */
  56148. engine: Nullable<ThinEngine>;
  56149. /**
  56150. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56151. */
  56152. scene: Nullable<Scene>;
  56153. }
  56154. /**
  56155. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56156. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56157. * is automatically managed.
  56158. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56159. * in your application.
  56160. *
  56161. * As the update is not automatic, you need to call them manually.
  56162. */
  56163. export class HtmlElementTexture extends BaseTexture {
  56164. /**
  56165. * The texture URL.
  56166. */
  56167. element: HTMLVideoElement | HTMLCanvasElement;
  56168. private static readonly DefaultOptions;
  56169. private _textureMatrix;
  56170. private _engine;
  56171. private _isVideo;
  56172. private _generateMipMaps;
  56173. private _samplingMode;
  56174. /**
  56175. * Instantiates a HtmlElementTexture from the following parameters.
  56176. *
  56177. * @param name Defines the name of the texture
  56178. * @param element Defines the video or canvas the texture is filled with
  56179. * @param options Defines the other none mandatory texture creation options
  56180. */
  56181. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56182. private _createInternalTexture;
  56183. /**
  56184. * Returns the texture matrix used in most of the material.
  56185. */
  56186. getTextureMatrix(): Matrix;
  56187. /**
  56188. * Updates the content of the texture.
  56189. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56190. */
  56191. update(invertY?: Nullable<boolean>): void;
  56192. }
  56193. }
  56194. declare module "babylonjs/Materials/Textures/index" {
  56195. export * from "babylonjs/Materials/Textures/baseTexture";
  56196. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  56197. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  56198. export * from "babylonjs/Materials/Textures/cubeTexture";
  56199. export * from "babylonjs/Materials/Textures/dynamicTexture";
  56200. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56201. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  56202. export * from "babylonjs/Materials/Textures/internalTexture";
  56203. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  56204. export * from "babylonjs/Materials/Textures/Loaders/index";
  56205. export * from "babylonjs/Materials/Textures/mirrorTexture";
  56206. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  56207. export * from "babylonjs/Materials/Textures/Procedurals/index";
  56208. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  56209. export * from "babylonjs/Materials/Textures/rawTexture";
  56210. export * from "babylonjs/Materials/Textures/rawTexture3D";
  56211. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  56212. export * from "babylonjs/Materials/Textures/refractionTexture";
  56213. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  56214. export * from "babylonjs/Materials/Textures/texture";
  56215. export * from "babylonjs/Materials/Textures/videoTexture";
  56216. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  56217. }
  56218. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  56219. /**
  56220. * Enum used to define the target of a block
  56221. */
  56222. export enum NodeMaterialBlockTargets {
  56223. /** Vertex shader */
  56224. Vertex = 1,
  56225. /** Fragment shader */
  56226. Fragment = 2,
  56227. /** Neutral */
  56228. Neutral = 4,
  56229. /** Vertex and Fragment */
  56230. VertexAndFragment = 3
  56231. }
  56232. }
  56233. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  56234. /**
  56235. * Defines the kind of connection point for node based material
  56236. */
  56237. export enum NodeMaterialBlockConnectionPointTypes {
  56238. /** Float */
  56239. Float = 1,
  56240. /** Int */
  56241. Int = 2,
  56242. /** Vector2 */
  56243. Vector2 = 4,
  56244. /** Vector3 */
  56245. Vector3 = 8,
  56246. /** Vector4 */
  56247. Vector4 = 16,
  56248. /** Color3 */
  56249. Color3 = 32,
  56250. /** Color4 */
  56251. Color4 = 64,
  56252. /** Matrix */
  56253. Matrix = 128,
  56254. /** Detect type based on connection */
  56255. AutoDetect = 1024,
  56256. /** Output type that will be defined by input type */
  56257. BasedOnInput = 2048
  56258. }
  56259. }
  56260. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  56261. /**
  56262. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56263. */
  56264. export enum NodeMaterialBlockConnectionPointMode {
  56265. /** Value is an uniform */
  56266. Uniform = 0,
  56267. /** Value is a mesh attribute */
  56268. Attribute = 1,
  56269. /** Value is a varying between vertex and fragment shaders */
  56270. Varying = 2,
  56271. /** Mode is undefined */
  56272. Undefined = 3
  56273. }
  56274. }
  56275. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  56276. /**
  56277. * Enum used to define system values e.g. values automatically provided by the system
  56278. */
  56279. export enum NodeMaterialSystemValues {
  56280. /** World */
  56281. World = 1,
  56282. /** View */
  56283. View = 2,
  56284. /** Projection */
  56285. Projection = 3,
  56286. /** ViewProjection */
  56287. ViewProjection = 4,
  56288. /** WorldView */
  56289. WorldView = 5,
  56290. /** WorldViewProjection */
  56291. WorldViewProjection = 6,
  56292. /** CameraPosition */
  56293. CameraPosition = 7,
  56294. /** Fog Color */
  56295. FogColor = 8,
  56296. /** Delta time */
  56297. DeltaTime = 9
  56298. }
  56299. }
  56300. declare module "babylonjs/Materials/Node/Enums/index" {
  56301. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56302. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56303. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  56304. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56305. }
  56306. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  56307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56308. /**
  56309. * Root class for all node material optimizers
  56310. */
  56311. export class NodeMaterialOptimizer {
  56312. /**
  56313. * Function used to optimize a NodeMaterial graph
  56314. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56315. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56316. */
  56317. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56318. }
  56319. }
  56320. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  56321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56324. import { Scene } from "babylonjs/scene";
  56325. /**
  56326. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56327. */
  56328. export class TransformBlock extends NodeMaterialBlock {
  56329. /**
  56330. * Defines the value to use to complement W value to transform it to a Vector4
  56331. */
  56332. complementW: number;
  56333. /**
  56334. * Defines the value to use to complement z value to transform it to a Vector4
  56335. */
  56336. complementZ: number;
  56337. /**
  56338. * Creates a new TransformBlock
  56339. * @param name defines the block name
  56340. */
  56341. constructor(name: string);
  56342. /**
  56343. * Gets the current class name
  56344. * @returns the class name
  56345. */
  56346. getClassName(): string;
  56347. /**
  56348. * Gets the vector input
  56349. */
  56350. readonly vector: NodeMaterialConnectionPoint;
  56351. /**
  56352. * Gets the output component
  56353. */
  56354. readonly output: NodeMaterialConnectionPoint;
  56355. /**
  56356. * Gets the matrix transform input
  56357. */
  56358. readonly transform: NodeMaterialConnectionPoint;
  56359. protected _buildBlock(state: NodeMaterialBuildState): this;
  56360. serialize(): any;
  56361. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56362. protected _dumpPropertiesCode(): string;
  56363. }
  56364. }
  56365. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  56366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56369. /**
  56370. * Block used to output the vertex position
  56371. */
  56372. export class VertexOutputBlock extends NodeMaterialBlock {
  56373. /**
  56374. * Creates a new VertexOutputBlock
  56375. * @param name defines the block name
  56376. */
  56377. constructor(name: string);
  56378. /**
  56379. * Gets the current class name
  56380. * @returns the class name
  56381. */
  56382. getClassName(): string;
  56383. /**
  56384. * Gets the vector input component
  56385. */
  56386. readonly vector: NodeMaterialConnectionPoint;
  56387. protected _buildBlock(state: NodeMaterialBuildState): this;
  56388. }
  56389. }
  56390. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  56391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56392. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56393. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56394. /**
  56395. * Block used to output the final color
  56396. */
  56397. export class FragmentOutputBlock extends NodeMaterialBlock {
  56398. /**
  56399. * Create a new FragmentOutputBlock
  56400. * @param name defines the block name
  56401. */
  56402. constructor(name: string);
  56403. /**
  56404. * Gets the current class name
  56405. * @returns the class name
  56406. */
  56407. getClassName(): string;
  56408. /**
  56409. * Gets the rgba input component
  56410. */
  56411. readonly rgba: NodeMaterialConnectionPoint;
  56412. /**
  56413. * Gets the rgb input component
  56414. */
  56415. readonly rgb: NodeMaterialConnectionPoint;
  56416. /**
  56417. * Gets the a input component
  56418. */
  56419. readonly a: NodeMaterialConnectionPoint;
  56420. protected _buildBlock(state: NodeMaterialBuildState): this;
  56421. }
  56422. }
  56423. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56429. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56430. import { Effect } from "babylonjs/Materials/effect";
  56431. import { Mesh } from "babylonjs/Meshes/mesh";
  56432. import { Nullable } from "babylonjs/types";
  56433. import { Scene } from "babylonjs/scene";
  56434. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56435. /**
  56436. * Block used to read a reflection texture from a sampler
  56437. */
  56438. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56439. private _define3DName;
  56440. private _defineCubicName;
  56441. private _defineExplicitName;
  56442. private _defineProjectionName;
  56443. private _defineLocalCubicName;
  56444. private _defineSphericalName;
  56445. private _definePlanarName;
  56446. private _defineEquirectangularName;
  56447. private _defineMirroredEquirectangularFixedName;
  56448. private _defineEquirectangularFixedName;
  56449. private _defineSkyboxName;
  56450. private _cubeSamplerName;
  56451. private _2DSamplerName;
  56452. private _positionUVWName;
  56453. private _directionWName;
  56454. private _reflectionCoordsName;
  56455. private _reflection2DCoordsName;
  56456. private _reflectionColorName;
  56457. private _reflectionMatrixName;
  56458. /**
  56459. * Gets or sets the texture associated with the node
  56460. */
  56461. texture: Nullable<BaseTexture>;
  56462. /**
  56463. * Create a new TextureBlock
  56464. * @param name defines the block name
  56465. */
  56466. constructor(name: string);
  56467. /**
  56468. * Gets the current class name
  56469. * @returns the class name
  56470. */
  56471. getClassName(): string;
  56472. /**
  56473. * Gets the world position input component
  56474. */
  56475. readonly position: NodeMaterialConnectionPoint;
  56476. /**
  56477. * Gets the world position input component
  56478. */
  56479. readonly worldPosition: NodeMaterialConnectionPoint;
  56480. /**
  56481. * Gets the world normal input component
  56482. */
  56483. readonly worldNormal: NodeMaterialConnectionPoint;
  56484. /**
  56485. * Gets the world input component
  56486. */
  56487. readonly world: NodeMaterialConnectionPoint;
  56488. /**
  56489. * Gets the camera (or eye) position component
  56490. */
  56491. readonly cameraPosition: NodeMaterialConnectionPoint;
  56492. /**
  56493. * Gets the view input component
  56494. */
  56495. readonly view: NodeMaterialConnectionPoint;
  56496. /**
  56497. * Gets the rgb output component
  56498. */
  56499. readonly rgb: NodeMaterialConnectionPoint;
  56500. /**
  56501. * Gets the r output component
  56502. */
  56503. readonly r: NodeMaterialConnectionPoint;
  56504. /**
  56505. * Gets the g output component
  56506. */
  56507. readonly g: NodeMaterialConnectionPoint;
  56508. /**
  56509. * Gets the b output component
  56510. */
  56511. readonly b: NodeMaterialConnectionPoint;
  56512. autoConfigure(material: NodeMaterial): void;
  56513. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56514. isReady(): boolean;
  56515. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56516. private _injectVertexCode;
  56517. private _writeOutput;
  56518. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56519. protected _dumpPropertiesCode(): string;
  56520. serialize(): any;
  56521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56522. }
  56523. }
  56524. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56525. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56526. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56527. import { Scene } from "babylonjs/scene";
  56528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56529. import { Matrix } from "babylonjs/Maths/math.vector";
  56530. import { Mesh } from "babylonjs/Meshes/mesh";
  56531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56532. import { Observable } from "babylonjs/Misc/observable";
  56533. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56534. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56535. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56536. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56537. import { Nullable } from "babylonjs/types";
  56538. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56539. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56540. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56541. /**
  56542. * Interface used to configure the node material editor
  56543. */
  56544. export interface INodeMaterialEditorOptions {
  56545. /** Define the URl to load node editor script */
  56546. editorURL?: string;
  56547. }
  56548. /** @hidden */
  56549. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56550. /** BONES */
  56551. NUM_BONE_INFLUENCERS: number;
  56552. BonesPerMesh: number;
  56553. BONETEXTURE: boolean;
  56554. /** MORPH TARGETS */
  56555. MORPHTARGETS: boolean;
  56556. MORPHTARGETS_NORMAL: boolean;
  56557. MORPHTARGETS_TANGENT: boolean;
  56558. MORPHTARGETS_UV: boolean;
  56559. NUM_MORPH_INFLUENCERS: number;
  56560. /** IMAGE PROCESSING */
  56561. IMAGEPROCESSING: boolean;
  56562. VIGNETTE: boolean;
  56563. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56564. VIGNETTEBLENDMODEOPAQUE: boolean;
  56565. TONEMAPPING: boolean;
  56566. TONEMAPPING_ACES: boolean;
  56567. CONTRAST: boolean;
  56568. EXPOSURE: boolean;
  56569. COLORCURVES: boolean;
  56570. COLORGRADING: boolean;
  56571. COLORGRADING3D: boolean;
  56572. SAMPLER3DGREENDEPTH: boolean;
  56573. SAMPLER3DBGRMAP: boolean;
  56574. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56575. /** MISC. */
  56576. BUMPDIRECTUV: number;
  56577. constructor();
  56578. setValue(name: string, value: boolean): void;
  56579. }
  56580. /**
  56581. * Class used to configure NodeMaterial
  56582. */
  56583. export interface INodeMaterialOptions {
  56584. /**
  56585. * Defines if blocks should emit comments
  56586. */
  56587. emitComments: boolean;
  56588. }
  56589. /**
  56590. * Class used to create a node based material built by assembling shader blocks
  56591. */
  56592. export class NodeMaterial extends PushMaterial {
  56593. private static _BuildIdGenerator;
  56594. private _options;
  56595. private _vertexCompilationState;
  56596. private _fragmentCompilationState;
  56597. private _sharedData;
  56598. private _buildId;
  56599. private _buildWasSuccessful;
  56600. private _cachedWorldViewMatrix;
  56601. private _cachedWorldViewProjectionMatrix;
  56602. private _optimizers;
  56603. private _animationFrame;
  56604. /** Define the URl to load node editor script */
  56605. static EditorURL: string;
  56606. private BJSNODEMATERIALEDITOR;
  56607. /** Get the inspector from bundle or global */
  56608. private _getGlobalNodeMaterialEditor;
  56609. /**
  56610. * Gets or sets data used by visual editor
  56611. * @see https://nme.babylonjs.com
  56612. */
  56613. editorData: any;
  56614. /**
  56615. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  56616. */
  56617. ignoreAlpha: boolean;
  56618. /**
  56619. * Defines the maximum number of lights that can be used in the material
  56620. */
  56621. maxSimultaneousLights: number;
  56622. /**
  56623. * Observable raised when the material is built
  56624. */
  56625. onBuildObservable: Observable<NodeMaterial>;
  56626. /**
  56627. * Gets or sets the root nodes of the material vertex shader
  56628. */
  56629. _vertexOutputNodes: NodeMaterialBlock[];
  56630. /**
  56631. * Gets or sets the root nodes of the material fragment (pixel) shader
  56632. */
  56633. _fragmentOutputNodes: NodeMaterialBlock[];
  56634. /** Gets or sets options to control the node material overall behavior */
  56635. options: INodeMaterialOptions;
  56636. /**
  56637. * Default configuration related to image processing available in the standard Material.
  56638. */
  56639. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56640. /**
  56641. * Gets the image processing configuration used either in this material.
  56642. */
  56643. /**
  56644. * Sets the Default image processing configuration used either in the this material.
  56645. *
  56646. * If sets to null, the scene one is in use.
  56647. */
  56648. imageProcessingConfiguration: ImageProcessingConfiguration;
  56649. /**
  56650. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56651. */
  56652. attachedBlocks: NodeMaterialBlock[];
  56653. /**
  56654. * Create a new node based material
  56655. * @param name defines the material name
  56656. * @param scene defines the hosting scene
  56657. * @param options defines creation option
  56658. */
  56659. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56660. /**
  56661. * Gets the current class name of the material e.g. "NodeMaterial"
  56662. * @returns the class name
  56663. */
  56664. getClassName(): string;
  56665. /**
  56666. * Keep track of the image processing observer to allow dispose and replace.
  56667. */
  56668. private _imageProcessingObserver;
  56669. /**
  56670. * Attaches a new image processing configuration to the Standard Material.
  56671. * @param configuration
  56672. */
  56673. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56674. /**
  56675. * Get a block by its name
  56676. * @param name defines the name of the block to retrieve
  56677. * @returns the required block or null if not found
  56678. */
  56679. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56680. /**
  56681. * Get a block by its name
  56682. * @param predicate defines the predicate used to find the good candidate
  56683. * @returns the required block or null if not found
  56684. */
  56685. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56686. /**
  56687. * Get an input block by its name
  56688. * @param predicate defines the predicate used to find the good candidate
  56689. * @returns the required input block or null if not found
  56690. */
  56691. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56692. /**
  56693. * Gets the list of input blocks attached to this material
  56694. * @returns an array of InputBlocks
  56695. */
  56696. getInputBlocks(): InputBlock[];
  56697. /**
  56698. * Adds a new optimizer to the list of optimizers
  56699. * @param optimizer defines the optimizers to add
  56700. * @returns the current material
  56701. */
  56702. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56703. /**
  56704. * Remove an optimizer from the list of optimizers
  56705. * @param optimizer defines the optimizers to remove
  56706. * @returns the current material
  56707. */
  56708. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56709. /**
  56710. * Add a new block to the list of output nodes
  56711. * @param node defines the node to add
  56712. * @returns the current material
  56713. */
  56714. addOutputNode(node: NodeMaterialBlock): this;
  56715. /**
  56716. * Remove a block from the list of root nodes
  56717. * @param node defines the node to remove
  56718. * @returns the current material
  56719. */
  56720. removeOutputNode(node: NodeMaterialBlock): this;
  56721. private _addVertexOutputNode;
  56722. private _removeVertexOutputNode;
  56723. private _addFragmentOutputNode;
  56724. private _removeFragmentOutputNode;
  56725. /**
  56726. * Specifies if the material will require alpha blending
  56727. * @returns a boolean specifying if alpha blending is needed
  56728. */
  56729. needAlphaBlending(): boolean;
  56730. /**
  56731. * Specifies if this material should be rendered in alpha test mode
  56732. * @returns a boolean specifying if an alpha test is needed.
  56733. */
  56734. needAlphaTesting(): boolean;
  56735. private _initializeBlock;
  56736. private _resetDualBlocks;
  56737. /**
  56738. * Remove a block from the current node material
  56739. * @param block defines the block to remove
  56740. */
  56741. removeBlock(block: NodeMaterialBlock): void;
  56742. /**
  56743. * Build the material and generates the inner effect
  56744. * @param verbose defines if the build should log activity
  56745. */
  56746. build(verbose?: boolean): void;
  56747. /**
  56748. * Runs an otpimization phase to try to improve the shader code
  56749. */
  56750. optimize(): void;
  56751. private _prepareDefinesForAttributes;
  56752. /**
  56753. * Get if the submesh is ready to be used and all its information available.
  56754. * Child classes can use it to update shaders
  56755. * @param mesh defines the mesh to check
  56756. * @param subMesh defines which submesh to check
  56757. * @param useInstances specifies that instances should be used
  56758. * @returns a boolean indicating that the submesh is ready or not
  56759. */
  56760. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56761. /**
  56762. * Get a string representing the shaders built by the current node graph
  56763. */
  56764. readonly compiledShaders: string;
  56765. /**
  56766. * Binds the world matrix to the material
  56767. * @param world defines the world transformation matrix
  56768. */
  56769. bindOnlyWorldMatrix(world: Matrix): void;
  56770. /**
  56771. * Binds the submesh to this material by preparing the effect and shader to draw
  56772. * @param world defines the world transformation matrix
  56773. * @param mesh defines the mesh containing the submesh
  56774. * @param subMesh defines the submesh to bind the material to
  56775. */
  56776. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56777. /**
  56778. * Gets the active textures from the material
  56779. * @returns an array of textures
  56780. */
  56781. getActiveTextures(): BaseTexture[];
  56782. /**
  56783. * Gets the list of texture blocks
  56784. * @returns an array of texture blocks
  56785. */
  56786. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56787. /**
  56788. * Specifies if the material uses a texture
  56789. * @param texture defines the texture to check against the material
  56790. * @returns a boolean specifying if the material uses the texture
  56791. */
  56792. hasTexture(texture: BaseTexture): boolean;
  56793. /**
  56794. * Disposes the material
  56795. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56796. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56797. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56798. */
  56799. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56800. /** Creates the node editor window. */
  56801. private _createNodeEditor;
  56802. /**
  56803. * Launch the node material editor
  56804. * @param config Define the configuration of the editor
  56805. * @return a promise fulfilled when the node editor is visible
  56806. */
  56807. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56808. /**
  56809. * Clear the current material
  56810. */
  56811. clear(): void;
  56812. /**
  56813. * Clear the current material and set it to a default state
  56814. */
  56815. setToDefault(): void;
  56816. /**
  56817. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56818. * @param url defines the url to load from
  56819. * @returns a promise that will fullfil when the material is fully loaded
  56820. */
  56821. loadAsync(url: string): Promise<void>;
  56822. private _gatherBlocks;
  56823. /**
  56824. * Generate a string containing the code declaration required to create an equivalent of this material
  56825. * @returns a string
  56826. */
  56827. generateCode(): string;
  56828. /**
  56829. * Serializes this material in a JSON representation
  56830. * @returns the serialized material object
  56831. */
  56832. serialize(): any;
  56833. private _restoreConnections;
  56834. /**
  56835. * Clear the current graph and load a new one from a serialization object
  56836. * @param source defines the JSON representation of the material
  56837. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56838. */
  56839. loadFromSerialization(source: any, rootUrl?: string): void;
  56840. /**
  56841. * Creates a node material from parsed material data
  56842. * @param source defines the JSON representation of the material
  56843. * @param scene defines the hosting scene
  56844. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56845. * @returns a new node material
  56846. */
  56847. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56848. /**
  56849. * Creates a new node material set to default basic configuration
  56850. * @param name defines the name of the material
  56851. * @param scene defines the hosting scene
  56852. * @returns a new NodeMaterial
  56853. */
  56854. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56855. }
  56856. }
  56857. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56860. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56863. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56864. import { Effect } from "babylonjs/Materials/effect";
  56865. import { Mesh } from "babylonjs/Meshes/mesh";
  56866. import { Nullable } from "babylonjs/types";
  56867. import { Texture } from "babylonjs/Materials/Textures/texture";
  56868. import { Scene } from "babylonjs/scene";
  56869. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56870. /**
  56871. * Block used to read a texture from a sampler
  56872. */
  56873. export class TextureBlock extends NodeMaterialBlock {
  56874. private _defineName;
  56875. private _linearDefineName;
  56876. private _tempTextureRead;
  56877. private _samplerName;
  56878. private _transformedUVName;
  56879. private _textureTransformName;
  56880. private _textureInfoName;
  56881. private _mainUVName;
  56882. private _mainUVDefineName;
  56883. /**
  56884. * Gets or sets the texture associated with the node
  56885. */
  56886. texture: Nullable<Texture>;
  56887. /**
  56888. * Create a new TextureBlock
  56889. * @param name defines the block name
  56890. */
  56891. constructor(name: string);
  56892. /**
  56893. * Gets the current class name
  56894. * @returns the class name
  56895. */
  56896. getClassName(): string;
  56897. /**
  56898. * Gets the uv input component
  56899. */
  56900. readonly uv: NodeMaterialConnectionPoint;
  56901. /**
  56902. * Gets the rgba output component
  56903. */
  56904. readonly rgba: NodeMaterialConnectionPoint;
  56905. /**
  56906. * Gets the rgb output component
  56907. */
  56908. readonly rgb: NodeMaterialConnectionPoint;
  56909. /**
  56910. * Gets the r output component
  56911. */
  56912. readonly r: NodeMaterialConnectionPoint;
  56913. /**
  56914. * Gets the g output component
  56915. */
  56916. readonly g: NodeMaterialConnectionPoint;
  56917. /**
  56918. * Gets the b output component
  56919. */
  56920. readonly b: NodeMaterialConnectionPoint;
  56921. /**
  56922. * Gets the a output component
  56923. */
  56924. readonly a: NodeMaterialConnectionPoint;
  56925. readonly target: NodeMaterialBlockTargets;
  56926. autoConfigure(material: NodeMaterial): void;
  56927. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56928. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56929. private _getTextureBase;
  56930. isReady(): boolean;
  56931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56932. private readonly _isMixed;
  56933. private _injectVertexCode;
  56934. private _writeTextureRead;
  56935. private _writeOutput;
  56936. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56937. protected _dumpPropertiesCode(): string;
  56938. serialize(): any;
  56939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56940. }
  56941. }
  56942. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56945. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56946. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56947. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56948. import { Scene } from "babylonjs/scene";
  56949. /**
  56950. * Class used to store shared data between 2 NodeMaterialBuildState
  56951. */
  56952. export class NodeMaterialBuildStateSharedData {
  56953. /**
  56954. * Gets the list of emitted varyings
  56955. */
  56956. temps: string[];
  56957. /**
  56958. * Gets the list of emitted varyings
  56959. */
  56960. varyings: string[];
  56961. /**
  56962. * Gets the varying declaration string
  56963. */
  56964. varyingDeclaration: string;
  56965. /**
  56966. * Input blocks
  56967. */
  56968. inputBlocks: InputBlock[];
  56969. /**
  56970. * Input blocks
  56971. */
  56972. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56973. /**
  56974. * Bindable blocks (Blocks that need to set data to the effect)
  56975. */
  56976. bindableBlocks: NodeMaterialBlock[];
  56977. /**
  56978. * List of blocks that can provide a compilation fallback
  56979. */
  56980. blocksWithFallbacks: NodeMaterialBlock[];
  56981. /**
  56982. * List of blocks that can provide a define update
  56983. */
  56984. blocksWithDefines: NodeMaterialBlock[];
  56985. /**
  56986. * List of blocks that can provide a repeatable content
  56987. */
  56988. repeatableContentBlocks: NodeMaterialBlock[];
  56989. /**
  56990. * List of blocks that can provide a dynamic list of uniforms
  56991. */
  56992. dynamicUniformBlocks: NodeMaterialBlock[];
  56993. /**
  56994. * List of blocks that can block the isReady function for the material
  56995. */
  56996. blockingBlocks: NodeMaterialBlock[];
  56997. /**
  56998. * Gets the list of animated inputs
  56999. */
  57000. animatedInputs: InputBlock[];
  57001. /**
  57002. * Build Id used to avoid multiple recompilations
  57003. */
  57004. buildId: number;
  57005. /** List of emitted variables */
  57006. variableNames: {
  57007. [key: string]: number;
  57008. };
  57009. /** List of emitted defines */
  57010. defineNames: {
  57011. [key: string]: number;
  57012. };
  57013. /** Should emit comments? */
  57014. emitComments: boolean;
  57015. /** Emit build activity */
  57016. verbose: boolean;
  57017. /** Gets or sets the hosting scene */
  57018. scene: Scene;
  57019. /**
  57020. * Gets the compilation hints emitted at compilation time
  57021. */
  57022. hints: {
  57023. needWorldViewMatrix: boolean;
  57024. needWorldViewProjectionMatrix: boolean;
  57025. needAlphaBlending: boolean;
  57026. needAlphaTesting: boolean;
  57027. };
  57028. /**
  57029. * List of compilation checks
  57030. */
  57031. checks: {
  57032. emitVertex: boolean;
  57033. emitFragment: boolean;
  57034. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57035. };
  57036. /** Creates a new shared data */
  57037. constructor();
  57038. /**
  57039. * Emits console errors and exceptions if there is a failing check
  57040. */
  57041. emitErrors(): void;
  57042. }
  57043. }
  57044. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  57045. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57046. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57047. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  57048. /**
  57049. * Class used to store node based material build state
  57050. */
  57051. export class NodeMaterialBuildState {
  57052. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57053. supportUniformBuffers: boolean;
  57054. /**
  57055. * Gets the list of emitted attributes
  57056. */
  57057. attributes: string[];
  57058. /**
  57059. * Gets the list of emitted uniforms
  57060. */
  57061. uniforms: string[];
  57062. /**
  57063. * Gets the list of emitted constants
  57064. */
  57065. constants: string[];
  57066. /**
  57067. * Gets the list of emitted samplers
  57068. */
  57069. samplers: string[];
  57070. /**
  57071. * Gets the list of emitted functions
  57072. */
  57073. functions: {
  57074. [key: string]: string;
  57075. };
  57076. /**
  57077. * Gets the list of emitted extensions
  57078. */
  57079. extensions: {
  57080. [key: string]: string;
  57081. };
  57082. /**
  57083. * Gets the target of the compilation state
  57084. */
  57085. target: NodeMaterialBlockTargets;
  57086. /**
  57087. * Gets the list of emitted counters
  57088. */
  57089. counters: {
  57090. [key: string]: number;
  57091. };
  57092. /**
  57093. * Shared data between multiple NodeMaterialBuildState instances
  57094. */
  57095. sharedData: NodeMaterialBuildStateSharedData;
  57096. /** @hidden */
  57097. _vertexState: NodeMaterialBuildState;
  57098. /** @hidden */
  57099. _attributeDeclaration: string;
  57100. /** @hidden */
  57101. _uniformDeclaration: string;
  57102. /** @hidden */
  57103. _constantDeclaration: string;
  57104. /** @hidden */
  57105. _samplerDeclaration: string;
  57106. /** @hidden */
  57107. _varyingTransfer: string;
  57108. private _repeatableContentAnchorIndex;
  57109. /** @hidden */
  57110. _builtCompilationString: string;
  57111. /**
  57112. * Gets the emitted compilation strings
  57113. */
  57114. compilationString: string;
  57115. /**
  57116. * Finalize the compilation strings
  57117. * @param state defines the current compilation state
  57118. */
  57119. finalize(state: NodeMaterialBuildState): void;
  57120. /** @hidden */
  57121. readonly _repeatableContentAnchor: string;
  57122. /** @hidden */
  57123. _getFreeVariableName(prefix: string): string;
  57124. /** @hidden */
  57125. _getFreeDefineName(prefix: string): string;
  57126. /** @hidden */
  57127. _excludeVariableName(name: string): void;
  57128. /** @hidden */
  57129. _emit2DSampler(name: string): void;
  57130. /** @hidden */
  57131. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57132. /** @hidden */
  57133. _emitExtension(name: string, extension: string): void;
  57134. /** @hidden */
  57135. _emitFunction(name: string, code: string, comments: string): void;
  57136. /** @hidden */
  57137. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57138. replaceStrings?: {
  57139. search: RegExp;
  57140. replace: string;
  57141. }[];
  57142. repeatKey?: string;
  57143. }): string;
  57144. /** @hidden */
  57145. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57146. repeatKey?: string;
  57147. removeAttributes?: boolean;
  57148. removeUniforms?: boolean;
  57149. removeVaryings?: boolean;
  57150. removeIfDef?: boolean;
  57151. replaceStrings?: {
  57152. search: RegExp;
  57153. replace: string;
  57154. }[];
  57155. }, storeKey?: string): void;
  57156. /** @hidden */
  57157. _registerTempVariable(name: string): boolean;
  57158. /** @hidden */
  57159. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57160. /** @hidden */
  57161. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57162. /** @hidden */
  57163. _emitFloat(value: number): string;
  57164. }
  57165. }
  57166. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  57167. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57169. import { Nullable } from "babylonjs/types";
  57170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57171. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57172. import { Effect } from "babylonjs/Materials/effect";
  57173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57174. import { Mesh } from "babylonjs/Meshes/mesh";
  57175. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57176. import { Scene } from "babylonjs/scene";
  57177. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57178. /**
  57179. * Defines a block that can be used inside a node based material
  57180. */
  57181. export class NodeMaterialBlock {
  57182. private _buildId;
  57183. private _buildTarget;
  57184. private _target;
  57185. private _isFinalMerger;
  57186. private _isInput;
  57187. protected _isUnique: boolean;
  57188. /** @hidden */
  57189. _codeVariableName: string;
  57190. /** @hidden */
  57191. _inputs: NodeMaterialConnectionPoint[];
  57192. /** @hidden */
  57193. _outputs: NodeMaterialConnectionPoint[];
  57194. /** @hidden */
  57195. _preparationId: number;
  57196. /**
  57197. * Gets or sets the name of the block
  57198. */
  57199. name: string;
  57200. /**
  57201. * Gets or sets the unique id of the node
  57202. */
  57203. uniqueId: number;
  57204. /**
  57205. * Gets or sets the comments associated with this block
  57206. */
  57207. comments: string;
  57208. /**
  57209. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57210. */
  57211. readonly isUnique: boolean;
  57212. /**
  57213. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57214. */
  57215. readonly isFinalMerger: boolean;
  57216. /**
  57217. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57218. */
  57219. readonly isInput: boolean;
  57220. /**
  57221. * Gets or sets the build Id
  57222. */
  57223. buildId: number;
  57224. /**
  57225. * Gets or sets the target of the block
  57226. */
  57227. target: NodeMaterialBlockTargets;
  57228. /**
  57229. * Gets the list of input points
  57230. */
  57231. readonly inputs: NodeMaterialConnectionPoint[];
  57232. /** Gets the list of output points */
  57233. readonly outputs: NodeMaterialConnectionPoint[];
  57234. /**
  57235. * Find an input by its name
  57236. * @param name defines the name of the input to look for
  57237. * @returns the input or null if not found
  57238. */
  57239. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57240. /**
  57241. * Find an output by its name
  57242. * @param name defines the name of the outputto look for
  57243. * @returns the output or null if not found
  57244. */
  57245. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57246. /**
  57247. * Creates a new NodeMaterialBlock
  57248. * @param name defines the block name
  57249. * @param target defines the target of that block (Vertex by default)
  57250. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57251. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57252. */
  57253. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57254. /**
  57255. * Initialize the block and prepare the context for build
  57256. * @param state defines the state that will be used for the build
  57257. */
  57258. initialize(state: NodeMaterialBuildState): void;
  57259. /**
  57260. * Bind data to effect. Will only be called for blocks with isBindable === true
  57261. * @param effect defines the effect to bind data to
  57262. * @param nodeMaterial defines the hosting NodeMaterial
  57263. * @param mesh defines the mesh that will be rendered
  57264. */
  57265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57266. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57267. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57268. protected _writeFloat(value: number): string;
  57269. /**
  57270. * Gets the current class name e.g. "NodeMaterialBlock"
  57271. * @returns the class name
  57272. */
  57273. getClassName(): string;
  57274. /**
  57275. * Register a new input. Must be called inside a block constructor
  57276. * @param name defines the connection point name
  57277. * @param type defines the connection point type
  57278. * @param isOptional defines a boolean indicating that this input can be omitted
  57279. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57280. * @returns the current block
  57281. */
  57282. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57283. /**
  57284. * Register a new output. Must be called inside a block constructor
  57285. * @param name defines the connection point name
  57286. * @param type defines the connection point type
  57287. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57288. * @returns the current block
  57289. */
  57290. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57291. /**
  57292. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57293. * @param forOutput defines an optional connection point to check compatibility with
  57294. * @returns the first available input or null
  57295. */
  57296. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57297. /**
  57298. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57299. * @param forBlock defines an optional block to check compatibility with
  57300. * @returns the first available input or null
  57301. */
  57302. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57303. /**
  57304. * Gets the sibling of the given output
  57305. * @param current defines the current output
  57306. * @returns the next output in the list or null
  57307. */
  57308. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57309. /**
  57310. * Connect current block with another block
  57311. * @param other defines the block to connect with
  57312. * @param options define the various options to help pick the right connections
  57313. * @returns the current block
  57314. */
  57315. connectTo(other: NodeMaterialBlock, options?: {
  57316. input?: string;
  57317. output?: string;
  57318. outputSwizzle?: string;
  57319. }): this | undefined;
  57320. protected _buildBlock(state: NodeMaterialBuildState): void;
  57321. /**
  57322. * Add uniforms, samplers and uniform buffers at compilation time
  57323. * @param state defines the state to update
  57324. * @param nodeMaterial defines the node material requesting the update
  57325. * @param defines defines the material defines to update
  57326. * @param uniformBuffers defines the list of uniform buffer names
  57327. */
  57328. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57329. /**
  57330. * Add potential fallbacks if shader compilation fails
  57331. * @param mesh defines the mesh to be rendered
  57332. * @param fallbacks defines the current prioritized list of fallbacks
  57333. */
  57334. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57335. /**
  57336. * Initialize defines for shader compilation
  57337. * @param mesh defines the mesh to be rendered
  57338. * @param nodeMaterial defines the node material requesting the update
  57339. * @param defines defines the material defines to update
  57340. * @param useInstances specifies that instances should be used
  57341. */
  57342. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57343. /**
  57344. * Update defines for shader compilation
  57345. * @param mesh defines the mesh to be rendered
  57346. * @param nodeMaterial defines the node material requesting the update
  57347. * @param defines defines the material defines to update
  57348. * @param useInstances specifies that instances should be used
  57349. */
  57350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57351. /**
  57352. * Lets the block try to connect some inputs automatically
  57353. * @param material defines the hosting NodeMaterial
  57354. */
  57355. autoConfigure(material: NodeMaterial): void;
  57356. /**
  57357. * Function called when a block is declared as repeatable content generator
  57358. * @param vertexShaderState defines the current compilation state for the vertex shader
  57359. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57360. * @param mesh defines the mesh to be rendered
  57361. * @param defines defines the material defines to update
  57362. */
  57363. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57364. /**
  57365. * Checks if the block is ready
  57366. * @param mesh defines the mesh to be rendered
  57367. * @param nodeMaterial defines the node material requesting the update
  57368. * @param defines defines the material defines to update
  57369. * @param useInstances specifies that instances should be used
  57370. * @returns true if the block is ready
  57371. */
  57372. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57373. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57374. private _processBuild;
  57375. /**
  57376. * Compile the current node and generate the shader code
  57377. * @param state defines the current compilation state (uniforms, samplers, current string)
  57378. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57379. * @returns true if already built
  57380. */
  57381. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57382. protected _inputRename(name: string): string;
  57383. protected _outputRename(name: string): string;
  57384. protected _dumpPropertiesCode(): string;
  57385. /** @hidden */
  57386. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57387. /** @hidden */
  57388. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57389. /**
  57390. * Clone the current block to a new identical block
  57391. * @param scene defines the hosting scene
  57392. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57393. * @returns a copy of the current block
  57394. */
  57395. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57396. /**
  57397. * Serializes this block in a JSON representation
  57398. * @returns the serialized block object
  57399. */
  57400. serialize(): any;
  57401. /** @hidden */
  57402. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57403. /**
  57404. * Release resources
  57405. */
  57406. dispose(): void;
  57407. }
  57408. }
  57409. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  57410. /**
  57411. * Enum defining the type of animations supported by InputBlock
  57412. */
  57413. export enum AnimatedInputBlockTypes {
  57414. /** No animation */
  57415. None = 0,
  57416. /** Time based animation. Will only work for floats */
  57417. Time = 1
  57418. }
  57419. }
  57420. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  57421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57422. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57423. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57424. import { Nullable } from "babylonjs/types";
  57425. import { Effect } from "babylonjs/Materials/effect";
  57426. import { Matrix } from "babylonjs/Maths/math.vector";
  57427. import { Scene } from "babylonjs/scene";
  57428. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57429. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57430. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57431. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57432. /**
  57433. * Block used to expose an input value
  57434. */
  57435. export class InputBlock extends NodeMaterialBlock {
  57436. private _mode;
  57437. private _associatedVariableName;
  57438. private _storedValue;
  57439. private _valueCallback;
  57440. private _type;
  57441. private _animationType;
  57442. /** Gets or set a value used to limit the range of float values */
  57443. min: number;
  57444. /** Gets or set a value used to limit the range of float values */
  57445. max: number;
  57446. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57447. matrixMode: number;
  57448. /** @hidden */
  57449. _systemValue: Nullable<NodeMaterialSystemValues>;
  57450. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57451. visibleInInspector: boolean;
  57452. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57453. isConstant: boolean;
  57454. /**
  57455. * Gets or sets the connection point type (default is float)
  57456. */
  57457. readonly type: NodeMaterialBlockConnectionPointTypes;
  57458. /**
  57459. * Creates a new InputBlock
  57460. * @param name defines the block name
  57461. * @param target defines the target of that block (Vertex by default)
  57462. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57463. */
  57464. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57465. /**
  57466. * Gets the output component
  57467. */
  57468. readonly output: NodeMaterialConnectionPoint;
  57469. /**
  57470. * Set the source of this connection point to a vertex attribute
  57471. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57472. * @returns the current connection point
  57473. */
  57474. setAsAttribute(attributeName?: string): InputBlock;
  57475. /**
  57476. * Set the source of this connection point to a system value
  57477. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57478. * @returns the current connection point
  57479. */
  57480. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57481. /**
  57482. * Gets or sets the value of that point.
  57483. * Please note that this value will be ignored if valueCallback is defined
  57484. */
  57485. value: any;
  57486. /**
  57487. * Gets or sets a callback used to get the value of that point.
  57488. * Please note that setting this value will force the connection point to ignore the value property
  57489. */
  57490. valueCallback: () => any;
  57491. /**
  57492. * Gets or sets the associated variable name in the shader
  57493. */
  57494. associatedVariableName: string;
  57495. /** Gets or sets the type of animation applied to the input */
  57496. animationType: AnimatedInputBlockTypes;
  57497. /**
  57498. * Gets a boolean indicating that this connection point not defined yet
  57499. */
  57500. readonly isUndefined: boolean;
  57501. /**
  57502. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57503. * In this case the connection point name must be the name of the uniform to use.
  57504. * Can only be set on inputs
  57505. */
  57506. isUniform: boolean;
  57507. /**
  57508. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57509. * In this case the connection point name must be the name of the attribute to use
  57510. * Can only be set on inputs
  57511. */
  57512. isAttribute: boolean;
  57513. /**
  57514. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57515. * Can only be set on exit points
  57516. */
  57517. isVarying: boolean;
  57518. /**
  57519. * Gets a boolean indicating that the current connection point is a system value
  57520. */
  57521. readonly isSystemValue: boolean;
  57522. /**
  57523. * Gets or sets the current well known value or null if not defined as a system value
  57524. */
  57525. systemValue: Nullable<NodeMaterialSystemValues>;
  57526. /**
  57527. * Gets the current class name
  57528. * @returns the class name
  57529. */
  57530. getClassName(): string;
  57531. /**
  57532. * Animate the input if animationType !== None
  57533. * @param scene defines the rendering scene
  57534. */
  57535. animate(scene: Scene): void;
  57536. private _emitDefine;
  57537. initialize(state: NodeMaterialBuildState): void;
  57538. /**
  57539. * Set the input block to its default value (based on its type)
  57540. */
  57541. setDefaultValue(): void;
  57542. private _emitConstant;
  57543. private _emit;
  57544. /** @hidden */
  57545. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57546. /** @hidden */
  57547. _transmit(effect: Effect, scene: Scene): void;
  57548. protected _buildBlock(state: NodeMaterialBuildState): void;
  57549. protected _dumpPropertiesCode(): string;
  57550. serialize(): any;
  57551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57552. }
  57553. }
  57554. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57555. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57556. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57557. import { Nullable } from "babylonjs/types";
  57558. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57559. import { Observable } from "babylonjs/Misc/observable";
  57560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57561. /**
  57562. * Enum used to define the compatibility state between two connection points
  57563. */
  57564. export enum NodeMaterialConnectionPointCompatibilityStates {
  57565. /** Points are compatibles */
  57566. Compatible = 0,
  57567. /** Points are incompatible because of their types */
  57568. TypeIncompatible = 1,
  57569. /** Points are incompatible because of their targets (vertex vs fragment) */
  57570. TargetIncompatible = 2
  57571. }
  57572. /**
  57573. * Defines the direction of a connection point
  57574. */
  57575. export enum NodeMaterialConnectionPointDirection {
  57576. /** Input */
  57577. Input = 0,
  57578. /** Output */
  57579. Output = 1
  57580. }
  57581. /**
  57582. * Defines a connection point for a block
  57583. */
  57584. export class NodeMaterialConnectionPoint {
  57585. /** @hidden */
  57586. _ownerBlock: NodeMaterialBlock;
  57587. /** @hidden */
  57588. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57589. private _endpoints;
  57590. private _associatedVariableName;
  57591. private _direction;
  57592. /** @hidden */
  57593. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57594. /** @hidden */
  57595. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57596. private _type;
  57597. /** @hidden */
  57598. _enforceAssociatedVariableName: boolean;
  57599. /** Gets the direction of the point */
  57600. readonly direction: NodeMaterialConnectionPointDirection;
  57601. /**
  57602. * Gets or sets the additional types supported by this connection point
  57603. */
  57604. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57605. /**
  57606. * Gets or sets the additional types excluded by this connection point
  57607. */
  57608. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57609. /**
  57610. * Observable triggered when this point is connected
  57611. */
  57612. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57613. /**
  57614. * Gets or sets the associated variable name in the shader
  57615. */
  57616. associatedVariableName: string;
  57617. /**
  57618. * Gets or sets the connection point type (default is float)
  57619. */
  57620. type: NodeMaterialBlockConnectionPointTypes;
  57621. /**
  57622. * Gets or sets the connection point name
  57623. */
  57624. name: string;
  57625. /**
  57626. * Gets or sets a boolean indicating that this connection point can be omitted
  57627. */
  57628. isOptional: boolean;
  57629. /**
  57630. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57631. */
  57632. define: string;
  57633. /** @hidden */
  57634. _prioritizeVertex: boolean;
  57635. private _target;
  57636. /** Gets or sets the target of that connection point */
  57637. target: NodeMaterialBlockTargets;
  57638. /**
  57639. * Gets a boolean indicating that the current point is connected
  57640. */
  57641. readonly isConnected: boolean;
  57642. /**
  57643. * Gets a boolean indicating that the current point is connected to an input block
  57644. */
  57645. readonly isConnectedToInputBlock: boolean;
  57646. /**
  57647. * Gets a the connected input block (if any)
  57648. */
  57649. readonly connectInputBlock: Nullable<InputBlock>;
  57650. /** Get the other side of the connection (if any) */
  57651. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57652. /** Get the block that owns this connection point */
  57653. readonly ownerBlock: NodeMaterialBlock;
  57654. /** Get the block connected on the other side of this connection (if any) */
  57655. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57656. /** Get the block connected on the endpoints of this connection (if any) */
  57657. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57658. /** Gets the list of connected endpoints */
  57659. readonly endpoints: NodeMaterialConnectionPoint[];
  57660. /** Gets a boolean indicating if that output point is connected to at least one input */
  57661. readonly hasEndpoints: boolean;
  57662. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57663. readonly isConnectedInVertexShader: boolean;
  57664. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57665. readonly isConnectedInFragmentShader: boolean;
  57666. /**
  57667. * Creates a new connection point
  57668. * @param name defines the connection point name
  57669. * @param ownerBlock defines the block hosting this connection point
  57670. * @param direction defines the direction of the connection point
  57671. */
  57672. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  57673. /**
  57674. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57675. * @returns the class name
  57676. */
  57677. getClassName(): string;
  57678. /**
  57679. * Gets a boolean indicating if the current point can be connected to another point
  57680. * @param connectionPoint defines the other connection point
  57681. * @returns a boolean
  57682. */
  57683. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57684. /**
  57685. * Gets a number indicating if the current point can be connected to another point
  57686. * @param connectionPoint defines the other connection point
  57687. * @returns a number defining the compatibility state
  57688. */
  57689. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57690. /**
  57691. * Connect this point to another connection point
  57692. * @param connectionPoint defines the other connection point
  57693. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57694. * @returns the current connection point
  57695. */
  57696. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57697. /**
  57698. * Disconnect this point from one of his endpoint
  57699. * @param endpoint defines the other connection point
  57700. * @returns the current connection point
  57701. */
  57702. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57703. /**
  57704. * Serializes this point in a JSON representation
  57705. * @returns the serialized point object
  57706. */
  57707. serialize(): any;
  57708. /**
  57709. * Release resources
  57710. */
  57711. dispose(): void;
  57712. }
  57713. }
  57714. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57715. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57716. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57718. import { Mesh } from "babylonjs/Meshes/mesh";
  57719. import { Effect } from "babylonjs/Materials/effect";
  57720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57721. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57722. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57723. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57724. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57725. /**
  57726. * Block used to add support for vertex skinning (bones)
  57727. */
  57728. export class BonesBlock extends NodeMaterialBlock {
  57729. /**
  57730. * Creates a new BonesBlock
  57731. * @param name defines the block name
  57732. */
  57733. constructor(name: string);
  57734. /**
  57735. * Initialize the block and prepare the context for build
  57736. * @param state defines the state that will be used for the build
  57737. */
  57738. initialize(state: NodeMaterialBuildState): void;
  57739. /**
  57740. * Gets the current class name
  57741. * @returns the class name
  57742. */
  57743. getClassName(): string;
  57744. /**
  57745. * Gets the matrix indices input component
  57746. */
  57747. readonly matricesIndices: NodeMaterialConnectionPoint;
  57748. /**
  57749. * Gets the matrix weights input component
  57750. */
  57751. readonly matricesWeights: NodeMaterialConnectionPoint;
  57752. /**
  57753. * Gets the extra matrix indices input component
  57754. */
  57755. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57756. /**
  57757. * Gets the extra matrix weights input component
  57758. */
  57759. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57760. /**
  57761. * Gets the world input component
  57762. */
  57763. readonly world: NodeMaterialConnectionPoint;
  57764. /**
  57765. * Gets the output component
  57766. */
  57767. readonly output: NodeMaterialConnectionPoint;
  57768. autoConfigure(material: NodeMaterial): void;
  57769. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57770. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57771. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57772. protected _buildBlock(state: NodeMaterialBuildState): this;
  57773. }
  57774. }
  57775. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57778. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57780. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57781. /**
  57782. * Block used to add support for instances
  57783. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57784. */
  57785. export class InstancesBlock extends NodeMaterialBlock {
  57786. /**
  57787. * Creates a new InstancesBlock
  57788. * @param name defines the block name
  57789. */
  57790. constructor(name: string);
  57791. /**
  57792. * Gets the current class name
  57793. * @returns the class name
  57794. */
  57795. getClassName(): string;
  57796. /**
  57797. * Gets the first world row input component
  57798. */
  57799. readonly world0: NodeMaterialConnectionPoint;
  57800. /**
  57801. * Gets the second world row input component
  57802. */
  57803. readonly world1: NodeMaterialConnectionPoint;
  57804. /**
  57805. * Gets the third world row input component
  57806. */
  57807. readonly world2: NodeMaterialConnectionPoint;
  57808. /**
  57809. * Gets the forth world row input component
  57810. */
  57811. readonly world3: NodeMaterialConnectionPoint;
  57812. /**
  57813. * Gets the world input component
  57814. */
  57815. readonly world: NodeMaterialConnectionPoint;
  57816. /**
  57817. * Gets the output component
  57818. */
  57819. readonly output: NodeMaterialConnectionPoint;
  57820. autoConfigure(material: NodeMaterial): void;
  57821. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57822. protected _buildBlock(state: NodeMaterialBuildState): this;
  57823. }
  57824. }
  57825. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57830. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57831. import { Effect } from "babylonjs/Materials/effect";
  57832. import { Mesh } from "babylonjs/Meshes/mesh";
  57833. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57834. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57835. /**
  57836. * Block used to add morph targets support to vertex shader
  57837. */
  57838. export class MorphTargetsBlock extends NodeMaterialBlock {
  57839. private _repeatableContentAnchor;
  57840. private _repeatebleContentGenerated;
  57841. /**
  57842. * Create a new MorphTargetsBlock
  57843. * @param name defines the block name
  57844. */
  57845. constructor(name: string);
  57846. /**
  57847. * Gets the current class name
  57848. * @returns the class name
  57849. */
  57850. getClassName(): string;
  57851. /**
  57852. * Gets the position input component
  57853. */
  57854. readonly position: NodeMaterialConnectionPoint;
  57855. /**
  57856. * Gets the normal input component
  57857. */
  57858. readonly normal: NodeMaterialConnectionPoint;
  57859. /**
  57860. * Gets the tangent input component
  57861. */
  57862. readonly tangent: NodeMaterialConnectionPoint;
  57863. /**
  57864. * Gets the tangent input component
  57865. */
  57866. readonly uv: NodeMaterialConnectionPoint;
  57867. /**
  57868. * Gets the position output component
  57869. */
  57870. readonly positionOutput: NodeMaterialConnectionPoint;
  57871. /**
  57872. * Gets the normal output component
  57873. */
  57874. readonly normalOutput: NodeMaterialConnectionPoint;
  57875. /**
  57876. * Gets the tangent output component
  57877. */
  57878. readonly tangentOutput: NodeMaterialConnectionPoint;
  57879. /**
  57880. * Gets the tangent output component
  57881. */
  57882. readonly uvOutput: NodeMaterialConnectionPoint;
  57883. initialize(state: NodeMaterialBuildState): void;
  57884. autoConfigure(material: NodeMaterial): void;
  57885. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57886. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57887. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57888. protected _buildBlock(state: NodeMaterialBuildState): this;
  57889. }
  57890. }
  57891. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57893. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57895. import { Nullable } from "babylonjs/types";
  57896. import { Scene } from "babylonjs/scene";
  57897. import { Effect } from "babylonjs/Materials/effect";
  57898. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57899. import { Mesh } from "babylonjs/Meshes/mesh";
  57900. import { Light } from "babylonjs/Lights/light";
  57901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57902. /**
  57903. * Block used to get data information from a light
  57904. */
  57905. export class LightInformationBlock extends NodeMaterialBlock {
  57906. private _lightDataUniformName;
  57907. private _lightColorUniformName;
  57908. private _lightTypeDefineName;
  57909. /**
  57910. * Gets or sets the light associated with this block
  57911. */
  57912. light: Nullable<Light>;
  57913. /**
  57914. * Creates a new LightInformationBlock
  57915. * @param name defines the block name
  57916. */
  57917. constructor(name: string);
  57918. /**
  57919. * Gets the current class name
  57920. * @returns the class name
  57921. */
  57922. getClassName(): string;
  57923. /**
  57924. * Gets the world position input component
  57925. */
  57926. readonly worldPosition: NodeMaterialConnectionPoint;
  57927. /**
  57928. * Gets the direction output component
  57929. */
  57930. readonly direction: NodeMaterialConnectionPoint;
  57931. /**
  57932. * Gets the direction output component
  57933. */
  57934. readonly color: NodeMaterialConnectionPoint;
  57935. /**
  57936. * Gets the direction output component
  57937. */
  57938. readonly intensity: NodeMaterialConnectionPoint;
  57939. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57941. protected _buildBlock(state: NodeMaterialBuildState): this;
  57942. serialize(): any;
  57943. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57944. }
  57945. }
  57946. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57947. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57948. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57949. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57950. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57951. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57952. }
  57953. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57958. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57959. import { Effect } from "babylonjs/Materials/effect";
  57960. import { Mesh } from "babylonjs/Meshes/mesh";
  57961. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57962. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57963. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57964. /**
  57965. * Block used to add image processing support to fragment shader
  57966. */
  57967. export class ImageProcessingBlock extends NodeMaterialBlock {
  57968. /**
  57969. * Create a new ImageProcessingBlock
  57970. * @param name defines the block name
  57971. */
  57972. constructor(name: string);
  57973. /**
  57974. * Gets the current class name
  57975. * @returns the class name
  57976. */
  57977. getClassName(): string;
  57978. /**
  57979. * Gets the color input component
  57980. */
  57981. readonly color: NodeMaterialConnectionPoint;
  57982. /**
  57983. * Gets the output component
  57984. */
  57985. readonly output: NodeMaterialConnectionPoint;
  57986. /**
  57987. * Initialize the block and prepare the context for build
  57988. * @param state defines the state that will be used for the build
  57989. */
  57990. initialize(state: NodeMaterialBuildState): void;
  57991. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57992. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57993. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57994. protected _buildBlock(state: NodeMaterialBuildState): this;
  57995. }
  57996. }
  57997. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58001. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58003. import { Effect } from "babylonjs/Materials/effect";
  58004. import { Mesh } from "babylonjs/Meshes/mesh";
  58005. import { Scene } from "babylonjs/scene";
  58006. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58007. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58008. /**
  58009. * Block used to pertub normals based on a normal map
  58010. */
  58011. export class PerturbNormalBlock extends NodeMaterialBlock {
  58012. private _tangentSpaceParameterName;
  58013. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58014. invertX: boolean;
  58015. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58016. invertY: boolean;
  58017. /**
  58018. * Create a new PerturbNormalBlock
  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 world position input component
  58029. */
  58030. readonly worldPosition: NodeMaterialConnectionPoint;
  58031. /**
  58032. * Gets the world normal input component
  58033. */
  58034. readonly worldNormal: NodeMaterialConnectionPoint;
  58035. /**
  58036. * Gets the uv input component
  58037. */
  58038. readonly uv: NodeMaterialConnectionPoint;
  58039. /**
  58040. * Gets the normal map color input component
  58041. */
  58042. readonly normalMapColor: NodeMaterialConnectionPoint;
  58043. /**
  58044. * Gets the strength input component
  58045. */
  58046. readonly strength: NodeMaterialConnectionPoint;
  58047. /**
  58048. * Gets the output component
  58049. */
  58050. readonly output: NodeMaterialConnectionPoint;
  58051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58052. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58053. autoConfigure(material: NodeMaterial): void;
  58054. protected _buildBlock(state: NodeMaterialBuildState): this;
  58055. protected _dumpPropertiesCode(): string;
  58056. serialize(): any;
  58057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58058. }
  58059. }
  58060. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  58061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58064. /**
  58065. * Block used to discard a pixel if a value is smaller than a cutoff
  58066. */
  58067. export class DiscardBlock extends NodeMaterialBlock {
  58068. /**
  58069. * Create a new DiscardBlock
  58070. * @param name defines the block name
  58071. */
  58072. constructor(name: string);
  58073. /**
  58074. * Gets the current class name
  58075. * @returns the class name
  58076. */
  58077. getClassName(): string;
  58078. /**
  58079. * Gets the color input component
  58080. */
  58081. readonly value: NodeMaterialConnectionPoint;
  58082. /**
  58083. * Gets the cutoff input component
  58084. */
  58085. readonly cutoff: NodeMaterialConnectionPoint;
  58086. protected _buildBlock(state: NodeMaterialBuildState): this;
  58087. }
  58088. }
  58089. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  58090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58093. /**
  58094. * Block used to test if the fragment shader is front facing
  58095. */
  58096. export class FrontFacingBlock extends NodeMaterialBlock {
  58097. /**
  58098. * Creates a new FrontFacingBlock
  58099. * @param name defines the block name
  58100. */
  58101. constructor(name: string);
  58102. /**
  58103. * Gets the current class name
  58104. * @returns the class name
  58105. */
  58106. getClassName(): string;
  58107. /**
  58108. * Gets the output component
  58109. */
  58110. readonly output: NodeMaterialConnectionPoint;
  58111. protected _buildBlock(state: NodeMaterialBuildState): this;
  58112. }
  58113. }
  58114. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  58115. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58116. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58117. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58118. /**
  58119. * Block used to get the derivative value on x and y of a given input
  58120. */
  58121. export class DerivativeBlock extends NodeMaterialBlock {
  58122. /**
  58123. * Create a new DerivativeBlock
  58124. * @param name defines the block name
  58125. */
  58126. constructor(name: string);
  58127. /**
  58128. * Gets the current class name
  58129. * @returns the class name
  58130. */
  58131. getClassName(): string;
  58132. /**
  58133. * Gets the input component
  58134. */
  58135. readonly input: NodeMaterialConnectionPoint;
  58136. /**
  58137. * Gets the derivative output on x
  58138. */
  58139. readonly dx: NodeMaterialConnectionPoint;
  58140. /**
  58141. * Gets the derivative output on y
  58142. */
  58143. readonly dy: NodeMaterialConnectionPoint;
  58144. protected _buildBlock(state: NodeMaterialBuildState): this;
  58145. }
  58146. }
  58147. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  58148. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  58149. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  58150. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  58151. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  58152. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  58153. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  58154. }
  58155. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  58156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58158. import { Mesh } from "babylonjs/Meshes/mesh";
  58159. import { Effect } from "babylonjs/Materials/effect";
  58160. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58162. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58163. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58164. /**
  58165. * Block used to add support for scene fog
  58166. */
  58167. export class FogBlock extends NodeMaterialBlock {
  58168. private _fogDistanceName;
  58169. private _fogParameters;
  58170. /**
  58171. * Create a new FogBlock
  58172. * @param name defines the block name
  58173. */
  58174. constructor(name: string);
  58175. /**
  58176. * Gets the current class name
  58177. * @returns the class name
  58178. */
  58179. getClassName(): string;
  58180. /**
  58181. * Gets the world position input component
  58182. */
  58183. readonly worldPosition: NodeMaterialConnectionPoint;
  58184. /**
  58185. * Gets the view input component
  58186. */
  58187. readonly view: NodeMaterialConnectionPoint;
  58188. /**
  58189. * Gets the color input component
  58190. */
  58191. readonly input: NodeMaterialConnectionPoint;
  58192. /**
  58193. * Gets the fog color input component
  58194. */
  58195. readonly fogColor: NodeMaterialConnectionPoint;
  58196. /**
  58197. * Gets the output component
  58198. */
  58199. readonly output: NodeMaterialConnectionPoint;
  58200. autoConfigure(material: NodeMaterial): void;
  58201. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58202. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58203. protected _buildBlock(state: NodeMaterialBuildState): this;
  58204. }
  58205. }
  58206. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  58207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58211. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58212. import { Effect } from "babylonjs/Materials/effect";
  58213. import { Mesh } from "babylonjs/Meshes/mesh";
  58214. import { Light } from "babylonjs/Lights/light";
  58215. import { Nullable } from "babylonjs/types";
  58216. import { Scene } from "babylonjs/scene";
  58217. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58218. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58219. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58220. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58221. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  58222. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58223. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58224. /**
  58225. * Block used to add light in the fragment shader
  58226. */
  58227. export class LightBlock extends NodeMaterialBlock {
  58228. private _lightId;
  58229. /**
  58230. * Gets or sets the light associated with this block
  58231. */
  58232. light: Nullable<Light>;
  58233. /**
  58234. * Create a new LightBlock
  58235. * @param name defines the block name
  58236. */
  58237. constructor(name: string);
  58238. /**
  58239. * Gets the current class name
  58240. * @returns the class name
  58241. */
  58242. getClassName(): string;
  58243. /**
  58244. * Gets the world position input component
  58245. */
  58246. readonly worldPosition: NodeMaterialConnectionPoint;
  58247. /**
  58248. * Gets the world normal input component
  58249. */
  58250. readonly worldNormal: NodeMaterialConnectionPoint;
  58251. /**
  58252. * Gets the camera (or eye) position component
  58253. */
  58254. readonly cameraPosition: NodeMaterialConnectionPoint;
  58255. /**
  58256. * Gets the glossiness component
  58257. */
  58258. readonly glossiness: NodeMaterialConnectionPoint;
  58259. /**
  58260. * Gets the glossinness power component
  58261. */
  58262. readonly glossPower: NodeMaterialConnectionPoint;
  58263. /**
  58264. * Gets the diffuse color component
  58265. */
  58266. readonly diffuseColor: NodeMaterialConnectionPoint;
  58267. /**
  58268. * Gets the specular color component
  58269. */
  58270. readonly specularColor: NodeMaterialConnectionPoint;
  58271. /**
  58272. * Gets the diffuse output component
  58273. */
  58274. readonly diffuseOutput: NodeMaterialConnectionPoint;
  58275. /**
  58276. * Gets the specular output component
  58277. */
  58278. readonly specularOutput: NodeMaterialConnectionPoint;
  58279. autoConfigure(material: NodeMaterial): void;
  58280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58281. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58283. private _injectVertexCode;
  58284. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58285. serialize(): any;
  58286. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58287. }
  58288. }
  58289. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  58290. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  58291. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  58292. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58293. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58294. }
  58295. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  58296. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58297. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58298. }
  58299. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  58300. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58301. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58302. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58303. /**
  58304. * Block used to multiply 2 values
  58305. */
  58306. export class MultiplyBlock extends NodeMaterialBlock {
  58307. /**
  58308. * Creates a new MultiplyBlock
  58309. * @param name defines the block name
  58310. */
  58311. constructor(name: string);
  58312. /**
  58313. * Gets the current class name
  58314. * @returns the class name
  58315. */
  58316. getClassName(): string;
  58317. /**
  58318. * Gets the left operand input component
  58319. */
  58320. readonly left: NodeMaterialConnectionPoint;
  58321. /**
  58322. * Gets the right operand input component
  58323. */
  58324. readonly right: NodeMaterialConnectionPoint;
  58325. /**
  58326. * Gets the output component
  58327. */
  58328. readonly output: NodeMaterialConnectionPoint;
  58329. protected _buildBlock(state: NodeMaterialBuildState): this;
  58330. }
  58331. }
  58332. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  58333. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58336. /**
  58337. * Block used to add 2 vectors
  58338. */
  58339. export class AddBlock extends NodeMaterialBlock {
  58340. /**
  58341. * Creates a new AddBlock
  58342. * @param name defines the block name
  58343. */
  58344. constructor(name: string);
  58345. /**
  58346. * Gets the current class name
  58347. * @returns the class name
  58348. */
  58349. getClassName(): string;
  58350. /**
  58351. * Gets the left operand input component
  58352. */
  58353. readonly left: NodeMaterialConnectionPoint;
  58354. /**
  58355. * Gets the right operand input component
  58356. */
  58357. readonly right: NodeMaterialConnectionPoint;
  58358. /**
  58359. * Gets the output component
  58360. */
  58361. readonly output: NodeMaterialConnectionPoint;
  58362. protected _buildBlock(state: NodeMaterialBuildState): this;
  58363. }
  58364. }
  58365. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  58366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58369. /**
  58370. * Block used to scale a vector by a float
  58371. */
  58372. export class ScaleBlock extends NodeMaterialBlock {
  58373. /**
  58374. * Creates a new ScaleBlock
  58375. * @param name defines the block name
  58376. */
  58377. constructor(name: string);
  58378. /**
  58379. * Gets the current class name
  58380. * @returns the class name
  58381. */
  58382. getClassName(): string;
  58383. /**
  58384. * Gets the input component
  58385. */
  58386. readonly input: NodeMaterialConnectionPoint;
  58387. /**
  58388. * Gets the factor input component
  58389. */
  58390. readonly factor: NodeMaterialConnectionPoint;
  58391. /**
  58392. * Gets the output component
  58393. */
  58394. readonly output: NodeMaterialConnectionPoint;
  58395. protected _buildBlock(state: NodeMaterialBuildState): this;
  58396. }
  58397. }
  58398. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  58399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58400. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58401. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58402. import { Scene } from "babylonjs/scene";
  58403. /**
  58404. * Block used to clamp a float
  58405. */
  58406. export class ClampBlock extends NodeMaterialBlock {
  58407. /** Gets or sets the minimum range */
  58408. minimum: number;
  58409. /** Gets or sets the maximum range */
  58410. maximum: number;
  58411. /**
  58412. * Creates a new ClampBlock
  58413. * @param name defines the block name
  58414. */
  58415. constructor(name: string);
  58416. /**
  58417. * Gets the current class name
  58418. * @returns the class name
  58419. */
  58420. getClassName(): string;
  58421. /**
  58422. * Gets the value input component
  58423. */
  58424. readonly value: NodeMaterialConnectionPoint;
  58425. /**
  58426. * Gets the output component
  58427. */
  58428. readonly output: NodeMaterialConnectionPoint;
  58429. protected _buildBlock(state: NodeMaterialBuildState): this;
  58430. protected _dumpPropertiesCode(): string;
  58431. serialize(): any;
  58432. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58433. }
  58434. }
  58435. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  58436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58439. /**
  58440. * Block used to apply a cross product between 2 vectors
  58441. */
  58442. export class CrossBlock extends NodeMaterialBlock {
  58443. /**
  58444. * Creates a new CrossBlock
  58445. * @param name defines the block name
  58446. */
  58447. constructor(name: string);
  58448. /**
  58449. * Gets the current class name
  58450. * @returns the class name
  58451. */
  58452. getClassName(): string;
  58453. /**
  58454. * Gets the left operand input component
  58455. */
  58456. readonly left: NodeMaterialConnectionPoint;
  58457. /**
  58458. * Gets the right operand input component
  58459. */
  58460. readonly right: NodeMaterialConnectionPoint;
  58461. /**
  58462. * Gets the output component
  58463. */
  58464. readonly output: NodeMaterialConnectionPoint;
  58465. protected _buildBlock(state: NodeMaterialBuildState): this;
  58466. }
  58467. }
  58468. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  58469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58472. /**
  58473. * Block used to apply a dot product between 2 vectors
  58474. */
  58475. export class DotBlock extends NodeMaterialBlock {
  58476. /**
  58477. * Creates a new DotBlock
  58478. * @param name defines the block name
  58479. */
  58480. constructor(name: string);
  58481. /**
  58482. * Gets the current class name
  58483. * @returns the class name
  58484. */
  58485. getClassName(): string;
  58486. /**
  58487. * Gets the left operand input component
  58488. */
  58489. readonly left: NodeMaterialConnectionPoint;
  58490. /**
  58491. * Gets the right operand input component
  58492. */
  58493. readonly right: NodeMaterialConnectionPoint;
  58494. /**
  58495. * Gets the output component
  58496. */
  58497. readonly output: NodeMaterialConnectionPoint;
  58498. protected _buildBlock(state: NodeMaterialBuildState): this;
  58499. }
  58500. }
  58501. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58505. import { Vector2 } from "babylonjs/Maths/math.vector";
  58506. import { Scene } from "babylonjs/scene";
  58507. /**
  58508. * Block used to remap a float from a range to a new one
  58509. */
  58510. export class RemapBlock extends NodeMaterialBlock {
  58511. /**
  58512. * Gets or sets the source range
  58513. */
  58514. sourceRange: Vector2;
  58515. /**
  58516. * Gets or sets the target range
  58517. */
  58518. targetRange: Vector2;
  58519. /**
  58520. * Creates a new RemapBlock
  58521. * @param name defines the block name
  58522. */
  58523. constructor(name: string);
  58524. /**
  58525. * Gets the current class name
  58526. * @returns the class name
  58527. */
  58528. getClassName(): string;
  58529. /**
  58530. * Gets the input component
  58531. */
  58532. readonly input: NodeMaterialConnectionPoint;
  58533. /**
  58534. * Gets the source min input component
  58535. */
  58536. readonly sourceMin: NodeMaterialConnectionPoint;
  58537. /**
  58538. * Gets the source max input component
  58539. */
  58540. readonly sourceMax: NodeMaterialConnectionPoint;
  58541. /**
  58542. * Gets the target min input component
  58543. */
  58544. readonly targetMin: NodeMaterialConnectionPoint;
  58545. /**
  58546. * Gets the target max input component
  58547. */
  58548. readonly targetMax: NodeMaterialConnectionPoint;
  58549. /**
  58550. * Gets the output component
  58551. */
  58552. readonly output: NodeMaterialConnectionPoint;
  58553. protected _buildBlock(state: NodeMaterialBuildState): this;
  58554. protected _dumpPropertiesCode(): string;
  58555. serialize(): any;
  58556. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58557. }
  58558. }
  58559. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58563. /**
  58564. * Block used to normalize a vector
  58565. */
  58566. export class NormalizeBlock extends NodeMaterialBlock {
  58567. /**
  58568. * Creates a new NormalizeBlock
  58569. * @param name defines the block name
  58570. */
  58571. constructor(name: string);
  58572. /**
  58573. * Gets the current class name
  58574. * @returns the class name
  58575. */
  58576. getClassName(): string;
  58577. /**
  58578. * Gets the input component
  58579. */
  58580. readonly input: NodeMaterialConnectionPoint;
  58581. /**
  58582. * Gets the output component
  58583. */
  58584. readonly output: NodeMaterialConnectionPoint;
  58585. protected _buildBlock(state: NodeMaterialBuildState): this;
  58586. }
  58587. }
  58588. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58592. import { Scene } from "babylonjs/scene";
  58593. /**
  58594. * Operations supported by the Trigonometry block
  58595. */
  58596. export enum TrigonometryBlockOperations {
  58597. /** Cos */
  58598. Cos = 0,
  58599. /** Sin */
  58600. Sin = 1,
  58601. /** Abs */
  58602. Abs = 2,
  58603. /** Exp */
  58604. Exp = 3,
  58605. /** Exp2 */
  58606. Exp2 = 4,
  58607. /** Round */
  58608. Round = 5,
  58609. /** Floor */
  58610. Floor = 6,
  58611. /** Ceiling */
  58612. Ceiling = 7,
  58613. /** Square root */
  58614. Sqrt = 8,
  58615. /** Log */
  58616. Log = 9,
  58617. /** Tangent */
  58618. Tan = 10,
  58619. /** Arc tangent */
  58620. ArcTan = 11,
  58621. /** Arc cosinus */
  58622. ArcCos = 12,
  58623. /** Arc sinus */
  58624. ArcSin = 13,
  58625. /** Fraction */
  58626. Fract = 14,
  58627. /** Sign */
  58628. Sign = 15,
  58629. /** To radians (from degrees) */
  58630. Radians = 16,
  58631. /** To degrees (from radians) */
  58632. Degrees = 17
  58633. }
  58634. /**
  58635. * Block used to apply trigonometry operation to floats
  58636. */
  58637. export class TrigonometryBlock extends NodeMaterialBlock {
  58638. /**
  58639. * Gets or sets the operation applied by the block
  58640. */
  58641. operation: TrigonometryBlockOperations;
  58642. /**
  58643. * Creates a new TrigonometryBlock
  58644. * @param name defines the block name
  58645. */
  58646. constructor(name: string);
  58647. /**
  58648. * Gets the current class name
  58649. * @returns the class name
  58650. */
  58651. getClassName(): string;
  58652. /**
  58653. * Gets the input component
  58654. */
  58655. readonly input: NodeMaterialConnectionPoint;
  58656. /**
  58657. * Gets the output component
  58658. */
  58659. readonly output: NodeMaterialConnectionPoint;
  58660. protected _buildBlock(state: NodeMaterialBuildState): this;
  58661. serialize(): any;
  58662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58663. protected _dumpPropertiesCode(): string;
  58664. }
  58665. }
  58666. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58667. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58668. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58669. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58670. /**
  58671. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58672. */
  58673. export class ColorMergerBlock extends NodeMaterialBlock {
  58674. /**
  58675. * Create a new ColorMergerBlock
  58676. * @param name defines the block name
  58677. */
  58678. constructor(name: string);
  58679. /**
  58680. * Gets the current class name
  58681. * @returns the class name
  58682. */
  58683. getClassName(): string;
  58684. /**
  58685. * Gets the rgb component (input)
  58686. */
  58687. readonly rgbIn: NodeMaterialConnectionPoint;
  58688. /**
  58689. * Gets the r component (input)
  58690. */
  58691. readonly r: NodeMaterialConnectionPoint;
  58692. /**
  58693. * Gets the g component (input)
  58694. */
  58695. readonly g: NodeMaterialConnectionPoint;
  58696. /**
  58697. * Gets the b component (input)
  58698. */
  58699. readonly b: NodeMaterialConnectionPoint;
  58700. /**
  58701. * Gets the a component (input)
  58702. */
  58703. readonly a: NodeMaterialConnectionPoint;
  58704. /**
  58705. * Gets the rgba component (output)
  58706. */
  58707. readonly rgba: NodeMaterialConnectionPoint;
  58708. /**
  58709. * Gets the rgb component (output)
  58710. */
  58711. readonly rgbOut: NodeMaterialConnectionPoint;
  58712. /**
  58713. * Gets the rgb component (output)
  58714. * @deprecated Please use rgbOut instead.
  58715. */
  58716. readonly rgb: NodeMaterialConnectionPoint;
  58717. protected _buildBlock(state: NodeMaterialBuildState): this;
  58718. }
  58719. }
  58720. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58723. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58724. /**
  58725. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58726. */
  58727. export class VectorMergerBlock extends NodeMaterialBlock {
  58728. /**
  58729. * Create a new VectorMergerBlock
  58730. * @param name defines the block name
  58731. */
  58732. constructor(name: string);
  58733. /**
  58734. * Gets the current class name
  58735. * @returns the class name
  58736. */
  58737. getClassName(): string;
  58738. /**
  58739. * Gets the xyz component (input)
  58740. */
  58741. readonly xyzIn: NodeMaterialConnectionPoint;
  58742. /**
  58743. * Gets the xy component (input)
  58744. */
  58745. readonly xyIn: NodeMaterialConnectionPoint;
  58746. /**
  58747. * Gets the x component (input)
  58748. */
  58749. readonly x: NodeMaterialConnectionPoint;
  58750. /**
  58751. * Gets the y component (input)
  58752. */
  58753. readonly y: NodeMaterialConnectionPoint;
  58754. /**
  58755. * Gets the z component (input)
  58756. */
  58757. readonly z: NodeMaterialConnectionPoint;
  58758. /**
  58759. * Gets the w component (input)
  58760. */
  58761. readonly w: NodeMaterialConnectionPoint;
  58762. /**
  58763. * Gets the xyzw component (output)
  58764. */
  58765. readonly xyzw: NodeMaterialConnectionPoint;
  58766. /**
  58767. * Gets the xyz component (output)
  58768. */
  58769. readonly xyzOut: NodeMaterialConnectionPoint;
  58770. /**
  58771. * Gets the xy component (output)
  58772. */
  58773. readonly xyOut: NodeMaterialConnectionPoint;
  58774. /**
  58775. * Gets the xy component (output)
  58776. * @deprecated Please use xyOut instead.
  58777. */
  58778. readonly xy: NodeMaterialConnectionPoint;
  58779. /**
  58780. * Gets the xyz component (output)
  58781. * @deprecated Please use xyzOut instead.
  58782. */
  58783. readonly xyz: NodeMaterialConnectionPoint;
  58784. protected _buildBlock(state: NodeMaterialBuildState): this;
  58785. }
  58786. }
  58787. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  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 Color3/4 into 4 outputs (one for each component)
  58793. */
  58794. export class ColorSplitterBlock extends NodeMaterialBlock {
  58795. /**
  58796. * Create a new ColorSplitterBlock
  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 rgba component (input)
  58807. */
  58808. readonly rgba: NodeMaterialConnectionPoint;
  58809. /**
  58810. * Gets the rgb component (input)
  58811. */
  58812. readonly rgbIn: NodeMaterialConnectionPoint;
  58813. /**
  58814. * Gets the rgb component (output)
  58815. */
  58816. readonly rgbOut: NodeMaterialConnectionPoint;
  58817. /**
  58818. * Gets the r component (output)
  58819. */
  58820. readonly r: NodeMaterialConnectionPoint;
  58821. /**
  58822. * Gets the g component (output)
  58823. */
  58824. readonly g: NodeMaterialConnectionPoint;
  58825. /**
  58826. * Gets the b component (output)
  58827. */
  58828. readonly b: NodeMaterialConnectionPoint;
  58829. /**
  58830. * Gets the a component (output)
  58831. */
  58832. readonly a: NodeMaterialConnectionPoint;
  58833. protected _inputRename(name: string): string;
  58834. protected _outputRename(name: string): string;
  58835. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58836. }
  58837. }
  58838. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58839. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58840. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58841. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58842. /**
  58843. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58844. */
  58845. export class VectorSplitterBlock extends NodeMaterialBlock {
  58846. /**
  58847. * Create a new VectorSplitterBlock
  58848. * @param name defines the block name
  58849. */
  58850. constructor(name: string);
  58851. /**
  58852. * Gets the current class name
  58853. * @returns the class name
  58854. */
  58855. getClassName(): string;
  58856. /**
  58857. * Gets the xyzw component (input)
  58858. */
  58859. readonly xyzw: NodeMaterialConnectionPoint;
  58860. /**
  58861. * Gets the xyz component (input)
  58862. */
  58863. readonly xyzIn: NodeMaterialConnectionPoint;
  58864. /**
  58865. * Gets the xy component (input)
  58866. */
  58867. readonly xyIn: NodeMaterialConnectionPoint;
  58868. /**
  58869. * Gets the xyz component (output)
  58870. */
  58871. readonly xyzOut: NodeMaterialConnectionPoint;
  58872. /**
  58873. * Gets the xy component (output)
  58874. */
  58875. readonly xyOut: NodeMaterialConnectionPoint;
  58876. /**
  58877. * Gets the x component (output)
  58878. */
  58879. readonly x: NodeMaterialConnectionPoint;
  58880. /**
  58881. * Gets the y component (output)
  58882. */
  58883. readonly y: NodeMaterialConnectionPoint;
  58884. /**
  58885. * Gets the z component (output)
  58886. */
  58887. readonly z: NodeMaterialConnectionPoint;
  58888. /**
  58889. * Gets the w component (output)
  58890. */
  58891. readonly w: NodeMaterialConnectionPoint;
  58892. protected _inputRename(name: string): string;
  58893. protected _outputRename(name: string): string;
  58894. protected _buildBlock(state: NodeMaterialBuildState): this;
  58895. }
  58896. }
  58897. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58901. /**
  58902. * Block used to lerp between 2 values
  58903. */
  58904. export class LerpBlock extends NodeMaterialBlock {
  58905. /**
  58906. * Creates a new LerpBlock
  58907. * @param name defines the block name
  58908. */
  58909. constructor(name: string);
  58910. /**
  58911. * Gets the current class name
  58912. * @returns the class name
  58913. */
  58914. getClassName(): string;
  58915. /**
  58916. * Gets the left operand input component
  58917. */
  58918. readonly left: NodeMaterialConnectionPoint;
  58919. /**
  58920. * Gets the right operand input component
  58921. */
  58922. readonly right: NodeMaterialConnectionPoint;
  58923. /**
  58924. * Gets the gradient operand input component
  58925. */
  58926. readonly gradient: NodeMaterialConnectionPoint;
  58927. /**
  58928. * Gets the output component
  58929. */
  58930. readonly output: NodeMaterialConnectionPoint;
  58931. protected _buildBlock(state: NodeMaterialBuildState): this;
  58932. }
  58933. }
  58934. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58938. /**
  58939. * Block used to divide 2 vectors
  58940. */
  58941. export class DivideBlock extends NodeMaterialBlock {
  58942. /**
  58943. * Creates a new DivideBlock
  58944. * @param name defines the block name
  58945. */
  58946. constructor(name: string);
  58947. /**
  58948. * Gets the current class name
  58949. * @returns the class name
  58950. */
  58951. getClassName(): string;
  58952. /**
  58953. * Gets the left operand input component
  58954. */
  58955. readonly left: NodeMaterialConnectionPoint;
  58956. /**
  58957. * Gets the right operand input component
  58958. */
  58959. readonly right: NodeMaterialConnectionPoint;
  58960. /**
  58961. * Gets the output component
  58962. */
  58963. readonly output: NodeMaterialConnectionPoint;
  58964. protected _buildBlock(state: NodeMaterialBuildState): this;
  58965. }
  58966. }
  58967. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58971. /**
  58972. * Block used to subtract 2 vectors
  58973. */
  58974. export class SubtractBlock extends NodeMaterialBlock {
  58975. /**
  58976. * Creates a new SubtractBlock
  58977. * @param name defines the block name
  58978. */
  58979. constructor(name: string);
  58980. /**
  58981. * Gets the current class name
  58982. * @returns the class name
  58983. */
  58984. getClassName(): string;
  58985. /**
  58986. * Gets the left operand input component
  58987. */
  58988. readonly left: NodeMaterialConnectionPoint;
  58989. /**
  58990. * Gets the right operand input component
  58991. */
  58992. readonly right: NodeMaterialConnectionPoint;
  58993. /**
  58994. * Gets the output component
  58995. */
  58996. readonly output: NodeMaterialConnectionPoint;
  58997. protected _buildBlock(state: NodeMaterialBuildState): this;
  58998. }
  58999. }
  59000. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  59001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59004. /**
  59005. * Block used to step a value
  59006. */
  59007. export class StepBlock extends NodeMaterialBlock {
  59008. /**
  59009. * Creates a new StepBlock
  59010. * @param name defines the block name
  59011. */
  59012. constructor(name: string);
  59013. /**
  59014. * Gets the current class name
  59015. * @returns the class name
  59016. */
  59017. getClassName(): string;
  59018. /**
  59019. * Gets the value operand input component
  59020. */
  59021. readonly value: NodeMaterialConnectionPoint;
  59022. /**
  59023. * Gets the edge operand input component
  59024. */
  59025. readonly edge: NodeMaterialConnectionPoint;
  59026. /**
  59027. * Gets the output component
  59028. */
  59029. readonly output: NodeMaterialConnectionPoint;
  59030. protected _buildBlock(state: NodeMaterialBuildState): this;
  59031. }
  59032. }
  59033. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  59034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59037. /**
  59038. * Block used to get the opposite (1 - x) of a value
  59039. */
  59040. export class OneMinusBlock extends NodeMaterialBlock {
  59041. /**
  59042. * Creates a new OneMinusBlock
  59043. * @param name defines the block name
  59044. */
  59045. constructor(name: string);
  59046. /**
  59047. * Gets the current class name
  59048. * @returns the class name
  59049. */
  59050. getClassName(): string;
  59051. /**
  59052. * Gets the input component
  59053. */
  59054. readonly input: NodeMaterialConnectionPoint;
  59055. /**
  59056. * Gets the output component
  59057. */
  59058. readonly output: NodeMaterialConnectionPoint;
  59059. protected _buildBlock(state: NodeMaterialBuildState): this;
  59060. }
  59061. }
  59062. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  59063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59066. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59067. /**
  59068. * Block used to get the view direction
  59069. */
  59070. export class ViewDirectionBlock extends NodeMaterialBlock {
  59071. /**
  59072. * Creates a new ViewDirectionBlock
  59073. * @param name defines the block name
  59074. */
  59075. constructor(name: string);
  59076. /**
  59077. * Gets the current class name
  59078. * @returns the class name
  59079. */
  59080. getClassName(): string;
  59081. /**
  59082. * Gets the world position component
  59083. */
  59084. readonly worldPosition: NodeMaterialConnectionPoint;
  59085. /**
  59086. * Gets the camera position component
  59087. */
  59088. readonly cameraPosition: NodeMaterialConnectionPoint;
  59089. /**
  59090. * Gets the output component
  59091. */
  59092. readonly output: NodeMaterialConnectionPoint;
  59093. autoConfigure(material: NodeMaterial): void;
  59094. protected _buildBlock(state: NodeMaterialBuildState): this;
  59095. }
  59096. }
  59097. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  59098. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59099. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59100. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59101. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59102. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  59103. /**
  59104. * Block used to compute fresnel value
  59105. */
  59106. export class FresnelBlock extends NodeMaterialBlock {
  59107. /**
  59108. * Create a new FresnelBlock
  59109. * @param name defines the block name
  59110. */
  59111. constructor(name: string);
  59112. /**
  59113. * Gets the current class name
  59114. * @returns the class name
  59115. */
  59116. getClassName(): string;
  59117. /**
  59118. * Gets the world normal input component
  59119. */
  59120. readonly worldNormal: NodeMaterialConnectionPoint;
  59121. /**
  59122. * Gets the view direction input component
  59123. */
  59124. readonly viewDirection: NodeMaterialConnectionPoint;
  59125. /**
  59126. * Gets the bias input component
  59127. */
  59128. readonly bias: NodeMaterialConnectionPoint;
  59129. /**
  59130. * Gets the camera (or eye) position component
  59131. */
  59132. readonly power: NodeMaterialConnectionPoint;
  59133. /**
  59134. * Gets the fresnel output component
  59135. */
  59136. readonly fresnel: NodeMaterialConnectionPoint;
  59137. autoConfigure(material: NodeMaterial): void;
  59138. protected _buildBlock(state: NodeMaterialBuildState): this;
  59139. }
  59140. }
  59141. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  59142. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59143. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59144. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59145. /**
  59146. * Block used to get the max of 2 values
  59147. */
  59148. export class MaxBlock extends NodeMaterialBlock {
  59149. /**
  59150. * Creates a new MaxBlock
  59151. * @param name defines the block name
  59152. */
  59153. constructor(name: string);
  59154. /**
  59155. * Gets the current class name
  59156. * @returns the class name
  59157. */
  59158. getClassName(): string;
  59159. /**
  59160. * Gets the left operand input component
  59161. */
  59162. readonly left: NodeMaterialConnectionPoint;
  59163. /**
  59164. * Gets the right operand input component
  59165. */
  59166. readonly right: NodeMaterialConnectionPoint;
  59167. /**
  59168. * Gets the output component
  59169. */
  59170. readonly output: NodeMaterialConnectionPoint;
  59171. protected _buildBlock(state: NodeMaterialBuildState): this;
  59172. }
  59173. }
  59174. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  59175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59178. /**
  59179. * Block used to get the min of 2 values
  59180. */
  59181. export class MinBlock extends NodeMaterialBlock {
  59182. /**
  59183. * Creates a new MinBlock
  59184. * @param name defines the block name
  59185. */
  59186. constructor(name: string);
  59187. /**
  59188. * Gets the current class name
  59189. * @returns the class name
  59190. */
  59191. getClassName(): string;
  59192. /**
  59193. * Gets the left operand input component
  59194. */
  59195. readonly left: NodeMaterialConnectionPoint;
  59196. /**
  59197. * Gets the right operand input component
  59198. */
  59199. readonly right: NodeMaterialConnectionPoint;
  59200. /**
  59201. * Gets the output component
  59202. */
  59203. readonly output: NodeMaterialConnectionPoint;
  59204. protected _buildBlock(state: NodeMaterialBuildState): this;
  59205. }
  59206. }
  59207. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  59208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59211. /**
  59212. * Block used to get the distance between 2 values
  59213. */
  59214. export class DistanceBlock extends NodeMaterialBlock {
  59215. /**
  59216. * Creates a new DistanceBlock
  59217. * @param name defines the block name
  59218. */
  59219. constructor(name: string);
  59220. /**
  59221. * Gets the current class name
  59222. * @returns the class name
  59223. */
  59224. getClassName(): string;
  59225. /**
  59226. * Gets the left operand input component
  59227. */
  59228. readonly left: NodeMaterialConnectionPoint;
  59229. /**
  59230. * Gets the right operand input component
  59231. */
  59232. readonly right: NodeMaterialConnectionPoint;
  59233. /**
  59234. * Gets the output component
  59235. */
  59236. readonly output: NodeMaterialConnectionPoint;
  59237. protected _buildBlock(state: NodeMaterialBuildState): this;
  59238. }
  59239. }
  59240. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  59241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59244. /**
  59245. * Block used to get the length of a vector
  59246. */
  59247. export class LengthBlock extends NodeMaterialBlock {
  59248. /**
  59249. * Creates a new LengthBlock
  59250. * @param name defines the block name
  59251. */
  59252. constructor(name: string);
  59253. /**
  59254. * Gets the current class name
  59255. * @returns the class name
  59256. */
  59257. getClassName(): string;
  59258. /**
  59259. * Gets the value input component
  59260. */
  59261. readonly value: NodeMaterialConnectionPoint;
  59262. /**
  59263. * Gets the output component
  59264. */
  59265. readonly output: NodeMaterialConnectionPoint;
  59266. protected _buildBlock(state: NodeMaterialBuildState): this;
  59267. }
  59268. }
  59269. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  59270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59273. /**
  59274. * Block used to get negative version of a value (i.e. x * -1)
  59275. */
  59276. export class NegateBlock extends NodeMaterialBlock {
  59277. /**
  59278. * Creates a new NegateBlock
  59279. * @param name defines the block name
  59280. */
  59281. constructor(name: string);
  59282. /**
  59283. * Gets the current class name
  59284. * @returns the class name
  59285. */
  59286. getClassName(): string;
  59287. /**
  59288. * Gets the value input component
  59289. */
  59290. readonly value: NodeMaterialConnectionPoint;
  59291. /**
  59292. * Gets the output component
  59293. */
  59294. readonly output: NodeMaterialConnectionPoint;
  59295. protected _buildBlock(state: NodeMaterialBuildState): this;
  59296. }
  59297. }
  59298. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  59299. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59300. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59301. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59302. /**
  59303. * Block used to get the value of the first parameter raised to the power of the second
  59304. */
  59305. export class PowBlock extends NodeMaterialBlock {
  59306. /**
  59307. * Creates a new PowBlock
  59308. * @param name defines the block name
  59309. */
  59310. constructor(name: string);
  59311. /**
  59312. * Gets the current class name
  59313. * @returns the class name
  59314. */
  59315. getClassName(): string;
  59316. /**
  59317. * Gets the value operand input component
  59318. */
  59319. readonly value: NodeMaterialConnectionPoint;
  59320. /**
  59321. * Gets the power operand input component
  59322. */
  59323. readonly power: NodeMaterialConnectionPoint;
  59324. /**
  59325. * Gets the output component
  59326. */
  59327. readonly output: NodeMaterialConnectionPoint;
  59328. protected _buildBlock(state: NodeMaterialBuildState): this;
  59329. }
  59330. }
  59331. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  59332. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59333. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59334. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59335. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59336. /**
  59337. * Block used to get a random number
  59338. */
  59339. export class RandomNumberBlock extends NodeMaterialBlock {
  59340. /**
  59341. * Creates a new RandomNumberBlock
  59342. * @param name defines the block name
  59343. */
  59344. constructor(name: string);
  59345. /**
  59346. * Gets the current class name
  59347. * @returns the class name
  59348. */
  59349. getClassName(): string;
  59350. /**
  59351. * Gets the seed input component
  59352. */
  59353. readonly seed: NodeMaterialConnectionPoint;
  59354. /**
  59355. * Gets the output component
  59356. */
  59357. readonly output: NodeMaterialConnectionPoint;
  59358. protected _buildBlock(state: NodeMaterialBuildState): this;
  59359. }
  59360. }
  59361. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  59362. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59363. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59364. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59365. /**
  59366. * Block used to compute arc tangent of 2 values
  59367. */
  59368. export class ArcTan2Block extends NodeMaterialBlock {
  59369. /**
  59370. * Creates a new ArcTan2Block
  59371. * @param name defines the block name
  59372. */
  59373. constructor(name: string);
  59374. /**
  59375. * Gets the current class name
  59376. * @returns the class name
  59377. */
  59378. getClassName(): string;
  59379. /**
  59380. * Gets the x operand input component
  59381. */
  59382. readonly x: NodeMaterialConnectionPoint;
  59383. /**
  59384. * Gets the y operand input component
  59385. */
  59386. readonly y: NodeMaterialConnectionPoint;
  59387. /**
  59388. * Gets the output component
  59389. */
  59390. readonly output: NodeMaterialConnectionPoint;
  59391. protected _buildBlock(state: NodeMaterialBuildState): this;
  59392. }
  59393. }
  59394. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  59395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59396. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59398. /**
  59399. * Block used to smooth step a value
  59400. */
  59401. export class SmoothStepBlock extends NodeMaterialBlock {
  59402. /**
  59403. * Creates a new SmoothStepBlock
  59404. * @param name defines the block name
  59405. */
  59406. constructor(name: string);
  59407. /**
  59408. * Gets the current class name
  59409. * @returns the class name
  59410. */
  59411. getClassName(): string;
  59412. /**
  59413. * Gets the value operand input component
  59414. */
  59415. readonly value: NodeMaterialConnectionPoint;
  59416. /**
  59417. * Gets the first edge operand input component
  59418. */
  59419. readonly edge0: NodeMaterialConnectionPoint;
  59420. /**
  59421. * Gets the second edge operand input component
  59422. */
  59423. readonly edge1: NodeMaterialConnectionPoint;
  59424. /**
  59425. * Gets the output component
  59426. */
  59427. readonly output: NodeMaterialConnectionPoint;
  59428. protected _buildBlock(state: NodeMaterialBuildState): this;
  59429. }
  59430. }
  59431. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  59432. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59433. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59435. /**
  59436. * Block used to get the reciprocal (1 / x) of a value
  59437. */
  59438. export class ReciprocalBlock extends NodeMaterialBlock {
  59439. /**
  59440. * Creates a new ReciprocalBlock
  59441. * @param name defines the block name
  59442. */
  59443. constructor(name: string);
  59444. /**
  59445. * Gets the current class name
  59446. * @returns the class name
  59447. */
  59448. getClassName(): string;
  59449. /**
  59450. * Gets the input component
  59451. */
  59452. readonly input: NodeMaterialConnectionPoint;
  59453. /**
  59454. * Gets the output component
  59455. */
  59456. readonly output: NodeMaterialConnectionPoint;
  59457. protected _buildBlock(state: NodeMaterialBuildState): this;
  59458. }
  59459. }
  59460. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  59461. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59462. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59463. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59464. /**
  59465. * Block used to replace a color by another one
  59466. */
  59467. export class ReplaceColorBlock extends NodeMaterialBlock {
  59468. /**
  59469. * Creates a new ReplaceColorBlock
  59470. * @param name defines the block name
  59471. */
  59472. constructor(name: string);
  59473. /**
  59474. * Gets the current class name
  59475. * @returns the class name
  59476. */
  59477. getClassName(): string;
  59478. /**
  59479. * Gets the value input component
  59480. */
  59481. readonly value: NodeMaterialConnectionPoint;
  59482. /**
  59483. * Gets the reference input component
  59484. */
  59485. readonly reference: NodeMaterialConnectionPoint;
  59486. /**
  59487. * Gets the distance input component
  59488. */
  59489. readonly distance: NodeMaterialConnectionPoint;
  59490. /**
  59491. * Gets the replacement input component
  59492. */
  59493. readonly replacement: NodeMaterialConnectionPoint;
  59494. /**
  59495. * Gets the output component
  59496. */
  59497. readonly output: NodeMaterialConnectionPoint;
  59498. protected _buildBlock(state: NodeMaterialBuildState): this;
  59499. }
  59500. }
  59501. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  59502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59505. /**
  59506. * Block used to posterize a value
  59507. * @see https://en.wikipedia.org/wiki/Posterization
  59508. */
  59509. export class PosterizeBlock extends NodeMaterialBlock {
  59510. /**
  59511. * Creates a new PosterizeBlock
  59512. * @param name defines the block name
  59513. */
  59514. constructor(name: string);
  59515. /**
  59516. * Gets the current class name
  59517. * @returns the class name
  59518. */
  59519. getClassName(): string;
  59520. /**
  59521. * Gets the value input component
  59522. */
  59523. readonly value: NodeMaterialConnectionPoint;
  59524. /**
  59525. * Gets the steps input component
  59526. */
  59527. readonly steps: NodeMaterialConnectionPoint;
  59528. /**
  59529. * Gets the output component
  59530. */
  59531. readonly output: NodeMaterialConnectionPoint;
  59532. protected _buildBlock(state: NodeMaterialBuildState): this;
  59533. }
  59534. }
  59535. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59536. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59539. import { Scene } from "babylonjs/scene";
  59540. /**
  59541. * Operations supported by the Wave block
  59542. */
  59543. export enum WaveBlockKind {
  59544. /** SawTooth */
  59545. SawTooth = 0,
  59546. /** Square */
  59547. Square = 1,
  59548. /** Triangle */
  59549. Triangle = 2
  59550. }
  59551. /**
  59552. * Block used to apply wave operation to floats
  59553. */
  59554. export class WaveBlock extends NodeMaterialBlock {
  59555. /**
  59556. * Gets or sets the kibnd of wave to be applied by the block
  59557. */
  59558. kind: WaveBlockKind;
  59559. /**
  59560. * Creates a new WaveBlock
  59561. * @param name defines the block name
  59562. */
  59563. constructor(name: string);
  59564. /**
  59565. * Gets the current class name
  59566. * @returns the class name
  59567. */
  59568. getClassName(): string;
  59569. /**
  59570. * Gets the input component
  59571. */
  59572. readonly input: NodeMaterialConnectionPoint;
  59573. /**
  59574. * Gets the output component
  59575. */
  59576. readonly output: NodeMaterialConnectionPoint;
  59577. protected _buildBlock(state: NodeMaterialBuildState): this;
  59578. serialize(): any;
  59579. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59580. }
  59581. }
  59582. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59586. import { Color3 } from "babylonjs/Maths/math.color";
  59587. import { Scene } from "babylonjs/scene";
  59588. /**
  59589. * Class used to store a color step for the GradientBlock
  59590. */
  59591. export class GradientBlockColorStep {
  59592. /**
  59593. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59594. */
  59595. step: number;
  59596. /**
  59597. * Gets or sets the color associated with this step
  59598. */
  59599. color: Color3;
  59600. /**
  59601. * Creates a new GradientBlockColorStep
  59602. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59603. * @param color defines the color associated with this step
  59604. */
  59605. constructor(
  59606. /**
  59607. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59608. */
  59609. step: number,
  59610. /**
  59611. * Gets or sets the color associated with this step
  59612. */
  59613. color: Color3);
  59614. }
  59615. /**
  59616. * Block used to return a color from a gradient based on an input value between 0 and 1
  59617. */
  59618. export class GradientBlock extends NodeMaterialBlock {
  59619. /**
  59620. * Gets or sets the list of color steps
  59621. */
  59622. colorSteps: GradientBlockColorStep[];
  59623. /**
  59624. * Creates a new GradientBlock
  59625. * @param name defines the block name
  59626. */
  59627. constructor(name: string);
  59628. /**
  59629. * Gets the current class name
  59630. * @returns the class name
  59631. */
  59632. getClassName(): string;
  59633. /**
  59634. * Gets the gradient input component
  59635. */
  59636. readonly gradient: NodeMaterialConnectionPoint;
  59637. /**
  59638. * Gets the output component
  59639. */
  59640. readonly output: NodeMaterialConnectionPoint;
  59641. private _writeColorConstant;
  59642. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59643. serialize(): any;
  59644. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59645. protected _dumpPropertiesCode(): string;
  59646. }
  59647. }
  59648. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59652. /**
  59653. * Block used to normalize lerp between 2 values
  59654. */
  59655. export class NLerpBlock extends NodeMaterialBlock {
  59656. /**
  59657. * Creates a new NLerpBlock
  59658. * @param name defines the block name
  59659. */
  59660. constructor(name: string);
  59661. /**
  59662. * Gets the current class name
  59663. * @returns the class name
  59664. */
  59665. getClassName(): string;
  59666. /**
  59667. * Gets the left operand input component
  59668. */
  59669. readonly left: NodeMaterialConnectionPoint;
  59670. /**
  59671. * Gets the right operand input component
  59672. */
  59673. readonly right: NodeMaterialConnectionPoint;
  59674. /**
  59675. * Gets the gradient operand input component
  59676. */
  59677. readonly gradient: NodeMaterialConnectionPoint;
  59678. /**
  59679. * Gets the output component
  59680. */
  59681. readonly output: NodeMaterialConnectionPoint;
  59682. protected _buildBlock(state: NodeMaterialBuildState): this;
  59683. }
  59684. }
  59685. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59686. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59687. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59688. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59689. import { Scene } from "babylonjs/scene";
  59690. /**
  59691. * block used to Generate a Worley Noise 3D Noise Pattern
  59692. */
  59693. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59694. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59695. manhattanDistance: boolean;
  59696. /**
  59697. * Creates a new WorleyNoise3DBlock
  59698. * @param name defines the block name
  59699. */
  59700. constructor(name: string);
  59701. /**
  59702. * Gets the current class name
  59703. * @returns the class name
  59704. */
  59705. getClassName(): string;
  59706. /**
  59707. * Gets the seed input component
  59708. */
  59709. readonly seed: NodeMaterialConnectionPoint;
  59710. /**
  59711. * Gets the jitter input component
  59712. */
  59713. readonly jitter: NodeMaterialConnectionPoint;
  59714. /**
  59715. * Gets the output component
  59716. */
  59717. readonly output: NodeMaterialConnectionPoint;
  59718. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59719. /**
  59720. * Exposes the properties to the UI?
  59721. */
  59722. protected _dumpPropertiesCode(): string;
  59723. /**
  59724. * Exposes the properties to the Seralize?
  59725. */
  59726. serialize(): any;
  59727. /**
  59728. * Exposes the properties to the deseralize?
  59729. */
  59730. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59731. }
  59732. }
  59733. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59737. /**
  59738. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59739. */
  59740. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59741. /**
  59742. * Creates a new SimplexPerlin3DBlock
  59743. * @param name defines the block name
  59744. */
  59745. constructor(name: string);
  59746. /**
  59747. * Gets the current class name
  59748. * @returns the class name
  59749. */
  59750. getClassName(): string;
  59751. /**
  59752. * Gets the seed operand input component
  59753. */
  59754. readonly seed: NodeMaterialConnectionPoint;
  59755. /**
  59756. * Gets the output component
  59757. */
  59758. readonly output: NodeMaterialConnectionPoint;
  59759. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59760. }
  59761. }
  59762. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59763. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59764. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59765. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59766. /**
  59767. * Block used to blend normals
  59768. */
  59769. export class NormalBlendBlock extends NodeMaterialBlock {
  59770. /**
  59771. * Creates a new NormalBlendBlock
  59772. * @param name defines the block name
  59773. */
  59774. constructor(name: string);
  59775. /**
  59776. * Gets the current class name
  59777. * @returns the class name
  59778. */
  59779. getClassName(): string;
  59780. /**
  59781. * Gets the first input component
  59782. */
  59783. readonly normalMap0: NodeMaterialConnectionPoint;
  59784. /**
  59785. * Gets the second input component
  59786. */
  59787. readonly normalMap1: NodeMaterialConnectionPoint;
  59788. /**
  59789. * Gets the output component
  59790. */
  59791. readonly output: NodeMaterialConnectionPoint;
  59792. protected _buildBlock(state: NodeMaterialBuildState): this;
  59793. }
  59794. }
  59795. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  59796. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59798. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59799. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59800. /**
  59801. * Block used to rotate a 2d vector by a given angle
  59802. */
  59803. export class Rotate2dBlock extends NodeMaterialBlock {
  59804. /**
  59805. * Creates a new Rotate2dBlock
  59806. * @param name defines the block name
  59807. */
  59808. constructor(name: string);
  59809. /**
  59810. * Gets the current class name
  59811. * @returns the class name
  59812. */
  59813. getClassName(): string;
  59814. /**
  59815. * Gets the input vector
  59816. */
  59817. readonly input: NodeMaterialConnectionPoint;
  59818. /**
  59819. * Gets the input angle
  59820. */
  59821. readonly angle: NodeMaterialConnectionPoint;
  59822. /**
  59823. * Gets the output component
  59824. */
  59825. readonly output: NodeMaterialConnectionPoint;
  59826. autoConfigure(material: NodeMaterial): void;
  59827. protected _buildBlock(state: NodeMaterialBuildState): this;
  59828. }
  59829. }
  59830. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  59831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59834. /**
  59835. * Block used to get the reflected vector from a direction and a normal
  59836. */
  59837. export class ReflectBlock extends NodeMaterialBlock {
  59838. /**
  59839. * Creates a new ReflectBlock
  59840. * @param name defines the block name
  59841. */
  59842. constructor(name: string);
  59843. /**
  59844. * Gets the current class name
  59845. * @returns the class name
  59846. */
  59847. getClassName(): string;
  59848. /**
  59849. * Gets the incident component
  59850. */
  59851. readonly incident: NodeMaterialConnectionPoint;
  59852. /**
  59853. * Gets the normal component
  59854. */
  59855. readonly normal: NodeMaterialConnectionPoint;
  59856. /**
  59857. * Gets the output component
  59858. */
  59859. readonly output: NodeMaterialConnectionPoint;
  59860. protected _buildBlock(state: NodeMaterialBuildState): this;
  59861. }
  59862. }
  59863. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  59864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59867. /**
  59868. * Block used to get the refracted vector from a direction and a normal
  59869. */
  59870. export class RefractBlock extends NodeMaterialBlock {
  59871. /**
  59872. * Creates a new RefractBlock
  59873. * @param name defines the block name
  59874. */
  59875. constructor(name: string);
  59876. /**
  59877. * Gets the current class name
  59878. * @returns the class name
  59879. */
  59880. getClassName(): string;
  59881. /**
  59882. * Gets the incident component
  59883. */
  59884. readonly incident: NodeMaterialConnectionPoint;
  59885. /**
  59886. * Gets the normal component
  59887. */
  59888. readonly normal: NodeMaterialConnectionPoint;
  59889. /**
  59890. * Gets the index of refraction component
  59891. */
  59892. readonly ior: NodeMaterialConnectionPoint;
  59893. /**
  59894. * Gets the output component
  59895. */
  59896. readonly output: NodeMaterialConnectionPoint;
  59897. protected _buildBlock(state: NodeMaterialBuildState): this;
  59898. }
  59899. }
  59900. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  59901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59904. /**
  59905. * Block used to desaturate a color
  59906. */
  59907. export class DesaturateBlock extends NodeMaterialBlock {
  59908. /**
  59909. * Creates a new DesaturateBlock
  59910. * @param name defines the block name
  59911. */
  59912. constructor(name: string);
  59913. /**
  59914. * Gets the current class name
  59915. * @returns the class name
  59916. */
  59917. getClassName(): string;
  59918. /**
  59919. * Gets the color operand input component
  59920. */
  59921. readonly color: NodeMaterialConnectionPoint;
  59922. /**
  59923. * Gets the level operand input component
  59924. */
  59925. readonly level: NodeMaterialConnectionPoint;
  59926. /**
  59927. * Gets the output component
  59928. */
  59929. readonly output: NodeMaterialConnectionPoint;
  59930. protected _buildBlock(state: NodeMaterialBuildState): this;
  59931. }
  59932. }
  59933. declare module "babylonjs/Materials/Node/Blocks/index" {
  59934. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59935. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59936. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59937. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59938. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59939. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59940. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59941. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59942. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59943. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59944. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59945. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59946. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59947. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59948. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59949. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59950. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59951. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59952. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59953. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59954. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59955. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59956. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59957. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59958. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59959. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59960. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59961. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59962. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59963. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59964. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59965. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59966. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59967. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59968. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59969. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59970. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59971. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59972. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59973. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59974. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  59975. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  59976. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  59977. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  59978. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  59979. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  59980. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  59981. }
  59982. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59983. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59984. }
  59985. declare module "babylonjs/Materials/Node/index" {
  59986. export * from "babylonjs/Materials/Node/Enums/index";
  59987. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59988. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59989. export * from "babylonjs/Materials/Node/nodeMaterial";
  59990. export * from "babylonjs/Materials/Node/Blocks/index";
  59991. export * from "babylonjs/Materials/Node/Optimizers/index";
  59992. }
  59993. declare module "babylonjs/Materials/effectRenderer" {
  59994. import { Nullable } from "babylonjs/types";
  59995. import { Texture } from "babylonjs/Materials/Textures/texture";
  59996. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59997. import { Viewport } from "babylonjs/Maths/math.viewport";
  59998. import { Observable } from "babylonjs/Misc/observable";
  59999. import { Effect } from "babylonjs/Materials/effect";
  60000. import "babylonjs/Engines/Extensions/engine.renderTarget";
  60001. import "babylonjs/Shaders/postprocess.vertex";
  60002. /**
  60003. * Effect Render Options
  60004. */
  60005. export interface IEffectRendererOptions {
  60006. /**
  60007. * Defines the vertices positions.
  60008. */
  60009. positions?: number[];
  60010. /**
  60011. * Defines the indices.
  60012. */
  60013. indices?: number[];
  60014. }
  60015. /**
  60016. * Helper class to render one or more effects
  60017. */
  60018. export class EffectRenderer {
  60019. private engine;
  60020. private static _DefaultOptions;
  60021. private _vertexBuffers;
  60022. private _indexBuffer;
  60023. private _ringBufferIndex;
  60024. private _ringScreenBuffer;
  60025. private _fullscreenViewport;
  60026. private _getNextFrameBuffer;
  60027. /**
  60028. * Creates an effect renderer
  60029. * @param engine the engine to use for rendering
  60030. * @param options defines the options of the effect renderer
  60031. */
  60032. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60033. /**
  60034. * Sets the current viewport in normalized coordinates 0-1
  60035. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60036. */
  60037. setViewport(viewport?: Viewport): void;
  60038. /**
  60039. * Binds the embedded attributes buffer to the effect.
  60040. * @param effect Defines the effect to bind the attributes for
  60041. */
  60042. bindBuffers(effect: Effect): void;
  60043. /**
  60044. * Sets the current effect wrapper to use during draw.
  60045. * The effect needs to be ready before calling this api.
  60046. * This also sets the default full screen position attribute.
  60047. * @param effectWrapper Defines the effect to draw with
  60048. */
  60049. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60050. /**
  60051. * Draws a full screen quad.
  60052. */
  60053. draw(): void;
  60054. /**
  60055. * renders one or more effects to a specified texture
  60056. * @param effectWrappers list of effects to renderer
  60057. * @param outputTexture texture to draw to, if null it will render to the screen
  60058. */
  60059. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60060. /**
  60061. * Disposes of the effect renderer
  60062. */
  60063. dispose(): void;
  60064. }
  60065. /**
  60066. * Options to create an EffectWrapper
  60067. */
  60068. interface EffectWrapperCreationOptions {
  60069. /**
  60070. * Engine to use to create the effect
  60071. */
  60072. engine: ThinEngine;
  60073. /**
  60074. * Fragment shader for the effect
  60075. */
  60076. fragmentShader: string;
  60077. /**
  60078. * Vertex shader for the effect
  60079. */
  60080. vertexShader?: string;
  60081. /**
  60082. * Attributes to use in the shader
  60083. */
  60084. attributeNames?: Array<string>;
  60085. /**
  60086. * Uniforms to use in the shader
  60087. */
  60088. uniformNames?: Array<string>;
  60089. /**
  60090. * Texture sampler names to use in the shader
  60091. */
  60092. samplerNames?: Array<string>;
  60093. /**
  60094. * The friendly name of the effect displayed in Spector.
  60095. */
  60096. name?: string;
  60097. }
  60098. /**
  60099. * Wraps an effect to be used for rendering
  60100. */
  60101. export class EffectWrapper {
  60102. /**
  60103. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60104. */
  60105. onApplyObservable: Observable<{}>;
  60106. /**
  60107. * The underlying effect
  60108. */
  60109. effect: Effect;
  60110. /**
  60111. * Creates an effect to be renderer
  60112. * @param creationOptions options to create the effect
  60113. */
  60114. constructor(creationOptions: EffectWrapperCreationOptions);
  60115. /**
  60116. * Disposes of the effect wrapper
  60117. */
  60118. dispose(): void;
  60119. }
  60120. }
  60121. declare module "babylonjs/Materials/index" {
  60122. export * from "babylonjs/Materials/Background/index";
  60123. export * from "babylonjs/Materials/colorCurves";
  60124. export * from "babylonjs/Materials/iEffectFallbacks";
  60125. export * from "babylonjs/Materials/effectFallbacks";
  60126. export * from "babylonjs/Materials/effect";
  60127. export * from "babylonjs/Materials/fresnelParameters";
  60128. export * from "babylonjs/Materials/imageProcessingConfiguration";
  60129. export * from "babylonjs/Materials/material";
  60130. export * from "babylonjs/Materials/materialDefines";
  60131. export * from "babylonjs/Materials/materialHelper";
  60132. export * from "babylonjs/Materials/multiMaterial";
  60133. export * from "babylonjs/Materials/PBR/index";
  60134. export * from "babylonjs/Materials/pushMaterial";
  60135. export * from "babylonjs/Materials/shaderMaterial";
  60136. export * from "babylonjs/Materials/standardMaterial";
  60137. export * from "babylonjs/Materials/Textures/index";
  60138. export * from "babylonjs/Materials/uniformBuffer";
  60139. export * from "babylonjs/Materials/materialFlags";
  60140. export * from "babylonjs/Materials/Node/index";
  60141. export * from "babylonjs/Materials/effectRenderer";
  60142. }
  60143. declare module "babylonjs/Maths/index" {
  60144. export * from "babylonjs/Maths/math.scalar";
  60145. export * from "babylonjs/Maths/math";
  60146. export * from "babylonjs/Maths/sphericalPolynomial";
  60147. }
  60148. declare module "babylonjs/Misc/workerPool" {
  60149. import { IDisposable } from "babylonjs/scene";
  60150. /**
  60151. * Helper class to push actions to a pool of workers.
  60152. */
  60153. export class WorkerPool implements IDisposable {
  60154. private _workerInfos;
  60155. private _pendingActions;
  60156. /**
  60157. * Constructor
  60158. * @param workers Array of workers to use for actions
  60159. */
  60160. constructor(workers: Array<Worker>);
  60161. /**
  60162. * Terminates all workers and clears any pending actions.
  60163. */
  60164. dispose(): void;
  60165. /**
  60166. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60167. * pended until a worker has completed its action.
  60168. * @param action The action to perform. Call onComplete when the action is complete.
  60169. */
  60170. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60171. private _execute;
  60172. }
  60173. }
  60174. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  60175. import { IDisposable } from "babylonjs/scene";
  60176. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60177. /**
  60178. * Configuration for Draco compression
  60179. */
  60180. export interface IDracoCompressionConfiguration {
  60181. /**
  60182. * Configuration for the decoder.
  60183. */
  60184. decoder: {
  60185. /**
  60186. * The url to the WebAssembly module.
  60187. */
  60188. wasmUrl?: string;
  60189. /**
  60190. * The url to the WebAssembly binary.
  60191. */
  60192. wasmBinaryUrl?: string;
  60193. /**
  60194. * The url to the fallback JavaScript module.
  60195. */
  60196. fallbackUrl?: string;
  60197. };
  60198. }
  60199. /**
  60200. * Draco compression (https://google.github.io/draco/)
  60201. *
  60202. * This class wraps the Draco module.
  60203. *
  60204. * **Encoder**
  60205. *
  60206. * The encoder is not currently implemented.
  60207. *
  60208. * **Decoder**
  60209. *
  60210. * 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.
  60211. *
  60212. * To update the configuration, use the following code:
  60213. * ```javascript
  60214. * DracoCompression.Configuration = {
  60215. * decoder: {
  60216. * wasmUrl: "<url to the WebAssembly library>",
  60217. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60218. * fallbackUrl: "<url to the fallback JavaScript library>",
  60219. * }
  60220. * };
  60221. * ```
  60222. *
  60223. * 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.
  60224. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60225. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60226. *
  60227. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60228. * ```javascript
  60229. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60230. * ```
  60231. *
  60232. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60233. */
  60234. export class DracoCompression implements IDisposable {
  60235. private _workerPoolPromise?;
  60236. private _decoderModulePromise?;
  60237. /**
  60238. * The configuration. Defaults to the following urls:
  60239. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60240. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60241. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60242. */
  60243. static Configuration: IDracoCompressionConfiguration;
  60244. /**
  60245. * Returns true if the decoder configuration is available.
  60246. */
  60247. static readonly DecoderAvailable: boolean;
  60248. /**
  60249. * Default number of workers to create when creating the draco compression object.
  60250. */
  60251. static DefaultNumWorkers: number;
  60252. private static GetDefaultNumWorkers;
  60253. private static _Default;
  60254. /**
  60255. * Default instance for the draco compression object.
  60256. */
  60257. static readonly Default: DracoCompression;
  60258. /**
  60259. * Constructor
  60260. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60261. */
  60262. constructor(numWorkers?: number);
  60263. /**
  60264. * Stop all async operations and release resources.
  60265. */
  60266. dispose(): void;
  60267. /**
  60268. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60269. * @returns a promise that resolves when ready
  60270. */
  60271. whenReadyAsync(): Promise<void>;
  60272. /**
  60273. * Decode Draco compressed mesh data to vertex data.
  60274. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60275. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60276. * @returns A promise that resolves with the decoded vertex data
  60277. */
  60278. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60279. [kind: string]: number;
  60280. }): Promise<VertexData>;
  60281. }
  60282. }
  60283. declare module "babylonjs/Meshes/Compression/index" {
  60284. export * from "babylonjs/Meshes/Compression/dracoCompression";
  60285. }
  60286. declare module "babylonjs/Meshes/csg" {
  60287. import { Nullable } from "babylonjs/types";
  60288. import { Scene } from "babylonjs/scene";
  60289. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60290. import { Mesh } from "babylonjs/Meshes/mesh";
  60291. import { Material } from "babylonjs/Materials/material";
  60292. /**
  60293. * Class for building Constructive Solid Geometry
  60294. */
  60295. export class CSG {
  60296. private polygons;
  60297. /**
  60298. * The world matrix
  60299. */
  60300. matrix: Matrix;
  60301. /**
  60302. * Stores the position
  60303. */
  60304. position: Vector3;
  60305. /**
  60306. * Stores the rotation
  60307. */
  60308. rotation: Vector3;
  60309. /**
  60310. * Stores the rotation quaternion
  60311. */
  60312. rotationQuaternion: Nullable<Quaternion>;
  60313. /**
  60314. * Stores the scaling vector
  60315. */
  60316. scaling: Vector3;
  60317. /**
  60318. * Convert the Mesh to CSG
  60319. * @param mesh The Mesh to convert to CSG
  60320. * @returns A new CSG from the Mesh
  60321. */
  60322. static FromMesh(mesh: Mesh): CSG;
  60323. /**
  60324. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60325. * @param polygons Polygons used to construct a CSG solid
  60326. */
  60327. private static FromPolygons;
  60328. /**
  60329. * Clones, or makes a deep copy, of the CSG
  60330. * @returns A new CSG
  60331. */
  60332. clone(): CSG;
  60333. /**
  60334. * Unions this CSG with another CSG
  60335. * @param csg The CSG to union against this CSG
  60336. * @returns The unioned CSG
  60337. */
  60338. union(csg: CSG): CSG;
  60339. /**
  60340. * Unions this CSG with another CSG in place
  60341. * @param csg The CSG to union against this CSG
  60342. */
  60343. unionInPlace(csg: CSG): void;
  60344. /**
  60345. * Subtracts this CSG with another CSG
  60346. * @param csg The CSG to subtract against this CSG
  60347. * @returns A new CSG
  60348. */
  60349. subtract(csg: CSG): CSG;
  60350. /**
  60351. * Subtracts this CSG with another CSG in place
  60352. * @param csg The CSG to subtact against this CSG
  60353. */
  60354. subtractInPlace(csg: CSG): void;
  60355. /**
  60356. * Intersect this CSG with another CSG
  60357. * @param csg The CSG to intersect against this CSG
  60358. * @returns A new CSG
  60359. */
  60360. intersect(csg: CSG): CSG;
  60361. /**
  60362. * Intersects this CSG with another CSG in place
  60363. * @param csg The CSG to intersect against this CSG
  60364. */
  60365. intersectInPlace(csg: CSG): void;
  60366. /**
  60367. * Return a new CSG solid with solid and empty space switched. This solid is
  60368. * not modified.
  60369. * @returns A new CSG solid with solid and empty space switched
  60370. */
  60371. inverse(): CSG;
  60372. /**
  60373. * Inverses the CSG in place
  60374. */
  60375. inverseInPlace(): void;
  60376. /**
  60377. * This is used to keep meshes transformations so they can be restored
  60378. * when we build back a Babylon Mesh
  60379. * NB : All CSG operations are performed in world coordinates
  60380. * @param csg The CSG to copy the transform attributes from
  60381. * @returns This CSG
  60382. */
  60383. copyTransformAttributes(csg: CSG): CSG;
  60384. /**
  60385. * Build Raw mesh from CSG
  60386. * Coordinates here are in world space
  60387. * @param name The name of the mesh geometry
  60388. * @param scene The Scene
  60389. * @param keepSubMeshes Specifies if the submeshes should be kept
  60390. * @returns A new Mesh
  60391. */
  60392. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60393. /**
  60394. * Build Mesh from CSG taking material and transforms into account
  60395. * @param name The name of the Mesh
  60396. * @param material The material of the Mesh
  60397. * @param scene The Scene
  60398. * @param keepSubMeshes Specifies if submeshes should be kept
  60399. * @returns The new Mesh
  60400. */
  60401. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60402. }
  60403. }
  60404. declare module "babylonjs/Meshes/trailMesh" {
  60405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60406. import { Mesh } from "babylonjs/Meshes/mesh";
  60407. import { Scene } from "babylonjs/scene";
  60408. /**
  60409. * Class used to create a trail following a mesh
  60410. */
  60411. export class TrailMesh extends Mesh {
  60412. private _generator;
  60413. private _autoStart;
  60414. private _running;
  60415. private _diameter;
  60416. private _length;
  60417. private _sectionPolygonPointsCount;
  60418. private _sectionVectors;
  60419. private _sectionNormalVectors;
  60420. private _beforeRenderObserver;
  60421. /**
  60422. * @constructor
  60423. * @param name The value used by scene.getMeshByName() to do a lookup.
  60424. * @param generator The mesh to generate a trail.
  60425. * @param scene The scene to add this mesh to.
  60426. * @param diameter Diameter of trailing mesh. Default is 1.
  60427. * @param length Length of trailing mesh. Default is 60.
  60428. * @param autoStart Automatically start trailing mesh. Default true.
  60429. */
  60430. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60431. /**
  60432. * "TrailMesh"
  60433. * @returns "TrailMesh"
  60434. */
  60435. getClassName(): string;
  60436. private _createMesh;
  60437. /**
  60438. * Start trailing mesh.
  60439. */
  60440. start(): void;
  60441. /**
  60442. * Stop trailing mesh.
  60443. */
  60444. stop(): void;
  60445. /**
  60446. * Update trailing mesh geometry.
  60447. */
  60448. update(): void;
  60449. /**
  60450. * Returns a new TrailMesh object.
  60451. * @param name is a string, the name given to the new mesh
  60452. * @param newGenerator use new generator object for cloned trail mesh
  60453. * @returns a new mesh
  60454. */
  60455. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60456. /**
  60457. * Serializes this trail mesh
  60458. * @param serializationObject object to write serialization to
  60459. */
  60460. serialize(serializationObject: any): void;
  60461. /**
  60462. * Parses a serialized trail mesh
  60463. * @param parsedMesh the serialized mesh
  60464. * @param scene the scene to create the trail mesh in
  60465. * @returns the created trail mesh
  60466. */
  60467. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60468. }
  60469. }
  60470. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  60471. import { Nullable } from "babylonjs/types";
  60472. import { Scene } from "babylonjs/scene";
  60473. import { Vector4 } from "babylonjs/Maths/math.vector";
  60474. import { Color4 } from "babylonjs/Maths/math.color";
  60475. import { Mesh } from "babylonjs/Meshes/mesh";
  60476. /**
  60477. * Class containing static functions to help procedurally build meshes
  60478. */
  60479. export class TiledBoxBuilder {
  60480. /**
  60481. * Creates a box mesh
  60482. * 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)
  60483. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60487. * @param name defines the name of the mesh
  60488. * @param options defines the options used to create the mesh
  60489. * @param scene defines the hosting scene
  60490. * @returns the box mesh
  60491. */
  60492. static CreateTiledBox(name: string, options: {
  60493. pattern?: number;
  60494. width?: number;
  60495. height?: number;
  60496. depth?: number;
  60497. tileSize?: number;
  60498. tileWidth?: number;
  60499. tileHeight?: number;
  60500. alignHorizontal?: number;
  60501. alignVertical?: number;
  60502. faceUV?: Vector4[];
  60503. faceColors?: Color4[];
  60504. sideOrientation?: number;
  60505. updatable?: boolean;
  60506. }, scene?: Nullable<Scene>): Mesh;
  60507. }
  60508. }
  60509. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  60510. import { Vector4 } from "babylonjs/Maths/math.vector";
  60511. import { Mesh } from "babylonjs/Meshes/mesh";
  60512. /**
  60513. * Class containing static functions to help procedurally build meshes
  60514. */
  60515. export class TorusKnotBuilder {
  60516. /**
  60517. * Creates a torus knot mesh
  60518. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60519. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60520. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60521. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60525. * @param name defines the name of the mesh
  60526. * @param options defines the options used to create the mesh
  60527. * @param scene defines the hosting scene
  60528. * @returns the torus knot mesh
  60529. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60530. */
  60531. static CreateTorusKnot(name: string, options: {
  60532. radius?: number;
  60533. tube?: number;
  60534. radialSegments?: number;
  60535. tubularSegments?: number;
  60536. p?: number;
  60537. q?: number;
  60538. updatable?: boolean;
  60539. sideOrientation?: number;
  60540. frontUVs?: Vector4;
  60541. backUVs?: Vector4;
  60542. }, scene: any): Mesh;
  60543. }
  60544. }
  60545. declare module "babylonjs/Meshes/polygonMesh" {
  60546. import { Scene } from "babylonjs/scene";
  60547. import { Vector2 } from "babylonjs/Maths/math.vector";
  60548. import { Mesh } from "babylonjs/Meshes/mesh";
  60549. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60550. import { Path2 } from "babylonjs/Maths/math.path";
  60551. /**
  60552. * Polygon
  60553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60554. */
  60555. export class Polygon {
  60556. /**
  60557. * Creates a rectangle
  60558. * @param xmin bottom X coord
  60559. * @param ymin bottom Y coord
  60560. * @param xmax top X coord
  60561. * @param ymax top Y coord
  60562. * @returns points that make the resulting rectation
  60563. */
  60564. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60565. /**
  60566. * Creates a circle
  60567. * @param radius radius of circle
  60568. * @param cx scale in x
  60569. * @param cy scale in y
  60570. * @param numberOfSides number of sides that make up the circle
  60571. * @returns points that make the resulting circle
  60572. */
  60573. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60574. /**
  60575. * Creates a polygon from input string
  60576. * @param input Input polygon data
  60577. * @returns the parsed points
  60578. */
  60579. static Parse(input: string): Vector2[];
  60580. /**
  60581. * Starts building a polygon from x and y coordinates
  60582. * @param x x coordinate
  60583. * @param y y coordinate
  60584. * @returns the started path2
  60585. */
  60586. static StartingAt(x: number, y: number): Path2;
  60587. }
  60588. /**
  60589. * Builds a polygon
  60590. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60591. */
  60592. export class PolygonMeshBuilder {
  60593. private _points;
  60594. private _outlinepoints;
  60595. private _holes;
  60596. private _name;
  60597. private _scene;
  60598. private _epoints;
  60599. private _eholes;
  60600. private _addToepoint;
  60601. /**
  60602. * Babylon reference to the earcut plugin.
  60603. */
  60604. bjsEarcut: any;
  60605. /**
  60606. * Creates a PolygonMeshBuilder
  60607. * @param name name of the builder
  60608. * @param contours Path of the polygon
  60609. * @param scene scene to add to when creating the mesh
  60610. * @param earcutInjection can be used to inject your own earcut reference
  60611. */
  60612. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60613. /**
  60614. * Adds a whole within the polygon
  60615. * @param hole Array of points defining the hole
  60616. * @returns this
  60617. */
  60618. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60619. /**
  60620. * Creates the polygon
  60621. * @param updatable If the mesh should be updatable
  60622. * @param depth The depth of the mesh created
  60623. * @returns the created mesh
  60624. */
  60625. build(updatable?: boolean, depth?: number): Mesh;
  60626. /**
  60627. * Creates the polygon
  60628. * @param depth The depth of the mesh created
  60629. * @returns the created VertexData
  60630. */
  60631. buildVertexData(depth?: number): VertexData;
  60632. /**
  60633. * Adds a side to the polygon
  60634. * @param positions points that make the polygon
  60635. * @param normals normals of the polygon
  60636. * @param uvs uvs of the polygon
  60637. * @param indices indices of the polygon
  60638. * @param bounds bounds of the polygon
  60639. * @param points points of the polygon
  60640. * @param depth depth of the polygon
  60641. * @param flip flip of the polygon
  60642. */
  60643. private addSide;
  60644. }
  60645. }
  60646. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  60647. import { Scene } from "babylonjs/scene";
  60648. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60649. import { Color4 } from "babylonjs/Maths/math.color";
  60650. import { Mesh } from "babylonjs/Meshes/mesh";
  60651. import { Nullable } from "babylonjs/types";
  60652. /**
  60653. * Class containing static functions to help procedurally build meshes
  60654. */
  60655. export class PolygonBuilder {
  60656. /**
  60657. * Creates a polygon mesh
  60658. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60659. * * 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
  60660. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60663. * * Remember you can only change the shape positions, not their number when updating a polygon
  60664. * @param name defines the name of the mesh
  60665. * @param options defines the options used to create the mesh
  60666. * @param scene defines the hosting scene
  60667. * @param earcutInjection can be used to inject your own earcut reference
  60668. * @returns the polygon mesh
  60669. */
  60670. static CreatePolygon(name: string, options: {
  60671. shape: Vector3[];
  60672. holes?: Vector3[][];
  60673. depth?: number;
  60674. faceUV?: Vector4[];
  60675. faceColors?: Color4[];
  60676. updatable?: boolean;
  60677. sideOrientation?: number;
  60678. frontUVs?: Vector4;
  60679. backUVs?: Vector4;
  60680. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60681. /**
  60682. * Creates an extruded polygon mesh, with depth in the Y direction.
  60683. * * 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)
  60684. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60685. * @param name defines the name of the mesh
  60686. * @param options defines the options used to create the mesh
  60687. * @param scene defines the hosting scene
  60688. * @param earcutInjection can be used to inject your own earcut reference
  60689. * @returns the polygon mesh
  60690. */
  60691. static ExtrudePolygon(name: string, options: {
  60692. shape: Vector3[];
  60693. holes?: Vector3[][];
  60694. depth?: number;
  60695. faceUV?: Vector4[];
  60696. faceColors?: Color4[];
  60697. updatable?: boolean;
  60698. sideOrientation?: number;
  60699. frontUVs?: Vector4;
  60700. backUVs?: Vector4;
  60701. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60702. }
  60703. }
  60704. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60705. import { Scene } from "babylonjs/scene";
  60706. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60707. import { Mesh } from "babylonjs/Meshes/mesh";
  60708. import { Nullable } from "babylonjs/types";
  60709. /**
  60710. * Class containing static functions to help procedurally build meshes
  60711. */
  60712. export class LatheBuilder {
  60713. /**
  60714. * Creates lathe mesh.
  60715. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60716. * * 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
  60717. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60718. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60719. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60720. * * 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
  60721. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60722. * * 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
  60723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60725. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60727. * @param name defines the name of the mesh
  60728. * @param options defines the options used to create the mesh
  60729. * @param scene defines the hosting scene
  60730. * @returns the lathe mesh
  60731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60732. */
  60733. static CreateLathe(name: string, options: {
  60734. shape: Vector3[];
  60735. radius?: number;
  60736. tessellation?: number;
  60737. clip?: number;
  60738. arc?: number;
  60739. closed?: boolean;
  60740. updatable?: boolean;
  60741. sideOrientation?: number;
  60742. frontUVs?: Vector4;
  60743. backUVs?: Vector4;
  60744. cap?: number;
  60745. invertUV?: boolean;
  60746. }, scene?: Nullable<Scene>): Mesh;
  60747. }
  60748. }
  60749. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60750. import { Nullable } from "babylonjs/types";
  60751. import { Scene } from "babylonjs/scene";
  60752. import { Vector4 } from "babylonjs/Maths/math.vector";
  60753. import { Mesh } from "babylonjs/Meshes/mesh";
  60754. /**
  60755. * Class containing static functions to help procedurally build meshes
  60756. */
  60757. export class TiledPlaneBuilder {
  60758. /**
  60759. * Creates a tiled plane mesh
  60760. * * The parameter `pattern` will, depending on value, do nothing or
  60761. * * * flip (reflect about central vertical) alternate tiles across and up
  60762. * * * flip every tile on alternate rows
  60763. * * * rotate (180 degs) alternate tiles across and up
  60764. * * * rotate every tile on alternate rows
  60765. * * * flip and rotate alternate tiles across and up
  60766. * * * flip and rotate every tile on alternate rows
  60767. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60768. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60770. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60771. * * 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)
  60772. * * 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)
  60773. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60774. * @param name defines the name of the mesh
  60775. * @param options defines the options used to create the mesh
  60776. * @param scene defines the hosting scene
  60777. * @returns the box mesh
  60778. */
  60779. static CreateTiledPlane(name: string, options: {
  60780. pattern?: number;
  60781. tileSize?: number;
  60782. tileWidth?: number;
  60783. tileHeight?: number;
  60784. size?: number;
  60785. width?: number;
  60786. height?: number;
  60787. alignHorizontal?: number;
  60788. alignVertical?: number;
  60789. sideOrientation?: number;
  60790. frontUVs?: Vector4;
  60791. backUVs?: Vector4;
  60792. updatable?: boolean;
  60793. }, scene?: Nullable<Scene>): Mesh;
  60794. }
  60795. }
  60796. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60797. import { Nullable } from "babylonjs/types";
  60798. import { Scene } from "babylonjs/scene";
  60799. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60800. import { Mesh } from "babylonjs/Meshes/mesh";
  60801. /**
  60802. * Class containing static functions to help procedurally build meshes
  60803. */
  60804. export class TubeBuilder {
  60805. /**
  60806. * Creates a tube mesh.
  60807. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60808. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60809. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60810. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60811. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60812. * * 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)
  60813. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60814. * * 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
  60815. * * 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
  60816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60818. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60820. * @param name defines the name of the mesh
  60821. * @param options defines the options used to create the mesh
  60822. * @param scene defines the hosting scene
  60823. * @returns the tube mesh
  60824. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60825. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60826. */
  60827. static CreateTube(name: string, options: {
  60828. path: Vector3[];
  60829. radius?: number;
  60830. tessellation?: number;
  60831. radiusFunction?: {
  60832. (i: number, distance: number): number;
  60833. };
  60834. cap?: number;
  60835. arc?: number;
  60836. updatable?: boolean;
  60837. sideOrientation?: number;
  60838. frontUVs?: Vector4;
  60839. backUVs?: Vector4;
  60840. instance?: Mesh;
  60841. invertUV?: boolean;
  60842. }, scene?: Nullable<Scene>): Mesh;
  60843. }
  60844. }
  60845. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60846. import { Scene } from "babylonjs/scene";
  60847. import { Vector4 } from "babylonjs/Maths/math.vector";
  60848. import { Mesh } from "babylonjs/Meshes/mesh";
  60849. import { Nullable } from "babylonjs/types";
  60850. /**
  60851. * Class containing static functions to help procedurally build meshes
  60852. */
  60853. export class IcoSphereBuilder {
  60854. /**
  60855. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60856. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60857. * * 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`)
  60858. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60859. * * 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
  60860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60863. * @param name defines the name of the mesh
  60864. * @param options defines the options used to create the mesh
  60865. * @param scene defines the hosting scene
  60866. * @returns the icosahedron mesh
  60867. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60868. */
  60869. static CreateIcoSphere(name: string, options: {
  60870. radius?: number;
  60871. radiusX?: number;
  60872. radiusY?: number;
  60873. radiusZ?: number;
  60874. flat?: boolean;
  60875. subdivisions?: number;
  60876. sideOrientation?: number;
  60877. frontUVs?: Vector4;
  60878. backUVs?: Vector4;
  60879. updatable?: boolean;
  60880. }, scene?: Nullable<Scene>): Mesh;
  60881. }
  60882. }
  60883. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60884. import { Vector3 } from "babylonjs/Maths/math.vector";
  60885. import { Mesh } from "babylonjs/Meshes/mesh";
  60886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60887. /**
  60888. * Class containing static functions to help procedurally build meshes
  60889. */
  60890. export class DecalBuilder {
  60891. /**
  60892. * Creates a decal mesh.
  60893. * 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
  60894. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60895. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60896. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60897. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60898. * @param name defines the name of the mesh
  60899. * @param sourceMesh defines the mesh where the decal must be applied
  60900. * @param options defines the options used to create the mesh
  60901. * @param scene defines the hosting scene
  60902. * @returns the decal mesh
  60903. * @see https://doc.babylonjs.com/how_to/decals
  60904. */
  60905. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60906. position?: Vector3;
  60907. normal?: Vector3;
  60908. size?: Vector3;
  60909. angle?: number;
  60910. }): Mesh;
  60911. }
  60912. }
  60913. declare module "babylonjs/Meshes/meshBuilder" {
  60914. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60915. import { Nullable } from "babylonjs/types";
  60916. import { Scene } from "babylonjs/scene";
  60917. import { Mesh } from "babylonjs/Meshes/mesh";
  60918. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60919. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60921. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60922. import { Plane } from "babylonjs/Maths/math.plane";
  60923. /**
  60924. * Class containing static functions to help procedurally build meshes
  60925. */
  60926. export class MeshBuilder {
  60927. /**
  60928. * Creates a box mesh
  60929. * * The parameter `size` sets the size (float) of each box side (default 1)
  60930. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60931. * * 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)
  60932. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60936. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60937. * @param name defines the name of the mesh
  60938. * @param options defines the options used to create the mesh
  60939. * @param scene defines the hosting scene
  60940. * @returns the box mesh
  60941. */
  60942. static CreateBox(name: string, options: {
  60943. size?: number;
  60944. width?: number;
  60945. height?: number;
  60946. depth?: number;
  60947. faceUV?: Vector4[];
  60948. faceColors?: Color4[];
  60949. sideOrientation?: number;
  60950. frontUVs?: Vector4;
  60951. backUVs?: Vector4;
  60952. updatable?: boolean;
  60953. }, scene?: Nullable<Scene>): Mesh;
  60954. /**
  60955. * Creates a tiled box mesh
  60956. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60958. * @param name defines the name of the mesh
  60959. * @param options defines the options used to create the mesh
  60960. * @param scene defines the hosting scene
  60961. * @returns the tiled box mesh
  60962. */
  60963. static CreateTiledBox(name: string, options: {
  60964. pattern?: number;
  60965. size?: number;
  60966. width?: number;
  60967. height?: number;
  60968. depth: number;
  60969. tileSize?: number;
  60970. tileWidth?: number;
  60971. tileHeight?: number;
  60972. faceUV?: Vector4[];
  60973. faceColors?: Color4[];
  60974. alignHorizontal?: number;
  60975. alignVertical?: number;
  60976. sideOrientation?: number;
  60977. updatable?: boolean;
  60978. }, scene?: Nullable<Scene>): Mesh;
  60979. /**
  60980. * Creates a sphere mesh
  60981. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60982. * * 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`)
  60983. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60984. * * 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
  60985. * * 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)
  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 sphere mesh
  60993. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60994. */
  60995. static CreateSphere(name: string, options: {
  60996. segments?: number;
  60997. diameter?: number;
  60998. diameterX?: number;
  60999. diameterY?: number;
  61000. diameterZ?: number;
  61001. arc?: number;
  61002. slice?: number;
  61003. sideOrientation?: number;
  61004. frontUVs?: Vector4;
  61005. backUVs?: Vector4;
  61006. updatable?: boolean;
  61007. }, scene?: Nullable<Scene>): Mesh;
  61008. /**
  61009. * Creates a plane polygonal mesh. By default, this is a disc
  61010. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61011. * * 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
  61012. * * 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
  61013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61016. * @param name defines the name of the mesh
  61017. * @param options defines the options used to create the mesh
  61018. * @param scene defines the hosting scene
  61019. * @returns the plane polygonal mesh
  61020. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61021. */
  61022. static CreateDisc(name: string, options: {
  61023. radius?: number;
  61024. tessellation?: number;
  61025. arc?: number;
  61026. updatable?: boolean;
  61027. sideOrientation?: number;
  61028. frontUVs?: Vector4;
  61029. backUVs?: Vector4;
  61030. }, scene?: Nullable<Scene>): Mesh;
  61031. /**
  61032. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61033. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61034. * * 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`)
  61035. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61036. * * 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
  61037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61040. * @param name defines the name of the mesh
  61041. * @param options defines the options used to create the mesh
  61042. * @param scene defines the hosting scene
  61043. * @returns the icosahedron mesh
  61044. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61045. */
  61046. static CreateIcoSphere(name: string, options: {
  61047. radius?: number;
  61048. radiusX?: number;
  61049. radiusY?: number;
  61050. radiusZ?: number;
  61051. flat?: boolean;
  61052. subdivisions?: number;
  61053. sideOrientation?: number;
  61054. frontUVs?: Vector4;
  61055. backUVs?: Vector4;
  61056. updatable?: boolean;
  61057. }, scene?: Nullable<Scene>): Mesh;
  61058. /**
  61059. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61060. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61061. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61062. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61063. * * 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
  61064. * * 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
  61065. * * 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
  61066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61068. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61069. * * 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
  61070. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61071. * * 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
  61072. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61074. * @param name defines the name of the mesh
  61075. * @param options defines the options used to create the mesh
  61076. * @param scene defines the hosting scene
  61077. * @returns the ribbon mesh
  61078. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61080. */
  61081. static CreateRibbon(name: string, options: {
  61082. pathArray: Vector3[][];
  61083. closeArray?: boolean;
  61084. closePath?: boolean;
  61085. offset?: number;
  61086. updatable?: boolean;
  61087. sideOrientation?: number;
  61088. frontUVs?: Vector4;
  61089. backUVs?: Vector4;
  61090. instance?: Mesh;
  61091. invertUV?: boolean;
  61092. uvs?: Vector2[];
  61093. colors?: Color4[];
  61094. }, scene?: Nullable<Scene>): Mesh;
  61095. /**
  61096. * Creates a cylinder or a cone mesh
  61097. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61098. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61099. * * 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.
  61100. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61101. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61102. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61103. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61104. * * 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).
  61105. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61106. * * 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).
  61107. * * 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
  61108. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61109. * * 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
  61110. * * 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.
  61111. * * If `enclose` is false, a ring surface is one element.
  61112. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61113. * * 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
  61114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61117. * @param name defines the name of the mesh
  61118. * @param options defines the options used to create the mesh
  61119. * @param scene defines the hosting scene
  61120. * @returns the cylinder mesh
  61121. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61122. */
  61123. static CreateCylinder(name: string, options: {
  61124. height?: number;
  61125. diameterTop?: number;
  61126. diameterBottom?: number;
  61127. diameter?: number;
  61128. tessellation?: number;
  61129. subdivisions?: number;
  61130. arc?: number;
  61131. faceColors?: Color4[];
  61132. faceUV?: Vector4[];
  61133. updatable?: boolean;
  61134. hasRings?: boolean;
  61135. enclose?: boolean;
  61136. cap?: number;
  61137. sideOrientation?: number;
  61138. frontUVs?: Vector4;
  61139. backUVs?: Vector4;
  61140. }, scene?: Nullable<Scene>): Mesh;
  61141. /**
  61142. * Creates a torus mesh
  61143. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61144. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61145. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61149. * @param name defines the name of the mesh
  61150. * @param options defines the options used to create the mesh
  61151. * @param scene defines the hosting scene
  61152. * @returns the torus mesh
  61153. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61154. */
  61155. static CreateTorus(name: string, options: {
  61156. diameter?: number;
  61157. thickness?: number;
  61158. tessellation?: number;
  61159. updatable?: boolean;
  61160. sideOrientation?: number;
  61161. frontUVs?: Vector4;
  61162. backUVs?: Vector4;
  61163. }, scene?: Nullable<Scene>): Mesh;
  61164. /**
  61165. * Creates a torus knot mesh
  61166. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61167. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61168. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61169. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61173. * @param name defines the name of the mesh
  61174. * @param options defines the options used to create the mesh
  61175. * @param scene defines the hosting scene
  61176. * @returns the torus knot mesh
  61177. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61178. */
  61179. static CreateTorusKnot(name: string, options: {
  61180. radius?: number;
  61181. tube?: number;
  61182. radialSegments?: number;
  61183. tubularSegments?: number;
  61184. p?: number;
  61185. q?: number;
  61186. updatable?: boolean;
  61187. sideOrientation?: number;
  61188. frontUVs?: Vector4;
  61189. backUVs?: Vector4;
  61190. }, scene?: Nullable<Scene>): Mesh;
  61191. /**
  61192. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61193. * * 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
  61194. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61195. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61196. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61197. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61198. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61199. * * 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
  61200. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61203. * @param name defines the name of the new line system
  61204. * @param options defines the options used to create the line system
  61205. * @param scene defines the hosting scene
  61206. * @returns a new line system mesh
  61207. */
  61208. static CreateLineSystem(name: string, options: {
  61209. lines: Vector3[][];
  61210. updatable?: boolean;
  61211. instance?: Nullable<LinesMesh>;
  61212. colors?: Nullable<Color4[][]>;
  61213. useVertexAlpha?: boolean;
  61214. }, scene: Nullable<Scene>): LinesMesh;
  61215. /**
  61216. * Creates a line mesh
  61217. * 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
  61218. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61219. * * The parameter `points` is an array successive Vector3
  61220. * * 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
  61221. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61222. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61223. * * When updating an instance, remember that only point positions can change, not the number of points
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61226. * @param name defines the name of the new line system
  61227. * @param options defines the options used to create the line system
  61228. * @param scene defines the hosting scene
  61229. * @returns a new line mesh
  61230. */
  61231. static CreateLines(name: string, options: {
  61232. points: Vector3[];
  61233. updatable?: boolean;
  61234. instance?: Nullable<LinesMesh>;
  61235. colors?: Color4[];
  61236. useVertexAlpha?: boolean;
  61237. }, scene?: Nullable<Scene>): LinesMesh;
  61238. /**
  61239. * Creates a dashed line mesh
  61240. * * 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
  61241. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61242. * * The parameter `points` is an array successive Vector3
  61243. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61244. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61245. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61246. * * 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
  61247. * * When updating an instance, remember that only point positions can change, not the number of points
  61248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61249. * @param name defines the name of the mesh
  61250. * @param options defines the options used to create the mesh
  61251. * @param scene defines the hosting scene
  61252. * @returns the dashed line mesh
  61253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61254. */
  61255. static CreateDashedLines(name: string, options: {
  61256. points: Vector3[];
  61257. dashSize?: number;
  61258. gapSize?: number;
  61259. dashNb?: number;
  61260. updatable?: boolean;
  61261. instance?: LinesMesh;
  61262. }, scene?: Nullable<Scene>): LinesMesh;
  61263. /**
  61264. * 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.
  61265. * * 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.
  61266. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61267. * * 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.
  61268. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61269. * * 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
  61270. * * 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
  61271. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61274. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61276. * @param name defines the name of the mesh
  61277. * @param options defines the options used to create the mesh
  61278. * @param scene defines the hosting scene
  61279. * @returns the extruded shape mesh
  61280. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61281. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61282. */
  61283. static ExtrudeShape(name: string, options: {
  61284. shape: Vector3[];
  61285. path: Vector3[];
  61286. scale?: number;
  61287. rotation?: number;
  61288. cap?: number;
  61289. updatable?: boolean;
  61290. sideOrientation?: number;
  61291. frontUVs?: Vector4;
  61292. backUVs?: Vector4;
  61293. instance?: Mesh;
  61294. invertUV?: boolean;
  61295. }, scene?: Nullable<Scene>): Mesh;
  61296. /**
  61297. * Creates an custom extruded shape mesh.
  61298. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61299. * * 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.
  61300. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61301. * * 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
  61302. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61303. * * 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
  61304. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61305. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61306. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61307. * * 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
  61308. * * 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
  61309. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61311. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61312. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61314. * @param name defines the name of the mesh
  61315. * @param options defines the options used to create the mesh
  61316. * @param scene defines the hosting scene
  61317. * @returns the custom extruded shape mesh
  61318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61319. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61321. */
  61322. static ExtrudeShapeCustom(name: string, options: {
  61323. shape: Vector3[];
  61324. path: Vector3[];
  61325. scaleFunction?: any;
  61326. rotationFunction?: any;
  61327. ribbonCloseArray?: boolean;
  61328. ribbonClosePath?: boolean;
  61329. cap?: number;
  61330. updatable?: boolean;
  61331. sideOrientation?: number;
  61332. frontUVs?: Vector4;
  61333. backUVs?: Vector4;
  61334. instance?: Mesh;
  61335. invertUV?: boolean;
  61336. }, scene?: Nullable<Scene>): Mesh;
  61337. /**
  61338. * Creates lathe mesh.
  61339. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61340. * * 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
  61341. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61342. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61343. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61344. * * 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
  61345. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61346. * * 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
  61347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61349. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61351. * @param name defines the name of the mesh
  61352. * @param options defines the options used to create the mesh
  61353. * @param scene defines the hosting scene
  61354. * @returns the lathe mesh
  61355. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61356. */
  61357. static CreateLathe(name: string, options: {
  61358. shape: Vector3[];
  61359. radius?: number;
  61360. tessellation?: number;
  61361. clip?: number;
  61362. arc?: number;
  61363. closed?: boolean;
  61364. updatable?: boolean;
  61365. sideOrientation?: number;
  61366. frontUVs?: Vector4;
  61367. backUVs?: Vector4;
  61368. cap?: number;
  61369. invertUV?: boolean;
  61370. }, scene?: Nullable<Scene>): Mesh;
  61371. /**
  61372. * Creates a tiled plane mesh
  61373. * * You can set a limited pattern arrangement with the tiles
  61374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61377. * @param name defines the name of the mesh
  61378. * @param options defines the options used to create the mesh
  61379. * @param scene defines the hosting scene
  61380. * @returns the plane mesh
  61381. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61382. */
  61383. static CreateTiledPlane(name: string, options: {
  61384. pattern?: number;
  61385. tileSize?: number;
  61386. tileWidth?: number;
  61387. tileHeight?: number;
  61388. size?: number;
  61389. width?: number;
  61390. height?: number;
  61391. alignHorizontal?: number;
  61392. alignVertical?: number;
  61393. sideOrientation?: number;
  61394. frontUVs?: Vector4;
  61395. backUVs?: Vector4;
  61396. updatable?: boolean;
  61397. }, scene?: Nullable<Scene>): Mesh;
  61398. /**
  61399. * Creates a plane mesh
  61400. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61401. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61402. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61406. * @param name defines the name of the mesh
  61407. * @param options defines the options used to create the mesh
  61408. * @param scene defines the hosting scene
  61409. * @returns the plane mesh
  61410. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61411. */
  61412. static CreatePlane(name: string, options: {
  61413. size?: number;
  61414. width?: number;
  61415. height?: number;
  61416. sideOrientation?: number;
  61417. frontUVs?: Vector4;
  61418. backUVs?: Vector4;
  61419. updatable?: boolean;
  61420. sourcePlane?: Plane;
  61421. }, scene?: Nullable<Scene>): Mesh;
  61422. /**
  61423. * Creates a ground mesh
  61424. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61425. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61427. * @param name defines the name of the mesh
  61428. * @param options defines the options used to create the mesh
  61429. * @param scene defines the hosting scene
  61430. * @returns the ground mesh
  61431. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61432. */
  61433. static CreateGround(name: string, options: {
  61434. width?: number;
  61435. height?: number;
  61436. subdivisions?: number;
  61437. subdivisionsX?: number;
  61438. subdivisionsY?: number;
  61439. updatable?: boolean;
  61440. }, scene?: Nullable<Scene>): Mesh;
  61441. /**
  61442. * Creates a tiled ground mesh
  61443. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61444. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61445. * * 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
  61446. * * 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
  61447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61448. * @param name defines the name of the mesh
  61449. * @param options defines the options used to create the mesh
  61450. * @param scene defines the hosting scene
  61451. * @returns the tiled ground mesh
  61452. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61453. */
  61454. static CreateTiledGround(name: string, options: {
  61455. xmin: number;
  61456. zmin: number;
  61457. xmax: number;
  61458. zmax: number;
  61459. subdivisions?: {
  61460. w: number;
  61461. h: number;
  61462. };
  61463. precision?: {
  61464. w: number;
  61465. h: number;
  61466. };
  61467. updatable?: boolean;
  61468. }, scene?: Nullable<Scene>): Mesh;
  61469. /**
  61470. * Creates a ground mesh from a height map
  61471. * * The parameter `url` sets the URL of the height map image resource.
  61472. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61473. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61474. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61475. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61476. * * 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.
  61477. * * 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).
  61478. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61480. * @param name defines the name of the mesh
  61481. * @param url defines the url to the height map
  61482. * @param options defines the options used to create the mesh
  61483. * @param scene defines the hosting scene
  61484. * @returns the ground mesh
  61485. * @see https://doc.babylonjs.com/babylon101/height_map
  61486. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61487. */
  61488. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61489. width?: number;
  61490. height?: number;
  61491. subdivisions?: number;
  61492. minHeight?: number;
  61493. maxHeight?: number;
  61494. colorFilter?: Color3;
  61495. alphaFilter?: number;
  61496. updatable?: boolean;
  61497. onReady?: (mesh: GroundMesh) => void;
  61498. }, scene?: Nullable<Scene>): GroundMesh;
  61499. /**
  61500. * Creates a polygon mesh
  61501. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61502. * * 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
  61503. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61506. * * Remember you can only change the shape positions, not their number when updating a polygon
  61507. * @param name defines the name of the mesh
  61508. * @param options defines the options used to create the mesh
  61509. * @param scene defines the hosting scene
  61510. * @param earcutInjection can be used to inject your own earcut reference
  61511. * @returns the polygon mesh
  61512. */
  61513. static CreatePolygon(name: string, options: {
  61514. shape: Vector3[];
  61515. holes?: Vector3[][];
  61516. depth?: number;
  61517. faceUV?: Vector4[];
  61518. faceColors?: Color4[];
  61519. updatable?: boolean;
  61520. sideOrientation?: number;
  61521. frontUVs?: Vector4;
  61522. backUVs?: Vector4;
  61523. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61524. /**
  61525. * Creates an extruded polygon mesh, with depth in the Y direction.
  61526. * * 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)
  61527. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61528. * @param name defines the name of the mesh
  61529. * @param options defines the options used to create the mesh
  61530. * @param scene defines the hosting scene
  61531. * @param earcutInjection can be used to inject your own earcut reference
  61532. * @returns the polygon mesh
  61533. */
  61534. static ExtrudePolygon(name: string, options: {
  61535. shape: Vector3[];
  61536. holes?: Vector3[][];
  61537. depth?: number;
  61538. faceUV?: Vector4[];
  61539. faceColors?: Color4[];
  61540. updatable?: boolean;
  61541. sideOrientation?: number;
  61542. frontUVs?: Vector4;
  61543. backUVs?: Vector4;
  61544. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61545. /**
  61546. * Creates a tube mesh.
  61547. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61548. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61549. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61550. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61551. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61552. * * 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)
  61553. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61554. * * 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
  61555. * * 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
  61556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61558. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61560. * @param name defines the name of the mesh
  61561. * @param options defines the options used to create the mesh
  61562. * @param scene defines the hosting scene
  61563. * @returns the tube mesh
  61564. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61565. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61566. */
  61567. static CreateTube(name: string, options: {
  61568. path: Vector3[];
  61569. radius?: number;
  61570. tessellation?: number;
  61571. radiusFunction?: {
  61572. (i: number, distance: number): number;
  61573. };
  61574. cap?: number;
  61575. arc?: number;
  61576. updatable?: boolean;
  61577. sideOrientation?: number;
  61578. frontUVs?: Vector4;
  61579. backUVs?: Vector4;
  61580. instance?: Mesh;
  61581. invertUV?: boolean;
  61582. }, scene?: Nullable<Scene>): Mesh;
  61583. /**
  61584. * Creates a polyhedron mesh
  61585. * * 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
  61586. * * The parameter `size` (positive float, default 1) sets the polygon size
  61587. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61588. * * 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`
  61589. * * 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
  61590. * * 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)`)
  61591. * * 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
  61592. * * 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
  61593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61596. * @param name defines the name of the mesh
  61597. * @param options defines the options used to create the mesh
  61598. * @param scene defines the hosting scene
  61599. * @returns the polyhedron mesh
  61600. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61601. */
  61602. static CreatePolyhedron(name: string, options: {
  61603. type?: number;
  61604. size?: number;
  61605. sizeX?: number;
  61606. sizeY?: number;
  61607. sizeZ?: number;
  61608. custom?: any;
  61609. faceUV?: Vector4[];
  61610. faceColors?: Color4[];
  61611. flat?: boolean;
  61612. updatable?: boolean;
  61613. sideOrientation?: number;
  61614. frontUVs?: Vector4;
  61615. backUVs?: Vector4;
  61616. }, scene?: Nullable<Scene>): Mesh;
  61617. /**
  61618. * Creates a decal mesh.
  61619. * 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
  61620. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61621. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61622. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61623. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61624. * @param name defines the name of the mesh
  61625. * @param sourceMesh defines the mesh where the decal must be applied
  61626. * @param options defines the options used to create the mesh
  61627. * @param scene defines the hosting scene
  61628. * @returns the decal mesh
  61629. * @see https://doc.babylonjs.com/how_to/decals
  61630. */
  61631. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61632. position?: Vector3;
  61633. normal?: Vector3;
  61634. size?: Vector3;
  61635. angle?: number;
  61636. }): Mesh;
  61637. }
  61638. }
  61639. declare module "babylonjs/Meshes/meshSimplification" {
  61640. import { Mesh } from "babylonjs/Meshes/mesh";
  61641. /**
  61642. * A simplifier interface for future simplification implementations
  61643. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61644. */
  61645. export interface ISimplifier {
  61646. /**
  61647. * Simplification of a given mesh according to the given settings.
  61648. * Since this requires computation, it is assumed that the function runs async.
  61649. * @param settings The settings of the simplification, including quality and distance
  61650. * @param successCallback A callback that will be called after the mesh was simplified.
  61651. * @param errorCallback in case of an error, this callback will be called. optional.
  61652. */
  61653. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61654. }
  61655. /**
  61656. * Expected simplification settings.
  61657. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61658. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61659. */
  61660. export interface ISimplificationSettings {
  61661. /**
  61662. * Gets or sets the expected quality
  61663. */
  61664. quality: number;
  61665. /**
  61666. * Gets or sets the distance when this optimized version should be used
  61667. */
  61668. distance: number;
  61669. /**
  61670. * Gets an already optimized mesh
  61671. */
  61672. optimizeMesh?: boolean;
  61673. }
  61674. /**
  61675. * Class used to specify simplification options
  61676. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61677. */
  61678. export class SimplificationSettings implements ISimplificationSettings {
  61679. /** expected quality */
  61680. quality: number;
  61681. /** distance when this optimized version should be used */
  61682. distance: number;
  61683. /** already optimized mesh */
  61684. optimizeMesh?: boolean | undefined;
  61685. /**
  61686. * Creates a SimplificationSettings
  61687. * @param quality expected quality
  61688. * @param distance distance when this optimized version should be used
  61689. * @param optimizeMesh already optimized mesh
  61690. */
  61691. constructor(
  61692. /** expected quality */
  61693. quality: number,
  61694. /** distance when this optimized version should be used */
  61695. distance: number,
  61696. /** already optimized mesh */
  61697. optimizeMesh?: boolean | undefined);
  61698. }
  61699. /**
  61700. * Interface used to define a simplification task
  61701. */
  61702. export interface ISimplificationTask {
  61703. /**
  61704. * Array of settings
  61705. */
  61706. settings: Array<ISimplificationSettings>;
  61707. /**
  61708. * Simplification type
  61709. */
  61710. simplificationType: SimplificationType;
  61711. /**
  61712. * Mesh to simplify
  61713. */
  61714. mesh: Mesh;
  61715. /**
  61716. * Callback called on success
  61717. */
  61718. successCallback?: () => void;
  61719. /**
  61720. * Defines if parallel processing can be used
  61721. */
  61722. parallelProcessing: boolean;
  61723. }
  61724. /**
  61725. * Queue used to order the simplification tasks
  61726. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61727. */
  61728. export class SimplificationQueue {
  61729. private _simplificationArray;
  61730. /**
  61731. * Gets a boolean indicating that the process is still running
  61732. */
  61733. running: boolean;
  61734. /**
  61735. * Creates a new queue
  61736. */
  61737. constructor();
  61738. /**
  61739. * Adds a new simplification task
  61740. * @param task defines a task to add
  61741. */
  61742. addTask(task: ISimplificationTask): void;
  61743. /**
  61744. * Execute next task
  61745. */
  61746. executeNext(): void;
  61747. /**
  61748. * Execute a simplification task
  61749. * @param task defines the task to run
  61750. */
  61751. runSimplification(task: ISimplificationTask): void;
  61752. private getSimplifier;
  61753. }
  61754. /**
  61755. * The implemented types of simplification
  61756. * At the moment only Quadratic Error Decimation is implemented
  61757. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61758. */
  61759. export enum SimplificationType {
  61760. /** Quadratic error decimation */
  61761. QUADRATIC = 0
  61762. }
  61763. }
  61764. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61765. import { Scene } from "babylonjs/scene";
  61766. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61767. import { ISceneComponent } from "babylonjs/sceneComponent";
  61768. module "babylonjs/scene" {
  61769. interface Scene {
  61770. /** @hidden (Backing field) */
  61771. _simplificationQueue: SimplificationQueue;
  61772. /**
  61773. * Gets or sets the simplification queue attached to the scene
  61774. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61775. */
  61776. simplificationQueue: SimplificationQueue;
  61777. }
  61778. }
  61779. module "babylonjs/Meshes/mesh" {
  61780. interface Mesh {
  61781. /**
  61782. * Simplify the mesh according to the given array of settings.
  61783. * Function will return immediately and will simplify async
  61784. * @param settings a collection of simplification settings
  61785. * @param parallelProcessing should all levels calculate parallel or one after the other
  61786. * @param simplificationType the type of simplification to run
  61787. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61788. * @returns the current mesh
  61789. */
  61790. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61791. }
  61792. }
  61793. /**
  61794. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61795. * created in a scene
  61796. */
  61797. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61798. /**
  61799. * The component name helpfull to identify the component in the list of scene components.
  61800. */
  61801. readonly name: string;
  61802. /**
  61803. * The scene the component belongs to.
  61804. */
  61805. scene: Scene;
  61806. /**
  61807. * Creates a new instance of the component for the given scene
  61808. * @param scene Defines the scene to register the component in
  61809. */
  61810. constructor(scene: Scene);
  61811. /**
  61812. * Registers the component in a given scene
  61813. */
  61814. register(): void;
  61815. /**
  61816. * Rebuilds the elements related to this component in case of
  61817. * context lost for instance.
  61818. */
  61819. rebuild(): void;
  61820. /**
  61821. * Disposes the component and the associated ressources
  61822. */
  61823. dispose(): void;
  61824. private _beforeCameraUpdate;
  61825. }
  61826. }
  61827. declare module "babylonjs/Meshes/Builders/index" {
  61828. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61829. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61830. export * from "babylonjs/Meshes/Builders/discBuilder";
  61831. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61832. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61833. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61834. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61835. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61836. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61837. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61838. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61839. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61840. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61841. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61842. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61843. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61844. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61845. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61846. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61847. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61848. }
  61849. declare module "babylonjs/Meshes/index" {
  61850. export * from "babylonjs/Meshes/abstractMesh";
  61851. export * from "babylonjs/Meshes/buffer";
  61852. export * from "babylonjs/Meshes/Compression/index";
  61853. export * from "babylonjs/Meshes/csg";
  61854. export * from "babylonjs/Meshes/geometry";
  61855. export * from "babylonjs/Meshes/groundMesh";
  61856. export * from "babylonjs/Meshes/trailMesh";
  61857. export * from "babylonjs/Meshes/instancedMesh";
  61858. export * from "babylonjs/Meshes/linesMesh";
  61859. export * from "babylonjs/Meshes/mesh";
  61860. export * from "babylonjs/Meshes/mesh.vertexData";
  61861. export * from "babylonjs/Meshes/meshBuilder";
  61862. export * from "babylonjs/Meshes/meshSimplification";
  61863. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61864. export * from "babylonjs/Meshes/polygonMesh";
  61865. export * from "babylonjs/Meshes/subMesh";
  61866. export * from "babylonjs/Meshes/meshLODLevel";
  61867. export * from "babylonjs/Meshes/transformNode";
  61868. export * from "babylonjs/Meshes/Builders/index";
  61869. export * from "babylonjs/Meshes/dataBuffer";
  61870. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61871. }
  61872. declare module "babylonjs/Morph/index" {
  61873. export * from "babylonjs/Morph/morphTarget";
  61874. export * from "babylonjs/Morph/morphTargetManager";
  61875. }
  61876. declare module "babylonjs/Navigation/INavigationEngine" {
  61877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61878. import { Vector3 } from "babylonjs/Maths/math";
  61879. import { Mesh } from "babylonjs/Meshes/mesh";
  61880. import { Scene } from "babylonjs/scene";
  61881. /**
  61882. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61883. */
  61884. export interface INavigationEnginePlugin {
  61885. /**
  61886. * plugin name
  61887. */
  61888. name: string;
  61889. /**
  61890. * Creates a navigation mesh
  61891. * @param meshes array of all the geometry used to compute the navigatio mesh
  61892. * @param parameters bunch of parameters used to filter geometry
  61893. */
  61894. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61895. /**
  61896. * Create a navigation mesh debug mesh
  61897. * @param scene is where the mesh will be added
  61898. * @returns debug display mesh
  61899. */
  61900. createDebugNavMesh(scene: Scene): Mesh;
  61901. /**
  61902. * Get a navigation mesh constrained position, closest to the parameter position
  61903. * @param position world position
  61904. * @returns the closest point to position constrained by the navigation mesh
  61905. */
  61906. getClosestPoint(position: Vector3): Vector3;
  61907. /**
  61908. * Get a navigation mesh constrained position, within a particular radius
  61909. * @param position world position
  61910. * @param maxRadius the maximum distance to the constrained world position
  61911. * @returns the closest point to position constrained by the navigation mesh
  61912. */
  61913. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61914. /**
  61915. * Compute the final position from a segment made of destination-position
  61916. * @param position world position
  61917. * @param destination world position
  61918. * @returns the resulting point along the navmesh
  61919. */
  61920. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61921. /**
  61922. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61923. * @param start world position
  61924. * @param end world position
  61925. * @returns array containing world position composing the path
  61926. */
  61927. computePath(start: Vector3, end: Vector3): Vector3[];
  61928. /**
  61929. * If this plugin is supported
  61930. * @returns true if plugin is supported
  61931. */
  61932. isSupported(): boolean;
  61933. /**
  61934. * Create a new Crowd so you can add agents
  61935. * @param maxAgents the maximum agent count in the crowd
  61936. * @param maxAgentRadius the maximum radius an agent can have
  61937. * @param scene to attach the crowd to
  61938. * @returns the crowd you can add agents to
  61939. */
  61940. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61941. /**
  61942. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61943. * The queries will try to find a solution within those bounds
  61944. * default is (1,1,1)
  61945. * @param extent x,y,z value that define the extent around the queries point of reference
  61946. */
  61947. setDefaultQueryExtent(extent: Vector3): void;
  61948. /**
  61949. * Get the Bounding box extent specified by setDefaultQueryExtent
  61950. * @returns the box extent values
  61951. */
  61952. getDefaultQueryExtent(): Vector3;
  61953. /**
  61954. * Release all resources
  61955. */
  61956. dispose(): void;
  61957. }
  61958. /**
  61959. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61960. */
  61961. export interface ICrowd {
  61962. /**
  61963. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61964. * You can attach anything to that node. The node position is updated in the scene update tick.
  61965. * @param pos world position that will be constrained by the navigation mesh
  61966. * @param parameters agent parameters
  61967. * @param transform hooked to the agent that will be update by the scene
  61968. * @returns agent index
  61969. */
  61970. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61971. /**
  61972. * Returns the agent position in world space
  61973. * @param index agent index returned by addAgent
  61974. * @returns world space position
  61975. */
  61976. getAgentPosition(index: number): Vector3;
  61977. /**
  61978. * Gets the agent velocity in world space
  61979. * @param index agent index returned by addAgent
  61980. * @returns world space velocity
  61981. */
  61982. getAgentVelocity(index: number): Vector3;
  61983. /**
  61984. * remove a particular agent previously created
  61985. * @param index agent index returned by addAgent
  61986. */
  61987. removeAgent(index: number): void;
  61988. /**
  61989. * get the list of all agents attached to this crowd
  61990. * @returns list of agent indices
  61991. */
  61992. getAgents(): number[];
  61993. /**
  61994. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61995. * @param deltaTime in seconds
  61996. */
  61997. update(deltaTime: number): void;
  61998. /**
  61999. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62000. * @param index agent index returned by addAgent
  62001. * @param destination targeted world position
  62002. */
  62003. agentGoto(index: number, destination: Vector3): void;
  62004. /**
  62005. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62006. * The queries will try to find a solution within those bounds
  62007. * default is (1,1,1)
  62008. * @param extent x,y,z value that define the extent around the queries point of reference
  62009. */
  62010. setDefaultQueryExtent(extent: Vector3): void;
  62011. /**
  62012. * Get the Bounding box extent specified by setDefaultQueryExtent
  62013. * @returns the box extent values
  62014. */
  62015. getDefaultQueryExtent(): Vector3;
  62016. /**
  62017. * Release all resources
  62018. */
  62019. dispose(): void;
  62020. }
  62021. /**
  62022. * Configures an agent
  62023. */
  62024. export interface IAgentParameters {
  62025. /**
  62026. * Agent radius. [Limit: >= 0]
  62027. */
  62028. radius: number;
  62029. /**
  62030. * Agent height. [Limit: > 0]
  62031. */
  62032. height: number;
  62033. /**
  62034. * Maximum allowed acceleration. [Limit: >= 0]
  62035. */
  62036. maxAcceleration: number;
  62037. /**
  62038. * Maximum allowed speed. [Limit: >= 0]
  62039. */
  62040. maxSpeed: number;
  62041. /**
  62042. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62043. */
  62044. collisionQueryRange: number;
  62045. /**
  62046. * The path visibility optimization range. [Limit: > 0]
  62047. */
  62048. pathOptimizationRange: number;
  62049. /**
  62050. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62051. */
  62052. separationWeight: number;
  62053. }
  62054. /**
  62055. * Configures the navigation mesh creation
  62056. */
  62057. export interface INavMeshParameters {
  62058. /**
  62059. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62060. */
  62061. cs: number;
  62062. /**
  62063. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62064. */
  62065. ch: number;
  62066. /**
  62067. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62068. */
  62069. walkableSlopeAngle: number;
  62070. /**
  62071. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62072. * be considered walkable. [Limit: >= 3] [Units: vx]
  62073. */
  62074. walkableHeight: number;
  62075. /**
  62076. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62077. */
  62078. walkableClimb: number;
  62079. /**
  62080. * The distance to erode/shrink the walkable area of the heightfield away from
  62081. * obstructions. [Limit: >=0] [Units: vx]
  62082. */
  62083. walkableRadius: number;
  62084. /**
  62085. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62086. */
  62087. maxEdgeLen: number;
  62088. /**
  62089. * The maximum distance a simplfied contour's border edges should deviate
  62090. * the original raw contour. [Limit: >=0] [Units: vx]
  62091. */
  62092. maxSimplificationError: number;
  62093. /**
  62094. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62095. */
  62096. minRegionArea: number;
  62097. /**
  62098. * Any regions with a span count smaller than this value will, if possible,
  62099. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62100. */
  62101. mergeRegionArea: number;
  62102. /**
  62103. * The maximum number of vertices allowed for polygons generated during the
  62104. * contour to polygon conversion process. [Limit: >= 3]
  62105. */
  62106. maxVertsPerPoly: number;
  62107. /**
  62108. * Sets the sampling distance to use when generating the detail mesh.
  62109. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62110. */
  62111. detailSampleDist: number;
  62112. /**
  62113. * The maximum distance the detail mesh surface should deviate from heightfield
  62114. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62115. */
  62116. detailSampleMaxError: number;
  62117. }
  62118. }
  62119. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  62120. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  62121. import { Mesh } from "babylonjs/Meshes/mesh";
  62122. import { Scene } from "babylonjs/scene";
  62123. import { Vector3 } from "babylonjs/Maths/math";
  62124. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62125. /**
  62126. * RecastJS navigation plugin
  62127. */
  62128. export class RecastJSPlugin implements INavigationEnginePlugin {
  62129. /**
  62130. * Reference to the Recast library
  62131. */
  62132. bjsRECAST: any;
  62133. /**
  62134. * plugin name
  62135. */
  62136. name: string;
  62137. /**
  62138. * the first navmesh created. We might extend this to support multiple navmeshes
  62139. */
  62140. navMesh: any;
  62141. /**
  62142. * Initializes the recastJS plugin
  62143. * @param recastInjection can be used to inject your own recast reference
  62144. */
  62145. constructor(recastInjection?: any);
  62146. /**
  62147. * Creates a navigation mesh
  62148. * @param meshes array of all the geometry used to compute the navigatio mesh
  62149. * @param parameters bunch of parameters used to filter geometry
  62150. */
  62151. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62152. /**
  62153. * Create a navigation mesh debug mesh
  62154. * @param scene is where the mesh will be added
  62155. * @returns debug display mesh
  62156. */
  62157. createDebugNavMesh(scene: Scene): Mesh;
  62158. /**
  62159. * Get a navigation mesh constrained position, closest to the parameter position
  62160. * @param position world position
  62161. * @returns the closest point to position constrained by the navigation mesh
  62162. */
  62163. getClosestPoint(position: Vector3): Vector3;
  62164. /**
  62165. * Get a navigation mesh constrained position, within a particular radius
  62166. * @param position world position
  62167. * @param maxRadius the maximum distance to the constrained world position
  62168. * @returns the closest point to position constrained by the navigation mesh
  62169. */
  62170. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62171. /**
  62172. * Compute the final position from a segment made of destination-position
  62173. * @param position world position
  62174. * @param destination world position
  62175. * @returns the resulting point along the navmesh
  62176. */
  62177. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62178. /**
  62179. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62180. * @param start world position
  62181. * @param end world position
  62182. * @returns array containing world position composing the path
  62183. */
  62184. computePath(start: Vector3, end: Vector3): Vector3[];
  62185. /**
  62186. * Create a new Crowd so you can add agents
  62187. * @param maxAgents the maximum agent count in the crowd
  62188. * @param maxAgentRadius the maximum radius an agent can have
  62189. * @param scene to attach the crowd to
  62190. * @returns the crowd you can add agents to
  62191. */
  62192. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62193. /**
  62194. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62195. * The queries will try to find a solution within those bounds
  62196. * default is (1,1,1)
  62197. * @param extent x,y,z value that define the extent around the queries point of reference
  62198. */
  62199. setDefaultQueryExtent(extent: Vector3): void;
  62200. /**
  62201. * Get the Bounding box extent specified by setDefaultQueryExtent
  62202. * @returns the box extent values
  62203. */
  62204. getDefaultQueryExtent(): Vector3;
  62205. /**
  62206. * Disposes
  62207. */
  62208. dispose(): void;
  62209. /**
  62210. * If this plugin is supported
  62211. * @returns true if plugin is supported
  62212. */
  62213. isSupported(): boolean;
  62214. }
  62215. /**
  62216. * Recast detour crowd implementation
  62217. */
  62218. export class RecastJSCrowd implements ICrowd {
  62219. /**
  62220. * Recast/detour plugin
  62221. */
  62222. bjsRECASTPlugin: RecastJSPlugin;
  62223. /**
  62224. * Link to the detour crowd
  62225. */
  62226. recastCrowd: any;
  62227. /**
  62228. * One transform per agent
  62229. */
  62230. transforms: TransformNode[];
  62231. /**
  62232. * All agents created
  62233. */
  62234. agents: number[];
  62235. /**
  62236. * Link to the scene is kept to unregister the crowd from the scene
  62237. */
  62238. private _scene;
  62239. /**
  62240. * Observer for crowd updates
  62241. */
  62242. private _onBeforeAnimationsObserver;
  62243. /**
  62244. * Constructor
  62245. * @param plugin recastJS plugin
  62246. * @param maxAgents the maximum agent count in the crowd
  62247. * @param maxAgentRadius the maximum radius an agent can have
  62248. * @param scene to attach the crowd to
  62249. * @returns the crowd you can add agents to
  62250. */
  62251. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62252. /**
  62253. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62254. * You can attach anything to that node. The node position is updated in the scene update tick.
  62255. * @param pos world position that will be constrained by the navigation mesh
  62256. * @param parameters agent parameters
  62257. * @param transform hooked to the agent that will be update by the scene
  62258. * @returns agent index
  62259. */
  62260. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62261. /**
  62262. * Returns the agent position in world space
  62263. * @param index agent index returned by addAgent
  62264. * @returns world space position
  62265. */
  62266. getAgentPosition(index: number): Vector3;
  62267. /**
  62268. * Returns the agent velocity in world space
  62269. * @param index agent index returned by addAgent
  62270. * @returns world space velocity
  62271. */
  62272. getAgentVelocity(index: number): Vector3;
  62273. /**
  62274. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62275. * @param index agent index returned by addAgent
  62276. * @param destination targeted world position
  62277. */
  62278. agentGoto(index: number, destination: Vector3): void;
  62279. /**
  62280. * remove a particular agent previously created
  62281. * @param index agent index returned by addAgent
  62282. */
  62283. removeAgent(index: number): void;
  62284. /**
  62285. * get the list of all agents attached to this crowd
  62286. * @returns list of agent indices
  62287. */
  62288. getAgents(): number[];
  62289. /**
  62290. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62291. * @param deltaTime in seconds
  62292. */
  62293. update(deltaTime: number): void;
  62294. /**
  62295. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62296. * The queries will try to find a solution within those bounds
  62297. * default is (1,1,1)
  62298. * @param extent x,y,z value that define the extent around the queries point of reference
  62299. */
  62300. setDefaultQueryExtent(extent: Vector3): void;
  62301. /**
  62302. * Get the Bounding box extent specified by setDefaultQueryExtent
  62303. * @returns the box extent values
  62304. */
  62305. getDefaultQueryExtent(): Vector3;
  62306. /**
  62307. * Release all resources
  62308. */
  62309. dispose(): void;
  62310. }
  62311. }
  62312. declare module "babylonjs/Navigation/Plugins/index" {
  62313. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  62314. }
  62315. declare module "babylonjs/Navigation/index" {
  62316. export * from "babylonjs/Navigation/INavigationEngine";
  62317. export * from "babylonjs/Navigation/Plugins/index";
  62318. }
  62319. declare module "babylonjs/Offline/database" {
  62320. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  62321. /**
  62322. * Class used to enable access to IndexedDB
  62323. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62324. */
  62325. export class Database implements IOfflineProvider {
  62326. private _callbackManifestChecked;
  62327. private _currentSceneUrl;
  62328. private _db;
  62329. private _enableSceneOffline;
  62330. private _enableTexturesOffline;
  62331. private _manifestVersionFound;
  62332. private _mustUpdateRessources;
  62333. private _hasReachedQuota;
  62334. private _isSupported;
  62335. private _idbFactory;
  62336. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62337. private static IsUASupportingBlobStorage;
  62338. /**
  62339. * Gets a boolean indicating if Database storate is enabled (off by default)
  62340. */
  62341. static IDBStorageEnabled: boolean;
  62342. /**
  62343. * Gets a boolean indicating if scene must be saved in the database
  62344. */
  62345. readonly enableSceneOffline: boolean;
  62346. /**
  62347. * Gets a boolean indicating if textures must be saved in the database
  62348. */
  62349. readonly enableTexturesOffline: boolean;
  62350. /**
  62351. * Creates a new Database
  62352. * @param urlToScene defines the url to load the scene
  62353. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62354. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62355. */
  62356. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62357. private static _ParseURL;
  62358. private static _ReturnFullUrlLocation;
  62359. private _checkManifestFile;
  62360. /**
  62361. * Open the database and make it available
  62362. * @param successCallback defines the callback to call on success
  62363. * @param errorCallback defines the callback to call on error
  62364. */
  62365. open(successCallback: () => void, errorCallback: () => void): void;
  62366. /**
  62367. * Loads an image from the database
  62368. * @param url defines the url to load from
  62369. * @param image defines the target DOM image
  62370. */
  62371. loadImage(url: string, image: HTMLImageElement): void;
  62372. private _loadImageFromDBAsync;
  62373. private _saveImageIntoDBAsync;
  62374. private _checkVersionFromDB;
  62375. private _loadVersionFromDBAsync;
  62376. private _saveVersionIntoDBAsync;
  62377. /**
  62378. * Loads a file from database
  62379. * @param url defines the URL to load from
  62380. * @param sceneLoaded defines a callback to call on success
  62381. * @param progressCallBack defines a callback to call when progress changed
  62382. * @param errorCallback defines a callback to call on error
  62383. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62384. */
  62385. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62386. private _loadFileAsync;
  62387. private _saveFileAsync;
  62388. /**
  62389. * Validates if xhr data is correct
  62390. * @param xhr defines the request to validate
  62391. * @param dataType defines the expected data type
  62392. * @returns true if data is correct
  62393. */
  62394. private static _ValidateXHRData;
  62395. }
  62396. }
  62397. declare module "babylonjs/Offline/index" {
  62398. export * from "babylonjs/Offline/database";
  62399. export * from "babylonjs/Offline/IOfflineProvider";
  62400. }
  62401. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  62402. /** @hidden */
  62403. export var gpuUpdateParticlesPixelShader: {
  62404. name: string;
  62405. shader: string;
  62406. };
  62407. }
  62408. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  62409. /** @hidden */
  62410. export var gpuUpdateParticlesVertexShader: {
  62411. name: string;
  62412. shader: string;
  62413. };
  62414. }
  62415. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  62416. /** @hidden */
  62417. export var clipPlaneFragmentDeclaration2: {
  62418. name: string;
  62419. shader: string;
  62420. };
  62421. }
  62422. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  62423. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  62424. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62425. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62426. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62427. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  62428. /** @hidden */
  62429. export var gpuRenderParticlesPixelShader: {
  62430. name: string;
  62431. shader: string;
  62432. };
  62433. }
  62434. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  62435. /** @hidden */
  62436. export var clipPlaneVertexDeclaration2: {
  62437. name: string;
  62438. shader: string;
  62439. };
  62440. }
  62441. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  62442. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  62443. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  62444. /** @hidden */
  62445. export var gpuRenderParticlesVertexShader: {
  62446. name: string;
  62447. shader: string;
  62448. };
  62449. }
  62450. declare module "babylonjs/Particles/gpuParticleSystem" {
  62451. import { Nullable } from "babylonjs/types";
  62452. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  62453. import { Observable } from "babylonjs/Misc/observable";
  62454. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62455. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62456. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  62457. import { Scene, IDisposable } from "babylonjs/scene";
  62458. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  62459. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62460. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  62461. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  62462. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  62463. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  62464. /**
  62465. * This represents a GPU particle system in Babylon
  62466. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62467. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62468. */
  62469. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62470. /**
  62471. * The layer mask we are rendering the particles through.
  62472. */
  62473. layerMask: number;
  62474. private _capacity;
  62475. private _activeCount;
  62476. private _currentActiveCount;
  62477. private _accumulatedCount;
  62478. private _renderEffect;
  62479. private _updateEffect;
  62480. private _buffer0;
  62481. private _buffer1;
  62482. private _spriteBuffer;
  62483. private _updateVAO;
  62484. private _renderVAO;
  62485. private _targetIndex;
  62486. private _sourceBuffer;
  62487. private _targetBuffer;
  62488. private _engine;
  62489. private _currentRenderId;
  62490. private _started;
  62491. private _stopped;
  62492. private _timeDelta;
  62493. private _randomTexture;
  62494. private _randomTexture2;
  62495. private _attributesStrideSize;
  62496. private _updateEffectOptions;
  62497. private _randomTextureSize;
  62498. private _actualFrame;
  62499. private readonly _rawTextureWidth;
  62500. /**
  62501. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62502. */
  62503. static readonly IsSupported: boolean;
  62504. /**
  62505. * An event triggered when the system is disposed.
  62506. */
  62507. onDisposeObservable: Observable<GPUParticleSystem>;
  62508. /**
  62509. * Gets the maximum number of particles active at the same time.
  62510. * @returns The max number of active particles.
  62511. */
  62512. getCapacity(): number;
  62513. /**
  62514. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62515. * to override the particles.
  62516. */
  62517. forceDepthWrite: boolean;
  62518. /**
  62519. * Gets or set the number of active particles
  62520. */
  62521. activeParticleCount: number;
  62522. private _preWarmDone;
  62523. /**
  62524. * Is this system ready to be used/rendered
  62525. * @return true if the system is ready
  62526. */
  62527. isReady(): boolean;
  62528. /**
  62529. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62530. * @returns True if it has been started, otherwise false.
  62531. */
  62532. isStarted(): boolean;
  62533. /**
  62534. * Starts the particle system and begins to emit
  62535. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62536. */
  62537. start(delay?: number): void;
  62538. /**
  62539. * Stops the particle system.
  62540. */
  62541. stop(): void;
  62542. /**
  62543. * Remove all active particles
  62544. */
  62545. reset(): void;
  62546. /**
  62547. * Returns the string "GPUParticleSystem"
  62548. * @returns a string containing the class name
  62549. */
  62550. getClassName(): string;
  62551. private _colorGradientsTexture;
  62552. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62553. /**
  62554. * Adds a new color gradient
  62555. * @param gradient defines the gradient to use (between 0 and 1)
  62556. * @param color1 defines the color to affect to the specified gradient
  62557. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62558. * @returns the current particle system
  62559. */
  62560. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62561. /**
  62562. * Remove a specific color gradient
  62563. * @param gradient defines the gradient to remove
  62564. * @returns the current particle system
  62565. */
  62566. removeColorGradient(gradient: number): GPUParticleSystem;
  62567. private _angularSpeedGradientsTexture;
  62568. private _sizeGradientsTexture;
  62569. private _velocityGradientsTexture;
  62570. private _limitVelocityGradientsTexture;
  62571. private _dragGradientsTexture;
  62572. private _addFactorGradient;
  62573. /**
  62574. * Adds a new size gradient
  62575. * @param gradient defines the gradient to use (between 0 and 1)
  62576. * @param factor defines the size factor to affect to the specified gradient
  62577. * @returns the current particle system
  62578. */
  62579. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62580. /**
  62581. * Remove a specific size gradient
  62582. * @param gradient defines the gradient to remove
  62583. * @returns the current particle system
  62584. */
  62585. removeSizeGradient(gradient: number): GPUParticleSystem;
  62586. /**
  62587. * Adds a new angular speed gradient
  62588. * @param gradient defines the gradient to use (between 0 and 1)
  62589. * @param factor defines the angular speed to affect to the specified gradient
  62590. * @returns the current particle system
  62591. */
  62592. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62593. /**
  62594. * Remove a specific angular speed gradient
  62595. * @param gradient defines the gradient to remove
  62596. * @returns the current particle system
  62597. */
  62598. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62599. /**
  62600. * Adds a new velocity gradient
  62601. * @param gradient defines the gradient to use (between 0 and 1)
  62602. * @param factor defines the velocity to affect to the specified gradient
  62603. * @returns the current particle system
  62604. */
  62605. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62606. /**
  62607. * Remove a specific velocity gradient
  62608. * @param gradient defines the gradient to remove
  62609. * @returns the current particle system
  62610. */
  62611. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62612. /**
  62613. * Adds a new limit velocity gradient
  62614. * @param gradient defines the gradient to use (between 0 and 1)
  62615. * @param factor defines the limit velocity value to affect to the specified gradient
  62616. * @returns the current particle system
  62617. */
  62618. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62619. /**
  62620. * Remove a specific limit velocity gradient
  62621. * @param gradient defines the gradient to remove
  62622. * @returns the current particle system
  62623. */
  62624. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62625. /**
  62626. * Adds a new drag gradient
  62627. * @param gradient defines the gradient to use (between 0 and 1)
  62628. * @param factor defines the drag value to affect to the specified gradient
  62629. * @returns the current particle system
  62630. */
  62631. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62632. /**
  62633. * Remove a specific drag gradient
  62634. * @param gradient defines the gradient to remove
  62635. * @returns the current particle system
  62636. */
  62637. removeDragGradient(gradient: number): GPUParticleSystem;
  62638. /**
  62639. * Not supported by GPUParticleSystem
  62640. * @param gradient defines the gradient to use (between 0 and 1)
  62641. * @param factor defines the emit rate value to affect to the specified gradient
  62642. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62643. * @returns the current particle system
  62644. */
  62645. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62646. /**
  62647. * Not supported by GPUParticleSystem
  62648. * @param gradient defines the gradient to remove
  62649. * @returns the current particle system
  62650. */
  62651. removeEmitRateGradient(gradient: number): IParticleSystem;
  62652. /**
  62653. * Not supported by GPUParticleSystem
  62654. * @param gradient defines the gradient to use (between 0 and 1)
  62655. * @param factor defines the start size value to affect to the specified gradient
  62656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62657. * @returns the current particle system
  62658. */
  62659. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62660. /**
  62661. * Not supported by GPUParticleSystem
  62662. * @param gradient defines the gradient to remove
  62663. * @returns the current particle system
  62664. */
  62665. removeStartSizeGradient(gradient: number): IParticleSystem;
  62666. /**
  62667. * Not supported by GPUParticleSystem
  62668. * @param gradient defines the gradient to use (between 0 and 1)
  62669. * @param min defines the color remap minimal range
  62670. * @param max defines the color remap maximal range
  62671. * @returns the current particle system
  62672. */
  62673. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62674. /**
  62675. * Not supported by GPUParticleSystem
  62676. * @param gradient defines the gradient to remove
  62677. * @returns the current particle system
  62678. */
  62679. removeColorRemapGradient(): IParticleSystem;
  62680. /**
  62681. * Not supported by GPUParticleSystem
  62682. * @param gradient defines the gradient to use (between 0 and 1)
  62683. * @param min defines the alpha remap minimal range
  62684. * @param max defines the alpha remap maximal range
  62685. * @returns the current particle system
  62686. */
  62687. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62688. /**
  62689. * Not supported by GPUParticleSystem
  62690. * @param gradient defines the gradient to remove
  62691. * @returns the current particle system
  62692. */
  62693. removeAlphaRemapGradient(): IParticleSystem;
  62694. /**
  62695. * Not supported by GPUParticleSystem
  62696. * @param gradient defines the gradient to use (between 0 and 1)
  62697. * @param color defines the color to affect to the specified gradient
  62698. * @returns the current particle system
  62699. */
  62700. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62701. /**
  62702. * Not supported by GPUParticleSystem
  62703. * @param gradient defines the gradient to remove
  62704. * @returns the current particle system
  62705. */
  62706. removeRampGradient(): IParticleSystem;
  62707. /**
  62708. * Not supported by GPUParticleSystem
  62709. * @returns the list of ramp gradients
  62710. */
  62711. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62712. /**
  62713. * Not supported by GPUParticleSystem
  62714. * Gets or sets a boolean indicating that ramp gradients must be used
  62715. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62716. */
  62717. useRampGradients: boolean;
  62718. /**
  62719. * Not supported by GPUParticleSystem
  62720. * @param gradient defines the gradient to use (between 0 and 1)
  62721. * @param factor defines the life time factor to affect to the specified gradient
  62722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62723. * @returns the current particle system
  62724. */
  62725. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62726. /**
  62727. * Not supported by GPUParticleSystem
  62728. * @param gradient defines the gradient to remove
  62729. * @returns the current particle system
  62730. */
  62731. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62732. /**
  62733. * Instantiates a GPU particle system.
  62734. * 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.
  62735. * @param name The name of the particle system
  62736. * @param options The options used to create the system
  62737. * @param scene The scene the particle system belongs to
  62738. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62739. */
  62740. constructor(name: string, options: Partial<{
  62741. capacity: number;
  62742. randomTextureSize: number;
  62743. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62744. protected _reset(): void;
  62745. private _createUpdateVAO;
  62746. private _createRenderVAO;
  62747. private _initialize;
  62748. /** @hidden */
  62749. _recreateUpdateEffect(): void;
  62750. /** @hidden */
  62751. _recreateRenderEffect(): void;
  62752. /**
  62753. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62754. * @param preWarm defines if we are in the pre-warmimg phase
  62755. */
  62756. animate(preWarm?: boolean): void;
  62757. private _createFactorGradientTexture;
  62758. private _createSizeGradientTexture;
  62759. private _createAngularSpeedGradientTexture;
  62760. private _createVelocityGradientTexture;
  62761. private _createLimitVelocityGradientTexture;
  62762. private _createDragGradientTexture;
  62763. private _createColorGradientTexture;
  62764. /**
  62765. * Renders the particle system in its current state
  62766. * @param preWarm defines if the system should only update the particles but not render them
  62767. * @returns the current number of particles
  62768. */
  62769. render(preWarm?: boolean): number;
  62770. /**
  62771. * Rebuilds the particle system
  62772. */
  62773. rebuild(): void;
  62774. private _releaseBuffers;
  62775. private _releaseVAOs;
  62776. /**
  62777. * Disposes the particle system and free the associated resources
  62778. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62779. */
  62780. dispose(disposeTexture?: boolean): void;
  62781. /**
  62782. * Clones the particle system.
  62783. * @param name The name of the cloned object
  62784. * @param newEmitter The new emitter to use
  62785. * @returns the cloned particle system
  62786. */
  62787. clone(name: string, newEmitter: any): GPUParticleSystem;
  62788. /**
  62789. * Serializes the particle system to a JSON object.
  62790. * @returns the JSON object
  62791. */
  62792. serialize(): any;
  62793. /**
  62794. * Parses a JSON object to create a GPU particle system.
  62795. * @param parsedParticleSystem The JSON object to parse
  62796. * @param scene The scene to create the particle system in
  62797. * @param rootUrl The root url to use to load external dependencies like texture
  62798. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62799. * @returns the parsed GPU particle system
  62800. */
  62801. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62802. }
  62803. }
  62804. declare module "babylonjs/Particles/particleSystemSet" {
  62805. import { Nullable } from "babylonjs/types";
  62806. import { Color3 } from "babylonjs/Maths/math.color";
  62807. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62809. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62810. import { Scene, IDisposable } from "babylonjs/scene";
  62811. /**
  62812. * Represents a set of particle systems working together to create a specific effect
  62813. */
  62814. export class ParticleSystemSet implements IDisposable {
  62815. /**
  62816. * Gets or sets base Assets URL
  62817. */
  62818. static BaseAssetsUrl: string;
  62819. private _emitterCreationOptions;
  62820. private _emitterNode;
  62821. /**
  62822. * Gets the particle system list
  62823. */
  62824. systems: IParticleSystem[];
  62825. /**
  62826. * Gets the emitter node used with this set
  62827. */
  62828. readonly emitterNode: Nullable<TransformNode>;
  62829. /**
  62830. * Creates a new emitter mesh as a sphere
  62831. * @param options defines the options used to create the sphere
  62832. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62833. * @param scene defines the hosting scene
  62834. */
  62835. setEmitterAsSphere(options: {
  62836. diameter: number;
  62837. segments: number;
  62838. color: Color3;
  62839. }, renderingGroupId: number, scene: Scene): void;
  62840. /**
  62841. * Starts all particle systems of the set
  62842. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62843. */
  62844. start(emitter?: AbstractMesh): void;
  62845. /**
  62846. * Release all associated resources
  62847. */
  62848. dispose(): void;
  62849. /**
  62850. * Serialize the set into a JSON compatible object
  62851. * @returns a JSON compatible representation of the set
  62852. */
  62853. serialize(): any;
  62854. /**
  62855. * Parse a new ParticleSystemSet from a serialized source
  62856. * @param data defines a JSON compatible representation of the set
  62857. * @param scene defines the hosting scene
  62858. * @param gpu defines if we want GPU particles or CPU particles
  62859. * @returns a new ParticleSystemSet
  62860. */
  62861. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62862. }
  62863. }
  62864. declare module "babylonjs/Particles/particleHelper" {
  62865. import { Nullable } from "babylonjs/types";
  62866. import { Scene } from "babylonjs/scene";
  62867. import { Vector3 } from "babylonjs/Maths/math.vector";
  62868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62869. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62870. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62871. /**
  62872. * This class is made for on one-liner static method to help creating particle system set.
  62873. */
  62874. export class ParticleHelper {
  62875. /**
  62876. * Gets or sets base Assets URL
  62877. */
  62878. static BaseAssetsUrl: string;
  62879. /**
  62880. * Create a default particle system that you can tweak
  62881. * @param emitter defines the emitter to use
  62882. * @param capacity defines the system capacity (default is 500 particles)
  62883. * @param scene defines the hosting scene
  62884. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62885. * @returns the new Particle system
  62886. */
  62887. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62888. /**
  62889. * This is the main static method (one-liner) of this helper to create different particle systems
  62890. * @param type This string represents the type to the particle system to create
  62891. * @param scene The scene where the particle system should live
  62892. * @param gpu If the system will use gpu
  62893. * @returns the ParticleSystemSet created
  62894. */
  62895. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62896. /**
  62897. * Static function used to export a particle system to a ParticleSystemSet variable.
  62898. * Please note that the emitter shape is not exported
  62899. * @param systems defines the particle systems to export
  62900. * @returns the created particle system set
  62901. */
  62902. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62903. }
  62904. }
  62905. declare module "babylonjs/Particles/particleSystemComponent" {
  62906. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62907. import { Effect } from "babylonjs/Materials/effect";
  62908. import "babylonjs/Shaders/particles.vertex";
  62909. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62910. module "babylonjs/Engines/engine" {
  62911. interface Engine {
  62912. /**
  62913. * Create an effect to use with particle systems.
  62914. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62915. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62916. * @param uniformsNames defines a list of attribute names
  62917. * @param samplers defines an array of string used to represent textures
  62918. * @param defines defines the string containing the defines to use to compile the shaders
  62919. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62920. * @param onCompiled defines a function to call when the effect creation is successful
  62921. * @param onError defines a function to call when the effect creation has failed
  62922. * @returns the new Effect
  62923. */
  62924. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62925. }
  62926. }
  62927. module "babylonjs/Meshes/mesh" {
  62928. interface Mesh {
  62929. /**
  62930. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62931. * @returns an array of IParticleSystem
  62932. */
  62933. getEmittedParticleSystems(): IParticleSystem[];
  62934. /**
  62935. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62936. * @returns an array of IParticleSystem
  62937. */
  62938. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62939. }
  62940. }
  62941. /**
  62942. * @hidden
  62943. */
  62944. export var _IDoNeedToBeInTheBuild: number;
  62945. }
  62946. declare module "babylonjs/Particles/pointsCloudSystem" {
  62947. import { Color4 } from "babylonjs/Maths/math";
  62948. import { Mesh } from "babylonjs/Meshes/mesh";
  62949. import { Scene, IDisposable } from "babylonjs/scene";
  62950. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62951. /** Defines the 4 color options */
  62952. export enum PointColor {
  62953. /** color value */
  62954. Color = 2,
  62955. /** uv value */
  62956. UV = 1,
  62957. /** random value */
  62958. Random = 0,
  62959. /** stated value */
  62960. Stated = 3
  62961. }
  62962. /**
  62963. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62964. * 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.
  62965. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62966. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62967. *
  62968. * Full documentation here : TO BE ENTERED
  62969. */
  62970. export class PointsCloudSystem implements IDisposable {
  62971. /**
  62972. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62973. * Example : var p = SPS.particles[i];
  62974. */
  62975. particles: CloudPoint[];
  62976. /**
  62977. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62978. */
  62979. nbParticles: number;
  62980. /**
  62981. * This a counter for your own usage. It's not set by any SPS functions.
  62982. */
  62983. counter: number;
  62984. /**
  62985. * The PCS name. This name is also given to the underlying mesh.
  62986. */
  62987. name: string;
  62988. /**
  62989. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62990. */
  62991. mesh: Mesh;
  62992. /**
  62993. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62994. * Please read :
  62995. */
  62996. vars: any;
  62997. /**
  62998. * @hidden
  62999. */
  63000. _size: number;
  63001. private _scene;
  63002. private _promises;
  63003. private _positions;
  63004. private _indices;
  63005. private _normals;
  63006. private _colors;
  63007. private _uvs;
  63008. private _indices32;
  63009. private _positions32;
  63010. private _colors32;
  63011. private _uvs32;
  63012. private _updatable;
  63013. private _isVisibilityBoxLocked;
  63014. private _alwaysVisible;
  63015. private _groups;
  63016. private _groupCounter;
  63017. private _computeParticleColor;
  63018. private _computeParticleTexture;
  63019. private _computeParticleRotation;
  63020. private _computeBoundingBox;
  63021. private _isReady;
  63022. /**
  63023. * Creates a PCS (Points Cloud System) object
  63024. * @param name (String) is the PCS name, this will be the underlying mesh name
  63025. * @param pointSize (number) is the size for each point
  63026. * @param scene (Scene) is the scene in which the PCS is added
  63027. * @param options defines the options of the PCS e.g.
  63028. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63029. */
  63030. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63031. updatable?: boolean;
  63032. });
  63033. /**
  63034. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63035. * If no points were added to the PCS, the returned mesh is just a single point.
  63036. * @returns a promise for the created mesh
  63037. */
  63038. buildMeshAsync(): Promise<Mesh>;
  63039. /**
  63040. * @hidden
  63041. */
  63042. private _buildMesh;
  63043. private _addParticle;
  63044. private _randomUnitVector;
  63045. private _getColorIndicesForCoord;
  63046. private _setPointsColorOrUV;
  63047. private _colorFromTexture;
  63048. private _calculateDensity;
  63049. /**
  63050. * Adds points to the PCS in random positions within a unit sphere
  63051. * @param nb (positive integer) the number of particles to be created from this model
  63052. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63053. * @returns the number of groups in the system
  63054. */
  63055. addPoints(nb: number, pointFunction?: any): number;
  63056. /**
  63057. * Adds points to the PCS from the surface of the model shape
  63058. * @param mesh is any Mesh object that will be used as a surface model for the points
  63059. * @param nb (positive integer) the number of particles to be created from this model
  63060. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63061. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63062. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63063. * @returns the number of groups in the system
  63064. */
  63065. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63066. /**
  63067. * Adds points to the PCS inside the model shape
  63068. * @param mesh is any Mesh object that will be used as a surface model for the points
  63069. * @param nb (positive integer) the number of particles to be created from this model
  63070. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63071. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63072. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63073. * @returns the number of groups in the system
  63074. */
  63075. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63076. /**
  63077. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63078. * This method calls `updateParticle()` for each particle of the SPS.
  63079. * For an animated SPS, it is usually called within the render loop.
  63080. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63081. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63082. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63083. * @returns the PCS.
  63084. */
  63085. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63086. /**
  63087. * Disposes the PCS.
  63088. */
  63089. dispose(): void;
  63090. /**
  63091. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63092. * doc :
  63093. * @returns the PCS.
  63094. */
  63095. refreshVisibleSize(): PointsCloudSystem;
  63096. /**
  63097. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63098. * @param size the size (float) of the visibility box
  63099. * note : this doesn't lock the PCS mesh bounding box.
  63100. * doc :
  63101. */
  63102. setVisibilityBox(size: number): void;
  63103. /**
  63104. * Gets whether the PCS is always visible or not
  63105. * doc :
  63106. */
  63107. /**
  63108. * Sets the PCS as always visible or not
  63109. * doc :
  63110. */
  63111. isAlwaysVisible: boolean;
  63112. /**
  63113. * Tells to `setParticles()` to compute the particle rotations or not
  63114. * Default value : false. The PCS is faster when it's set to false
  63115. * Note : particle rotations are only applied to parent particles
  63116. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63117. */
  63118. computeParticleRotation: boolean;
  63119. /**
  63120. * Tells to `setParticles()` to compute the particle colors or not.
  63121. * Default value : true. The PCS is faster when it's set to false.
  63122. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63123. */
  63124. /**
  63125. * Gets if `setParticles()` computes the particle colors or not.
  63126. * Default value : false. The PCS is faster when it's set to false.
  63127. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63128. */
  63129. computeParticleColor: boolean;
  63130. /**
  63131. * Gets if `setParticles()` computes the particle textures or not.
  63132. * Default value : false. The PCS is faster when it's set to false.
  63133. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63134. */
  63135. computeParticleTexture: boolean;
  63136. /**
  63137. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63138. */
  63139. /**
  63140. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63141. */
  63142. computeBoundingBox: boolean;
  63143. /**
  63144. * This function does nothing. It may be overwritten to set all the particle first values.
  63145. * The PCS doesn't call this function, you may have to call it by your own.
  63146. * doc :
  63147. */
  63148. initParticles(): void;
  63149. /**
  63150. * This function does nothing. It may be overwritten to recycle a particle
  63151. * The PCS doesn't call this function, you can to call it
  63152. * doc :
  63153. * @param particle The particle to recycle
  63154. * @returns the recycled particle
  63155. */
  63156. recycleParticle(particle: CloudPoint): CloudPoint;
  63157. /**
  63158. * Updates a particle : this function should be overwritten by the user.
  63159. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63160. * doc :
  63161. * @example : just set a particle position or velocity and recycle conditions
  63162. * @param particle The particle to update
  63163. * @returns the updated particle
  63164. */
  63165. updateParticle(particle: CloudPoint): CloudPoint;
  63166. /**
  63167. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63168. * This does nothing and may be overwritten by the user.
  63169. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63170. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63171. * @param update the boolean update value actually passed to setParticles()
  63172. */
  63173. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63174. /**
  63175. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63176. * This will be passed three parameters.
  63177. * This does nothing and may be overwritten by the user.
  63178. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63179. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63180. * @param update the boolean update value actually passed to setParticles()
  63181. */
  63182. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63183. }
  63184. }
  63185. declare module "babylonjs/Particles/cloudPoint" {
  63186. import { Nullable } from "babylonjs/types";
  63187. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  63188. import { Mesh } from "babylonjs/Meshes/mesh";
  63189. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63190. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  63191. /**
  63192. * Represents one particle of a points cloud system.
  63193. */
  63194. export class CloudPoint {
  63195. /**
  63196. * particle global index
  63197. */
  63198. idx: number;
  63199. /**
  63200. * The color of the particle
  63201. */
  63202. color: Nullable<Color4>;
  63203. /**
  63204. * The world space position of the particle.
  63205. */
  63206. position: Vector3;
  63207. /**
  63208. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63209. */
  63210. rotation: Vector3;
  63211. /**
  63212. * The world space rotation quaternion of the particle.
  63213. */
  63214. rotationQuaternion: Nullable<Quaternion>;
  63215. /**
  63216. * The uv of the particle.
  63217. */
  63218. uv: Nullable<Vector2>;
  63219. /**
  63220. * The current speed of the particle.
  63221. */
  63222. velocity: Vector3;
  63223. /**
  63224. * The pivot point in the particle local space.
  63225. */
  63226. pivot: Vector3;
  63227. /**
  63228. * Must the particle be translated from its pivot point in its local space ?
  63229. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63230. * Default : false
  63231. */
  63232. translateFromPivot: boolean;
  63233. /**
  63234. * Index of this particle in the global "positions" array (Internal use)
  63235. * @hidden
  63236. */
  63237. _pos: number;
  63238. /**
  63239. * @hidden Index of this particle in the global "indices" array (Internal use)
  63240. */
  63241. _ind: number;
  63242. /**
  63243. * Group this particle belongs to
  63244. */
  63245. _group: PointsGroup;
  63246. /**
  63247. * Group id of this particle
  63248. */
  63249. groupId: number;
  63250. /**
  63251. * Index of the particle in its group id (Internal use)
  63252. */
  63253. idxInGroup: number;
  63254. /**
  63255. * @hidden Particle BoundingInfo object (Internal use)
  63256. */
  63257. _boundingInfo: BoundingInfo;
  63258. /**
  63259. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63260. */
  63261. _pcs: PointsCloudSystem;
  63262. /**
  63263. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63264. */
  63265. _stillInvisible: boolean;
  63266. /**
  63267. * @hidden Last computed particle rotation matrix
  63268. */
  63269. _rotationMatrix: number[];
  63270. /**
  63271. * Parent particle Id, if any.
  63272. * Default null.
  63273. */
  63274. parentId: Nullable<number>;
  63275. /**
  63276. * @hidden Internal global position in the PCS.
  63277. */
  63278. _globalPosition: Vector3;
  63279. /**
  63280. * Creates a Point Cloud object.
  63281. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63282. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63283. * @param group (PointsGroup) is the group the particle belongs to
  63284. * @param groupId (integer) is the group identifier in the PCS.
  63285. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63286. * @param pcs defines the PCS it is associated to
  63287. */
  63288. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63289. /**
  63290. * get point size
  63291. */
  63292. /**
  63293. * Set point size
  63294. */
  63295. size: Vector3;
  63296. /**
  63297. * Legacy support, changed quaternion to rotationQuaternion
  63298. */
  63299. /**
  63300. * Legacy support, changed quaternion to rotationQuaternion
  63301. */
  63302. quaternion: Nullable<Quaternion>;
  63303. /**
  63304. * Returns a boolean. True if the particle intersects a mesh, else false
  63305. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63306. * @param target is the object (point or mesh) what the intersection is computed against
  63307. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63308. * @returns true if it intersects
  63309. */
  63310. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63311. /**
  63312. * get the rotation matrix of the particle
  63313. * @hidden
  63314. */
  63315. getRotationMatrix(m: Matrix): void;
  63316. }
  63317. /**
  63318. * Represents a group of points in a points cloud system
  63319. * * PCS internal tool, don't use it manually.
  63320. */
  63321. export class PointsGroup {
  63322. /**
  63323. * The group id
  63324. * @hidden
  63325. */
  63326. groupID: number;
  63327. /**
  63328. * image data for group (internal use)
  63329. * @hidden
  63330. */
  63331. _groupImageData: Nullable<ArrayBufferView>;
  63332. /**
  63333. * Image Width (internal use)
  63334. * @hidden
  63335. */
  63336. _groupImgWidth: number;
  63337. /**
  63338. * Image Height (internal use)
  63339. * @hidden
  63340. */
  63341. _groupImgHeight: number;
  63342. /**
  63343. * Custom position function (internal use)
  63344. * @hidden
  63345. */
  63346. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63347. /**
  63348. * density per facet for surface points
  63349. * @hidden
  63350. */
  63351. _groupDensity: number[];
  63352. /**
  63353. * Only when points are colored by texture carries pointer to texture list array
  63354. * @hidden
  63355. */
  63356. _textureNb: number;
  63357. /**
  63358. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63359. * PCS internal tool, don't use it manually.
  63360. * @hidden
  63361. */
  63362. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63363. }
  63364. }
  63365. declare module "babylonjs/Particles/index" {
  63366. export * from "babylonjs/Particles/baseParticleSystem";
  63367. export * from "babylonjs/Particles/EmitterTypes/index";
  63368. export * from "babylonjs/Particles/gpuParticleSystem";
  63369. export * from "babylonjs/Particles/IParticleSystem";
  63370. export * from "babylonjs/Particles/particle";
  63371. export * from "babylonjs/Particles/particleHelper";
  63372. export * from "babylonjs/Particles/particleSystem";
  63373. export * from "babylonjs/Particles/particleSystemComponent";
  63374. export * from "babylonjs/Particles/particleSystemSet";
  63375. export * from "babylonjs/Particles/solidParticle";
  63376. export * from "babylonjs/Particles/solidParticleSystem";
  63377. export * from "babylonjs/Particles/cloudPoint";
  63378. export * from "babylonjs/Particles/pointsCloudSystem";
  63379. export * from "babylonjs/Particles/subEmitter";
  63380. }
  63381. declare module "babylonjs/Physics/physicsEngineComponent" {
  63382. import { Nullable } from "babylonjs/types";
  63383. import { Observable, Observer } from "babylonjs/Misc/observable";
  63384. import { Vector3 } from "babylonjs/Maths/math.vector";
  63385. import { Mesh } from "babylonjs/Meshes/mesh";
  63386. import { ISceneComponent } from "babylonjs/sceneComponent";
  63387. import { Scene } from "babylonjs/scene";
  63388. import { Node } from "babylonjs/node";
  63389. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63390. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63391. module "babylonjs/scene" {
  63392. interface Scene {
  63393. /** @hidden (Backing field) */
  63394. _physicsEngine: Nullable<IPhysicsEngine>;
  63395. /** @hidden */
  63396. _physicsTimeAccumulator: number;
  63397. /**
  63398. * Gets the current physics engine
  63399. * @returns a IPhysicsEngine or null if none attached
  63400. */
  63401. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63402. /**
  63403. * Enables physics to the current scene
  63404. * @param gravity defines the scene's gravity for the physics engine
  63405. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63406. * @return a boolean indicating if the physics engine was initialized
  63407. */
  63408. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63409. /**
  63410. * Disables and disposes the physics engine associated with the scene
  63411. */
  63412. disablePhysicsEngine(): void;
  63413. /**
  63414. * Gets a boolean indicating if there is an active physics engine
  63415. * @returns a boolean indicating if there is an active physics engine
  63416. */
  63417. isPhysicsEnabled(): boolean;
  63418. /**
  63419. * Deletes a physics compound impostor
  63420. * @param compound defines the compound to delete
  63421. */
  63422. deleteCompoundImpostor(compound: any): void;
  63423. /**
  63424. * An event triggered when physic simulation is about to be run
  63425. */
  63426. onBeforePhysicsObservable: Observable<Scene>;
  63427. /**
  63428. * An event triggered when physic simulation has been done
  63429. */
  63430. onAfterPhysicsObservable: Observable<Scene>;
  63431. }
  63432. }
  63433. module "babylonjs/Meshes/abstractMesh" {
  63434. interface AbstractMesh {
  63435. /** @hidden */
  63436. _physicsImpostor: Nullable<PhysicsImpostor>;
  63437. /**
  63438. * Gets or sets impostor used for physic simulation
  63439. * @see http://doc.babylonjs.com/features/physics_engine
  63440. */
  63441. physicsImpostor: Nullable<PhysicsImpostor>;
  63442. /**
  63443. * Gets the current physics impostor
  63444. * @see http://doc.babylonjs.com/features/physics_engine
  63445. * @returns a physics impostor or null
  63446. */
  63447. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63448. /** Apply a physic impulse to the mesh
  63449. * @param force defines the force to apply
  63450. * @param contactPoint defines where to apply the force
  63451. * @returns the current mesh
  63452. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63453. */
  63454. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63455. /**
  63456. * Creates a physic joint between two meshes
  63457. * @param otherMesh defines the other mesh to use
  63458. * @param pivot1 defines the pivot to use on this mesh
  63459. * @param pivot2 defines the pivot to use on the other mesh
  63460. * @param options defines additional options (can be plugin dependent)
  63461. * @returns the current mesh
  63462. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63463. */
  63464. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63465. /** @hidden */
  63466. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63467. }
  63468. }
  63469. /**
  63470. * Defines the physics engine scene component responsible to manage a physics engine
  63471. */
  63472. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63473. /**
  63474. * The component name helpful to identify the component in the list of scene components.
  63475. */
  63476. readonly name: string;
  63477. /**
  63478. * The scene the component belongs to.
  63479. */
  63480. scene: Scene;
  63481. /**
  63482. * Creates a new instance of the component for the given scene
  63483. * @param scene Defines the scene to register the component in
  63484. */
  63485. constructor(scene: Scene);
  63486. /**
  63487. * Registers the component in a given scene
  63488. */
  63489. register(): void;
  63490. /**
  63491. * Rebuilds the elements related to this component in case of
  63492. * context lost for instance.
  63493. */
  63494. rebuild(): void;
  63495. /**
  63496. * Disposes the component and the associated ressources
  63497. */
  63498. dispose(): void;
  63499. }
  63500. }
  63501. declare module "babylonjs/Physics/physicsHelper" {
  63502. import { Nullable } from "babylonjs/types";
  63503. import { Vector3 } from "babylonjs/Maths/math.vector";
  63504. import { Mesh } from "babylonjs/Meshes/mesh";
  63505. import { Scene } from "babylonjs/scene";
  63506. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63507. /**
  63508. * A helper for physics simulations
  63509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63510. */
  63511. export class PhysicsHelper {
  63512. private _scene;
  63513. private _physicsEngine;
  63514. /**
  63515. * Initializes the Physics helper
  63516. * @param scene Babylon.js scene
  63517. */
  63518. constructor(scene: Scene);
  63519. /**
  63520. * Applies a radial explosion impulse
  63521. * @param origin the origin of the explosion
  63522. * @param radiusOrEventOptions the radius or the options of radial explosion
  63523. * @param strength the explosion strength
  63524. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63525. * @returns A physics radial explosion event, or null
  63526. */
  63527. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63528. /**
  63529. * Applies a radial explosion force
  63530. * @param origin the origin of the explosion
  63531. * @param radiusOrEventOptions the radius or the options of radial explosion
  63532. * @param strength the explosion strength
  63533. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63534. * @returns A physics radial explosion event, or null
  63535. */
  63536. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63537. /**
  63538. * Creates a gravitational field
  63539. * @param origin the origin of the explosion
  63540. * @param radiusOrEventOptions the radius or the options of radial explosion
  63541. * @param strength the explosion strength
  63542. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63543. * @returns A physics gravitational field event, or null
  63544. */
  63545. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63546. /**
  63547. * Creates a physics updraft event
  63548. * @param origin the origin of the updraft
  63549. * @param radiusOrEventOptions the radius or the options of the updraft
  63550. * @param strength the strength of the updraft
  63551. * @param height the height of the updraft
  63552. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63553. * @returns A physics updraft event, or null
  63554. */
  63555. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63556. /**
  63557. * Creates a physics vortex event
  63558. * @param origin the of the vortex
  63559. * @param radiusOrEventOptions the radius or the options of the vortex
  63560. * @param strength the strength of the vortex
  63561. * @param height the height of the vortex
  63562. * @returns a Physics vortex event, or null
  63563. * A physics vortex event or null
  63564. */
  63565. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63566. }
  63567. /**
  63568. * Represents a physics radial explosion event
  63569. */
  63570. class PhysicsRadialExplosionEvent {
  63571. private _scene;
  63572. private _options;
  63573. private _sphere;
  63574. private _dataFetched;
  63575. /**
  63576. * Initializes a radial explosioin event
  63577. * @param _scene BabylonJS scene
  63578. * @param _options The options for the vortex event
  63579. */
  63580. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63581. /**
  63582. * Returns the data related to the radial explosion event (sphere).
  63583. * @returns The radial explosion event data
  63584. */
  63585. getData(): PhysicsRadialExplosionEventData;
  63586. /**
  63587. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63588. * @param impostor A physics imposter
  63589. * @param origin the origin of the explosion
  63590. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63591. */
  63592. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63593. /**
  63594. * Triggers affecterd impostors callbacks
  63595. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63596. */
  63597. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63598. /**
  63599. * Disposes the sphere.
  63600. * @param force Specifies if the sphere should be disposed by force
  63601. */
  63602. dispose(force?: boolean): void;
  63603. /*** Helpers ***/
  63604. private _prepareSphere;
  63605. private _intersectsWithSphere;
  63606. }
  63607. /**
  63608. * Represents a gravitational field event
  63609. */
  63610. class PhysicsGravitationalFieldEvent {
  63611. private _physicsHelper;
  63612. private _scene;
  63613. private _origin;
  63614. private _options;
  63615. private _tickCallback;
  63616. private _sphere;
  63617. private _dataFetched;
  63618. /**
  63619. * Initializes the physics gravitational field event
  63620. * @param _physicsHelper A physics helper
  63621. * @param _scene BabylonJS scene
  63622. * @param _origin The origin position of the gravitational field event
  63623. * @param _options The options for the vortex event
  63624. */
  63625. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63626. /**
  63627. * Returns the data related to the gravitational field event (sphere).
  63628. * @returns A gravitational field event
  63629. */
  63630. getData(): PhysicsGravitationalFieldEventData;
  63631. /**
  63632. * Enables the gravitational field.
  63633. */
  63634. enable(): void;
  63635. /**
  63636. * Disables the gravitational field.
  63637. */
  63638. disable(): void;
  63639. /**
  63640. * Disposes the sphere.
  63641. * @param force The force to dispose from the gravitational field event
  63642. */
  63643. dispose(force?: boolean): void;
  63644. private _tick;
  63645. }
  63646. /**
  63647. * Represents a physics updraft event
  63648. */
  63649. class PhysicsUpdraftEvent {
  63650. private _scene;
  63651. private _origin;
  63652. private _options;
  63653. private _physicsEngine;
  63654. private _originTop;
  63655. private _originDirection;
  63656. private _tickCallback;
  63657. private _cylinder;
  63658. private _cylinderPosition;
  63659. private _dataFetched;
  63660. /**
  63661. * Initializes the physics updraft event
  63662. * @param _scene BabylonJS scene
  63663. * @param _origin The origin position of the updraft
  63664. * @param _options The options for the updraft event
  63665. */
  63666. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63667. /**
  63668. * Returns the data related to the updraft event (cylinder).
  63669. * @returns A physics updraft event
  63670. */
  63671. getData(): PhysicsUpdraftEventData;
  63672. /**
  63673. * Enables the updraft.
  63674. */
  63675. enable(): void;
  63676. /**
  63677. * Disables the updraft.
  63678. */
  63679. disable(): void;
  63680. /**
  63681. * Disposes the cylinder.
  63682. * @param force Specifies if the updraft should be disposed by force
  63683. */
  63684. dispose(force?: boolean): void;
  63685. private getImpostorHitData;
  63686. private _tick;
  63687. /*** Helpers ***/
  63688. private _prepareCylinder;
  63689. private _intersectsWithCylinder;
  63690. }
  63691. /**
  63692. * Represents a physics vortex event
  63693. */
  63694. class PhysicsVortexEvent {
  63695. private _scene;
  63696. private _origin;
  63697. private _options;
  63698. private _physicsEngine;
  63699. private _originTop;
  63700. private _tickCallback;
  63701. private _cylinder;
  63702. private _cylinderPosition;
  63703. private _dataFetched;
  63704. /**
  63705. * Initializes the physics vortex event
  63706. * @param _scene The BabylonJS scene
  63707. * @param _origin The origin position of the vortex
  63708. * @param _options The options for the vortex event
  63709. */
  63710. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63711. /**
  63712. * Returns the data related to the vortex event (cylinder).
  63713. * @returns The physics vortex event data
  63714. */
  63715. getData(): PhysicsVortexEventData;
  63716. /**
  63717. * Enables the vortex.
  63718. */
  63719. enable(): void;
  63720. /**
  63721. * Disables the cortex.
  63722. */
  63723. disable(): void;
  63724. /**
  63725. * Disposes the sphere.
  63726. * @param force
  63727. */
  63728. dispose(force?: boolean): void;
  63729. private getImpostorHitData;
  63730. private _tick;
  63731. /*** Helpers ***/
  63732. private _prepareCylinder;
  63733. private _intersectsWithCylinder;
  63734. }
  63735. /**
  63736. * Options fot the radial explosion event
  63737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63738. */
  63739. export class PhysicsRadialExplosionEventOptions {
  63740. /**
  63741. * The radius of the sphere for the radial explosion.
  63742. */
  63743. radius: number;
  63744. /**
  63745. * The strenth of the explosion.
  63746. */
  63747. strength: number;
  63748. /**
  63749. * The strenght of the force in correspondence to the distance of the affected object
  63750. */
  63751. falloff: PhysicsRadialImpulseFalloff;
  63752. /**
  63753. * Sphere options for the radial explosion.
  63754. */
  63755. sphere: {
  63756. segments: number;
  63757. diameter: number;
  63758. };
  63759. /**
  63760. * Sphere options for the radial explosion.
  63761. */
  63762. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63763. }
  63764. /**
  63765. * Options fot the updraft event
  63766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63767. */
  63768. export class PhysicsUpdraftEventOptions {
  63769. /**
  63770. * The radius of the cylinder for the vortex
  63771. */
  63772. radius: number;
  63773. /**
  63774. * The strenth of the updraft.
  63775. */
  63776. strength: number;
  63777. /**
  63778. * The height of the cylinder for the updraft.
  63779. */
  63780. height: number;
  63781. /**
  63782. * The mode for the the updraft.
  63783. */
  63784. updraftMode: PhysicsUpdraftMode;
  63785. }
  63786. /**
  63787. * Options fot the vortex event
  63788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63789. */
  63790. export class PhysicsVortexEventOptions {
  63791. /**
  63792. * The radius of the cylinder for the vortex
  63793. */
  63794. radius: number;
  63795. /**
  63796. * The strenth of the vortex.
  63797. */
  63798. strength: number;
  63799. /**
  63800. * The height of the cylinder for the vortex.
  63801. */
  63802. height: number;
  63803. /**
  63804. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63805. */
  63806. centripetalForceThreshold: number;
  63807. /**
  63808. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63809. */
  63810. centripetalForceMultiplier: number;
  63811. /**
  63812. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63813. */
  63814. centrifugalForceMultiplier: number;
  63815. /**
  63816. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63817. */
  63818. updraftForceMultiplier: number;
  63819. }
  63820. /**
  63821. * The strenght of the force in correspondence to the distance of the affected object
  63822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63823. */
  63824. export enum PhysicsRadialImpulseFalloff {
  63825. /** Defines that impulse is constant in strength across it's whole radius */
  63826. Constant = 0,
  63827. /** Defines that impulse gets weaker if it's further from the origin */
  63828. Linear = 1
  63829. }
  63830. /**
  63831. * The strength of the force in correspondence to the distance of the affected object
  63832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63833. */
  63834. export enum PhysicsUpdraftMode {
  63835. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63836. Center = 0,
  63837. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63838. Perpendicular = 1
  63839. }
  63840. /**
  63841. * Interface for a physics hit data
  63842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63843. */
  63844. export interface PhysicsHitData {
  63845. /**
  63846. * The force applied at the contact point
  63847. */
  63848. force: Vector3;
  63849. /**
  63850. * The contact point
  63851. */
  63852. contactPoint: Vector3;
  63853. /**
  63854. * The distance from the origin to the contact point
  63855. */
  63856. distanceFromOrigin: number;
  63857. }
  63858. /**
  63859. * Interface for radial explosion event data
  63860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63861. */
  63862. export interface PhysicsRadialExplosionEventData {
  63863. /**
  63864. * A sphere used for the radial explosion event
  63865. */
  63866. sphere: Mesh;
  63867. }
  63868. /**
  63869. * Interface for gravitational field event data
  63870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63871. */
  63872. export interface PhysicsGravitationalFieldEventData {
  63873. /**
  63874. * A sphere mesh used for the gravitational field event
  63875. */
  63876. sphere: Mesh;
  63877. }
  63878. /**
  63879. * Interface for updraft event data
  63880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63881. */
  63882. export interface PhysicsUpdraftEventData {
  63883. /**
  63884. * A cylinder used for the updraft event
  63885. */
  63886. cylinder: Mesh;
  63887. }
  63888. /**
  63889. * Interface for vortex event data
  63890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63891. */
  63892. export interface PhysicsVortexEventData {
  63893. /**
  63894. * A cylinder used for the vortex event
  63895. */
  63896. cylinder: Mesh;
  63897. }
  63898. /**
  63899. * Interface for an affected physics impostor
  63900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63901. */
  63902. export interface PhysicsAffectedImpostorWithData {
  63903. /**
  63904. * The impostor affected by the effect
  63905. */
  63906. impostor: PhysicsImpostor;
  63907. /**
  63908. * The data about the hit/horce from the explosion
  63909. */
  63910. hitData: PhysicsHitData;
  63911. }
  63912. }
  63913. declare module "babylonjs/Physics/Plugins/index" {
  63914. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63915. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63916. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63917. }
  63918. declare module "babylonjs/Physics/index" {
  63919. export * from "babylonjs/Physics/IPhysicsEngine";
  63920. export * from "babylonjs/Physics/physicsEngine";
  63921. export * from "babylonjs/Physics/physicsEngineComponent";
  63922. export * from "babylonjs/Physics/physicsHelper";
  63923. export * from "babylonjs/Physics/physicsImpostor";
  63924. export * from "babylonjs/Physics/physicsJoint";
  63925. export * from "babylonjs/Physics/Plugins/index";
  63926. }
  63927. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63928. /** @hidden */
  63929. export var blackAndWhitePixelShader: {
  63930. name: string;
  63931. shader: string;
  63932. };
  63933. }
  63934. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63935. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63936. import { Camera } from "babylonjs/Cameras/camera";
  63937. import { Engine } from "babylonjs/Engines/engine";
  63938. import "babylonjs/Shaders/blackAndWhite.fragment";
  63939. /**
  63940. * Post process used to render in black and white
  63941. */
  63942. export class BlackAndWhitePostProcess extends PostProcess {
  63943. /**
  63944. * Linear about to convert he result to black and white (default: 1)
  63945. */
  63946. degree: number;
  63947. /**
  63948. * Creates a black and white post process
  63949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63950. * @param name The name of the effect.
  63951. * @param options The required width/height ratio to downsize to before computing the render pass.
  63952. * @param camera The camera to apply the render pass to.
  63953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63954. * @param engine The engine which the post process will be applied. (default: current engine)
  63955. * @param reusable If the post process can be reused on the same frame. (default: false)
  63956. */
  63957. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63958. }
  63959. }
  63960. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63961. import { Nullable } from "babylonjs/types";
  63962. import { Camera } from "babylonjs/Cameras/camera";
  63963. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63964. import { Engine } from "babylonjs/Engines/engine";
  63965. /**
  63966. * This represents a set of one or more post processes in Babylon.
  63967. * A post process can be used to apply a shader to a texture after it is rendered.
  63968. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63969. */
  63970. export class PostProcessRenderEffect {
  63971. private _postProcesses;
  63972. private _getPostProcesses;
  63973. private _singleInstance;
  63974. private _cameras;
  63975. private _indicesForCamera;
  63976. /**
  63977. * Name of the effect
  63978. * @hidden
  63979. */
  63980. _name: string;
  63981. /**
  63982. * Instantiates a post process render effect.
  63983. * A post process can be used to apply a shader to a texture after it is rendered.
  63984. * @param engine The engine the effect is tied to
  63985. * @param name The name of the effect
  63986. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63987. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63988. */
  63989. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63990. /**
  63991. * Checks if all the post processes in the effect are supported.
  63992. */
  63993. readonly isSupported: boolean;
  63994. /**
  63995. * Updates the current state of the effect
  63996. * @hidden
  63997. */
  63998. _update(): void;
  63999. /**
  64000. * Attaches the effect on cameras
  64001. * @param cameras The camera to attach to.
  64002. * @hidden
  64003. */
  64004. _attachCameras(cameras: Camera): void;
  64005. /**
  64006. * Attaches the effect on cameras
  64007. * @param cameras The camera to attach to.
  64008. * @hidden
  64009. */
  64010. _attachCameras(cameras: Camera[]): void;
  64011. /**
  64012. * Detaches the effect on cameras
  64013. * @param cameras The camera to detatch from.
  64014. * @hidden
  64015. */
  64016. _detachCameras(cameras: Camera): void;
  64017. /**
  64018. * Detatches the effect on cameras
  64019. * @param cameras The camera to detatch from.
  64020. * @hidden
  64021. */
  64022. _detachCameras(cameras: Camera[]): void;
  64023. /**
  64024. * Enables the effect on given cameras
  64025. * @param cameras The camera to enable.
  64026. * @hidden
  64027. */
  64028. _enable(cameras: Camera): void;
  64029. /**
  64030. * Enables the effect on given cameras
  64031. * @param cameras The camera to enable.
  64032. * @hidden
  64033. */
  64034. _enable(cameras: Nullable<Camera[]>): void;
  64035. /**
  64036. * Disables the effect on the given cameras
  64037. * @param cameras The camera to disable.
  64038. * @hidden
  64039. */
  64040. _disable(cameras: Camera): void;
  64041. /**
  64042. * Disables the effect on the given cameras
  64043. * @param cameras The camera to disable.
  64044. * @hidden
  64045. */
  64046. _disable(cameras: Nullable<Camera[]>): void;
  64047. /**
  64048. * Gets a list of the post processes contained in the effect.
  64049. * @param camera The camera to get the post processes on.
  64050. * @returns The list of the post processes in the effect.
  64051. */
  64052. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64053. }
  64054. }
  64055. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  64056. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64057. /** @hidden */
  64058. export var extractHighlightsPixelShader: {
  64059. name: string;
  64060. shader: string;
  64061. };
  64062. }
  64063. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  64064. import { Nullable } from "babylonjs/types";
  64065. import { Camera } from "babylonjs/Cameras/camera";
  64066. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64067. import { Engine } from "babylonjs/Engines/engine";
  64068. import "babylonjs/Shaders/extractHighlights.fragment";
  64069. /**
  64070. * 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.
  64071. */
  64072. export class ExtractHighlightsPostProcess extends PostProcess {
  64073. /**
  64074. * The luminance threshold, pixels below this value will be set to black.
  64075. */
  64076. threshold: number;
  64077. /** @hidden */
  64078. _exposure: number;
  64079. /**
  64080. * Post process which has the input texture to be used when performing highlight extraction
  64081. * @hidden
  64082. */
  64083. _inputPostProcess: Nullable<PostProcess>;
  64084. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64085. }
  64086. }
  64087. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  64088. /** @hidden */
  64089. export var bloomMergePixelShader: {
  64090. name: string;
  64091. shader: string;
  64092. };
  64093. }
  64094. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  64095. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64096. import { Nullable } from "babylonjs/types";
  64097. import { Engine } from "babylonjs/Engines/engine";
  64098. import { Camera } from "babylonjs/Cameras/camera";
  64099. import "babylonjs/Shaders/bloomMerge.fragment";
  64100. /**
  64101. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64102. */
  64103. export class BloomMergePostProcess extends PostProcess {
  64104. /** Weight of the bloom to be added to the original input. */
  64105. weight: number;
  64106. /**
  64107. * Creates a new instance of @see BloomMergePostProcess
  64108. * @param name The name of the effect.
  64109. * @param originalFromInput Post process which's input will be used for the merge.
  64110. * @param blurred Blurred highlights post process which's output will be used.
  64111. * @param weight Weight of the bloom to be added to the original input.
  64112. * @param options The required width/height ratio to downsize to before computing the render pass.
  64113. * @param camera The camera to apply the render pass to.
  64114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64115. * @param engine The engine which the post process will be applied. (default: current engine)
  64116. * @param reusable If the post process can be reused on the same frame. (default: false)
  64117. * @param textureType Type of textures used when performing the post process. (default: 0)
  64118. * @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)
  64119. */
  64120. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64121. /** Weight of the bloom to be added to the original input. */
  64122. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64123. }
  64124. }
  64125. declare module "babylonjs/PostProcesses/bloomEffect" {
  64126. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64127. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64128. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64129. import { Camera } from "babylonjs/Cameras/camera";
  64130. import { Scene } from "babylonjs/scene";
  64131. /**
  64132. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64133. */
  64134. export class BloomEffect extends PostProcessRenderEffect {
  64135. private bloomScale;
  64136. /**
  64137. * @hidden Internal
  64138. */
  64139. _effects: Array<PostProcess>;
  64140. /**
  64141. * @hidden Internal
  64142. */
  64143. _downscale: ExtractHighlightsPostProcess;
  64144. private _blurX;
  64145. private _blurY;
  64146. private _merge;
  64147. /**
  64148. * The luminance threshold to find bright areas of the image to bloom.
  64149. */
  64150. threshold: number;
  64151. /**
  64152. * The strength of the bloom.
  64153. */
  64154. weight: number;
  64155. /**
  64156. * Specifies the size of the bloom blur kernel, relative to the final output size
  64157. */
  64158. kernel: number;
  64159. /**
  64160. * Creates a new instance of @see BloomEffect
  64161. * @param scene The scene the effect belongs to.
  64162. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64163. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64164. * @param bloomWeight The the strength of bloom.
  64165. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64166. * @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)
  64167. */
  64168. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64169. /**
  64170. * Disposes each of the internal effects for a given camera.
  64171. * @param camera The camera to dispose the effect on.
  64172. */
  64173. disposeEffects(camera: Camera): void;
  64174. /**
  64175. * @hidden Internal
  64176. */
  64177. _updateEffects(): void;
  64178. /**
  64179. * Internal
  64180. * @returns if all the contained post processes are ready.
  64181. * @hidden
  64182. */
  64183. _isReady(): boolean;
  64184. }
  64185. }
  64186. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  64187. /** @hidden */
  64188. export var chromaticAberrationPixelShader: {
  64189. name: string;
  64190. shader: string;
  64191. };
  64192. }
  64193. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  64194. import { Vector2 } from "babylonjs/Maths/math.vector";
  64195. import { Nullable } from "babylonjs/types";
  64196. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64197. import { Camera } from "babylonjs/Cameras/camera";
  64198. import { Engine } from "babylonjs/Engines/engine";
  64199. import "babylonjs/Shaders/chromaticAberration.fragment";
  64200. /**
  64201. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64202. */
  64203. export class ChromaticAberrationPostProcess extends PostProcess {
  64204. /**
  64205. * The amount of seperation of rgb channels (default: 30)
  64206. */
  64207. aberrationAmount: number;
  64208. /**
  64209. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64210. */
  64211. radialIntensity: number;
  64212. /**
  64213. * 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))
  64214. */
  64215. direction: Vector2;
  64216. /**
  64217. * 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))
  64218. */
  64219. centerPosition: Vector2;
  64220. /**
  64221. * Creates a new instance ChromaticAberrationPostProcess
  64222. * @param name The name of the effect.
  64223. * @param screenWidth The width of the screen to apply the effect on.
  64224. * @param screenHeight The height of the screen to apply the effect on.
  64225. * @param options The required width/height ratio to downsize to before computing the render pass.
  64226. * @param camera The camera to apply the render pass to.
  64227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64228. * @param engine The engine which the post process will be applied. (default: current engine)
  64229. * @param reusable If the post process can be reused on the same frame. (default: false)
  64230. * @param textureType Type of textures used when performing the post process. (default: 0)
  64231. * @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)
  64232. */
  64233. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64234. }
  64235. }
  64236. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  64237. /** @hidden */
  64238. export var circleOfConfusionPixelShader: {
  64239. name: string;
  64240. shader: string;
  64241. };
  64242. }
  64243. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  64244. import { Nullable } from "babylonjs/types";
  64245. import { Engine } from "babylonjs/Engines/engine";
  64246. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64247. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64248. import { Camera } from "babylonjs/Cameras/camera";
  64249. import "babylonjs/Shaders/circleOfConfusion.fragment";
  64250. /**
  64251. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64252. */
  64253. export class CircleOfConfusionPostProcess extends PostProcess {
  64254. /**
  64255. * 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.
  64256. */
  64257. lensSize: number;
  64258. /**
  64259. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64260. */
  64261. fStop: number;
  64262. /**
  64263. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64264. */
  64265. focusDistance: number;
  64266. /**
  64267. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64268. */
  64269. focalLength: number;
  64270. private _depthTexture;
  64271. /**
  64272. * Creates a new instance CircleOfConfusionPostProcess
  64273. * @param name The name of the effect.
  64274. * @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.
  64275. * @param options The required width/height ratio to downsize to before computing the render pass.
  64276. * @param camera The camera to apply the render pass to.
  64277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64278. * @param engine The engine which the post process will be applied. (default: current engine)
  64279. * @param reusable If the post process can be reused on the same frame. (default: false)
  64280. * @param textureType Type of textures used when performing the post process. (default: 0)
  64281. * @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)
  64282. */
  64283. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64284. /**
  64285. * 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.
  64286. */
  64287. depthTexture: RenderTargetTexture;
  64288. }
  64289. }
  64290. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  64291. /** @hidden */
  64292. export var colorCorrectionPixelShader: {
  64293. name: string;
  64294. shader: string;
  64295. };
  64296. }
  64297. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  64298. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64299. import { Engine } from "babylonjs/Engines/engine";
  64300. import { Camera } from "babylonjs/Cameras/camera";
  64301. import "babylonjs/Shaders/colorCorrection.fragment";
  64302. /**
  64303. *
  64304. * This post-process allows the modification of rendered colors by using
  64305. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64306. *
  64307. * The object needs to be provided an url to a texture containing the color
  64308. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64309. * Use an image editing software to tweak the LUT to match your needs.
  64310. *
  64311. * For an example of a color LUT, see here:
  64312. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64313. * For explanations on color grading, see here:
  64314. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64315. *
  64316. */
  64317. export class ColorCorrectionPostProcess extends PostProcess {
  64318. private _colorTableTexture;
  64319. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64320. }
  64321. }
  64322. declare module "babylonjs/Shaders/convolution.fragment" {
  64323. /** @hidden */
  64324. export var convolutionPixelShader: {
  64325. name: string;
  64326. shader: string;
  64327. };
  64328. }
  64329. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  64330. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64331. import { Nullable } from "babylonjs/types";
  64332. import { Camera } from "babylonjs/Cameras/camera";
  64333. import { Engine } from "babylonjs/Engines/engine";
  64334. import "babylonjs/Shaders/convolution.fragment";
  64335. /**
  64336. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64337. * input texture to perform effects such as edge detection or sharpening
  64338. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64339. */
  64340. export class ConvolutionPostProcess extends PostProcess {
  64341. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64342. kernel: number[];
  64343. /**
  64344. * Creates a new instance ConvolutionPostProcess
  64345. * @param name The name of the effect.
  64346. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64347. * @param options The required width/height ratio to downsize to before computing the render pass.
  64348. * @param camera The camera to apply the render pass to.
  64349. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64350. * @param engine The engine which the post process will be applied. (default: current engine)
  64351. * @param reusable If the post process can be reused on the same frame. (default: false)
  64352. * @param textureType Type of textures used when performing the post process. (default: 0)
  64353. */
  64354. constructor(name: string,
  64355. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64356. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64357. /**
  64358. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64359. */
  64360. static EdgeDetect0Kernel: number[];
  64361. /**
  64362. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64363. */
  64364. static EdgeDetect1Kernel: number[];
  64365. /**
  64366. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64367. */
  64368. static EdgeDetect2Kernel: number[];
  64369. /**
  64370. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64371. */
  64372. static SharpenKernel: number[];
  64373. /**
  64374. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64375. */
  64376. static EmbossKernel: number[];
  64377. /**
  64378. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64379. */
  64380. static GaussianKernel: number[];
  64381. }
  64382. }
  64383. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  64384. import { Nullable } from "babylonjs/types";
  64385. import { Vector2 } from "babylonjs/Maths/math.vector";
  64386. import { Camera } from "babylonjs/Cameras/camera";
  64387. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64388. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64389. import { Engine } from "babylonjs/Engines/engine";
  64390. import { Scene } from "babylonjs/scene";
  64391. /**
  64392. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64393. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64394. * based on samples that have a large difference in distance than the center pixel.
  64395. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64396. */
  64397. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64398. direction: Vector2;
  64399. /**
  64400. * Creates a new instance CircleOfConfusionPostProcess
  64401. * @param name The name of the effect.
  64402. * @param scene The scene the effect belongs to.
  64403. * @param direction The direction the blur should be applied.
  64404. * @param kernel The size of the kernel used to blur.
  64405. * @param options The required width/height ratio to downsize to before computing the render pass.
  64406. * @param camera The camera to apply the render pass to.
  64407. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64408. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64410. * @param engine The engine which the post process will be applied. (default: current engine)
  64411. * @param reusable If the post process can be reused on the same frame. (default: false)
  64412. * @param textureType Type of textures used when performing the post process. (default: 0)
  64413. * @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)
  64414. */
  64415. 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);
  64416. }
  64417. }
  64418. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  64419. /** @hidden */
  64420. export var depthOfFieldMergePixelShader: {
  64421. name: string;
  64422. shader: string;
  64423. };
  64424. }
  64425. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  64426. import { Nullable } from "babylonjs/types";
  64427. import { Camera } from "babylonjs/Cameras/camera";
  64428. import { Effect } from "babylonjs/Materials/effect";
  64429. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64430. import { Engine } from "babylonjs/Engines/engine";
  64431. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  64432. /**
  64433. * Options to be set when merging outputs from the default pipeline.
  64434. */
  64435. export class DepthOfFieldMergePostProcessOptions {
  64436. /**
  64437. * The original image to merge on top of
  64438. */
  64439. originalFromInput: PostProcess;
  64440. /**
  64441. * Parameters to perform the merge of the depth of field effect
  64442. */
  64443. depthOfField?: {
  64444. circleOfConfusion: PostProcess;
  64445. blurSteps: Array<PostProcess>;
  64446. };
  64447. /**
  64448. * Parameters to perform the merge of bloom effect
  64449. */
  64450. bloom?: {
  64451. blurred: PostProcess;
  64452. weight: number;
  64453. };
  64454. }
  64455. /**
  64456. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64457. */
  64458. export class DepthOfFieldMergePostProcess extends PostProcess {
  64459. private blurSteps;
  64460. /**
  64461. * Creates a new instance of DepthOfFieldMergePostProcess
  64462. * @param name The name of the effect.
  64463. * @param originalFromInput Post process which's input will be used for the merge.
  64464. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64465. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64466. * @param options The required width/height ratio to downsize to before computing the render pass.
  64467. * @param camera The camera to apply the render pass to.
  64468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64469. * @param engine The engine which the post process will be applied. (default: current engine)
  64470. * @param reusable If the post process can be reused on the same frame. (default: false)
  64471. * @param textureType Type of textures used when performing the post process. (default: 0)
  64472. * @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)
  64473. */
  64474. 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);
  64475. /**
  64476. * Updates the effect with the current post process compile time values and recompiles the shader.
  64477. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64478. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64479. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64480. * @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
  64481. * @param onCompiled Called when the shader has been compiled.
  64482. * @param onError Called if there is an error when compiling a shader.
  64483. */
  64484. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64485. }
  64486. }
  64487. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  64488. import { Nullable } from "babylonjs/types";
  64489. import { Camera } from "babylonjs/Cameras/camera";
  64490. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64491. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64492. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64493. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64494. import { Scene } from "babylonjs/scene";
  64495. /**
  64496. * Specifies the level of max blur that should be applied when using the depth of field effect
  64497. */
  64498. export enum DepthOfFieldEffectBlurLevel {
  64499. /**
  64500. * Subtle blur
  64501. */
  64502. Low = 0,
  64503. /**
  64504. * Medium blur
  64505. */
  64506. Medium = 1,
  64507. /**
  64508. * Large blur
  64509. */
  64510. High = 2
  64511. }
  64512. /**
  64513. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64514. */
  64515. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64516. private _circleOfConfusion;
  64517. /**
  64518. * @hidden Internal, blurs from high to low
  64519. */
  64520. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64521. private _depthOfFieldBlurY;
  64522. private _dofMerge;
  64523. /**
  64524. * @hidden Internal post processes in depth of field effect
  64525. */
  64526. _effects: Array<PostProcess>;
  64527. /**
  64528. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64529. */
  64530. focalLength: number;
  64531. /**
  64532. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64533. */
  64534. fStop: number;
  64535. /**
  64536. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64537. */
  64538. focusDistance: number;
  64539. /**
  64540. * 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.
  64541. */
  64542. lensSize: number;
  64543. /**
  64544. * Creates a new instance DepthOfFieldEffect
  64545. * @param scene The scene the effect belongs to.
  64546. * @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.
  64547. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64548. * @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)
  64549. */
  64550. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64551. /**
  64552. * Get the current class name of the current effet
  64553. * @returns "DepthOfFieldEffect"
  64554. */
  64555. getClassName(): string;
  64556. /**
  64557. * 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.
  64558. */
  64559. depthTexture: RenderTargetTexture;
  64560. /**
  64561. * Disposes each of the internal effects for a given camera.
  64562. * @param camera The camera to dispose the effect on.
  64563. */
  64564. disposeEffects(camera: Camera): void;
  64565. /**
  64566. * @hidden Internal
  64567. */
  64568. _updateEffects(): void;
  64569. /**
  64570. * Internal
  64571. * @returns if all the contained post processes are ready.
  64572. * @hidden
  64573. */
  64574. _isReady(): boolean;
  64575. }
  64576. }
  64577. declare module "babylonjs/Shaders/displayPass.fragment" {
  64578. /** @hidden */
  64579. export var displayPassPixelShader: {
  64580. name: string;
  64581. shader: string;
  64582. };
  64583. }
  64584. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  64585. import { Nullable } from "babylonjs/types";
  64586. import { Camera } from "babylonjs/Cameras/camera";
  64587. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64588. import { Engine } from "babylonjs/Engines/engine";
  64589. import "babylonjs/Shaders/displayPass.fragment";
  64590. /**
  64591. * DisplayPassPostProcess which produces an output the same as it's input
  64592. */
  64593. export class DisplayPassPostProcess extends PostProcess {
  64594. /**
  64595. * Creates the DisplayPassPostProcess
  64596. * @param name The name of the effect.
  64597. * @param options The required width/height ratio to downsize to before computing the render pass.
  64598. * @param camera The camera to apply the render pass to.
  64599. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64600. * @param engine The engine which the post process will be applied. (default: current engine)
  64601. * @param reusable If the post process can be reused on the same frame. (default: false)
  64602. */
  64603. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64604. }
  64605. }
  64606. declare module "babylonjs/Shaders/filter.fragment" {
  64607. /** @hidden */
  64608. export var filterPixelShader: {
  64609. name: string;
  64610. shader: string;
  64611. };
  64612. }
  64613. declare module "babylonjs/PostProcesses/filterPostProcess" {
  64614. import { Nullable } from "babylonjs/types";
  64615. import { Matrix } from "babylonjs/Maths/math.vector";
  64616. import { Camera } from "babylonjs/Cameras/camera";
  64617. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64618. import { Engine } from "babylonjs/Engines/engine";
  64619. import "babylonjs/Shaders/filter.fragment";
  64620. /**
  64621. * Applies a kernel filter to the image
  64622. */
  64623. export class FilterPostProcess extends PostProcess {
  64624. /** The matrix to be applied to the image */
  64625. kernelMatrix: Matrix;
  64626. /**
  64627. *
  64628. * @param name The name of the effect.
  64629. * @param kernelMatrix The matrix to be applied to the image
  64630. * @param options The required width/height ratio to downsize to before computing the render pass.
  64631. * @param camera The camera to apply the render pass to.
  64632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64633. * @param engine The engine which the post process will be applied. (default: current engine)
  64634. * @param reusable If the post process can be reused on the same frame. (default: false)
  64635. */
  64636. constructor(name: string,
  64637. /** The matrix to be applied to the image */
  64638. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64639. }
  64640. }
  64641. declare module "babylonjs/Shaders/fxaa.fragment" {
  64642. /** @hidden */
  64643. export var fxaaPixelShader: {
  64644. name: string;
  64645. shader: string;
  64646. };
  64647. }
  64648. declare module "babylonjs/Shaders/fxaa.vertex" {
  64649. /** @hidden */
  64650. export var fxaaVertexShader: {
  64651. name: string;
  64652. shader: string;
  64653. };
  64654. }
  64655. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64656. import { Nullable } from "babylonjs/types";
  64657. import { Camera } from "babylonjs/Cameras/camera";
  64658. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64659. import { Engine } from "babylonjs/Engines/engine";
  64660. import "babylonjs/Shaders/fxaa.fragment";
  64661. import "babylonjs/Shaders/fxaa.vertex";
  64662. /**
  64663. * Fxaa post process
  64664. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64665. */
  64666. export class FxaaPostProcess extends PostProcess {
  64667. /** @hidden */
  64668. texelWidth: number;
  64669. /** @hidden */
  64670. texelHeight: number;
  64671. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64672. private _getDefines;
  64673. }
  64674. }
  64675. declare module "babylonjs/Shaders/grain.fragment" {
  64676. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64677. /** @hidden */
  64678. export var grainPixelShader: {
  64679. name: string;
  64680. shader: string;
  64681. };
  64682. }
  64683. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64684. import { Nullable } from "babylonjs/types";
  64685. import { Camera } from "babylonjs/Cameras/camera";
  64686. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64687. import { Engine } from "babylonjs/Engines/engine";
  64688. import "babylonjs/Shaders/grain.fragment";
  64689. /**
  64690. * The GrainPostProcess adds noise to the image at mid luminance levels
  64691. */
  64692. export class GrainPostProcess extends PostProcess {
  64693. /**
  64694. * The intensity of the grain added (default: 30)
  64695. */
  64696. intensity: number;
  64697. /**
  64698. * If the grain should be randomized on every frame
  64699. */
  64700. animated: boolean;
  64701. /**
  64702. * Creates a new instance of @see GrainPostProcess
  64703. * @param name The name of the effect.
  64704. * @param options The required width/height ratio to downsize to before computing the render pass.
  64705. * @param camera The camera to apply the render pass to.
  64706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64707. * @param engine The engine which the post process will be applied. (default: current engine)
  64708. * @param reusable If the post process can be reused on the same frame. (default: false)
  64709. * @param textureType Type of textures used when performing the post process. (default: 0)
  64710. * @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)
  64711. */
  64712. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64713. }
  64714. }
  64715. declare module "babylonjs/Shaders/highlights.fragment" {
  64716. /** @hidden */
  64717. export var highlightsPixelShader: {
  64718. name: string;
  64719. shader: string;
  64720. };
  64721. }
  64722. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64723. import { Nullable } from "babylonjs/types";
  64724. import { Camera } from "babylonjs/Cameras/camera";
  64725. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64726. import { Engine } from "babylonjs/Engines/engine";
  64727. import "babylonjs/Shaders/highlights.fragment";
  64728. /**
  64729. * Extracts highlights from the image
  64730. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64731. */
  64732. export class HighlightsPostProcess extends PostProcess {
  64733. /**
  64734. * Extracts highlights from the image
  64735. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64736. * @param name The name of the effect.
  64737. * @param options The required width/height ratio to downsize to before computing the render pass.
  64738. * @param camera The camera to apply the render pass to.
  64739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64740. * @param engine The engine which the post process will be applied. (default: current engine)
  64741. * @param reusable If the post process can be reused on the same frame. (default: false)
  64742. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64743. */
  64744. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64745. }
  64746. }
  64747. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64748. /** @hidden */
  64749. export var mrtFragmentDeclaration: {
  64750. name: string;
  64751. shader: string;
  64752. };
  64753. }
  64754. declare module "babylonjs/Shaders/geometry.fragment" {
  64755. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64756. /** @hidden */
  64757. export var geometryPixelShader: {
  64758. name: string;
  64759. shader: string;
  64760. };
  64761. }
  64762. declare module "babylonjs/Shaders/geometry.vertex" {
  64763. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64764. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64765. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64766. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64767. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64768. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64769. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64770. /** @hidden */
  64771. export var geometryVertexShader: {
  64772. name: string;
  64773. shader: string;
  64774. };
  64775. }
  64776. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64777. import { Matrix } from "babylonjs/Maths/math.vector";
  64778. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64779. import { Mesh } from "babylonjs/Meshes/mesh";
  64780. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64781. import { Effect } from "babylonjs/Materials/effect";
  64782. import { Scene } from "babylonjs/scene";
  64783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64784. import "babylonjs/Shaders/geometry.fragment";
  64785. import "babylonjs/Shaders/geometry.vertex";
  64786. /** @hidden */
  64787. interface ISavedTransformationMatrix {
  64788. world: Matrix;
  64789. viewProjection: Matrix;
  64790. }
  64791. /**
  64792. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64793. */
  64794. export class GeometryBufferRenderer {
  64795. /**
  64796. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64797. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64798. */
  64799. static readonly POSITION_TEXTURE_TYPE: number;
  64800. /**
  64801. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64802. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64803. */
  64804. static readonly VELOCITY_TEXTURE_TYPE: number;
  64805. /**
  64806. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64807. * in order to compute objects velocities when enableVelocity is set to "true"
  64808. * @hidden
  64809. */
  64810. _previousTransformationMatrices: {
  64811. [index: number]: ISavedTransformationMatrix;
  64812. };
  64813. /**
  64814. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64815. * in order to compute objects velocities when enableVelocity is set to "true"
  64816. * @hidden
  64817. */
  64818. _previousBonesTransformationMatrices: {
  64819. [index: number]: Float32Array;
  64820. };
  64821. /**
  64822. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64823. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64824. */
  64825. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64826. private _scene;
  64827. private _multiRenderTarget;
  64828. private _ratio;
  64829. private _enablePosition;
  64830. private _enableVelocity;
  64831. private _positionIndex;
  64832. private _velocityIndex;
  64833. protected _effect: Effect;
  64834. protected _cachedDefines: string;
  64835. /**
  64836. * Set the render list (meshes to be rendered) used in the G buffer.
  64837. */
  64838. renderList: Mesh[];
  64839. /**
  64840. * Gets wether or not G buffer are supported by the running hardware.
  64841. * This requires draw buffer supports
  64842. */
  64843. readonly isSupported: boolean;
  64844. /**
  64845. * Returns the index of the given texture type in the G-Buffer textures array
  64846. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64847. * @returns the index of the given texture type in the G-Buffer textures array
  64848. */
  64849. getTextureIndex(textureType: number): number;
  64850. /**
  64851. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64852. */
  64853. /**
  64854. * Sets whether or not objects positions are enabled for the G buffer.
  64855. */
  64856. enablePosition: boolean;
  64857. /**
  64858. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64859. */
  64860. /**
  64861. * Sets wether or not objects velocities are enabled for the G buffer.
  64862. */
  64863. enableVelocity: boolean;
  64864. /**
  64865. * Gets the scene associated with the buffer.
  64866. */
  64867. readonly scene: Scene;
  64868. /**
  64869. * Gets the ratio used by the buffer during its creation.
  64870. * How big is the buffer related to the main canvas.
  64871. */
  64872. readonly ratio: number;
  64873. /** @hidden */
  64874. static _SceneComponentInitialization: (scene: Scene) => void;
  64875. /**
  64876. * Creates a new G Buffer for the scene
  64877. * @param scene The scene the buffer belongs to
  64878. * @param ratio How big is the buffer related to the main canvas.
  64879. */
  64880. constructor(scene: Scene, ratio?: number);
  64881. /**
  64882. * Checks wether everything is ready to render a submesh to the G buffer.
  64883. * @param subMesh the submesh to check readiness for
  64884. * @param useInstances is the mesh drawn using instance or not
  64885. * @returns true if ready otherwise false
  64886. */
  64887. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64888. /**
  64889. * Gets the current underlying G Buffer.
  64890. * @returns the buffer
  64891. */
  64892. getGBuffer(): MultiRenderTarget;
  64893. /**
  64894. * Gets the number of samples used to render the buffer (anti aliasing).
  64895. */
  64896. /**
  64897. * Sets the number of samples used to render the buffer (anti aliasing).
  64898. */
  64899. samples: number;
  64900. /**
  64901. * Disposes the renderer and frees up associated resources.
  64902. */
  64903. dispose(): void;
  64904. protected _createRenderTargets(): void;
  64905. private _copyBonesTransformationMatrices;
  64906. }
  64907. }
  64908. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64909. import { Nullable } from "babylonjs/types";
  64910. import { Scene } from "babylonjs/scene";
  64911. import { ISceneComponent } from "babylonjs/sceneComponent";
  64912. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64913. module "babylonjs/scene" {
  64914. interface Scene {
  64915. /** @hidden (Backing field) */
  64916. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64917. /**
  64918. * Gets or Sets the current geometry buffer associated to the scene.
  64919. */
  64920. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64921. /**
  64922. * Enables a GeometryBufferRender and associates it with the scene
  64923. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64924. * @returns the GeometryBufferRenderer
  64925. */
  64926. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64927. /**
  64928. * Disables the GeometryBufferRender associated with the scene
  64929. */
  64930. disableGeometryBufferRenderer(): void;
  64931. }
  64932. }
  64933. /**
  64934. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64935. * in several rendering techniques.
  64936. */
  64937. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64938. /**
  64939. * The component name helpful to identify the component in the list of scene components.
  64940. */
  64941. readonly name: string;
  64942. /**
  64943. * The scene the component belongs to.
  64944. */
  64945. scene: Scene;
  64946. /**
  64947. * Creates a new instance of the component for the given scene
  64948. * @param scene Defines the scene to register the component in
  64949. */
  64950. constructor(scene: Scene);
  64951. /**
  64952. * Registers the component in a given scene
  64953. */
  64954. register(): void;
  64955. /**
  64956. * Rebuilds the elements related to this component in case of
  64957. * context lost for instance.
  64958. */
  64959. rebuild(): void;
  64960. /**
  64961. * Disposes the component and the associated ressources
  64962. */
  64963. dispose(): void;
  64964. private _gatherRenderTargets;
  64965. }
  64966. }
  64967. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64968. /** @hidden */
  64969. export var motionBlurPixelShader: {
  64970. name: string;
  64971. shader: string;
  64972. };
  64973. }
  64974. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64975. import { Nullable } from "babylonjs/types";
  64976. import { Camera } from "babylonjs/Cameras/camera";
  64977. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64978. import { Scene } from "babylonjs/scene";
  64979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64980. import "babylonjs/Animations/animatable";
  64981. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64982. import "babylonjs/Shaders/motionBlur.fragment";
  64983. import { Engine } from "babylonjs/Engines/engine";
  64984. /**
  64985. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64986. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64987. * As an example, all you have to do is to create the post-process:
  64988. * var mb = new BABYLON.MotionBlurPostProcess(
  64989. * 'mb', // The name of the effect.
  64990. * scene, // The scene containing the objects to blur according to their velocity.
  64991. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64992. * camera // The camera to apply the render pass to.
  64993. * );
  64994. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64995. */
  64996. export class MotionBlurPostProcess extends PostProcess {
  64997. /**
  64998. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64999. */
  65000. motionStrength: number;
  65001. /**
  65002. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65003. */
  65004. /**
  65005. * Sets the number of iterations to be used for motion blur quality
  65006. */
  65007. motionBlurSamples: number;
  65008. private _motionBlurSamples;
  65009. private _geometryBufferRenderer;
  65010. /**
  65011. * Creates a new instance MotionBlurPostProcess
  65012. * @param name The name of the effect.
  65013. * @param scene The scene containing the objects to blur according to their velocity.
  65014. * @param options The required width/height ratio to downsize to before computing the render pass.
  65015. * @param camera The camera to apply the render pass to.
  65016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65017. * @param engine The engine which the post process will be applied. (default: current engine)
  65018. * @param reusable If the post process can be reused on the same frame. (default: false)
  65019. * @param textureType Type of textures used when performing the post process. (default: 0)
  65020. * @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)
  65021. */
  65022. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65023. /**
  65024. * Excludes the given skinned mesh from computing bones velocities.
  65025. * 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.
  65026. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65027. */
  65028. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65029. /**
  65030. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65031. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65032. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65033. */
  65034. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65035. /**
  65036. * Disposes the post process.
  65037. * @param camera The camera to dispose the post process on.
  65038. */
  65039. dispose(camera?: Camera): void;
  65040. }
  65041. }
  65042. declare module "babylonjs/Shaders/refraction.fragment" {
  65043. /** @hidden */
  65044. export var refractionPixelShader: {
  65045. name: string;
  65046. shader: string;
  65047. };
  65048. }
  65049. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  65050. import { Color3 } from "babylonjs/Maths/math.color";
  65051. import { Camera } from "babylonjs/Cameras/camera";
  65052. import { Texture } from "babylonjs/Materials/Textures/texture";
  65053. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65054. import { Engine } from "babylonjs/Engines/engine";
  65055. import "babylonjs/Shaders/refraction.fragment";
  65056. /**
  65057. * Post process which applies a refractin texture
  65058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65059. */
  65060. export class RefractionPostProcess extends PostProcess {
  65061. /** the base color of the refraction (used to taint the rendering) */
  65062. color: Color3;
  65063. /** simulated refraction depth */
  65064. depth: number;
  65065. /** the coefficient of the base color (0 to remove base color tainting) */
  65066. colorLevel: number;
  65067. private _refTexture;
  65068. private _ownRefractionTexture;
  65069. /**
  65070. * Gets or sets the refraction texture
  65071. * Please note that you are responsible for disposing the texture if you set it manually
  65072. */
  65073. refractionTexture: Texture;
  65074. /**
  65075. * Initializes the RefractionPostProcess
  65076. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65077. * @param name The name of the effect.
  65078. * @param refractionTextureUrl Url of the refraction texture to use
  65079. * @param color the base color of the refraction (used to taint the rendering)
  65080. * @param depth simulated refraction depth
  65081. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65082. * @param camera The camera to apply the render pass to.
  65083. * @param options The required width/height ratio to downsize to before computing the render pass.
  65084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65085. * @param engine The engine which the post process will be applied. (default: current engine)
  65086. * @param reusable If the post process can be reused on the same frame. (default: false)
  65087. */
  65088. constructor(name: string, refractionTextureUrl: string,
  65089. /** the base color of the refraction (used to taint the rendering) */
  65090. color: Color3,
  65091. /** simulated refraction depth */
  65092. depth: number,
  65093. /** the coefficient of the base color (0 to remove base color tainting) */
  65094. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65095. /**
  65096. * Disposes of the post process
  65097. * @param camera Camera to dispose post process on
  65098. */
  65099. dispose(camera: Camera): void;
  65100. }
  65101. }
  65102. declare module "babylonjs/Shaders/sharpen.fragment" {
  65103. /** @hidden */
  65104. export var sharpenPixelShader: {
  65105. name: string;
  65106. shader: string;
  65107. };
  65108. }
  65109. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  65110. import { Nullable } from "babylonjs/types";
  65111. import { Camera } from "babylonjs/Cameras/camera";
  65112. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65113. import "babylonjs/Shaders/sharpen.fragment";
  65114. import { Engine } from "babylonjs/Engines/engine";
  65115. /**
  65116. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65117. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65118. */
  65119. export class SharpenPostProcess extends PostProcess {
  65120. /**
  65121. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65122. */
  65123. colorAmount: number;
  65124. /**
  65125. * How much sharpness should be applied (default: 0.3)
  65126. */
  65127. edgeAmount: number;
  65128. /**
  65129. * Creates a new instance ConvolutionPostProcess
  65130. * @param name The name of the effect.
  65131. * @param options The required width/height ratio to downsize to before computing the render pass.
  65132. * @param camera The camera to apply the render pass to.
  65133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65134. * @param engine The engine which the post process will be applied. (default: current engine)
  65135. * @param reusable If the post process can be reused on the same frame. (default: false)
  65136. * @param textureType Type of textures used when performing the post process. (default: 0)
  65137. * @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)
  65138. */
  65139. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65140. }
  65141. }
  65142. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  65143. import { Nullable } from "babylonjs/types";
  65144. import { Camera } from "babylonjs/Cameras/camera";
  65145. import { Engine } from "babylonjs/Engines/engine";
  65146. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65147. import { IInspectable } from "babylonjs/Misc/iInspectable";
  65148. /**
  65149. * PostProcessRenderPipeline
  65150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65151. */
  65152. export class PostProcessRenderPipeline {
  65153. private engine;
  65154. private _renderEffects;
  65155. private _renderEffectsForIsolatedPass;
  65156. /**
  65157. * List of inspectable custom properties (used by the Inspector)
  65158. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65159. */
  65160. inspectableCustomProperties: IInspectable[];
  65161. /**
  65162. * @hidden
  65163. */
  65164. protected _cameras: Camera[];
  65165. /** @hidden */
  65166. _name: string;
  65167. /**
  65168. * Gets pipeline name
  65169. */
  65170. readonly name: string;
  65171. /** Gets the list of attached cameras */
  65172. readonly cameras: Camera[];
  65173. /**
  65174. * Initializes a PostProcessRenderPipeline
  65175. * @param engine engine to add the pipeline to
  65176. * @param name name of the pipeline
  65177. */
  65178. constructor(engine: Engine, name: string);
  65179. /**
  65180. * Gets the class name
  65181. * @returns "PostProcessRenderPipeline"
  65182. */
  65183. getClassName(): string;
  65184. /**
  65185. * If all the render effects in the pipeline are supported
  65186. */
  65187. readonly isSupported: boolean;
  65188. /**
  65189. * Adds an effect to the pipeline
  65190. * @param renderEffect the effect to add
  65191. */
  65192. addEffect(renderEffect: PostProcessRenderEffect): void;
  65193. /** @hidden */
  65194. _rebuild(): void;
  65195. /** @hidden */
  65196. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65197. /** @hidden */
  65198. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65199. /** @hidden */
  65200. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65201. /** @hidden */
  65202. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65203. /** @hidden */
  65204. _attachCameras(cameras: Camera, unique: boolean): void;
  65205. /** @hidden */
  65206. _attachCameras(cameras: Camera[], unique: boolean): void;
  65207. /** @hidden */
  65208. _detachCameras(cameras: Camera): void;
  65209. /** @hidden */
  65210. _detachCameras(cameras: Nullable<Camera[]>): void;
  65211. /** @hidden */
  65212. _update(): void;
  65213. /** @hidden */
  65214. _reset(): void;
  65215. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65216. /**
  65217. * Disposes of the pipeline
  65218. */
  65219. dispose(): void;
  65220. }
  65221. }
  65222. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  65223. import { Camera } from "babylonjs/Cameras/camera";
  65224. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65225. /**
  65226. * PostProcessRenderPipelineManager class
  65227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65228. */
  65229. export class PostProcessRenderPipelineManager {
  65230. private _renderPipelines;
  65231. /**
  65232. * Initializes a PostProcessRenderPipelineManager
  65233. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65234. */
  65235. constructor();
  65236. /**
  65237. * Gets the list of supported render pipelines
  65238. */
  65239. readonly supportedPipelines: PostProcessRenderPipeline[];
  65240. /**
  65241. * Adds a pipeline to the manager
  65242. * @param renderPipeline The pipeline to add
  65243. */
  65244. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65245. /**
  65246. * Attaches a camera to the pipeline
  65247. * @param renderPipelineName The name of the pipeline to attach to
  65248. * @param cameras the camera to attach
  65249. * @param unique if the camera can be attached multiple times to the pipeline
  65250. */
  65251. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65252. /**
  65253. * Detaches a camera from the pipeline
  65254. * @param renderPipelineName The name of the pipeline to detach from
  65255. * @param cameras the camera to detach
  65256. */
  65257. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65258. /**
  65259. * Enables an effect by name on a pipeline
  65260. * @param renderPipelineName the name of the pipeline to enable the effect in
  65261. * @param renderEffectName the name of the effect to enable
  65262. * @param cameras the cameras that the effect should be enabled on
  65263. */
  65264. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65265. /**
  65266. * Disables an effect by name on a pipeline
  65267. * @param renderPipelineName the name of the pipeline to disable the effect in
  65268. * @param renderEffectName the name of the effect to disable
  65269. * @param cameras the cameras that the effect should be disabled on
  65270. */
  65271. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65272. /**
  65273. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65274. */
  65275. update(): void;
  65276. /** @hidden */
  65277. _rebuild(): void;
  65278. /**
  65279. * Disposes of the manager and pipelines
  65280. */
  65281. dispose(): void;
  65282. }
  65283. }
  65284. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  65285. import { ISceneComponent } from "babylonjs/sceneComponent";
  65286. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65287. import { Scene } from "babylonjs/scene";
  65288. module "babylonjs/scene" {
  65289. interface Scene {
  65290. /** @hidden (Backing field) */
  65291. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65292. /**
  65293. * Gets the postprocess render pipeline manager
  65294. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65295. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65296. */
  65297. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65298. }
  65299. }
  65300. /**
  65301. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65302. */
  65303. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65304. /**
  65305. * The component name helpfull to identify the component in the list of scene components.
  65306. */
  65307. readonly name: string;
  65308. /**
  65309. * The scene the component belongs to.
  65310. */
  65311. scene: Scene;
  65312. /**
  65313. * Creates a new instance of the component for the given scene
  65314. * @param scene Defines the scene to register the component in
  65315. */
  65316. constructor(scene: Scene);
  65317. /**
  65318. * Registers the component in a given scene
  65319. */
  65320. register(): void;
  65321. /**
  65322. * Rebuilds the elements related to this component in case of
  65323. * context lost for instance.
  65324. */
  65325. rebuild(): void;
  65326. /**
  65327. * Disposes the component and the associated ressources
  65328. */
  65329. dispose(): void;
  65330. private _gatherRenderTargets;
  65331. }
  65332. }
  65333. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  65334. import { Nullable } from "babylonjs/types";
  65335. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65336. import { Camera } from "babylonjs/Cameras/camera";
  65337. import { IDisposable } from "babylonjs/scene";
  65338. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  65339. import { Scene } from "babylonjs/scene";
  65340. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  65341. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65342. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65343. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  65344. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65345. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65346. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  65347. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65348. import { Animation } from "babylonjs/Animations/animation";
  65349. /**
  65350. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65351. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65352. */
  65353. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65354. private _scene;
  65355. private _camerasToBeAttached;
  65356. /**
  65357. * ID of the sharpen post process,
  65358. */
  65359. private readonly SharpenPostProcessId;
  65360. /**
  65361. * @ignore
  65362. * ID of the image processing post process;
  65363. */
  65364. readonly ImageProcessingPostProcessId: string;
  65365. /**
  65366. * @ignore
  65367. * ID of the Fast Approximate Anti-Aliasing post process;
  65368. */
  65369. readonly FxaaPostProcessId: string;
  65370. /**
  65371. * ID of the chromatic aberration post process,
  65372. */
  65373. private readonly ChromaticAberrationPostProcessId;
  65374. /**
  65375. * ID of the grain post process
  65376. */
  65377. private readonly GrainPostProcessId;
  65378. /**
  65379. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65380. */
  65381. sharpen: SharpenPostProcess;
  65382. private _sharpenEffect;
  65383. private bloom;
  65384. /**
  65385. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65386. */
  65387. depthOfField: DepthOfFieldEffect;
  65388. /**
  65389. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65390. */
  65391. fxaa: FxaaPostProcess;
  65392. /**
  65393. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65394. */
  65395. imageProcessing: ImageProcessingPostProcess;
  65396. /**
  65397. * Chromatic aberration post process which will shift rgb colors in the image
  65398. */
  65399. chromaticAberration: ChromaticAberrationPostProcess;
  65400. private _chromaticAberrationEffect;
  65401. /**
  65402. * Grain post process which add noise to the image
  65403. */
  65404. grain: GrainPostProcess;
  65405. private _grainEffect;
  65406. /**
  65407. * Glow post process which adds a glow to emissive areas of the image
  65408. */
  65409. private _glowLayer;
  65410. /**
  65411. * Animations which can be used to tweak settings over a period of time
  65412. */
  65413. animations: Animation[];
  65414. private _imageProcessingConfigurationObserver;
  65415. private _sharpenEnabled;
  65416. private _bloomEnabled;
  65417. private _depthOfFieldEnabled;
  65418. private _depthOfFieldBlurLevel;
  65419. private _fxaaEnabled;
  65420. private _imageProcessingEnabled;
  65421. private _defaultPipelineTextureType;
  65422. private _bloomScale;
  65423. private _chromaticAberrationEnabled;
  65424. private _grainEnabled;
  65425. private _buildAllowed;
  65426. /**
  65427. * Gets active scene
  65428. */
  65429. readonly scene: Scene;
  65430. /**
  65431. * Enable or disable the sharpen process from the pipeline
  65432. */
  65433. sharpenEnabled: boolean;
  65434. private _resizeObserver;
  65435. private _hardwareScaleLevel;
  65436. private _bloomKernel;
  65437. /**
  65438. * Specifies the size of the bloom blur kernel, relative to the final output size
  65439. */
  65440. bloomKernel: number;
  65441. /**
  65442. * Specifies the weight of the bloom in the final rendering
  65443. */
  65444. private _bloomWeight;
  65445. /**
  65446. * Specifies the luma threshold for the area that will be blurred by the bloom
  65447. */
  65448. private _bloomThreshold;
  65449. private _hdr;
  65450. /**
  65451. * The strength of the bloom.
  65452. */
  65453. bloomWeight: number;
  65454. /**
  65455. * The strength of the bloom.
  65456. */
  65457. bloomThreshold: number;
  65458. /**
  65459. * The scale of the bloom, lower value will provide better performance.
  65460. */
  65461. bloomScale: number;
  65462. /**
  65463. * Enable or disable the bloom from the pipeline
  65464. */
  65465. bloomEnabled: boolean;
  65466. private _rebuildBloom;
  65467. /**
  65468. * If the depth of field is enabled.
  65469. */
  65470. depthOfFieldEnabled: boolean;
  65471. /**
  65472. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65473. */
  65474. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  65475. /**
  65476. * If the anti aliasing is enabled.
  65477. */
  65478. fxaaEnabled: boolean;
  65479. private _samples;
  65480. /**
  65481. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65482. */
  65483. samples: number;
  65484. /**
  65485. * If image processing is enabled.
  65486. */
  65487. imageProcessingEnabled: boolean;
  65488. /**
  65489. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65490. */
  65491. glowLayerEnabled: boolean;
  65492. /**
  65493. * Gets the glow layer (or null if not defined)
  65494. */
  65495. readonly glowLayer: Nullable<GlowLayer>;
  65496. /**
  65497. * Enable or disable the chromaticAberration process from the pipeline
  65498. */
  65499. chromaticAberrationEnabled: boolean;
  65500. /**
  65501. * Enable or disable the grain process from the pipeline
  65502. */
  65503. grainEnabled: boolean;
  65504. /**
  65505. * @constructor
  65506. * @param name - The rendering pipeline name (default: "")
  65507. * @param hdr - If high dynamic range textures should be used (default: true)
  65508. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65509. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65510. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65511. */
  65512. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65513. /**
  65514. * Get the class name
  65515. * @returns "DefaultRenderingPipeline"
  65516. */
  65517. getClassName(): string;
  65518. /**
  65519. * Force the compilation of the entire pipeline.
  65520. */
  65521. prepare(): void;
  65522. private _hasCleared;
  65523. private _prevPostProcess;
  65524. private _prevPrevPostProcess;
  65525. private _setAutoClearAndTextureSharing;
  65526. private _depthOfFieldSceneObserver;
  65527. private _buildPipeline;
  65528. private _disposePostProcesses;
  65529. /**
  65530. * Adds a camera to the pipeline
  65531. * @param camera the camera to be added
  65532. */
  65533. addCamera(camera: Camera): void;
  65534. /**
  65535. * Removes a camera from the pipeline
  65536. * @param camera the camera to remove
  65537. */
  65538. removeCamera(camera: Camera): void;
  65539. /**
  65540. * Dispose of the pipeline and stop all post processes
  65541. */
  65542. dispose(): void;
  65543. /**
  65544. * Serialize the rendering pipeline (Used when exporting)
  65545. * @returns the serialized object
  65546. */
  65547. serialize(): any;
  65548. /**
  65549. * Parse the serialized pipeline
  65550. * @param source Source pipeline.
  65551. * @param scene The scene to load the pipeline to.
  65552. * @param rootUrl The URL of the serialized pipeline.
  65553. * @returns An instantiated pipeline from the serialized object.
  65554. */
  65555. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65556. }
  65557. }
  65558. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  65559. /** @hidden */
  65560. export var lensHighlightsPixelShader: {
  65561. name: string;
  65562. shader: string;
  65563. };
  65564. }
  65565. declare module "babylonjs/Shaders/depthOfField.fragment" {
  65566. /** @hidden */
  65567. export var depthOfFieldPixelShader: {
  65568. name: string;
  65569. shader: string;
  65570. };
  65571. }
  65572. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  65573. import { Camera } from "babylonjs/Cameras/camera";
  65574. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65575. import { Scene } from "babylonjs/scene";
  65576. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65577. import "babylonjs/Shaders/chromaticAberration.fragment";
  65578. import "babylonjs/Shaders/lensHighlights.fragment";
  65579. import "babylonjs/Shaders/depthOfField.fragment";
  65580. /**
  65581. * BABYLON.JS Chromatic Aberration GLSL Shader
  65582. * Author: Olivier Guyot
  65583. * Separates very slightly R, G and B colors on the edges of the screen
  65584. * Inspired by Francois Tarlier & Martins Upitis
  65585. */
  65586. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65587. /**
  65588. * @ignore
  65589. * The chromatic aberration PostProcess id in the pipeline
  65590. */
  65591. LensChromaticAberrationEffect: string;
  65592. /**
  65593. * @ignore
  65594. * The highlights enhancing PostProcess id in the pipeline
  65595. */
  65596. HighlightsEnhancingEffect: string;
  65597. /**
  65598. * @ignore
  65599. * The depth-of-field PostProcess id in the pipeline
  65600. */
  65601. LensDepthOfFieldEffect: string;
  65602. private _scene;
  65603. private _depthTexture;
  65604. private _grainTexture;
  65605. private _chromaticAberrationPostProcess;
  65606. private _highlightsPostProcess;
  65607. private _depthOfFieldPostProcess;
  65608. private _edgeBlur;
  65609. private _grainAmount;
  65610. private _chromaticAberration;
  65611. private _distortion;
  65612. private _highlightsGain;
  65613. private _highlightsThreshold;
  65614. private _dofDistance;
  65615. private _dofAperture;
  65616. private _dofDarken;
  65617. private _dofPentagon;
  65618. private _blurNoise;
  65619. /**
  65620. * @constructor
  65621. *
  65622. * Effect parameters are as follow:
  65623. * {
  65624. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65625. * edge_blur: number; // from 0 to x (1 for realism)
  65626. * distortion: number; // from 0 to x (1 for realism)
  65627. * grain_amount: number; // from 0 to 1
  65628. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65629. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65630. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65631. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65632. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65633. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65634. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65635. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65636. * }
  65637. * Note: if an effect parameter is unset, effect is disabled
  65638. *
  65639. * @param name The rendering pipeline name
  65640. * @param parameters - An object containing all parameters (see above)
  65641. * @param scene The scene linked to this pipeline
  65642. * @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)
  65643. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65644. */
  65645. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65646. /**
  65647. * Get the class name
  65648. * @returns "LensRenderingPipeline"
  65649. */
  65650. getClassName(): string;
  65651. /**
  65652. * Gets associated scene
  65653. */
  65654. readonly scene: Scene;
  65655. /**
  65656. * Gets or sets the edge blur
  65657. */
  65658. edgeBlur: number;
  65659. /**
  65660. * Gets or sets the grain amount
  65661. */
  65662. grainAmount: number;
  65663. /**
  65664. * Gets or sets the chromatic aberration amount
  65665. */
  65666. chromaticAberration: number;
  65667. /**
  65668. * Gets or sets the depth of field aperture
  65669. */
  65670. dofAperture: number;
  65671. /**
  65672. * Gets or sets the edge distortion
  65673. */
  65674. edgeDistortion: number;
  65675. /**
  65676. * Gets or sets the depth of field distortion
  65677. */
  65678. dofDistortion: number;
  65679. /**
  65680. * Gets or sets the darken out of focus amount
  65681. */
  65682. darkenOutOfFocus: number;
  65683. /**
  65684. * Gets or sets a boolean indicating if blur noise is enabled
  65685. */
  65686. blurNoise: boolean;
  65687. /**
  65688. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65689. */
  65690. pentagonBokeh: boolean;
  65691. /**
  65692. * Gets or sets the highlight grain amount
  65693. */
  65694. highlightsGain: number;
  65695. /**
  65696. * Gets or sets the highlight threshold
  65697. */
  65698. highlightsThreshold: number;
  65699. /**
  65700. * Sets the amount of blur at the edges
  65701. * @param amount blur amount
  65702. */
  65703. setEdgeBlur(amount: number): void;
  65704. /**
  65705. * Sets edge blur to 0
  65706. */
  65707. disableEdgeBlur(): void;
  65708. /**
  65709. * Sets the amout of grain
  65710. * @param amount Amount of grain
  65711. */
  65712. setGrainAmount(amount: number): void;
  65713. /**
  65714. * Set grain amount to 0
  65715. */
  65716. disableGrain(): void;
  65717. /**
  65718. * Sets the chromatic aberration amount
  65719. * @param amount amount of chromatic aberration
  65720. */
  65721. setChromaticAberration(amount: number): void;
  65722. /**
  65723. * Sets chromatic aberration amount to 0
  65724. */
  65725. disableChromaticAberration(): void;
  65726. /**
  65727. * Sets the EdgeDistortion amount
  65728. * @param amount amount of EdgeDistortion
  65729. */
  65730. setEdgeDistortion(amount: number): void;
  65731. /**
  65732. * Sets edge distortion to 0
  65733. */
  65734. disableEdgeDistortion(): void;
  65735. /**
  65736. * Sets the FocusDistance amount
  65737. * @param amount amount of FocusDistance
  65738. */
  65739. setFocusDistance(amount: number): void;
  65740. /**
  65741. * Disables depth of field
  65742. */
  65743. disableDepthOfField(): void;
  65744. /**
  65745. * Sets the Aperture amount
  65746. * @param amount amount of Aperture
  65747. */
  65748. setAperture(amount: number): void;
  65749. /**
  65750. * Sets the DarkenOutOfFocus amount
  65751. * @param amount amount of DarkenOutOfFocus
  65752. */
  65753. setDarkenOutOfFocus(amount: number): void;
  65754. private _pentagonBokehIsEnabled;
  65755. /**
  65756. * Creates a pentagon bokeh effect
  65757. */
  65758. enablePentagonBokeh(): void;
  65759. /**
  65760. * Disables the pentagon bokeh effect
  65761. */
  65762. disablePentagonBokeh(): void;
  65763. /**
  65764. * Enables noise blur
  65765. */
  65766. enableNoiseBlur(): void;
  65767. /**
  65768. * Disables noise blur
  65769. */
  65770. disableNoiseBlur(): void;
  65771. /**
  65772. * Sets the HighlightsGain amount
  65773. * @param amount amount of HighlightsGain
  65774. */
  65775. setHighlightsGain(amount: number): void;
  65776. /**
  65777. * Sets the HighlightsThreshold amount
  65778. * @param amount amount of HighlightsThreshold
  65779. */
  65780. setHighlightsThreshold(amount: number): void;
  65781. /**
  65782. * Disables highlights
  65783. */
  65784. disableHighlights(): void;
  65785. /**
  65786. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65787. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65788. */
  65789. dispose(disableDepthRender?: boolean): void;
  65790. private _createChromaticAberrationPostProcess;
  65791. private _createHighlightsPostProcess;
  65792. private _createDepthOfFieldPostProcess;
  65793. private _createGrainTexture;
  65794. }
  65795. }
  65796. declare module "babylonjs/Shaders/ssao2.fragment" {
  65797. /** @hidden */
  65798. export var ssao2PixelShader: {
  65799. name: string;
  65800. shader: string;
  65801. };
  65802. }
  65803. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65804. /** @hidden */
  65805. export var ssaoCombinePixelShader: {
  65806. name: string;
  65807. shader: string;
  65808. };
  65809. }
  65810. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65811. import { Camera } from "babylonjs/Cameras/camera";
  65812. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65813. import { Scene } from "babylonjs/scene";
  65814. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65815. import "babylonjs/Shaders/ssao2.fragment";
  65816. import "babylonjs/Shaders/ssaoCombine.fragment";
  65817. /**
  65818. * Render pipeline to produce ssao effect
  65819. */
  65820. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65821. /**
  65822. * @ignore
  65823. * The PassPostProcess id in the pipeline that contains the original scene color
  65824. */
  65825. SSAOOriginalSceneColorEffect: string;
  65826. /**
  65827. * @ignore
  65828. * The SSAO PostProcess id in the pipeline
  65829. */
  65830. SSAORenderEffect: string;
  65831. /**
  65832. * @ignore
  65833. * The horizontal blur PostProcess id in the pipeline
  65834. */
  65835. SSAOBlurHRenderEffect: string;
  65836. /**
  65837. * @ignore
  65838. * The vertical blur PostProcess id in the pipeline
  65839. */
  65840. SSAOBlurVRenderEffect: string;
  65841. /**
  65842. * @ignore
  65843. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65844. */
  65845. SSAOCombineRenderEffect: string;
  65846. /**
  65847. * The output strength of the SSAO post-process. Default value is 1.0.
  65848. */
  65849. totalStrength: number;
  65850. /**
  65851. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65852. */
  65853. maxZ: number;
  65854. /**
  65855. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65856. */
  65857. minZAspect: number;
  65858. private _samples;
  65859. /**
  65860. * Number of samples used for the SSAO calculations. Default value is 8
  65861. */
  65862. samples: number;
  65863. private _textureSamples;
  65864. /**
  65865. * Number of samples to use for antialiasing
  65866. */
  65867. textureSamples: number;
  65868. /**
  65869. * Ratio object used for SSAO ratio and blur ratio
  65870. */
  65871. private _ratio;
  65872. /**
  65873. * Dynamically generated sphere sampler.
  65874. */
  65875. private _sampleSphere;
  65876. /**
  65877. * Blur filter offsets
  65878. */
  65879. private _samplerOffsets;
  65880. private _expensiveBlur;
  65881. /**
  65882. * If bilateral blur should be used
  65883. */
  65884. expensiveBlur: boolean;
  65885. /**
  65886. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65887. */
  65888. radius: number;
  65889. /**
  65890. * The base color of the SSAO post-process
  65891. * The final result is "base + ssao" between [0, 1]
  65892. */
  65893. base: number;
  65894. /**
  65895. * Support test.
  65896. */
  65897. static readonly IsSupported: boolean;
  65898. private _scene;
  65899. private _depthTexture;
  65900. private _normalTexture;
  65901. private _randomTexture;
  65902. private _originalColorPostProcess;
  65903. private _ssaoPostProcess;
  65904. private _blurHPostProcess;
  65905. private _blurVPostProcess;
  65906. private _ssaoCombinePostProcess;
  65907. /**
  65908. * Gets active scene
  65909. */
  65910. readonly scene: Scene;
  65911. /**
  65912. * @constructor
  65913. * @param name The rendering pipeline name
  65914. * @param scene The scene linked to this pipeline
  65915. * @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 }
  65916. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65917. */
  65918. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65919. /**
  65920. * Get the class name
  65921. * @returns "SSAO2RenderingPipeline"
  65922. */
  65923. getClassName(): string;
  65924. /**
  65925. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65926. */
  65927. dispose(disableGeometryBufferRenderer?: boolean): void;
  65928. private _createBlurPostProcess;
  65929. /** @hidden */
  65930. _rebuild(): void;
  65931. private _bits;
  65932. private _radicalInverse_VdC;
  65933. private _hammersley;
  65934. private _hemisphereSample_uniform;
  65935. private _generateHemisphere;
  65936. private _createSSAOPostProcess;
  65937. private _createSSAOCombinePostProcess;
  65938. private _createRandomTexture;
  65939. /**
  65940. * Serialize the rendering pipeline (Used when exporting)
  65941. * @returns the serialized object
  65942. */
  65943. serialize(): any;
  65944. /**
  65945. * Parse the serialized pipeline
  65946. * @param source Source pipeline.
  65947. * @param scene The scene to load the pipeline to.
  65948. * @param rootUrl The URL of the serialized pipeline.
  65949. * @returns An instantiated pipeline from the serialized object.
  65950. */
  65951. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65952. }
  65953. }
  65954. declare module "babylonjs/Shaders/ssao.fragment" {
  65955. /** @hidden */
  65956. export var ssaoPixelShader: {
  65957. name: string;
  65958. shader: string;
  65959. };
  65960. }
  65961. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65962. import { Camera } from "babylonjs/Cameras/camera";
  65963. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65964. import { Scene } from "babylonjs/scene";
  65965. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65966. import "babylonjs/Shaders/ssao.fragment";
  65967. import "babylonjs/Shaders/ssaoCombine.fragment";
  65968. /**
  65969. * Render pipeline to produce ssao effect
  65970. */
  65971. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65972. /**
  65973. * @ignore
  65974. * The PassPostProcess id in the pipeline that contains the original scene color
  65975. */
  65976. SSAOOriginalSceneColorEffect: string;
  65977. /**
  65978. * @ignore
  65979. * The SSAO PostProcess id in the pipeline
  65980. */
  65981. SSAORenderEffect: string;
  65982. /**
  65983. * @ignore
  65984. * The horizontal blur PostProcess id in the pipeline
  65985. */
  65986. SSAOBlurHRenderEffect: string;
  65987. /**
  65988. * @ignore
  65989. * The vertical blur PostProcess id in the pipeline
  65990. */
  65991. SSAOBlurVRenderEffect: string;
  65992. /**
  65993. * @ignore
  65994. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65995. */
  65996. SSAOCombineRenderEffect: string;
  65997. /**
  65998. * The output strength of the SSAO post-process. Default value is 1.0.
  65999. */
  66000. totalStrength: number;
  66001. /**
  66002. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66003. */
  66004. radius: number;
  66005. /**
  66006. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66007. * Must not be equal to fallOff and superior to fallOff.
  66008. * Default value is 0.0075
  66009. */
  66010. area: number;
  66011. /**
  66012. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66013. * Must not be equal to area and inferior to area.
  66014. * Default value is 0.000001
  66015. */
  66016. fallOff: number;
  66017. /**
  66018. * The base color of the SSAO post-process
  66019. * The final result is "base + ssao" between [0, 1]
  66020. */
  66021. base: number;
  66022. private _scene;
  66023. private _depthTexture;
  66024. private _randomTexture;
  66025. private _originalColorPostProcess;
  66026. private _ssaoPostProcess;
  66027. private _blurHPostProcess;
  66028. private _blurVPostProcess;
  66029. private _ssaoCombinePostProcess;
  66030. private _firstUpdate;
  66031. /**
  66032. * Gets active scene
  66033. */
  66034. readonly scene: Scene;
  66035. /**
  66036. * @constructor
  66037. * @param name - The rendering pipeline name
  66038. * @param scene - The scene linked to this pipeline
  66039. * @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 }
  66040. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66041. */
  66042. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66043. /**
  66044. * Get the class name
  66045. * @returns "SSAORenderingPipeline"
  66046. */
  66047. getClassName(): string;
  66048. /**
  66049. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66050. */
  66051. dispose(disableDepthRender?: boolean): void;
  66052. private _createBlurPostProcess;
  66053. /** @hidden */
  66054. _rebuild(): void;
  66055. private _createSSAOPostProcess;
  66056. private _createSSAOCombinePostProcess;
  66057. private _createRandomTexture;
  66058. }
  66059. }
  66060. declare module "babylonjs/Shaders/standard.fragment" {
  66061. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66062. /** @hidden */
  66063. export var standardPixelShader: {
  66064. name: string;
  66065. shader: string;
  66066. };
  66067. }
  66068. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  66069. import { Nullable } from "babylonjs/types";
  66070. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66071. import { Camera } from "babylonjs/Cameras/camera";
  66072. import { Texture } from "babylonjs/Materials/Textures/texture";
  66073. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66074. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66075. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  66076. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66077. import { IDisposable } from "babylonjs/scene";
  66078. import { SpotLight } from "babylonjs/Lights/spotLight";
  66079. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  66080. import { Scene } from "babylonjs/scene";
  66081. import { Animation } from "babylonjs/Animations/animation";
  66082. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66083. import "babylonjs/Shaders/standard.fragment";
  66084. /**
  66085. * Standard rendering pipeline
  66086. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66087. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66088. */
  66089. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66090. /**
  66091. * Public members
  66092. */
  66093. /**
  66094. * Post-process which contains the original scene color before the pipeline applies all the effects
  66095. */
  66096. originalPostProcess: Nullable<PostProcess>;
  66097. /**
  66098. * Post-process used to down scale an image x4
  66099. */
  66100. downSampleX4PostProcess: Nullable<PostProcess>;
  66101. /**
  66102. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66103. */
  66104. brightPassPostProcess: Nullable<PostProcess>;
  66105. /**
  66106. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66107. */
  66108. blurHPostProcesses: PostProcess[];
  66109. /**
  66110. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66111. */
  66112. blurVPostProcesses: PostProcess[];
  66113. /**
  66114. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66115. */
  66116. textureAdderPostProcess: Nullable<PostProcess>;
  66117. /**
  66118. * Post-process used to create volumetric lighting effect
  66119. */
  66120. volumetricLightPostProcess: Nullable<PostProcess>;
  66121. /**
  66122. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66123. */
  66124. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66125. /**
  66126. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66127. */
  66128. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66129. /**
  66130. * Post-process used to merge the volumetric light effect and the real scene color
  66131. */
  66132. volumetricLightMergePostProces: Nullable<PostProcess>;
  66133. /**
  66134. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66135. */
  66136. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66137. /**
  66138. * Base post-process used to calculate the average luminance of the final image for HDR
  66139. */
  66140. luminancePostProcess: Nullable<PostProcess>;
  66141. /**
  66142. * Post-processes used to create down sample post-processes in order to get
  66143. * the average luminance of the final image for HDR
  66144. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66145. */
  66146. luminanceDownSamplePostProcesses: PostProcess[];
  66147. /**
  66148. * Post-process used to create a HDR effect (light adaptation)
  66149. */
  66150. hdrPostProcess: Nullable<PostProcess>;
  66151. /**
  66152. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66153. */
  66154. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66155. /**
  66156. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66157. */
  66158. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66159. /**
  66160. * Post-process used to merge the final HDR post-process and the real scene color
  66161. */
  66162. hdrFinalPostProcess: Nullable<PostProcess>;
  66163. /**
  66164. * Post-process used to create a lens flare effect
  66165. */
  66166. lensFlarePostProcess: Nullable<PostProcess>;
  66167. /**
  66168. * Post-process that merges the result of the lens flare post-process and the real scene color
  66169. */
  66170. lensFlareComposePostProcess: Nullable<PostProcess>;
  66171. /**
  66172. * Post-process used to create a motion blur effect
  66173. */
  66174. motionBlurPostProcess: Nullable<PostProcess>;
  66175. /**
  66176. * Post-process used to create a depth of field effect
  66177. */
  66178. depthOfFieldPostProcess: Nullable<PostProcess>;
  66179. /**
  66180. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66181. */
  66182. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66183. /**
  66184. * Represents the brightness threshold in order to configure the illuminated surfaces
  66185. */
  66186. brightThreshold: number;
  66187. /**
  66188. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66189. */
  66190. blurWidth: number;
  66191. /**
  66192. * Sets if the blur for highlighted surfaces must be only horizontal
  66193. */
  66194. horizontalBlur: boolean;
  66195. /**
  66196. * Gets the overall exposure used by the pipeline
  66197. */
  66198. /**
  66199. * Sets the overall exposure used by the pipeline
  66200. */
  66201. exposure: number;
  66202. /**
  66203. * Texture used typically to simulate "dirty" on camera lens
  66204. */
  66205. lensTexture: Nullable<Texture>;
  66206. /**
  66207. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66208. */
  66209. volumetricLightCoefficient: number;
  66210. /**
  66211. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66212. */
  66213. volumetricLightPower: number;
  66214. /**
  66215. * Used the set the blur intensity to smooth the volumetric lights
  66216. */
  66217. volumetricLightBlurScale: number;
  66218. /**
  66219. * Light (spot or directional) used to generate the volumetric lights rays
  66220. * The source light must have a shadow generate so the pipeline can get its
  66221. * depth map
  66222. */
  66223. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66224. /**
  66225. * For eye adaptation, represents the minimum luminance the eye can see
  66226. */
  66227. hdrMinimumLuminance: number;
  66228. /**
  66229. * For eye adaptation, represents the decrease luminance speed
  66230. */
  66231. hdrDecreaseRate: number;
  66232. /**
  66233. * For eye adaptation, represents the increase luminance speed
  66234. */
  66235. hdrIncreaseRate: number;
  66236. /**
  66237. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66238. */
  66239. /**
  66240. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66241. */
  66242. hdrAutoExposure: boolean;
  66243. /**
  66244. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66245. */
  66246. lensColorTexture: Nullable<Texture>;
  66247. /**
  66248. * The overall strengh for the lens flare effect
  66249. */
  66250. lensFlareStrength: number;
  66251. /**
  66252. * Dispersion coefficient for lens flare ghosts
  66253. */
  66254. lensFlareGhostDispersal: number;
  66255. /**
  66256. * Main lens flare halo width
  66257. */
  66258. lensFlareHaloWidth: number;
  66259. /**
  66260. * Based on the lens distortion effect, defines how much the lens flare result
  66261. * is distorted
  66262. */
  66263. lensFlareDistortionStrength: number;
  66264. /**
  66265. * Configures the blur intensity used for for lens flare (halo)
  66266. */
  66267. lensFlareBlurWidth: number;
  66268. /**
  66269. * Lens star texture must be used to simulate rays on the flares and is available
  66270. * in the documentation
  66271. */
  66272. lensStarTexture: Nullable<Texture>;
  66273. /**
  66274. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66275. * flare effect by taking account of the dirt texture
  66276. */
  66277. lensFlareDirtTexture: Nullable<Texture>;
  66278. /**
  66279. * Represents the focal length for the depth of field effect
  66280. */
  66281. depthOfFieldDistance: number;
  66282. /**
  66283. * Represents the blur intensity for the blurred part of the depth of field effect
  66284. */
  66285. depthOfFieldBlurWidth: number;
  66286. /**
  66287. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66288. */
  66289. /**
  66290. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66291. */
  66292. motionStrength: number;
  66293. /**
  66294. * Gets wether or not the motion blur post-process is object based or screen based.
  66295. */
  66296. /**
  66297. * Sets wether or not the motion blur post-process should be object based or screen based
  66298. */
  66299. objectBasedMotionBlur: boolean;
  66300. /**
  66301. * List of animations for the pipeline (IAnimatable implementation)
  66302. */
  66303. animations: Animation[];
  66304. /**
  66305. * Private members
  66306. */
  66307. private _scene;
  66308. private _currentDepthOfFieldSource;
  66309. private _basePostProcess;
  66310. private _fixedExposure;
  66311. private _currentExposure;
  66312. private _hdrAutoExposure;
  66313. private _hdrCurrentLuminance;
  66314. private _motionStrength;
  66315. private _isObjectBasedMotionBlur;
  66316. private _floatTextureType;
  66317. private _camerasToBeAttached;
  66318. private _ratio;
  66319. private _bloomEnabled;
  66320. private _depthOfFieldEnabled;
  66321. private _vlsEnabled;
  66322. private _lensFlareEnabled;
  66323. private _hdrEnabled;
  66324. private _motionBlurEnabled;
  66325. private _fxaaEnabled;
  66326. private _motionBlurSamples;
  66327. private _volumetricLightStepsCount;
  66328. private _samples;
  66329. /**
  66330. * @ignore
  66331. * Specifies if the bloom pipeline is enabled
  66332. */
  66333. BloomEnabled: boolean;
  66334. /**
  66335. * @ignore
  66336. * Specifies if the depth of field pipeline is enabed
  66337. */
  66338. DepthOfFieldEnabled: boolean;
  66339. /**
  66340. * @ignore
  66341. * Specifies if the lens flare pipeline is enabed
  66342. */
  66343. LensFlareEnabled: boolean;
  66344. /**
  66345. * @ignore
  66346. * Specifies if the HDR pipeline is enabled
  66347. */
  66348. HDREnabled: boolean;
  66349. /**
  66350. * @ignore
  66351. * Specifies if the volumetric lights scattering effect is enabled
  66352. */
  66353. VLSEnabled: boolean;
  66354. /**
  66355. * @ignore
  66356. * Specifies if the motion blur effect is enabled
  66357. */
  66358. MotionBlurEnabled: boolean;
  66359. /**
  66360. * Specifies if anti-aliasing is enabled
  66361. */
  66362. fxaaEnabled: boolean;
  66363. /**
  66364. * Specifies the number of steps used to calculate the volumetric lights
  66365. * Typically in interval [50, 200]
  66366. */
  66367. volumetricLightStepsCount: number;
  66368. /**
  66369. * Specifies the number of samples used for the motion blur effect
  66370. * Typically in interval [16, 64]
  66371. */
  66372. motionBlurSamples: number;
  66373. /**
  66374. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66375. */
  66376. samples: number;
  66377. /**
  66378. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66379. * @constructor
  66380. * @param name The rendering pipeline name
  66381. * @param scene The scene linked to this pipeline
  66382. * @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)
  66383. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66384. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66385. */
  66386. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66387. private _buildPipeline;
  66388. private _createDownSampleX4PostProcess;
  66389. private _createBrightPassPostProcess;
  66390. private _createBlurPostProcesses;
  66391. private _createTextureAdderPostProcess;
  66392. private _createVolumetricLightPostProcess;
  66393. private _createLuminancePostProcesses;
  66394. private _createHdrPostProcess;
  66395. private _createLensFlarePostProcess;
  66396. private _createDepthOfFieldPostProcess;
  66397. private _createMotionBlurPostProcess;
  66398. private _getDepthTexture;
  66399. private _disposePostProcesses;
  66400. /**
  66401. * Dispose of the pipeline and stop all post processes
  66402. */
  66403. dispose(): void;
  66404. /**
  66405. * Serialize the rendering pipeline (Used when exporting)
  66406. * @returns the serialized object
  66407. */
  66408. serialize(): any;
  66409. /**
  66410. * Parse the serialized pipeline
  66411. * @param source Source pipeline.
  66412. * @param scene The scene to load the pipeline to.
  66413. * @param rootUrl The URL of the serialized pipeline.
  66414. * @returns An instantiated pipeline from the serialized object.
  66415. */
  66416. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66417. /**
  66418. * Luminance steps
  66419. */
  66420. static LuminanceSteps: number;
  66421. }
  66422. }
  66423. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  66424. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  66425. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  66426. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  66427. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  66428. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  66429. }
  66430. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  66431. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  66432. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66433. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66434. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66435. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66436. }
  66437. declare module "babylonjs/Shaders/tonemap.fragment" {
  66438. /** @hidden */
  66439. export var tonemapPixelShader: {
  66440. name: string;
  66441. shader: string;
  66442. };
  66443. }
  66444. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  66445. import { Camera } from "babylonjs/Cameras/camera";
  66446. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66447. import "babylonjs/Shaders/tonemap.fragment";
  66448. import { Engine } from "babylonjs/Engines/engine";
  66449. /** Defines operator used for tonemapping */
  66450. export enum TonemappingOperator {
  66451. /** Hable */
  66452. Hable = 0,
  66453. /** Reinhard */
  66454. Reinhard = 1,
  66455. /** HejiDawson */
  66456. HejiDawson = 2,
  66457. /** Photographic */
  66458. Photographic = 3
  66459. }
  66460. /**
  66461. * Defines a post process to apply tone mapping
  66462. */
  66463. export class TonemapPostProcess extends PostProcess {
  66464. private _operator;
  66465. /** Defines the required exposure adjustement */
  66466. exposureAdjustment: number;
  66467. /**
  66468. * Creates a new TonemapPostProcess
  66469. * @param name defines the name of the postprocess
  66470. * @param _operator defines the operator to use
  66471. * @param exposureAdjustment defines the required exposure adjustement
  66472. * @param camera defines the camera to use (can be null)
  66473. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66474. * @param engine defines the hosting engine (can be ignore if camera is set)
  66475. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66476. */
  66477. constructor(name: string, _operator: TonemappingOperator,
  66478. /** Defines the required exposure adjustement */
  66479. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66480. }
  66481. }
  66482. declare module "babylonjs/Shaders/depth.vertex" {
  66483. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66484. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66485. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66486. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66487. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66488. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66489. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66490. /** @hidden */
  66491. export var depthVertexShader: {
  66492. name: string;
  66493. shader: string;
  66494. };
  66495. }
  66496. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  66497. /** @hidden */
  66498. export var volumetricLightScatteringPixelShader: {
  66499. name: string;
  66500. shader: string;
  66501. };
  66502. }
  66503. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  66504. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66505. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66506. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66507. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66508. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66509. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66510. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66511. /** @hidden */
  66512. export var volumetricLightScatteringPassVertexShader: {
  66513. name: string;
  66514. shader: string;
  66515. };
  66516. }
  66517. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  66518. /** @hidden */
  66519. export var volumetricLightScatteringPassPixelShader: {
  66520. name: string;
  66521. shader: string;
  66522. };
  66523. }
  66524. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  66525. import { Vector3 } from "babylonjs/Maths/math.vector";
  66526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66527. import { Mesh } from "babylonjs/Meshes/mesh";
  66528. import { Camera } from "babylonjs/Cameras/camera";
  66529. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66530. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66531. import { Scene } from "babylonjs/scene";
  66532. import "babylonjs/Meshes/Builders/planeBuilder";
  66533. import "babylonjs/Shaders/depth.vertex";
  66534. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  66535. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  66536. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  66537. import { Engine } from "babylonjs/Engines/engine";
  66538. /**
  66539. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66540. */
  66541. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66542. private _volumetricLightScatteringPass;
  66543. private _volumetricLightScatteringRTT;
  66544. private _viewPort;
  66545. private _screenCoordinates;
  66546. private _cachedDefines;
  66547. /**
  66548. * If not undefined, the mesh position is computed from the attached node position
  66549. */
  66550. attachedNode: {
  66551. position: Vector3;
  66552. };
  66553. /**
  66554. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66555. */
  66556. customMeshPosition: Vector3;
  66557. /**
  66558. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66559. */
  66560. useCustomMeshPosition: boolean;
  66561. /**
  66562. * If the post-process should inverse the light scattering direction
  66563. */
  66564. invert: boolean;
  66565. /**
  66566. * The internal mesh used by the post-process
  66567. */
  66568. mesh: Mesh;
  66569. /**
  66570. * @hidden
  66571. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66572. */
  66573. useDiffuseColor: boolean;
  66574. /**
  66575. * Array containing the excluded meshes not rendered in the internal pass
  66576. */
  66577. excludedMeshes: AbstractMesh[];
  66578. /**
  66579. * Controls the overall intensity of the post-process
  66580. */
  66581. exposure: number;
  66582. /**
  66583. * Dissipates each sample's contribution in range [0, 1]
  66584. */
  66585. decay: number;
  66586. /**
  66587. * Controls the overall intensity of each sample
  66588. */
  66589. weight: number;
  66590. /**
  66591. * Controls the density of each sample
  66592. */
  66593. density: number;
  66594. /**
  66595. * @constructor
  66596. * @param name The post-process name
  66597. * @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)
  66598. * @param camera The camera that the post-process will be attached to
  66599. * @param mesh The mesh used to create the light scattering
  66600. * @param samples The post-process quality, default 100
  66601. * @param samplingModeThe post-process filtering mode
  66602. * @param engine The babylon engine
  66603. * @param reusable If the post-process is reusable
  66604. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66605. */
  66606. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66607. /**
  66608. * Returns the string "VolumetricLightScatteringPostProcess"
  66609. * @returns "VolumetricLightScatteringPostProcess"
  66610. */
  66611. getClassName(): string;
  66612. private _isReady;
  66613. /**
  66614. * Sets the new light position for light scattering effect
  66615. * @param position The new custom light position
  66616. */
  66617. setCustomMeshPosition(position: Vector3): void;
  66618. /**
  66619. * Returns the light position for light scattering effect
  66620. * @return Vector3 The custom light position
  66621. */
  66622. getCustomMeshPosition(): Vector3;
  66623. /**
  66624. * Disposes the internal assets and detaches the post-process from the camera
  66625. */
  66626. dispose(camera: Camera): void;
  66627. /**
  66628. * Returns the render target texture used by the post-process
  66629. * @return the render target texture used by the post-process
  66630. */
  66631. getPass(): RenderTargetTexture;
  66632. private _meshExcluded;
  66633. private _createPass;
  66634. private _updateMeshScreenCoordinates;
  66635. /**
  66636. * Creates a default mesh for the Volumeric Light Scattering post-process
  66637. * @param name The mesh name
  66638. * @param scene The scene where to create the mesh
  66639. * @return the default mesh
  66640. */
  66641. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66642. }
  66643. }
  66644. declare module "babylonjs/PostProcesses/index" {
  66645. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  66646. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  66647. export * from "babylonjs/PostProcesses/bloomEffect";
  66648. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  66649. export * from "babylonjs/PostProcesses/blurPostProcess";
  66650. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66651. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66652. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66653. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66654. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66655. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66656. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66657. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66658. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66659. export * from "babylonjs/PostProcesses/filterPostProcess";
  66660. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66661. export * from "babylonjs/PostProcesses/grainPostProcess";
  66662. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66663. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66664. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66665. export * from "babylonjs/PostProcesses/passPostProcess";
  66666. export * from "babylonjs/PostProcesses/postProcess";
  66667. export * from "babylonjs/PostProcesses/postProcessManager";
  66668. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66669. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66670. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66671. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66672. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66673. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66674. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66675. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66676. }
  66677. declare module "babylonjs/Probes/index" {
  66678. export * from "babylonjs/Probes/reflectionProbe";
  66679. }
  66680. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66681. import { Scene } from "babylonjs/scene";
  66682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66683. import { SmartArray } from "babylonjs/Misc/smartArray";
  66684. import { ISceneComponent } from "babylonjs/sceneComponent";
  66685. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66686. import "babylonjs/Meshes/Builders/boxBuilder";
  66687. import "babylonjs/Shaders/color.fragment";
  66688. import "babylonjs/Shaders/color.vertex";
  66689. import { Color3 } from "babylonjs/Maths/math.color";
  66690. module "babylonjs/scene" {
  66691. interface Scene {
  66692. /** @hidden (Backing field) */
  66693. _boundingBoxRenderer: BoundingBoxRenderer;
  66694. /** @hidden (Backing field) */
  66695. _forceShowBoundingBoxes: boolean;
  66696. /**
  66697. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66698. */
  66699. forceShowBoundingBoxes: boolean;
  66700. /**
  66701. * Gets the bounding box renderer associated with the scene
  66702. * @returns a BoundingBoxRenderer
  66703. */
  66704. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66705. }
  66706. }
  66707. module "babylonjs/Meshes/abstractMesh" {
  66708. interface AbstractMesh {
  66709. /** @hidden (Backing field) */
  66710. _showBoundingBox: boolean;
  66711. /**
  66712. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66713. */
  66714. showBoundingBox: boolean;
  66715. }
  66716. }
  66717. /**
  66718. * Component responsible of rendering the bounding box of the meshes in a scene.
  66719. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66720. */
  66721. export class BoundingBoxRenderer implements ISceneComponent {
  66722. /**
  66723. * The component name helpfull to identify the component in the list of scene components.
  66724. */
  66725. readonly name: string;
  66726. /**
  66727. * The scene the component belongs to.
  66728. */
  66729. scene: Scene;
  66730. /**
  66731. * Color of the bounding box lines placed in front of an object
  66732. */
  66733. frontColor: Color3;
  66734. /**
  66735. * Color of the bounding box lines placed behind an object
  66736. */
  66737. backColor: Color3;
  66738. /**
  66739. * Defines if the renderer should show the back lines or not
  66740. */
  66741. showBackLines: boolean;
  66742. /**
  66743. * @hidden
  66744. */
  66745. renderList: SmartArray<BoundingBox>;
  66746. private _colorShader;
  66747. private _vertexBuffers;
  66748. private _indexBuffer;
  66749. private _fillIndexBuffer;
  66750. private _fillIndexData;
  66751. /**
  66752. * Instantiates a new bounding box renderer in a scene.
  66753. * @param scene the scene the renderer renders in
  66754. */
  66755. constructor(scene: Scene);
  66756. /**
  66757. * Registers the component in a given scene
  66758. */
  66759. register(): void;
  66760. private _evaluateSubMesh;
  66761. private _activeMesh;
  66762. private _prepareRessources;
  66763. private _createIndexBuffer;
  66764. /**
  66765. * Rebuilds the elements related to this component in case of
  66766. * context lost for instance.
  66767. */
  66768. rebuild(): void;
  66769. /**
  66770. * @hidden
  66771. */
  66772. reset(): void;
  66773. /**
  66774. * Render the bounding boxes of a specific rendering group
  66775. * @param renderingGroupId defines the rendering group to render
  66776. */
  66777. render(renderingGroupId: number): void;
  66778. /**
  66779. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66780. * @param mesh Define the mesh to render the occlusion bounding box for
  66781. */
  66782. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66783. /**
  66784. * Dispose and release the resources attached to this renderer.
  66785. */
  66786. dispose(): void;
  66787. }
  66788. }
  66789. declare module "babylonjs/Shaders/depth.fragment" {
  66790. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66791. /** @hidden */
  66792. export var depthPixelShader: {
  66793. name: string;
  66794. shader: string;
  66795. };
  66796. }
  66797. declare module "babylonjs/Rendering/depthRenderer" {
  66798. import { Nullable } from "babylonjs/types";
  66799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66800. import { Scene } from "babylonjs/scene";
  66801. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66802. import { Camera } from "babylonjs/Cameras/camera";
  66803. import "babylonjs/Shaders/depth.fragment";
  66804. import "babylonjs/Shaders/depth.vertex";
  66805. /**
  66806. * This represents a depth renderer in Babylon.
  66807. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66808. */
  66809. export class DepthRenderer {
  66810. private _scene;
  66811. private _depthMap;
  66812. private _effect;
  66813. private readonly _storeNonLinearDepth;
  66814. private readonly _clearColor;
  66815. /** Get if the depth renderer is using packed depth or not */
  66816. readonly isPacked: boolean;
  66817. private _cachedDefines;
  66818. private _camera;
  66819. /**
  66820. * Specifiess that the depth renderer will only be used within
  66821. * the camera it is created for.
  66822. * This can help forcing its rendering during the camera processing.
  66823. */
  66824. useOnlyInActiveCamera: boolean;
  66825. /** @hidden */
  66826. static _SceneComponentInitialization: (scene: Scene) => void;
  66827. /**
  66828. * Instantiates a depth renderer
  66829. * @param scene The scene the renderer belongs to
  66830. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66831. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66832. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66833. */
  66834. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66835. /**
  66836. * Creates the depth rendering effect and checks if the effect is ready.
  66837. * @param subMesh The submesh to be used to render the depth map of
  66838. * @param useInstances If multiple world instances should be used
  66839. * @returns if the depth renderer is ready to render the depth map
  66840. */
  66841. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66842. /**
  66843. * Gets the texture which the depth map will be written to.
  66844. * @returns The depth map texture
  66845. */
  66846. getDepthMap(): RenderTargetTexture;
  66847. /**
  66848. * Disposes of the depth renderer.
  66849. */
  66850. dispose(): void;
  66851. }
  66852. }
  66853. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66854. import { Nullable } from "babylonjs/types";
  66855. import { Scene } from "babylonjs/scene";
  66856. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66857. import { Camera } from "babylonjs/Cameras/camera";
  66858. import { ISceneComponent } from "babylonjs/sceneComponent";
  66859. module "babylonjs/scene" {
  66860. interface Scene {
  66861. /** @hidden (Backing field) */
  66862. _depthRenderer: {
  66863. [id: string]: DepthRenderer;
  66864. };
  66865. /**
  66866. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66867. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66868. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66869. * @returns the created depth renderer
  66870. */
  66871. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66872. /**
  66873. * Disables a depth renderer for a given camera
  66874. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66875. */
  66876. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66877. }
  66878. }
  66879. /**
  66880. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66881. * in several rendering techniques.
  66882. */
  66883. export class DepthRendererSceneComponent implements ISceneComponent {
  66884. /**
  66885. * The component name helpfull to identify the component in the list of scene components.
  66886. */
  66887. readonly name: string;
  66888. /**
  66889. * The scene the component belongs to.
  66890. */
  66891. scene: Scene;
  66892. /**
  66893. * Creates a new instance of the component for the given scene
  66894. * @param scene Defines the scene to register the component in
  66895. */
  66896. constructor(scene: Scene);
  66897. /**
  66898. * Registers the component in a given scene
  66899. */
  66900. register(): void;
  66901. /**
  66902. * Rebuilds the elements related to this component in case of
  66903. * context lost for instance.
  66904. */
  66905. rebuild(): void;
  66906. /**
  66907. * Disposes the component and the associated ressources
  66908. */
  66909. dispose(): void;
  66910. private _gatherRenderTargets;
  66911. private _gatherActiveCameraRenderTargets;
  66912. }
  66913. }
  66914. declare module "babylonjs/Shaders/outline.fragment" {
  66915. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66916. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66917. /** @hidden */
  66918. export var outlinePixelShader: {
  66919. name: string;
  66920. shader: string;
  66921. };
  66922. }
  66923. declare module "babylonjs/Shaders/outline.vertex" {
  66924. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66925. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66926. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66927. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66928. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66929. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66930. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66931. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66932. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66933. /** @hidden */
  66934. export var outlineVertexShader: {
  66935. name: string;
  66936. shader: string;
  66937. };
  66938. }
  66939. declare module "babylonjs/Rendering/outlineRenderer" {
  66940. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66941. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66942. import { Scene } from "babylonjs/scene";
  66943. import { ISceneComponent } from "babylonjs/sceneComponent";
  66944. import "babylonjs/Shaders/outline.fragment";
  66945. import "babylonjs/Shaders/outline.vertex";
  66946. module "babylonjs/scene" {
  66947. interface Scene {
  66948. /** @hidden */
  66949. _outlineRenderer: OutlineRenderer;
  66950. /**
  66951. * Gets the outline renderer associated with the scene
  66952. * @returns a OutlineRenderer
  66953. */
  66954. getOutlineRenderer(): OutlineRenderer;
  66955. }
  66956. }
  66957. module "babylonjs/Meshes/abstractMesh" {
  66958. interface AbstractMesh {
  66959. /** @hidden (Backing field) */
  66960. _renderOutline: boolean;
  66961. /**
  66962. * Gets or sets a boolean indicating if the outline must be rendered as well
  66963. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66964. */
  66965. renderOutline: boolean;
  66966. /** @hidden (Backing field) */
  66967. _renderOverlay: boolean;
  66968. /**
  66969. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66970. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66971. */
  66972. renderOverlay: boolean;
  66973. }
  66974. }
  66975. /**
  66976. * This class is responsible to draw bothe outline/overlay of meshes.
  66977. * It should not be used directly but through the available method on mesh.
  66978. */
  66979. export class OutlineRenderer implements ISceneComponent {
  66980. /**
  66981. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66982. */
  66983. private static _StencilReference;
  66984. /**
  66985. * The name of the component. Each component must have a unique name.
  66986. */
  66987. name: string;
  66988. /**
  66989. * The scene the component belongs to.
  66990. */
  66991. scene: Scene;
  66992. /**
  66993. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66994. */
  66995. zOffset: number;
  66996. private _engine;
  66997. private _effect;
  66998. private _cachedDefines;
  66999. private _savedDepthWrite;
  67000. /**
  67001. * Instantiates a new outline renderer. (There could be only one per scene).
  67002. * @param scene Defines the scene it belongs to
  67003. */
  67004. constructor(scene: Scene);
  67005. /**
  67006. * Register the component to one instance of a scene.
  67007. */
  67008. register(): void;
  67009. /**
  67010. * Rebuilds the elements related to this component in case of
  67011. * context lost for instance.
  67012. */
  67013. rebuild(): void;
  67014. /**
  67015. * Disposes the component and the associated ressources.
  67016. */
  67017. dispose(): void;
  67018. /**
  67019. * Renders the outline in the canvas.
  67020. * @param subMesh Defines the sumesh to render
  67021. * @param batch Defines the batch of meshes in case of instances
  67022. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67023. */
  67024. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67025. /**
  67026. * Returns whether or not the outline renderer is ready for a given submesh.
  67027. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67028. * @param subMesh Defines the submesh to check readyness for
  67029. * @param useInstances Defines wheter wee are trying to render instances or not
  67030. * @returns true if ready otherwise false
  67031. */
  67032. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67033. private _beforeRenderingMesh;
  67034. private _afterRenderingMesh;
  67035. }
  67036. }
  67037. declare module "babylonjs/Rendering/index" {
  67038. export * from "babylonjs/Rendering/boundingBoxRenderer";
  67039. export * from "babylonjs/Rendering/depthRenderer";
  67040. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  67041. export * from "babylonjs/Rendering/edgesRenderer";
  67042. export * from "babylonjs/Rendering/geometryBufferRenderer";
  67043. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67044. export * from "babylonjs/Rendering/outlineRenderer";
  67045. export * from "babylonjs/Rendering/renderingGroup";
  67046. export * from "babylonjs/Rendering/renderingManager";
  67047. export * from "babylonjs/Rendering/utilityLayerRenderer";
  67048. }
  67049. declare module "babylonjs/Sprites/spritePackedManager" {
  67050. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  67051. import { Scene } from "babylonjs/scene";
  67052. /**
  67053. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67054. * @see http://doc.babylonjs.com/babylon101/sprites
  67055. */
  67056. export class SpritePackedManager extends SpriteManager {
  67057. /** defines the packed manager's name */
  67058. name: string;
  67059. /**
  67060. * Creates a new sprite manager from a packed sprite sheet
  67061. * @param name defines the manager's name
  67062. * @param imgUrl defines the sprite sheet url
  67063. * @param capacity defines the maximum allowed number of sprites
  67064. * @param scene defines the hosting scene
  67065. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67066. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67067. * @param samplingMode defines the smapling mode to use with spritesheet
  67068. * @param fromPacked set to true; do not alter
  67069. */
  67070. constructor(
  67071. /** defines the packed manager's name */
  67072. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67073. }
  67074. }
  67075. declare module "babylonjs/Sprites/index" {
  67076. export * from "babylonjs/Sprites/sprite";
  67077. export * from "babylonjs/Sprites/spriteManager";
  67078. export * from "babylonjs/Sprites/spritePackedManager";
  67079. export * from "babylonjs/Sprites/spriteSceneComponent";
  67080. }
  67081. declare module "babylonjs/States/index" {
  67082. export * from "babylonjs/States/alphaCullingState";
  67083. export * from "babylonjs/States/depthCullingState";
  67084. export * from "babylonjs/States/stencilState";
  67085. }
  67086. declare module "babylonjs/Misc/assetsManager" {
  67087. import { Scene } from "babylonjs/scene";
  67088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67089. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67090. import { Skeleton } from "babylonjs/Bones/skeleton";
  67091. import { Observable } from "babylonjs/Misc/observable";
  67092. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67093. import { Texture } from "babylonjs/Materials/Textures/texture";
  67094. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  67095. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  67096. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  67097. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  67098. /**
  67099. * Defines the list of states available for a task inside a AssetsManager
  67100. */
  67101. export enum AssetTaskState {
  67102. /**
  67103. * Initialization
  67104. */
  67105. INIT = 0,
  67106. /**
  67107. * Running
  67108. */
  67109. RUNNING = 1,
  67110. /**
  67111. * Done
  67112. */
  67113. DONE = 2,
  67114. /**
  67115. * Error
  67116. */
  67117. ERROR = 3
  67118. }
  67119. /**
  67120. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67121. */
  67122. export abstract class AbstractAssetTask {
  67123. /**
  67124. * Task name
  67125. */ name: string;
  67126. /**
  67127. * Callback called when the task is successful
  67128. */
  67129. onSuccess: (task: any) => void;
  67130. /**
  67131. * Callback called when the task is not successful
  67132. */
  67133. onError: (task: any, message?: string, exception?: any) => void;
  67134. /**
  67135. * Creates a new AssetsManager
  67136. * @param name defines the name of the task
  67137. */
  67138. constructor(
  67139. /**
  67140. * Task name
  67141. */ name: string);
  67142. private _isCompleted;
  67143. private _taskState;
  67144. private _errorObject;
  67145. /**
  67146. * Get if the task is completed
  67147. */
  67148. readonly isCompleted: boolean;
  67149. /**
  67150. * Gets the current state of the task
  67151. */
  67152. readonly taskState: AssetTaskState;
  67153. /**
  67154. * Gets the current error object (if task is in error)
  67155. */
  67156. readonly errorObject: {
  67157. message?: string;
  67158. exception?: any;
  67159. };
  67160. /**
  67161. * Internal only
  67162. * @hidden
  67163. */
  67164. _setErrorObject(message?: string, exception?: any): void;
  67165. /**
  67166. * Execute the current task
  67167. * @param scene defines the scene where you want your assets to be loaded
  67168. * @param onSuccess is a callback called when the task is successfully executed
  67169. * @param onError is a callback called if an error occurs
  67170. */
  67171. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67172. /**
  67173. * Execute the current task
  67174. * @param scene defines the scene where you want your assets to be loaded
  67175. * @param onSuccess is a callback called when the task is successfully executed
  67176. * @param onError is a callback called if an error occurs
  67177. */
  67178. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67179. /**
  67180. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67181. * This can be used with failed tasks that have the reason for failure fixed.
  67182. */
  67183. reset(): void;
  67184. private onErrorCallback;
  67185. private onDoneCallback;
  67186. }
  67187. /**
  67188. * Define the interface used by progress events raised during assets loading
  67189. */
  67190. export interface IAssetsProgressEvent {
  67191. /**
  67192. * Defines the number of remaining tasks to process
  67193. */
  67194. remainingCount: number;
  67195. /**
  67196. * Defines the total number of tasks
  67197. */
  67198. totalCount: number;
  67199. /**
  67200. * Defines the task that was just processed
  67201. */
  67202. task: AbstractAssetTask;
  67203. }
  67204. /**
  67205. * Class used to share progress information about assets loading
  67206. */
  67207. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67208. /**
  67209. * Defines the number of remaining tasks to process
  67210. */
  67211. remainingCount: number;
  67212. /**
  67213. * Defines the total number of tasks
  67214. */
  67215. totalCount: number;
  67216. /**
  67217. * Defines the task that was just processed
  67218. */
  67219. task: AbstractAssetTask;
  67220. /**
  67221. * Creates a AssetsProgressEvent
  67222. * @param remainingCount defines the number of remaining tasks to process
  67223. * @param totalCount defines the total number of tasks
  67224. * @param task defines the task that was just processed
  67225. */
  67226. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67227. }
  67228. /**
  67229. * Define a task used by AssetsManager to load meshes
  67230. */
  67231. export class MeshAssetTask extends AbstractAssetTask {
  67232. /**
  67233. * Defines the name of the task
  67234. */
  67235. name: string;
  67236. /**
  67237. * Defines the list of mesh's names you want to load
  67238. */
  67239. meshesNames: any;
  67240. /**
  67241. * Defines the root url to use as a base to load your meshes and associated resources
  67242. */
  67243. rootUrl: string;
  67244. /**
  67245. * Defines the filename of the scene to load from
  67246. */
  67247. sceneFilename: string;
  67248. /**
  67249. * Gets the list of loaded meshes
  67250. */
  67251. loadedMeshes: Array<AbstractMesh>;
  67252. /**
  67253. * Gets the list of loaded particle systems
  67254. */
  67255. loadedParticleSystems: Array<IParticleSystem>;
  67256. /**
  67257. * Gets the list of loaded skeletons
  67258. */
  67259. loadedSkeletons: Array<Skeleton>;
  67260. /**
  67261. * Gets the list of loaded animation groups
  67262. */
  67263. loadedAnimationGroups: Array<AnimationGroup>;
  67264. /**
  67265. * Callback called when the task is successful
  67266. */
  67267. onSuccess: (task: MeshAssetTask) => void;
  67268. /**
  67269. * Callback called when the task is successful
  67270. */
  67271. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67272. /**
  67273. * Creates a new MeshAssetTask
  67274. * @param name defines the name of the task
  67275. * @param meshesNames defines the list of mesh's names you want to load
  67276. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67277. * @param sceneFilename defines the filename of the scene to load from
  67278. */
  67279. constructor(
  67280. /**
  67281. * Defines the name of the task
  67282. */
  67283. name: string,
  67284. /**
  67285. * Defines the list of mesh's names you want to load
  67286. */
  67287. meshesNames: any,
  67288. /**
  67289. * Defines the root url to use as a base to load your meshes and associated resources
  67290. */
  67291. rootUrl: string,
  67292. /**
  67293. * Defines the filename of the scene to load from
  67294. */
  67295. sceneFilename: string);
  67296. /**
  67297. * Execute the current task
  67298. * @param scene defines the scene where you want your assets to be loaded
  67299. * @param onSuccess is a callback called when the task is successfully executed
  67300. * @param onError is a callback called if an error occurs
  67301. */
  67302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67303. }
  67304. /**
  67305. * Define a task used by AssetsManager to load text content
  67306. */
  67307. export class TextFileAssetTask extends AbstractAssetTask {
  67308. /**
  67309. * Defines the name of the task
  67310. */
  67311. name: string;
  67312. /**
  67313. * Defines the location of the file to load
  67314. */
  67315. url: string;
  67316. /**
  67317. * Gets the loaded text string
  67318. */
  67319. text: string;
  67320. /**
  67321. * Callback called when the task is successful
  67322. */
  67323. onSuccess: (task: TextFileAssetTask) => void;
  67324. /**
  67325. * Callback called when the task is successful
  67326. */
  67327. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67328. /**
  67329. * Creates a new TextFileAssetTask object
  67330. * @param name defines the name of the task
  67331. * @param url defines the location of the file to load
  67332. */
  67333. constructor(
  67334. /**
  67335. * Defines the name of the task
  67336. */
  67337. name: string,
  67338. /**
  67339. * Defines the location of the file to load
  67340. */
  67341. url: string);
  67342. /**
  67343. * Execute the current task
  67344. * @param scene defines the scene where you want your assets to be loaded
  67345. * @param onSuccess is a callback called when the task is successfully executed
  67346. * @param onError is a callback called if an error occurs
  67347. */
  67348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67349. }
  67350. /**
  67351. * Define a task used by AssetsManager to load binary data
  67352. */
  67353. export class BinaryFileAssetTask extends AbstractAssetTask {
  67354. /**
  67355. * Defines the name of the task
  67356. */
  67357. name: string;
  67358. /**
  67359. * Defines the location of the file to load
  67360. */
  67361. url: string;
  67362. /**
  67363. * Gets the lodaded data (as an array buffer)
  67364. */
  67365. data: ArrayBuffer;
  67366. /**
  67367. * Callback called when the task is successful
  67368. */
  67369. onSuccess: (task: BinaryFileAssetTask) => void;
  67370. /**
  67371. * Callback called when the task is successful
  67372. */
  67373. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67374. /**
  67375. * Creates a new BinaryFileAssetTask object
  67376. * @param name defines the name of the new task
  67377. * @param url defines the location of the file to load
  67378. */
  67379. constructor(
  67380. /**
  67381. * Defines the name of the task
  67382. */
  67383. name: string,
  67384. /**
  67385. * Defines the location of the file to load
  67386. */
  67387. url: string);
  67388. /**
  67389. * Execute the current task
  67390. * @param scene defines the scene where you want your assets to be loaded
  67391. * @param onSuccess is a callback called when the task is successfully executed
  67392. * @param onError is a callback called if an error occurs
  67393. */
  67394. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67395. }
  67396. /**
  67397. * Define a task used by AssetsManager to load images
  67398. */
  67399. export class ImageAssetTask extends AbstractAssetTask {
  67400. /**
  67401. * Defines the name of the task
  67402. */
  67403. name: string;
  67404. /**
  67405. * Defines the location of the image to load
  67406. */
  67407. url: string;
  67408. /**
  67409. * Gets the loaded images
  67410. */
  67411. image: HTMLImageElement;
  67412. /**
  67413. * Callback called when the task is successful
  67414. */
  67415. onSuccess: (task: ImageAssetTask) => void;
  67416. /**
  67417. * Callback called when the task is successful
  67418. */
  67419. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67420. /**
  67421. * Creates a new ImageAssetTask
  67422. * @param name defines the name of the task
  67423. * @param url defines the location of the image to load
  67424. */
  67425. constructor(
  67426. /**
  67427. * Defines the name of the task
  67428. */
  67429. name: string,
  67430. /**
  67431. * Defines the location of the image to load
  67432. */
  67433. url: string);
  67434. /**
  67435. * Execute the current task
  67436. * @param scene defines the scene where you want your assets to be loaded
  67437. * @param onSuccess is a callback called when the task is successfully executed
  67438. * @param onError is a callback called if an error occurs
  67439. */
  67440. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67441. }
  67442. /**
  67443. * Defines the interface used by texture loading tasks
  67444. */
  67445. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67446. /**
  67447. * Gets the loaded texture
  67448. */
  67449. texture: TEX;
  67450. }
  67451. /**
  67452. * Define a task used by AssetsManager to load 2D textures
  67453. */
  67454. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67455. /**
  67456. * Defines the name of the task
  67457. */
  67458. name: string;
  67459. /**
  67460. * Defines the location of the file to load
  67461. */
  67462. url: string;
  67463. /**
  67464. * Defines if mipmap should not be generated (default is false)
  67465. */
  67466. noMipmap?: boolean | undefined;
  67467. /**
  67468. * Defines if texture must be inverted on Y axis (default is false)
  67469. */
  67470. invertY?: boolean | undefined;
  67471. /**
  67472. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67473. */
  67474. samplingMode: number;
  67475. /**
  67476. * Gets the loaded texture
  67477. */
  67478. texture: Texture;
  67479. /**
  67480. * Callback called when the task is successful
  67481. */
  67482. onSuccess: (task: TextureAssetTask) => void;
  67483. /**
  67484. * Callback called when the task is successful
  67485. */
  67486. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67487. /**
  67488. * Creates a new TextureAssetTask object
  67489. * @param name defines the name of the task
  67490. * @param url defines the location of the file to load
  67491. * @param noMipmap defines if mipmap should not be generated (default is false)
  67492. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67493. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67494. */
  67495. constructor(
  67496. /**
  67497. * Defines the name of the task
  67498. */
  67499. name: string,
  67500. /**
  67501. * Defines the location of the file to load
  67502. */
  67503. url: string,
  67504. /**
  67505. * Defines if mipmap should not be generated (default is false)
  67506. */
  67507. noMipmap?: boolean | undefined,
  67508. /**
  67509. * Defines if texture must be inverted on Y axis (default is false)
  67510. */
  67511. invertY?: boolean | undefined,
  67512. /**
  67513. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67514. */
  67515. samplingMode?: number);
  67516. /**
  67517. * Execute the current task
  67518. * @param scene defines the scene where you want your assets to be loaded
  67519. * @param onSuccess is a callback called when the task is successfully executed
  67520. * @param onError is a callback called if an error occurs
  67521. */
  67522. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67523. }
  67524. /**
  67525. * Define a task used by AssetsManager to load cube textures
  67526. */
  67527. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67528. /**
  67529. * Defines the name of the task
  67530. */
  67531. name: string;
  67532. /**
  67533. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67534. */
  67535. url: string;
  67536. /**
  67537. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67538. */
  67539. extensions?: string[] | undefined;
  67540. /**
  67541. * Defines if mipmaps should not be generated (default is false)
  67542. */
  67543. noMipmap?: boolean | undefined;
  67544. /**
  67545. * Defines the explicit list of files (undefined by default)
  67546. */
  67547. files?: string[] | undefined;
  67548. /**
  67549. * Gets the loaded texture
  67550. */
  67551. texture: CubeTexture;
  67552. /**
  67553. * Callback called when the task is successful
  67554. */
  67555. onSuccess: (task: CubeTextureAssetTask) => void;
  67556. /**
  67557. * Callback called when the task is successful
  67558. */
  67559. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67560. /**
  67561. * Creates a new CubeTextureAssetTask
  67562. * @param name defines the name of the task
  67563. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67564. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67565. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67566. * @param files defines the explicit list of files (undefined by default)
  67567. */
  67568. constructor(
  67569. /**
  67570. * Defines the name of the task
  67571. */
  67572. name: string,
  67573. /**
  67574. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67575. */
  67576. url: string,
  67577. /**
  67578. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67579. */
  67580. extensions?: string[] | undefined,
  67581. /**
  67582. * Defines if mipmaps should not be generated (default is false)
  67583. */
  67584. noMipmap?: boolean | undefined,
  67585. /**
  67586. * Defines the explicit list of files (undefined by default)
  67587. */
  67588. files?: string[] | undefined);
  67589. /**
  67590. * Execute the current task
  67591. * @param scene defines the scene where you want your assets to be loaded
  67592. * @param onSuccess is a callback called when the task is successfully executed
  67593. * @param onError is a callback called if an error occurs
  67594. */
  67595. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67596. }
  67597. /**
  67598. * Define a task used by AssetsManager to load HDR cube textures
  67599. */
  67600. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  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. * Gets the loaded texture
  67631. */
  67632. texture: HDRCubeTexture;
  67633. /**
  67634. * Callback called when the task is successful
  67635. */
  67636. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67637. /**
  67638. * Callback called when the task is successful
  67639. */
  67640. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67641. /**
  67642. * Creates a new HDRCubeTextureAssetTask object
  67643. * @param name defines the name of the task
  67644. * @param url defines the location of the file to load
  67645. * @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.
  67646. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67647. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67648. * @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)
  67649. * @param reserved Internal use only
  67650. */
  67651. constructor(
  67652. /**
  67653. * Defines the name of the task
  67654. */
  67655. name: string,
  67656. /**
  67657. * Defines the location of the file to load
  67658. */
  67659. url: string,
  67660. /**
  67661. * Defines the desired size (the more it increases the longer the generation will be)
  67662. */
  67663. size: number,
  67664. /**
  67665. * Defines if mipmaps should not be generated (default is false)
  67666. */
  67667. noMipmap?: boolean,
  67668. /**
  67669. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67670. */
  67671. generateHarmonics?: boolean,
  67672. /**
  67673. * 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)
  67674. */
  67675. gammaSpace?: boolean,
  67676. /**
  67677. * Internal Use Only
  67678. */
  67679. reserved?: boolean);
  67680. /**
  67681. * Execute the current task
  67682. * @param scene defines the scene where you want your assets to be loaded
  67683. * @param onSuccess is a callback called when the task is successfully executed
  67684. * @param onError is a callback called if an error occurs
  67685. */
  67686. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67687. }
  67688. /**
  67689. * Define a task used by AssetsManager to load Equirectangular cube textures
  67690. */
  67691. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67692. /**
  67693. * Defines the name of the task
  67694. */
  67695. name: string;
  67696. /**
  67697. * Defines the location of the file to load
  67698. */
  67699. url: string;
  67700. /**
  67701. * Defines the desired size (the more it increases the longer the generation will be)
  67702. */
  67703. size: number;
  67704. /**
  67705. * Defines if mipmaps should not be generated (default is false)
  67706. */
  67707. noMipmap: boolean;
  67708. /**
  67709. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67710. * but the standard material would require them in Gamma space) (default is true)
  67711. */
  67712. gammaSpace: boolean;
  67713. /**
  67714. * Gets the loaded texture
  67715. */
  67716. texture: EquiRectangularCubeTexture;
  67717. /**
  67718. * Callback called when the task is successful
  67719. */
  67720. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67721. /**
  67722. * Callback called when the task is successful
  67723. */
  67724. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67725. /**
  67726. * Creates a new EquiRectangularCubeTextureAssetTask object
  67727. * @param name defines the name of the task
  67728. * @param url defines the location of the file to load
  67729. * @param size defines the desired size (the more it increases the longer the generation will be)
  67730. * If the size is omitted this implies you are using a preprocessed cubemap.
  67731. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67732. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67733. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67734. * (default is true)
  67735. */
  67736. constructor(
  67737. /**
  67738. * Defines the name of the task
  67739. */
  67740. name: string,
  67741. /**
  67742. * Defines the location of the file to load
  67743. */
  67744. url: string,
  67745. /**
  67746. * Defines the desired size (the more it increases the longer the generation will be)
  67747. */
  67748. size: number,
  67749. /**
  67750. * Defines if mipmaps should not be generated (default is false)
  67751. */
  67752. noMipmap?: boolean,
  67753. /**
  67754. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67755. * but the standard material would require them in Gamma space) (default is true)
  67756. */
  67757. gammaSpace?: boolean);
  67758. /**
  67759. * Execute the current task
  67760. * @param scene defines the scene where you want your assets to be loaded
  67761. * @param onSuccess is a callback called when the task is successfully executed
  67762. * @param onError is a callback called if an error occurs
  67763. */
  67764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67765. }
  67766. /**
  67767. * This class can be used to easily import assets into a scene
  67768. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67769. */
  67770. export class AssetsManager {
  67771. private _scene;
  67772. private _isLoading;
  67773. protected _tasks: AbstractAssetTask[];
  67774. protected _waitingTasksCount: number;
  67775. protected _totalTasksCount: number;
  67776. /**
  67777. * Callback called when all tasks are processed
  67778. */
  67779. onFinish: (tasks: AbstractAssetTask[]) => void;
  67780. /**
  67781. * Callback called when a task is successful
  67782. */
  67783. onTaskSuccess: (task: AbstractAssetTask) => void;
  67784. /**
  67785. * Callback called when a task had an error
  67786. */
  67787. onTaskError: (task: AbstractAssetTask) => void;
  67788. /**
  67789. * Callback called when a task is done (whatever the result is)
  67790. */
  67791. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67792. /**
  67793. * Observable called when all tasks are processed
  67794. */
  67795. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67796. /**
  67797. * Observable called when a task had an error
  67798. */
  67799. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67800. /**
  67801. * Observable called when all tasks were executed
  67802. */
  67803. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67804. /**
  67805. * Observable called when a task is done (whatever the result is)
  67806. */
  67807. onProgressObservable: Observable<IAssetsProgressEvent>;
  67808. /**
  67809. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67811. */
  67812. useDefaultLoadingScreen: boolean;
  67813. /**
  67814. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67815. * when all assets have been downloaded.
  67816. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67817. */
  67818. autoHideLoadingUI: boolean;
  67819. /**
  67820. * Creates a new AssetsManager
  67821. * @param scene defines the scene to work on
  67822. */
  67823. constructor(scene: Scene);
  67824. /**
  67825. * Add a MeshAssetTask to the list of active tasks
  67826. * @param taskName defines the name of the new task
  67827. * @param meshesNames defines the name of meshes to load
  67828. * @param rootUrl defines the root url to use to locate files
  67829. * @param sceneFilename defines the filename of the scene file
  67830. * @returns a new MeshAssetTask object
  67831. */
  67832. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67833. /**
  67834. * Add a TextFileAssetTask to the list of active tasks
  67835. * @param taskName defines the name of the new task
  67836. * @param url defines the url of the file to load
  67837. * @returns a new TextFileAssetTask object
  67838. */
  67839. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67840. /**
  67841. * Add a BinaryFileAssetTask to the list of active tasks
  67842. * @param taskName defines the name of the new task
  67843. * @param url defines the url of the file to load
  67844. * @returns a new BinaryFileAssetTask object
  67845. */
  67846. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67847. /**
  67848. * Add a ImageAssetTask to the list of active tasks
  67849. * @param taskName defines the name of the new task
  67850. * @param url defines the url of the file to load
  67851. * @returns a new ImageAssetTask object
  67852. */
  67853. addImageTask(taskName: string, url: string): ImageAssetTask;
  67854. /**
  67855. * Add a TextureAssetTask to the list of active tasks
  67856. * @param taskName defines the name of the new task
  67857. * @param url defines the url of the file to load
  67858. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67859. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67860. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67861. * @returns a new TextureAssetTask object
  67862. */
  67863. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67864. /**
  67865. * Add a CubeTextureAssetTask to the list of active tasks
  67866. * @param taskName defines the name of the new task
  67867. * @param url defines the url of the file to load
  67868. * @param extensions defines the extension to use to load the cube map (can be null)
  67869. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67870. * @param files defines the list of files to load (can be null)
  67871. * @returns a new CubeTextureAssetTask object
  67872. */
  67873. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67874. /**
  67875. *
  67876. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67877. * @param taskName defines the name of the new task
  67878. * @param url defines the url of the file to load
  67879. * @param size defines the size you want for the cubemap (can be null)
  67880. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67881. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67882. * @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)
  67883. * @param reserved Internal use only
  67884. * @returns a new HDRCubeTextureAssetTask object
  67885. */
  67886. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67887. /**
  67888. *
  67889. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67890. * @param taskName defines the name of the new task
  67891. * @param url defines the url of the file to load
  67892. * @param size defines the size you want for the cubemap (can be null)
  67893. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67894. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67895. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67896. * @returns a new EquiRectangularCubeTextureAssetTask object
  67897. */
  67898. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67899. /**
  67900. * Remove a task from the assets manager.
  67901. * @param task the task to remove
  67902. */
  67903. removeTask(task: AbstractAssetTask): void;
  67904. private _decreaseWaitingTasksCount;
  67905. private _runTask;
  67906. /**
  67907. * Reset the AssetsManager and remove all tasks
  67908. * @return the current instance of the AssetsManager
  67909. */
  67910. reset(): AssetsManager;
  67911. /**
  67912. * Start the loading process
  67913. * @return the current instance of the AssetsManager
  67914. */
  67915. load(): AssetsManager;
  67916. /**
  67917. * Start the loading process as an async operation
  67918. * @return a promise returning the list of failed tasks
  67919. */
  67920. loadAsync(): Promise<void>;
  67921. }
  67922. }
  67923. declare module "babylonjs/Misc/deferred" {
  67924. /**
  67925. * Wrapper class for promise with external resolve and reject.
  67926. */
  67927. export class Deferred<T> {
  67928. /**
  67929. * The promise associated with this deferred object.
  67930. */
  67931. readonly promise: Promise<T>;
  67932. private _resolve;
  67933. private _reject;
  67934. /**
  67935. * The resolve method of the promise associated with this deferred object.
  67936. */
  67937. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67938. /**
  67939. * The reject method of the promise associated with this deferred object.
  67940. */
  67941. readonly reject: (reason?: any) => void;
  67942. /**
  67943. * Constructor for this deferred object.
  67944. */
  67945. constructor();
  67946. }
  67947. }
  67948. declare module "babylonjs/Misc/meshExploder" {
  67949. import { Mesh } from "babylonjs/Meshes/mesh";
  67950. /**
  67951. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67952. */
  67953. export class MeshExploder {
  67954. private _centerMesh;
  67955. private _meshes;
  67956. private _meshesOrigins;
  67957. private _toCenterVectors;
  67958. private _scaledDirection;
  67959. private _newPosition;
  67960. private _centerPosition;
  67961. /**
  67962. * Explodes meshes from a center mesh.
  67963. * @param meshes The meshes to explode.
  67964. * @param centerMesh The mesh to be center of explosion.
  67965. */
  67966. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67967. private _setCenterMesh;
  67968. /**
  67969. * Get class name
  67970. * @returns "MeshExploder"
  67971. */
  67972. getClassName(): string;
  67973. /**
  67974. * "Exploded meshes"
  67975. * @returns Array of meshes with the centerMesh at index 0.
  67976. */
  67977. getMeshes(): Array<Mesh>;
  67978. /**
  67979. * Explodes meshes giving a specific direction
  67980. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67981. */
  67982. explode(direction?: number): void;
  67983. }
  67984. }
  67985. declare module "babylonjs/Misc/filesInput" {
  67986. import { Engine } from "babylonjs/Engines/engine";
  67987. import { Scene } from "babylonjs/scene";
  67988. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67989. /**
  67990. * Class used to help managing file picking and drag'n'drop
  67991. */
  67992. export class FilesInput {
  67993. /**
  67994. * List of files ready to be loaded
  67995. */
  67996. static readonly FilesToLoad: {
  67997. [key: string]: File;
  67998. };
  67999. /**
  68000. * Callback called when a file is processed
  68001. */
  68002. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68003. private _engine;
  68004. private _currentScene;
  68005. private _sceneLoadedCallback;
  68006. private _progressCallback;
  68007. private _additionalRenderLoopLogicCallback;
  68008. private _textureLoadingCallback;
  68009. private _startingProcessingFilesCallback;
  68010. private _onReloadCallback;
  68011. private _errorCallback;
  68012. private _elementToMonitor;
  68013. private _sceneFileToLoad;
  68014. private _filesToLoad;
  68015. /**
  68016. * Creates a new FilesInput
  68017. * @param engine defines the rendering engine
  68018. * @param scene defines the hosting scene
  68019. * @param sceneLoadedCallback callback called when scene is loaded
  68020. * @param progressCallback callback called to track progress
  68021. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68022. * @param textureLoadingCallback callback called when a texture is loading
  68023. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68024. * @param onReloadCallback callback called when a reload is requested
  68025. * @param errorCallback callback call if an error occurs
  68026. */
  68027. 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);
  68028. private _dragEnterHandler;
  68029. private _dragOverHandler;
  68030. private _dropHandler;
  68031. /**
  68032. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68033. * @param elementToMonitor defines the DOM element to track
  68034. */
  68035. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68036. /**
  68037. * Release all associated resources
  68038. */
  68039. dispose(): void;
  68040. private renderFunction;
  68041. private drag;
  68042. private drop;
  68043. private _traverseFolder;
  68044. private _processFiles;
  68045. /**
  68046. * Load files from a drop event
  68047. * @param event defines the drop event to use as source
  68048. */
  68049. loadFiles(event: any): void;
  68050. private _processReload;
  68051. /**
  68052. * Reload the current scene from the loaded files
  68053. */
  68054. reload(): void;
  68055. }
  68056. }
  68057. declare module "babylonjs/Misc/HighDynamicRange/index" {
  68058. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  68059. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  68060. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  68061. }
  68062. declare module "babylonjs/Misc/sceneOptimizer" {
  68063. import { Scene, IDisposable } from "babylonjs/scene";
  68064. import { Observable } from "babylonjs/Misc/observable";
  68065. /**
  68066. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68068. */
  68069. export class SceneOptimization {
  68070. /**
  68071. * Defines the priority of this optimization (0 by default which means first in the list)
  68072. */
  68073. priority: number;
  68074. /**
  68075. * Gets a string describing the action executed by the current optimization
  68076. * @returns description string
  68077. */
  68078. getDescription(): string;
  68079. /**
  68080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68081. * @param scene defines the current scene where to apply this optimization
  68082. * @param optimizer defines the current optimizer
  68083. * @returns true if everything that can be done was applied
  68084. */
  68085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68086. /**
  68087. * Creates the SceneOptimization object
  68088. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68089. * @param desc defines the description associated with the optimization
  68090. */
  68091. constructor(
  68092. /**
  68093. * Defines the priority of this optimization (0 by default which means first in the list)
  68094. */
  68095. priority?: number);
  68096. }
  68097. /**
  68098. * Defines an optimization used to reduce the size of render target textures
  68099. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68100. */
  68101. export class TextureOptimization extends SceneOptimization {
  68102. /**
  68103. * Defines the priority of this optimization (0 by default which means first in the list)
  68104. */
  68105. priority: number;
  68106. /**
  68107. * 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
  68108. */
  68109. maximumSize: number;
  68110. /**
  68111. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68112. */
  68113. step: number;
  68114. /**
  68115. * Gets a string describing the action executed by the current optimization
  68116. * @returns description string
  68117. */
  68118. getDescription(): string;
  68119. /**
  68120. * Creates the TextureOptimization object
  68121. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68122. * @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
  68123. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  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 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
  68132. */
  68133. maximumSize?: number,
  68134. /**
  68135. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  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 increase or decrease the rendering resolution
  68148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68149. */
  68150. export class HardwareScalingOptimization extends SceneOptimization {
  68151. /**
  68152. * Defines the priority of this optimization (0 by default which means first in the list)
  68153. */
  68154. priority: number;
  68155. /**
  68156. * Defines the maximum scale to use (2 by default)
  68157. */
  68158. maximumScale: number;
  68159. /**
  68160. * Defines the step to use between two passes (0.5 by default)
  68161. */
  68162. step: number;
  68163. private _currentScale;
  68164. private _directionOffset;
  68165. /**
  68166. * Gets a string describing the action executed by the current optimization
  68167. * @return description string
  68168. */
  68169. getDescription(): string;
  68170. /**
  68171. * Creates the HardwareScalingOptimization object
  68172. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68173. * @param maximumScale defines the maximum scale to use (2 by default)
  68174. * @param step defines the step to use between two passes (0.5 by default)
  68175. */
  68176. constructor(
  68177. /**
  68178. * Defines the priority of this optimization (0 by default which means first in the list)
  68179. */
  68180. priority?: number,
  68181. /**
  68182. * Defines the maximum scale to use (2 by default)
  68183. */
  68184. maximumScale?: number,
  68185. /**
  68186. * Defines the step to use between two passes (0.5 by default)
  68187. */
  68188. step?: number);
  68189. /**
  68190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68191. * @param scene defines the current scene where to apply this optimization
  68192. * @param optimizer defines the current optimizer
  68193. * @returns true if everything that can be done was applied
  68194. */
  68195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68196. }
  68197. /**
  68198. * Defines an optimization used to remove shadows
  68199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68200. */
  68201. export class ShadowsOptimization extends SceneOptimization {
  68202. /**
  68203. * Gets a string describing the action executed by the current optimization
  68204. * @return description string
  68205. */
  68206. getDescription(): string;
  68207. /**
  68208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68209. * @param scene defines the current scene where to apply this optimization
  68210. * @param optimizer defines the current optimizer
  68211. * @returns true if everything that can be done was applied
  68212. */
  68213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68214. }
  68215. /**
  68216. * Defines an optimization used to turn post-processes off
  68217. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68218. */
  68219. export class PostProcessesOptimization extends SceneOptimization {
  68220. /**
  68221. * Gets a string describing the action executed by the current optimization
  68222. * @return description string
  68223. */
  68224. getDescription(): string;
  68225. /**
  68226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68227. * @param scene defines the current scene where to apply this optimization
  68228. * @param optimizer defines the current optimizer
  68229. * @returns true if everything that can be done was applied
  68230. */
  68231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68232. }
  68233. /**
  68234. * Defines an optimization used to turn lens flares off
  68235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68236. */
  68237. export class LensFlaresOptimization extends SceneOptimization {
  68238. /**
  68239. * Gets a string describing the action executed by the current optimization
  68240. * @return description string
  68241. */
  68242. getDescription(): string;
  68243. /**
  68244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68245. * @param scene defines the current scene where to apply this optimization
  68246. * @param optimizer defines the current optimizer
  68247. * @returns true if everything that can be done was applied
  68248. */
  68249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68250. }
  68251. /**
  68252. * Defines an optimization based on user defined callback.
  68253. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68254. */
  68255. export class CustomOptimization extends SceneOptimization {
  68256. /**
  68257. * Callback called to apply the custom optimization.
  68258. */
  68259. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68260. /**
  68261. * Callback called to get custom description
  68262. */
  68263. onGetDescription: () => string;
  68264. /**
  68265. * Gets a string describing the action executed by the current optimization
  68266. * @returns description string
  68267. */
  68268. getDescription(): string;
  68269. /**
  68270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68271. * @param scene defines the current scene where to apply this optimization
  68272. * @param optimizer defines the current optimizer
  68273. * @returns true if everything that can be done was applied
  68274. */
  68275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68276. }
  68277. /**
  68278. * Defines an optimization used to turn particles off
  68279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68280. */
  68281. export class ParticlesOptimization extends SceneOptimization {
  68282. /**
  68283. * Gets a string describing the action executed by the current optimization
  68284. * @return description string
  68285. */
  68286. getDescription(): string;
  68287. /**
  68288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68289. * @param scene defines the current scene where to apply this optimization
  68290. * @param optimizer defines the current optimizer
  68291. * @returns true if everything that can be done was applied
  68292. */
  68293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68294. }
  68295. /**
  68296. * Defines an optimization used to turn render targets off
  68297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68298. */
  68299. export class RenderTargetsOptimization extends SceneOptimization {
  68300. /**
  68301. * Gets a string describing the action executed by the current optimization
  68302. * @return description string
  68303. */
  68304. getDescription(): string;
  68305. /**
  68306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68307. * @param scene defines the current scene where to apply this optimization
  68308. * @param optimizer defines the current optimizer
  68309. * @returns true if everything that can be done was applied
  68310. */
  68311. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68312. }
  68313. /**
  68314. * Defines an optimization used to merge meshes with compatible materials
  68315. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68316. */
  68317. export class MergeMeshesOptimization extends SceneOptimization {
  68318. private static _UpdateSelectionTree;
  68319. /**
  68320. * Gets or sets a boolean which defines if optimization octree has to be updated
  68321. */
  68322. /**
  68323. * Gets or sets a boolean which defines if optimization octree has to be updated
  68324. */
  68325. static UpdateSelectionTree: boolean;
  68326. /**
  68327. * Gets a string describing the action executed by the current optimization
  68328. * @return description string
  68329. */
  68330. getDescription(): string;
  68331. private _canBeMerged;
  68332. /**
  68333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68334. * @param scene defines the current scene where to apply this optimization
  68335. * @param optimizer defines the current optimizer
  68336. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68337. * @returns true if everything that can be done was applied
  68338. */
  68339. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68340. }
  68341. /**
  68342. * Defines a list of options used by SceneOptimizer
  68343. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68344. */
  68345. export class SceneOptimizerOptions {
  68346. /**
  68347. * Defines the target frame rate to reach (60 by default)
  68348. */
  68349. targetFrameRate: number;
  68350. /**
  68351. * Defines the interval between two checkes (2000ms by default)
  68352. */
  68353. trackerDuration: number;
  68354. /**
  68355. * Gets the list of optimizations to apply
  68356. */
  68357. optimizations: SceneOptimization[];
  68358. /**
  68359. * Creates a new list of options used by SceneOptimizer
  68360. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68361. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68362. */
  68363. constructor(
  68364. /**
  68365. * Defines the target frame rate to reach (60 by default)
  68366. */
  68367. targetFrameRate?: number,
  68368. /**
  68369. * Defines the interval between two checkes (2000ms by default)
  68370. */
  68371. trackerDuration?: number);
  68372. /**
  68373. * Add a new optimization
  68374. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68375. * @returns the current SceneOptimizerOptions
  68376. */
  68377. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68378. /**
  68379. * Add a new custom optimization
  68380. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68381. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68382. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68383. * @returns the current SceneOptimizerOptions
  68384. */
  68385. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68386. /**
  68387. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68388. * @param targetFrameRate defines the target frame rate (60 by default)
  68389. * @returns a SceneOptimizerOptions object
  68390. */
  68391. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68392. /**
  68393. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68394. * @param targetFrameRate defines the target frame rate (60 by default)
  68395. * @returns a SceneOptimizerOptions object
  68396. */
  68397. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68398. /**
  68399. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68400. * @param targetFrameRate defines the target frame rate (60 by default)
  68401. * @returns a SceneOptimizerOptions object
  68402. */
  68403. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68404. }
  68405. /**
  68406. * Class used to run optimizations in order to reach a target frame rate
  68407. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68408. */
  68409. export class SceneOptimizer implements IDisposable {
  68410. private _isRunning;
  68411. private _options;
  68412. private _scene;
  68413. private _currentPriorityLevel;
  68414. private _targetFrameRate;
  68415. private _trackerDuration;
  68416. private _currentFrameRate;
  68417. private _sceneDisposeObserver;
  68418. private _improvementMode;
  68419. /**
  68420. * Defines an observable called when the optimizer reaches the target frame rate
  68421. */
  68422. onSuccessObservable: Observable<SceneOptimizer>;
  68423. /**
  68424. * Defines an observable called when the optimizer enables an optimization
  68425. */
  68426. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68427. /**
  68428. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68429. */
  68430. onFailureObservable: Observable<SceneOptimizer>;
  68431. /**
  68432. * Gets a boolean indicating if the optimizer is in improvement mode
  68433. */
  68434. readonly isInImprovementMode: boolean;
  68435. /**
  68436. * Gets the current priority level (0 at start)
  68437. */
  68438. readonly currentPriorityLevel: number;
  68439. /**
  68440. * Gets the current frame rate checked by the SceneOptimizer
  68441. */
  68442. readonly currentFrameRate: number;
  68443. /**
  68444. * Gets or sets the current target frame rate (60 by default)
  68445. */
  68446. /**
  68447. * Gets or sets the current target frame rate (60 by default)
  68448. */
  68449. targetFrameRate: number;
  68450. /**
  68451. * Gets or sets the current interval between two checks (every 2000ms by default)
  68452. */
  68453. /**
  68454. * Gets or sets the current interval between two checks (every 2000ms by default)
  68455. */
  68456. trackerDuration: number;
  68457. /**
  68458. * Gets the list of active optimizations
  68459. */
  68460. readonly optimizations: SceneOptimization[];
  68461. /**
  68462. * Creates a new SceneOptimizer
  68463. * @param scene defines the scene to work on
  68464. * @param options defines the options to use with the SceneOptimizer
  68465. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68466. * @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)
  68467. */
  68468. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68469. /**
  68470. * Stops the current optimizer
  68471. */
  68472. stop(): void;
  68473. /**
  68474. * Reset the optimizer to initial step (current priority level = 0)
  68475. */
  68476. reset(): void;
  68477. /**
  68478. * Start the optimizer. By default it will try to reach a specific framerate
  68479. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68480. */
  68481. start(): void;
  68482. private _checkCurrentState;
  68483. /**
  68484. * Release all resources
  68485. */
  68486. dispose(): void;
  68487. /**
  68488. * Helper function to create a SceneOptimizer with one single line of code
  68489. * @param scene defines the scene to work on
  68490. * @param options defines the options to use with the SceneOptimizer
  68491. * @param onSuccess defines a callback to call on success
  68492. * @param onFailure defines a callback to call on failure
  68493. * @returns the new SceneOptimizer object
  68494. */
  68495. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68496. }
  68497. }
  68498. declare module "babylonjs/Misc/sceneSerializer" {
  68499. import { Scene } from "babylonjs/scene";
  68500. /**
  68501. * Class used to serialize a scene into a string
  68502. */
  68503. export class SceneSerializer {
  68504. /**
  68505. * Clear cache used by a previous serialization
  68506. */
  68507. static ClearCache(): void;
  68508. /**
  68509. * Serialize a scene into a JSON compatible object
  68510. * @param scene defines the scene to serialize
  68511. * @returns a JSON compatible object
  68512. */
  68513. static Serialize(scene: Scene): any;
  68514. /**
  68515. * Serialize a mesh into a JSON compatible object
  68516. * @param toSerialize defines the mesh to serialize
  68517. * @param withParents defines if parents must be serialized as well
  68518. * @param withChildren defines if children must be serialized as well
  68519. * @returns a JSON compatible object
  68520. */
  68521. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68522. }
  68523. }
  68524. declare module "babylonjs/Misc/textureTools" {
  68525. import { Texture } from "babylonjs/Materials/Textures/texture";
  68526. /**
  68527. * Class used to host texture specific utilities
  68528. */
  68529. export class TextureTools {
  68530. /**
  68531. * Uses the GPU to create a copy texture rescaled at a given size
  68532. * @param texture Texture to copy from
  68533. * @param width defines the desired width
  68534. * @param height defines the desired height
  68535. * @param useBilinearMode defines if bilinear mode has to be used
  68536. * @return the generated texture
  68537. */
  68538. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68539. }
  68540. }
  68541. declare module "babylonjs/Misc/videoRecorder" {
  68542. import { Nullable } from "babylonjs/types";
  68543. import { Engine } from "babylonjs/Engines/engine";
  68544. /**
  68545. * This represents the different options available for the video capture.
  68546. */
  68547. export interface VideoRecorderOptions {
  68548. /** Defines the mime type of the video. */
  68549. mimeType: string;
  68550. /** Defines the FPS the video should be recorded at. */
  68551. fps: number;
  68552. /** Defines the chunk size for the recording data. */
  68553. recordChunckSize: number;
  68554. /** The audio tracks to attach to the recording. */
  68555. audioTracks?: MediaStreamTrack[];
  68556. }
  68557. /**
  68558. * This can help with recording videos from BabylonJS.
  68559. * This is based on the available WebRTC functionalities of the browser.
  68560. *
  68561. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68562. */
  68563. export class VideoRecorder {
  68564. private static readonly _defaultOptions;
  68565. /**
  68566. * Returns whether or not the VideoRecorder is available in your browser.
  68567. * @param engine Defines the Babylon Engine.
  68568. * @returns true if supported otherwise false.
  68569. */
  68570. static IsSupported(engine: Engine): boolean;
  68571. private readonly _options;
  68572. private _canvas;
  68573. private _mediaRecorder;
  68574. private _recordedChunks;
  68575. private _fileName;
  68576. private _resolve;
  68577. private _reject;
  68578. /**
  68579. * True when a recording is already in progress.
  68580. */
  68581. readonly isRecording: boolean;
  68582. /**
  68583. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68584. * @param engine Defines the BabylonJS Engine you wish to record.
  68585. * @param options Defines options that can be used to customize the capture.
  68586. */
  68587. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68588. /**
  68589. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68590. */
  68591. stopRecording(): void;
  68592. /**
  68593. * Starts recording the canvas for a max duration specified in parameters.
  68594. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68595. * If null no automatic download will start and you can rely on the promise to get the data back.
  68596. * @param maxDuration Defines the maximum recording time in seconds.
  68597. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68598. * @return A promise callback at the end of the recording with the video data in Blob.
  68599. */
  68600. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68601. /**
  68602. * Releases internal resources used during the recording.
  68603. */
  68604. dispose(): void;
  68605. private _handleDataAvailable;
  68606. private _handleError;
  68607. private _handleStop;
  68608. }
  68609. }
  68610. declare module "babylonjs/Misc/screenshotTools" {
  68611. import { Camera } from "babylonjs/Cameras/camera";
  68612. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  68613. import { Engine } from "babylonjs/Engines/engine";
  68614. /**
  68615. * Class containing a set of static utilities functions for screenshots
  68616. */
  68617. export class ScreenshotTools {
  68618. /**
  68619. * Captures a screenshot of the current rendering
  68620. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68621. * @param engine defines the rendering engine
  68622. * @param camera defines the source camera
  68623. * @param size This parameter can be set to a single number or to an object with the
  68624. * following (optional) properties: precision, width, height. If a single number is passed,
  68625. * it will be used for both width and height. If an object is passed, the screenshot size
  68626. * will be derived from the parameters. The precision property is a multiplier allowing
  68627. * rendering at a higher or lower resolution
  68628. * @param successCallback defines the callback receives a single parameter which contains the
  68629. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68630. * src parameter of an <img> to display it
  68631. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68632. * Check your browser for supported MIME types
  68633. */
  68634. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68635. /**
  68636. * Captures a screenshot of the current rendering
  68637. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68638. * @param engine defines the rendering engine
  68639. * @param camera defines the source camera
  68640. * @param size This parameter can be set to a single number or to an object with the
  68641. * following (optional) properties: precision, width, height. If a single number is passed,
  68642. * it will be used for both width and height. If an object is passed, the screenshot size
  68643. * will be derived from the parameters. The precision property is a multiplier allowing
  68644. * rendering at a higher or lower resolution
  68645. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68646. * Check your browser for supported MIME types
  68647. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68648. * to the src parameter of an <img> to display it
  68649. */
  68650. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68651. /**
  68652. * Generates an image screenshot from the specified camera.
  68653. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68654. * @param engine The engine to use for rendering
  68655. * @param camera The camera to use for rendering
  68656. * @param size This parameter can be set to a single number or to an object with the
  68657. * following (optional) properties: precision, width, height. If a single number is passed,
  68658. * it will be used for both width and height. If an object is passed, the screenshot size
  68659. * will be derived from the parameters. The precision property is a multiplier allowing
  68660. * rendering at a higher or lower resolution
  68661. * @param successCallback The callback receives a single parameter which contains the
  68662. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68663. * src parameter of an <img> to display it
  68664. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68665. * Check your browser for supported MIME types
  68666. * @param samples Texture samples (default: 1)
  68667. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68668. * @param fileName A name for for the downloaded file.
  68669. */
  68670. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68671. /**
  68672. * Generates an image screenshot from the specified camera.
  68673. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68674. * @param engine The engine to use for rendering
  68675. * @param camera The camera to use for rendering
  68676. * @param size This parameter can be set to a single number or to an object with the
  68677. * following (optional) properties: precision, width, height. If a single number is passed,
  68678. * it will be used for both width and height. If an object is passed, the screenshot size
  68679. * will be derived from the parameters. The precision property is a multiplier allowing
  68680. * rendering at a higher or lower resolution
  68681. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68682. * Check your browser for supported MIME types
  68683. * @param samples Texture samples (default: 1)
  68684. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68685. * @param fileName A name for for the downloaded file.
  68686. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68687. * to the src parameter of an <img> to display it
  68688. */
  68689. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68690. /**
  68691. * Gets height and width for screenshot size
  68692. * @private
  68693. */
  68694. private static _getScreenshotSize;
  68695. }
  68696. }
  68697. declare module "babylonjs/Misc/dataReader" {
  68698. /**
  68699. * Interface for a data buffer
  68700. */
  68701. export interface IDataBuffer {
  68702. /**
  68703. * Reads bytes from the data buffer.
  68704. * @param byteOffset The byte offset to read
  68705. * @param byteLength The byte length to read
  68706. * @returns A promise that resolves when the bytes are read
  68707. */
  68708. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68709. /**
  68710. * The byte length of the buffer.
  68711. */
  68712. readonly byteLength: number;
  68713. }
  68714. /**
  68715. * Utility class for reading from a data buffer
  68716. */
  68717. export class DataReader {
  68718. /**
  68719. * The data buffer associated with this data reader.
  68720. */
  68721. readonly buffer: IDataBuffer;
  68722. /**
  68723. * The current byte offset from the beginning of the data buffer.
  68724. */
  68725. byteOffset: number;
  68726. private _dataView;
  68727. private _dataByteOffset;
  68728. /**
  68729. * Constructor
  68730. * @param buffer The buffer to read
  68731. */
  68732. constructor(buffer: IDataBuffer);
  68733. /**
  68734. * Loads the given byte length.
  68735. * @param byteLength The byte length to load
  68736. * @returns A promise that resolves when the load is complete
  68737. */
  68738. loadAsync(byteLength: number): Promise<void>;
  68739. /**
  68740. * Read a unsigned 32-bit integer from the currently loaded data range.
  68741. * @returns The 32-bit integer read
  68742. */
  68743. readUint32(): number;
  68744. /**
  68745. * Read a byte array from the currently loaded data range.
  68746. * @param byteLength The byte length to read
  68747. * @returns The byte array read
  68748. */
  68749. readUint8Array(byteLength: number): Uint8Array;
  68750. /**
  68751. * Read a string from the currently loaded data range.
  68752. * @param byteLength The byte length to read
  68753. * @returns The string read
  68754. */
  68755. readString(byteLength: number): string;
  68756. /**
  68757. * Skips the given byte length the currently loaded data range.
  68758. * @param byteLength The byte length to skip
  68759. */
  68760. skipBytes(byteLength: number): void;
  68761. }
  68762. }
  68763. declare module "babylonjs/Misc/index" {
  68764. export * from "babylonjs/Misc/andOrNotEvaluator";
  68765. export * from "babylonjs/Misc/assetsManager";
  68766. export * from "babylonjs/Misc/basis";
  68767. export * from "babylonjs/Misc/dds";
  68768. export * from "babylonjs/Misc/decorators";
  68769. export * from "babylonjs/Misc/deferred";
  68770. export * from "babylonjs/Misc/environmentTextureTools";
  68771. export * from "babylonjs/Misc/meshExploder";
  68772. export * from "babylonjs/Misc/filesInput";
  68773. export * from "babylonjs/Misc/HighDynamicRange/index";
  68774. export * from "babylonjs/Misc/khronosTextureContainer";
  68775. export * from "babylonjs/Misc/observable";
  68776. export * from "babylonjs/Misc/performanceMonitor";
  68777. export * from "babylonjs/Misc/promise";
  68778. export * from "babylonjs/Misc/sceneOptimizer";
  68779. export * from "babylonjs/Misc/sceneSerializer";
  68780. export * from "babylonjs/Misc/smartArray";
  68781. export * from "babylonjs/Misc/stringDictionary";
  68782. export * from "babylonjs/Misc/tags";
  68783. export * from "babylonjs/Misc/textureTools";
  68784. export * from "babylonjs/Misc/tga";
  68785. export * from "babylonjs/Misc/tools";
  68786. export * from "babylonjs/Misc/videoRecorder";
  68787. export * from "babylonjs/Misc/virtualJoystick";
  68788. export * from "babylonjs/Misc/workerPool";
  68789. export * from "babylonjs/Misc/logger";
  68790. export * from "babylonjs/Misc/typeStore";
  68791. export * from "babylonjs/Misc/filesInputStore";
  68792. export * from "babylonjs/Misc/deepCopier";
  68793. export * from "babylonjs/Misc/pivotTools";
  68794. export * from "babylonjs/Misc/precisionDate";
  68795. export * from "babylonjs/Misc/screenshotTools";
  68796. export * from "babylonjs/Misc/typeStore";
  68797. export * from "babylonjs/Misc/webRequest";
  68798. export * from "babylonjs/Misc/iInspectable";
  68799. export * from "babylonjs/Misc/brdfTextureTools";
  68800. export * from "babylonjs/Misc/rgbdTextureTools";
  68801. export * from "babylonjs/Misc/gradients";
  68802. export * from "babylonjs/Misc/perfCounter";
  68803. export * from "babylonjs/Misc/fileRequest";
  68804. export * from "babylonjs/Misc/customAnimationFrameRequester";
  68805. export * from "babylonjs/Misc/retryStrategy";
  68806. export * from "babylonjs/Misc/interfaces/screenshotSize";
  68807. export * from "babylonjs/Misc/canvasGenerator";
  68808. export * from "babylonjs/Misc/fileTools";
  68809. export * from "babylonjs/Misc/stringTools";
  68810. export * from "babylonjs/Misc/dataReader";
  68811. }
  68812. declare module "babylonjs/index" {
  68813. export * from "babylonjs/abstractScene";
  68814. export * from "babylonjs/Actions/index";
  68815. export * from "babylonjs/Animations/index";
  68816. export * from "babylonjs/assetContainer";
  68817. export * from "babylonjs/Audio/index";
  68818. export * from "babylonjs/Behaviors/index";
  68819. export * from "babylonjs/Bones/index";
  68820. export * from "babylonjs/Cameras/index";
  68821. export * from "babylonjs/Collisions/index";
  68822. export * from "babylonjs/Culling/index";
  68823. export * from "babylonjs/Debug/index";
  68824. export * from "babylonjs/Engines/index";
  68825. export * from "babylonjs/Events/index";
  68826. export * from "babylonjs/Gamepads/index";
  68827. export * from "babylonjs/Gizmos/index";
  68828. export * from "babylonjs/Helpers/index";
  68829. export * from "babylonjs/Instrumentation/index";
  68830. export * from "babylonjs/Layers/index";
  68831. export * from "babylonjs/LensFlares/index";
  68832. export * from "babylonjs/Lights/index";
  68833. export * from "babylonjs/Loading/index";
  68834. export * from "babylonjs/Materials/index";
  68835. export * from "babylonjs/Maths/index";
  68836. export * from "babylonjs/Meshes/index";
  68837. export * from "babylonjs/Morph/index";
  68838. export * from "babylonjs/Navigation/index";
  68839. export * from "babylonjs/node";
  68840. export * from "babylonjs/Offline/index";
  68841. export * from "babylonjs/Particles/index";
  68842. export * from "babylonjs/Physics/index";
  68843. export * from "babylonjs/PostProcesses/index";
  68844. export * from "babylonjs/Probes/index";
  68845. export * from "babylonjs/Rendering/index";
  68846. export * from "babylonjs/scene";
  68847. export * from "babylonjs/sceneComponent";
  68848. export * from "babylonjs/Sprites/index";
  68849. export * from "babylonjs/States/index";
  68850. export * from "babylonjs/Misc/index";
  68851. export * from "babylonjs/types";
  68852. }
  68853. declare module "babylonjs/Animations/pathCursor" {
  68854. import { Vector3 } from "babylonjs/Maths/math.vector";
  68855. import { Path2 } from "babylonjs/Maths/math.path";
  68856. /**
  68857. * A cursor which tracks a point on a path
  68858. */
  68859. export class PathCursor {
  68860. private path;
  68861. /**
  68862. * Stores path cursor callbacks for when an onchange event is triggered
  68863. */
  68864. private _onchange;
  68865. /**
  68866. * The value of the path cursor
  68867. */
  68868. value: number;
  68869. /**
  68870. * The animation array of the path cursor
  68871. */
  68872. animations: Animation[];
  68873. /**
  68874. * Initializes the path cursor
  68875. * @param path The path to track
  68876. */
  68877. constructor(path: Path2);
  68878. /**
  68879. * Gets the cursor point on the path
  68880. * @returns A point on the path cursor at the cursor location
  68881. */
  68882. getPoint(): Vector3;
  68883. /**
  68884. * Moves the cursor ahead by the step amount
  68885. * @param step The amount to move the cursor forward
  68886. * @returns This path cursor
  68887. */
  68888. moveAhead(step?: number): PathCursor;
  68889. /**
  68890. * Moves the cursor behind by the step amount
  68891. * @param step The amount to move the cursor back
  68892. * @returns This path cursor
  68893. */
  68894. moveBack(step?: number): PathCursor;
  68895. /**
  68896. * Moves the cursor by the step amount
  68897. * If the step amount is greater than one, an exception is thrown
  68898. * @param step The amount to move the cursor
  68899. * @returns This path cursor
  68900. */
  68901. move(step: number): PathCursor;
  68902. /**
  68903. * Ensures that the value is limited between zero and one
  68904. * @returns This path cursor
  68905. */
  68906. private ensureLimits;
  68907. /**
  68908. * Runs onchange callbacks on change (used by the animation engine)
  68909. * @returns This path cursor
  68910. */
  68911. private raiseOnChange;
  68912. /**
  68913. * Executes a function on change
  68914. * @param f A path cursor onchange callback
  68915. * @returns This path cursor
  68916. */
  68917. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68918. }
  68919. }
  68920. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68921. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68922. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68923. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68924. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68925. }
  68926. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68927. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68928. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68929. }
  68930. declare module "babylonjs/Engines/Processors/index" {
  68931. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68932. export * from "babylonjs/Engines/Processors/Expressions/index";
  68933. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68934. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68935. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68936. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68937. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68938. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68939. }
  68940. declare module "babylonjs/Legacy/legacy" {
  68941. import * as Babylon from "babylonjs/index";
  68942. export * from "babylonjs/index";
  68943. }
  68944. declare module "babylonjs/Shaders/blur.fragment" {
  68945. /** @hidden */
  68946. export var blurPixelShader: {
  68947. name: string;
  68948. shader: string;
  68949. };
  68950. }
  68951. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68952. /** @hidden */
  68953. export var pointCloudVertexDeclaration: {
  68954. name: string;
  68955. shader: string;
  68956. };
  68957. }
  68958. declare module "babylonjs" {
  68959. export * from "babylonjs/Legacy/legacy";
  68960. }
  68961. declare module BABYLON {
  68962. /** Alias type for value that can be null */
  68963. export type Nullable<T> = T | null;
  68964. /**
  68965. * Alias type for number that are floats
  68966. * @ignorenaming
  68967. */
  68968. export type float = number;
  68969. /**
  68970. * Alias type for number that are doubles.
  68971. * @ignorenaming
  68972. */
  68973. export type double = number;
  68974. /**
  68975. * Alias type for number that are integer
  68976. * @ignorenaming
  68977. */
  68978. export type int = number;
  68979. /** Alias type for number array or Float32Array */
  68980. export type FloatArray = number[] | Float32Array;
  68981. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68982. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68983. /**
  68984. * Alias for types that can be used by a Buffer or VertexBuffer.
  68985. */
  68986. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68987. /**
  68988. * Alias type for primitive types
  68989. * @ignorenaming
  68990. */
  68991. type Primitive = undefined | null | boolean | string | number | Function;
  68992. /**
  68993. * Type modifier to make all the properties of an object Readonly
  68994. */
  68995. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68996. /**
  68997. * Type modifier to make all the properties of an object Readonly recursively
  68998. */
  68999. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  69000. /**
  69001. * Type modifier to make object properties readonly.
  69002. */
  69003. export type DeepImmutableObject<T> = {
  69004. readonly [K in keyof T]: DeepImmutable<T[K]>;
  69005. };
  69006. /** @hidden */
  69007. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  69008. }
  69009. }
  69010. declare module BABYLON {
  69011. /**
  69012. * A class serves as a medium between the observable and its observers
  69013. */
  69014. export class EventState {
  69015. /**
  69016. * Create a new EventState
  69017. * @param mask defines the mask associated with this state
  69018. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  69019. * @param target defines the original target of the state
  69020. * @param currentTarget defines the current target of the state
  69021. */
  69022. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  69023. /**
  69024. * Initialize the current event state
  69025. * @param mask defines the mask associated with this state
  69026. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  69027. * @param target defines the original target of the state
  69028. * @param currentTarget defines the current target of the state
  69029. * @returns the current event state
  69030. */
  69031. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  69032. /**
  69033. * An Observer can set this property to true to prevent subsequent observers of being notified
  69034. */
  69035. skipNextObservers: boolean;
  69036. /**
  69037. * Get the mask value that were used to trigger the event corresponding to this EventState object
  69038. */
  69039. mask: number;
  69040. /**
  69041. * The object that originally notified the event
  69042. */
  69043. target?: any;
  69044. /**
  69045. * The current object in the bubbling phase
  69046. */
  69047. currentTarget?: any;
  69048. /**
  69049. * This will be populated with the return value of the last function that was executed.
  69050. * If it is the first function in the callback chain it will be the event data.
  69051. */
  69052. lastReturnValue?: any;
  69053. }
  69054. /**
  69055. * Represent an Observer registered to a given Observable object.
  69056. */
  69057. export class Observer<T> {
  69058. /**
  69059. * Defines the callback to call when the observer is notified
  69060. */
  69061. callback: (eventData: T, eventState: EventState) => void;
  69062. /**
  69063. * Defines the mask of the observer (used to filter notifications)
  69064. */
  69065. mask: number;
  69066. /**
  69067. * Defines the current scope used to restore the JS context
  69068. */
  69069. scope: any;
  69070. /** @hidden */
  69071. _willBeUnregistered: boolean;
  69072. /**
  69073. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  69074. */
  69075. unregisterOnNextCall: boolean;
  69076. /**
  69077. * Creates a new observer
  69078. * @param callback defines the callback to call when the observer is notified
  69079. * @param mask defines the mask of the observer (used to filter notifications)
  69080. * @param scope defines the current scope used to restore the JS context
  69081. */
  69082. constructor(
  69083. /**
  69084. * Defines the callback to call when the observer is notified
  69085. */
  69086. callback: (eventData: T, eventState: EventState) => void,
  69087. /**
  69088. * Defines the mask of the observer (used to filter notifications)
  69089. */
  69090. mask: number,
  69091. /**
  69092. * Defines the current scope used to restore the JS context
  69093. */
  69094. scope?: any);
  69095. }
  69096. /**
  69097. * Represent a list of observers registered to multiple Observables object.
  69098. */
  69099. export class MultiObserver<T> {
  69100. private _observers;
  69101. private _observables;
  69102. /**
  69103. * Release associated resources
  69104. */
  69105. dispose(): void;
  69106. /**
  69107. * Raise a callback when one of the observable will notify
  69108. * @param observables defines a list of observables to watch
  69109. * @param callback defines the callback to call on notification
  69110. * @param mask defines the mask used to filter notifications
  69111. * @param scope defines the current scope used to restore the JS context
  69112. * @returns the new MultiObserver
  69113. */
  69114. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  69115. }
  69116. /**
  69117. * The Observable class is a simple implementation of the Observable pattern.
  69118. *
  69119. * 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.
  69120. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  69121. * 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).
  69122. * 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.
  69123. */
  69124. export class Observable<T> {
  69125. private _observers;
  69126. private _eventState;
  69127. private _onObserverAdded;
  69128. /**
  69129. * Gets the list of observers
  69130. */
  69131. readonly observers: Array<Observer<T>>;
  69132. /**
  69133. * Creates a new observable
  69134. * @param onObserverAdded defines a callback to call when a new observer is added
  69135. */
  69136. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  69137. /**
  69138. * Create a new Observer with the specified callback
  69139. * @param callback the callback that will be executed for that Observer
  69140. * @param mask the mask used to filter observers
  69141. * @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.
  69142. * @param scope optional scope for the callback to be called from
  69143. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  69144. * @returns the new observer created for the callback
  69145. */
  69146. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  69147. /**
  69148. * Create a new Observer with the specified callback and unregisters after the next notification
  69149. * @param callback the callback that will be executed for that Observer
  69150. * @returns the new observer created for the callback
  69151. */
  69152. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  69153. /**
  69154. * Remove an Observer from the Observable object
  69155. * @param observer the instance of the Observer to remove
  69156. * @returns false if it doesn't belong to this Observable
  69157. */
  69158. remove(observer: Nullable<Observer<T>>): boolean;
  69159. /**
  69160. * Remove a callback from the Observable object
  69161. * @param callback the callback to remove
  69162. * @param scope optional scope. If used only the callbacks with this scope will be removed
  69163. * @returns false if it doesn't belong to this Observable
  69164. */
  69165. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  69166. private _deferUnregister;
  69167. private _remove;
  69168. /**
  69169. * Moves the observable to the top of the observer list making it get called first when notified
  69170. * @param observer the observer to move
  69171. */
  69172. makeObserverTopPriority(observer: Observer<T>): void;
  69173. /**
  69174. * Moves the observable to the bottom of the observer list making it get called last when notified
  69175. * @param observer the observer to move
  69176. */
  69177. makeObserverBottomPriority(observer: Observer<T>): void;
  69178. /**
  69179. * Notify all Observers by calling their respective callback with the given data
  69180. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  69181. * @param eventData defines the data to send to all observers
  69182. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  69183. * @param target defines the original target of the state
  69184. * @param currentTarget defines the current target of the state
  69185. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  69186. */
  69187. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  69188. /**
  69189. * Calling this will execute each callback, expecting it to be a promise or return a value.
  69190. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  69191. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  69192. * and it is crucial that all callbacks will be executed.
  69193. * The order of the callbacks is kept, callbacks are not executed parallel.
  69194. *
  69195. * @param eventData The data to be sent to each callback
  69196. * @param mask is used to filter observers defaults to -1
  69197. * @param target defines the callback target (see EventState)
  69198. * @param currentTarget defines he current object in the bubbling phase
  69199. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  69200. */
  69201. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  69202. /**
  69203. * Notify a specific observer
  69204. * @param observer defines the observer to notify
  69205. * @param eventData defines the data to be sent to each callback
  69206. * @param mask is used to filter observers defaults to -1
  69207. */
  69208. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  69209. /**
  69210. * Gets a boolean indicating if the observable has at least one observer
  69211. * @returns true is the Observable has at least one Observer registered
  69212. */
  69213. hasObservers(): boolean;
  69214. /**
  69215. * Clear the list of observers
  69216. */
  69217. clear(): void;
  69218. /**
  69219. * Clone the current observable
  69220. * @returns a new observable
  69221. */
  69222. clone(): Observable<T>;
  69223. /**
  69224. * Does this observable handles observer registered with a given mask
  69225. * @param mask defines the mask to be tested
  69226. * @return whether or not one observer registered with the given mask is handeled
  69227. **/
  69228. hasSpecificMask(mask?: number): boolean;
  69229. }
  69230. }
  69231. declare module BABYLON {
  69232. /**
  69233. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  69234. * Babylon.js
  69235. */
  69236. export class DomManagement {
  69237. /**
  69238. * Checks if the window object exists
  69239. * @returns true if the window object exists
  69240. */
  69241. static IsWindowObjectExist(): boolean;
  69242. /**
  69243. * Checks if the navigator object exists
  69244. * @returns true if the navigator object exists
  69245. */
  69246. static IsNavigatorAvailable(): boolean;
  69247. /**
  69248. * Extracts text content from a DOM element hierarchy
  69249. * @param element defines the root element
  69250. * @returns a string
  69251. */
  69252. static GetDOMTextContent(element: HTMLElement): string;
  69253. }
  69254. }
  69255. declare module BABYLON {
  69256. /**
  69257. * Logger used througouht the application to allow configuration of
  69258. * the log level required for the messages.
  69259. */
  69260. export class Logger {
  69261. /**
  69262. * No log
  69263. */
  69264. static readonly NoneLogLevel: number;
  69265. /**
  69266. * Only message logs
  69267. */
  69268. static readonly MessageLogLevel: number;
  69269. /**
  69270. * Only warning logs
  69271. */
  69272. static readonly WarningLogLevel: number;
  69273. /**
  69274. * Only error logs
  69275. */
  69276. static readonly ErrorLogLevel: number;
  69277. /**
  69278. * All logs
  69279. */
  69280. static readonly AllLogLevel: number;
  69281. private static _LogCache;
  69282. /**
  69283. * Gets a value indicating the number of loading errors
  69284. * @ignorenaming
  69285. */
  69286. static errorsCount: number;
  69287. /**
  69288. * Callback called when a new log is added
  69289. */
  69290. static OnNewCacheEntry: (entry: string) => void;
  69291. private static _AddLogEntry;
  69292. private static _FormatMessage;
  69293. private static _LogDisabled;
  69294. private static _LogEnabled;
  69295. private static _WarnDisabled;
  69296. private static _WarnEnabled;
  69297. private static _ErrorDisabled;
  69298. private static _ErrorEnabled;
  69299. /**
  69300. * Log a message to the console
  69301. */
  69302. static Log: (message: string) => void;
  69303. /**
  69304. * Write a warning message to the console
  69305. */
  69306. static Warn: (message: string) => void;
  69307. /**
  69308. * Write an error message to the console
  69309. */
  69310. static Error: (message: string) => void;
  69311. /**
  69312. * Gets current log cache (list of logs)
  69313. */
  69314. static readonly LogCache: string;
  69315. /**
  69316. * Clears the log cache
  69317. */
  69318. static ClearLogCache(): void;
  69319. /**
  69320. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  69321. */
  69322. static LogLevels: number;
  69323. }
  69324. }
  69325. declare module BABYLON {
  69326. /** @hidden */
  69327. export class _TypeStore {
  69328. /** @hidden */
  69329. static RegisteredTypes: {
  69330. [key: string]: Object;
  69331. };
  69332. /** @hidden */
  69333. static GetClass(fqdn: string): any;
  69334. }
  69335. }
  69336. declare module BABYLON {
  69337. /**
  69338. * Helper to manipulate strings
  69339. */
  69340. export class StringTools {
  69341. /**
  69342. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69343. * @param str Source string
  69344. * @param suffix Suffix to search for in the source string
  69345. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69346. */
  69347. static EndsWith(str: string, suffix: string): boolean;
  69348. /**
  69349. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69350. * @param str Source string
  69351. * @param suffix Suffix to search for in the source string
  69352. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69353. */
  69354. static StartsWith(str: string, suffix: string): boolean;
  69355. /**
  69356. * Decodes a buffer into a string
  69357. * @param buffer The buffer to decode
  69358. * @returns The decoded string
  69359. */
  69360. static Decode(buffer: Uint8Array | Uint16Array): string;
  69361. /**
  69362. * Encode a buffer to a base64 string
  69363. * @param buffer defines the buffer to encode
  69364. * @returns the encoded string
  69365. */
  69366. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  69367. }
  69368. }
  69369. declare module BABYLON {
  69370. /**
  69371. * Class containing a set of static utilities functions for deep copy.
  69372. */
  69373. export class DeepCopier {
  69374. /**
  69375. * Tries to copy an object by duplicating every property
  69376. * @param source defines the source object
  69377. * @param destination defines the target object
  69378. * @param doNotCopyList defines a list of properties to avoid
  69379. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  69380. */
  69381. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  69382. }
  69383. }
  69384. declare module BABYLON {
  69385. /**
  69386. * Class containing a set of static utilities functions for precision date
  69387. */
  69388. export class PrecisionDate {
  69389. /**
  69390. * Gets either window.performance.now() if supported or Date.now() else
  69391. */
  69392. static readonly Now: number;
  69393. }
  69394. }
  69395. declare module BABYLON {
  69396. /** @hidden */
  69397. export class _DevTools {
  69398. static WarnImport(name: string): string;
  69399. }
  69400. }
  69401. declare module BABYLON {
  69402. /**
  69403. * Interface used to define the mechanism to get data from the network
  69404. */
  69405. export interface IWebRequest {
  69406. /**
  69407. * Returns client's response url
  69408. */
  69409. responseURL: string;
  69410. /**
  69411. * Returns client's status
  69412. */
  69413. status: number;
  69414. /**
  69415. * Returns client's status as a text
  69416. */
  69417. statusText: string;
  69418. }
  69419. }
  69420. declare module BABYLON {
  69421. /**
  69422. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  69423. */
  69424. export class WebRequest implements IWebRequest {
  69425. private _xhr;
  69426. /**
  69427. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  69428. * i.e. when loading files, where the server/service expects an Authorization header
  69429. */
  69430. static CustomRequestHeaders: {
  69431. [key: string]: string;
  69432. };
  69433. /**
  69434. * Add callback functions in this array to update all the requests before they get sent to the network
  69435. */
  69436. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  69437. private _injectCustomRequestHeaders;
  69438. /**
  69439. * Gets or sets a function to be called when loading progress changes
  69440. */
  69441. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  69442. /**
  69443. * Returns client's state
  69444. */
  69445. readonly readyState: number;
  69446. /**
  69447. * Returns client's status
  69448. */
  69449. readonly status: number;
  69450. /**
  69451. * Returns client's status as a text
  69452. */
  69453. readonly statusText: string;
  69454. /**
  69455. * Returns client's response
  69456. */
  69457. readonly response: any;
  69458. /**
  69459. * Returns client's response url
  69460. */
  69461. readonly responseURL: string;
  69462. /**
  69463. * Returns client's response as text
  69464. */
  69465. readonly responseText: string;
  69466. /**
  69467. * Gets or sets the expected response type
  69468. */
  69469. responseType: XMLHttpRequestResponseType;
  69470. /** @hidden */
  69471. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  69472. /** @hidden */
  69473. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  69474. /**
  69475. * Cancels any network activity
  69476. */
  69477. abort(): void;
  69478. /**
  69479. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  69480. * @param body defines an optional request body
  69481. */
  69482. send(body?: Document | BodyInit | null): void;
  69483. /**
  69484. * Sets the request method, request URL
  69485. * @param method defines the method to use (GET, POST, etc..)
  69486. * @param url defines the url to connect with
  69487. */
  69488. open(method: string, url: string): void;
  69489. /**
  69490. * Sets the value of a request header.
  69491. * @param name The name of the header whose value is to be set
  69492. * @param value The value to set as the body of the header
  69493. */
  69494. setRequestHeader(name: string, value: string): void;
  69495. /**
  69496. * Get the string containing the text of a particular header's value.
  69497. * @param name The name of the header
  69498. * @returns The string containing the text of the given header name
  69499. */
  69500. getResponseHeader(name: string): Nullable<string>;
  69501. }
  69502. }
  69503. declare module BABYLON {
  69504. /**
  69505. * File request interface
  69506. */
  69507. export interface IFileRequest {
  69508. /**
  69509. * Raised when the request is complete (success or error).
  69510. */
  69511. onCompleteObservable: Observable<IFileRequest>;
  69512. /**
  69513. * Aborts the request for a file.
  69514. */
  69515. abort: () => void;
  69516. }
  69517. }
  69518. declare module BABYLON {
  69519. /**
  69520. * Define options used to create a render target texture
  69521. */
  69522. export class RenderTargetCreationOptions {
  69523. /**
  69524. * Specifies is mipmaps must be generated
  69525. */
  69526. generateMipMaps?: boolean;
  69527. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69528. generateDepthBuffer?: boolean;
  69529. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69530. generateStencilBuffer?: boolean;
  69531. /** Defines texture type (int by default) */
  69532. type?: number;
  69533. /** Defines sampling mode (trilinear by default) */
  69534. samplingMode?: number;
  69535. /** Defines format (RGBA by default) */
  69536. format?: number;
  69537. }
  69538. }
  69539. declare module BABYLON {
  69540. /**
  69541. * @hidden
  69542. **/
  69543. export class _TimeToken {
  69544. _startTimeQuery: Nullable<WebGLQuery>;
  69545. _endTimeQuery: Nullable<WebGLQuery>;
  69546. _timeElapsedQuery: Nullable<WebGLQuery>;
  69547. _timeElapsedQueryEnded: boolean;
  69548. }
  69549. }
  69550. declare module BABYLON {
  69551. /** Defines the cross module used constants to avoid circular dependncies */
  69552. export class Constants {
  69553. /** Defines that alpha blending is disabled */
  69554. static readonly ALPHA_DISABLE: number;
  69555. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69556. static readonly ALPHA_ADD: number;
  69557. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69558. static readonly ALPHA_COMBINE: number;
  69559. /** Defines that alpha blending to DEST - SRC * DEST */
  69560. static readonly ALPHA_SUBTRACT: number;
  69561. /** Defines that alpha blending to SRC * DEST */
  69562. static readonly ALPHA_MULTIPLY: number;
  69563. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69564. static readonly ALPHA_MAXIMIZED: number;
  69565. /** Defines that alpha blending to SRC + DEST */
  69566. static readonly ALPHA_ONEONE: number;
  69567. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69568. static readonly ALPHA_PREMULTIPLIED: number;
  69569. /**
  69570. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69571. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69572. */
  69573. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69574. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69575. static readonly ALPHA_INTERPOLATE: number;
  69576. /**
  69577. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69578. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69579. */
  69580. static readonly ALPHA_SCREENMODE: number;
  69581. /**
  69582. * Defines that alpha blending to SRC + DST
  69583. * Alpha will be set to SRC ALPHA + DST ALPHA
  69584. */
  69585. static readonly ALPHA_ONEONE_ONEONE: number;
  69586. /**
  69587. * Defines that alpha blending to SRC * DST ALPHA + DST
  69588. * Alpha will be set to 0
  69589. */
  69590. static readonly ALPHA_ALPHATOCOLOR: number;
  69591. /**
  69592. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69593. */
  69594. static readonly ALPHA_REVERSEONEMINUS: number;
  69595. /**
  69596. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69597. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69598. */
  69599. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69600. /**
  69601. * Defines that alpha blending to SRC + DST
  69602. * Alpha will be set to SRC ALPHA
  69603. */
  69604. static readonly ALPHA_ONEONE_ONEZERO: number;
  69605. /** Defines that alpha blending equation a SUM */
  69606. static readonly ALPHA_EQUATION_ADD: number;
  69607. /** Defines that alpha blending equation a SUBSTRACTION */
  69608. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69609. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69610. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  69611. /** Defines that alpha blending equation a MAX operation */
  69612. static readonly ALPHA_EQUATION_MAX: number;
  69613. /** Defines that alpha blending equation a MIN operation */
  69614. static readonly ALPHA_EQUATION_MIN: number;
  69615. /**
  69616. * Defines that alpha blending equation a DARKEN operation:
  69617. * It takes the min of the src and sums the alpha channels.
  69618. */
  69619. static readonly ALPHA_EQUATION_DARKEN: number;
  69620. /** Defines that the ressource is not delayed*/
  69621. static readonly DELAYLOADSTATE_NONE: number;
  69622. /** Defines that the ressource was successfully delay loaded */
  69623. static readonly DELAYLOADSTATE_LOADED: number;
  69624. /** Defines that the ressource is currently delay loading */
  69625. static readonly DELAYLOADSTATE_LOADING: number;
  69626. /** Defines that the ressource is delayed and has not started loading */
  69627. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69629. static readonly NEVER: number;
  69630. /** 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 */
  69631. static readonly ALWAYS: number;
  69632. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69633. static readonly LESS: number;
  69634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69635. static readonly EQUAL: number;
  69636. /** 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 */
  69637. static readonly LEQUAL: number;
  69638. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69639. static readonly GREATER: number;
  69640. /** 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 */
  69641. static readonly GEQUAL: number;
  69642. /** 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 */
  69643. static readonly NOTEQUAL: number;
  69644. /** Passed to stencilOperation to specify that stencil value must be kept */
  69645. static readonly KEEP: number;
  69646. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69647. static readonly REPLACE: number;
  69648. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69649. static readonly INCR: number;
  69650. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69651. static readonly DECR: number;
  69652. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69653. static readonly INVERT: number;
  69654. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69655. static readonly INCR_WRAP: number;
  69656. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69657. static readonly DECR_WRAP: number;
  69658. /** Texture is not repeating outside of 0..1 UVs */
  69659. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69660. /** Texture is repeating outside of 0..1 UVs */
  69661. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69662. /** Texture is repeating and mirrored */
  69663. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69664. /** ALPHA */
  69665. static readonly TEXTUREFORMAT_ALPHA: number;
  69666. /** LUMINANCE */
  69667. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69668. /** LUMINANCE_ALPHA */
  69669. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69670. /** RGB */
  69671. static readonly TEXTUREFORMAT_RGB: number;
  69672. /** RGBA */
  69673. static readonly TEXTUREFORMAT_RGBA: number;
  69674. /** RED */
  69675. static readonly TEXTUREFORMAT_RED: number;
  69676. /** RED (2nd reference) */
  69677. static readonly TEXTUREFORMAT_R: number;
  69678. /** RG */
  69679. static readonly TEXTUREFORMAT_RG: number;
  69680. /** RED_INTEGER */
  69681. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69682. /** RED_INTEGER (2nd reference) */
  69683. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69684. /** RG_INTEGER */
  69685. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69686. /** RGB_INTEGER */
  69687. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69688. /** RGBA_INTEGER */
  69689. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69690. /** UNSIGNED_BYTE */
  69691. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69692. /** UNSIGNED_BYTE (2nd reference) */
  69693. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69694. /** FLOAT */
  69695. static readonly TEXTURETYPE_FLOAT: number;
  69696. /** HALF_FLOAT */
  69697. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69698. /** BYTE */
  69699. static readonly TEXTURETYPE_BYTE: number;
  69700. /** SHORT */
  69701. static readonly TEXTURETYPE_SHORT: number;
  69702. /** UNSIGNED_SHORT */
  69703. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69704. /** INT */
  69705. static readonly TEXTURETYPE_INT: number;
  69706. /** UNSIGNED_INT */
  69707. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69708. /** UNSIGNED_SHORT_4_4_4_4 */
  69709. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69710. /** UNSIGNED_SHORT_5_5_5_1 */
  69711. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69712. /** UNSIGNED_SHORT_5_6_5 */
  69713. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69714. /** UNSIGNED_INT_2_10_10_10_REV */
  69715. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69716. /** UNSIGNED_INT_24_8 */
  69717. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69718. /** UNSIGNED_INT_10F_11F_11F_REV */
  69719. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69720. /** UNSIGNED_INT_5_9_9_9_REV */
  69721. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69722. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69723. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69724. /** nearest is mag = nearest and min = nearest and mip = nearest */
  69725. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69726. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69727. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69728. /** Trilinear is mag = linear and min = linear and mip = linear */
  69729. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69730. /** nearest is mag = nearest and min = nearest and mip = linear */
  69731. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69732. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69733. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69734. /** Trilinear is mag = linear and min = linear and mip = linear */
  69735. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69736. /** mag = nearest and min = nearest and mip = nearest */
  69737. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69738. /** mag = nearest and min = linear and mip = nearest */
  69739. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69740. /** mag = nearest and min = linear and mip = linear */
  69741. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69742. /** mag = nearest and min = linear and mip = none */
  69743. static readonly TEXTURE_NEAREST_LINEAR: number;
  69744. /** mag = nearest and min = nearest and mip = none */
  69745. static readonly TEXTURE_NEAREST_NEAREST: number;
  69746. /** mag = linear and min = nearest and mip = nearest */
  69747. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69748. /** mag = linear and min = nearest and mip = linear */
  69749. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69750. /** mag = linear and min = linear and mip = none */
  69751. static readonly TEXTURE_LINEAR_LINEAR: number;
  69752. /** mag = linear and min = nearest and mip = none */
  69753. static readonly TEXTURE_LINEAR_NEAREST: number;
  69754. /** Explicit coordinates mode */
  69755. static readonly TEXTURE_EXPLICIT_MODE: number;
  69756. /** Spherical coordinates mode */
  69757. static readonly TEXTURE_SPHERICAL_MODE: number;
  69758. /** Planar coordinates mode */
  69759. static readonly TEXTURE_PLANAR_MODE: number;
  69760. /** Cubic coordinates mode */
  69761. static readonly TEXTURE_CUBIC_MODE: number;
  69762. /** Projection coordinates mode */
  69763. static readonly TEXTURE_PROJECTION_MODE: number;
  69764. /** Skybox coordinates mode */
  69765. static readonly TEXTURE_SKYBOX_MODE: number;
  69766. /** Inverse Cubic coordinates mode */
  69767. static readonly TEXTURE_INVCUBIC_MODE: number;
  69768. /** Equirectangular coordinates mode */
  69769. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69770. /** Equirectangular Fixed coordinates mode */
  69771. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69772. /** Equirectangular Fixed Mirrored coordinates mode */
  69773. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69774. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69775. static readonly SCALEMODE_FLOOR: number;
  69776. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69777. static readonly SCALEMODE_NEAREST: number;
  69778. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69779. static readonly SCALEMODE_CEILING: number;
  69780. /**
  69781. * The dirty texture flag value
  69782. */
  69783. static readonly MATERIAL_TextureDirtyFlag: number;
  69784. /**
  69785. * The dirty light flag value
  69786. */
  69787. static readonly MATERIAL_LightDirtyFlag: number;
  69788. /**
  69789. * The dirty fresnel flag value
  69790. */
  69791. static readonly MATERIAL_FresnelDirtyFlag: number;
  69792. /**
  69793. * The dirty attribute flag value
  69794. */
  69795. static readonly MATERIAL_AttributesDirtyFlag: number;
  69796. /**
  69797. * The dirty misc flag value
  69798. */
  69799. static readonly MATERIAL_MiscDirtyFlag: number;
  69800. /**
  69801. * The all dirty flag value
  69802. */
  69803. static readonly MATERIAL_AllDirtyFlag: number;
  69804. /**
  69805. * Returns the triangle fill mode
  69806. */
  69807. static readonly MATERIAL_TriangleFillMode: number;
  69808. /**
  69809. * Returns the wireframe mode
  69810. */
  69811. static readonly MATERIAL_WireFrameFillMode: number;
  69812. /**
  69813. * Returns the point fill mode
  69814. */
  69815. static readonly MATERIAL_PointFillMode: number;
  69816. /**
  69817. * Returns the point list draw mode
  69818. */
  69819. static readonly MATERIAL_PointListDrawMode: number;
  69820. /**
  69821. * Returns the line list draw mode
  69822. */
  69823. static readonly MATERIAL_LineListDrawMode: number;
  69824. /**
  69825. * Returns the line loop draw mode
  69826. */
  69827. static readonly MATERIAL_LineLoopDrawMode: number;
  69828. /**
  69829. * Returns the line strip draw mode
  69830. */
  69831. static readonly MATERIAL_LineStripDrawMode: number;
  69832. /**
  69833. * Returns the triangle strip draw mode
  69834. */
  69835. static readonly MATERIAL_TriangleStripDrawMode: number;
  69836. /**
  69837. * Returns the triangle fan draw mode
  69838. */
  69839. static readonly MATERIAL_TriangleFanDrawMode: number;
  69840. /**
  69841. * Stores the clock-wise side orientation
  69842. */
  69843. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69844. /**
  69845. * Stores the counter clock-wise side orientation
  69846. */
  69847. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69848. /**
  69849. * Nothing
  69850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69851. */
  69852. static readonly ACTION_NothingTrigger: number;
  69853. /**
  69854. * On pick
  69855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69856. */
  69857. static readonly ACTION_OnPickTrigger: number;
  69858. /**
  69859. * On left pick
  69860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69861. */
  69862. static readonly ACTION_OnLeftPickTrigger: number;
  69863. /**
  69864. * On right pick
  69865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69866. */
  69867. static readonly ACTION_OnRightPickTrigger: number;
  69868. /**
  69869. * On center pick
  69870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69871. */
  69872. static readonly ACTION_OnCenterPickTrigger: number;
  69873. /**
  69874. * On pick down
  69875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69876. */
  69877. static readonly ACTION_OnPickDownTrigger: number;
  69878. /**
  69879. * On double pick
  69880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69881. */
  69882. static readonly ACTION_OnDoublePickTrigger: number;
  69883. /**
  69884. * On pick up
  69885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69886. */
  69887. static readonly ACTION_OnPickUpTrigger: number;
  69888. /**
  69889. * On pick out.
  69890. * This trigger will only be raised if you also declared a OnPickDown
  69891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69892. */
  69893. static readonly ACTION_OnPickOutTrigger: number;
  69894. /**
  69895. * On long press
  69896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69897. */
  69898. static readonly ACTION_OnLongPressTrigger: number;
  69899. /**
  69900. * On pointer over
  69901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69902. */
  69903. static readonly ACTION_OnPointerOverTrigger: number;
  69904. /**
  69905. * On pointer out
  69906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69907. */
  69908. static readonly ACTION_OnPointerOutTrigger: number;
  69909. /**
  69910. * On every frame
  69911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69912. */
  69913. static readonly ACTION_OnEveryFrameTrigger: number;
  69914. /**
  69915. * On intersection enter
  69916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69917. */
  69918. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69919. /**
  69920. * On intersection exit
  69921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69922. */
  69923. static readonly ACTION_OnIntersectionExitTrigger: number;
  69924. /**
  69925. * On key down
  69926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69927. */
  69928. static readonly ACTION_OnKeyDownTrigger: number;
  69929. /**
  69930. * On key up
  69931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69932. */
  69933. static readonly ACTION_OnKeyUpTrigger: number;
  69934. /**
  69935. * Billboard mode will only apply to Y axis
  69936. */
  69937. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69938. /**
  69939. * Billboard mode will apply to all axes
  69940. */
  69941. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69942. /**
  69943. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69944. */
  69945. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69946. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69947. * Test order :
  69948. * Is the bounding sphere outside the frustum ?
  69949. * If not, are the bounding box vertices outside the frustum ?
  69950. * It not, then the cullable object is in the frustum.
  69951. */
  69952. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69953. /** Culling strategy : Bounding Sphere Only.
  69954. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69955. * It's also less accurate than the standard because some not visible objects can still be selected.
  69956. * Test : is the bounding sphere outside the frustum ?
  69957. * If not, then the cullable object is in the frustum.
  69958. */
  69959. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69960. /** Culling strategy : Optimistic Inclusion.
  69961. * This in an inclusion test first, then the standard exclusion test.
  69962. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69963. * 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.
  69964. * Anyway, it's as accurate as the standard strategy.
  69965. * Test :
  69966. * Is the cullable object bounding sphere center in the frustum ?
  69967. * If not, apply the default culling strategy.
  69968. */
  69969. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69970. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69971. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69972. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69973. * 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.
  69974. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69975. * Test :
  69976. * Is the cullable object bounding sphere center in the frustum ?
  69977. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69978. */
  69979. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69980. /**
  69981. * No logging while loading
  69982. */
  69983. static readonly SCENELOADER_NO_LOGGING: number;
  69984. /**
  69985. * Minimal logging while loading
  69986. */
  69987. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69988. /**
  69989. * Summary logging while loading
  69990. */
  69991. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69992. /**
  69993. * Detailled logging while loading
  69994. */
  69995. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69996. }
  69997. }
  69998. declare module BABYLON {
  69999. /**
  70000. * This represents the required contract to create a new type of texture loader.
  70001. */
  70002. export interface IInternalTextureLoader {
  70003. /**
  70004. * Defines wether the loader supports cascade loading the different faces.
  70005. */
  70006. supportCascades: boolean;
  70007. /**
  70008. * This returns if the loader support the current file information.
  70009. * @param extension defines the file extension of the file being loaded
  70010. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70011. * @param fallback defines the fallback internal texture if any
  70012. * @param isBase64 defines whether the texture is encoded as a base64
  70013. * @param isBuffer defines whether the texture data are stored as a buffer
  70014. * @returns true if the loader can load the specified file
  70015. */
  70016. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70017. /**
  70018. * Transform the url before loading if required.
  70019. * @param rootUrl the url of the texture
  70020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70021. * @returns the transformed texture
  70022. */
  70023. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70024. /**
  70025. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70026. * @param rootUrl the url of the texture
  70027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70028. * @returns the fallback texture
  70029. */
  70030. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70031. /**
  70032. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70033. * @param data contains the texture data
  70034. * @param texture defines the BabylonJS internal texture
  70035. * @param createPolynomials will be true if polynomials have been requested
  70036. * @param onLoad defines the callback to trigger once the texture is ready
  70037. * @param onError defines the callback to trigger in case of error
  70038. */
  70039. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70040. /**
  70041. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70042. * @param data contains the texture data
  70043. * @param texture defines the BabylonJS internal texture
  70044. * @param callback defines the method to call once ready to upload
  70045. */
  70046. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70047. }
  70048. }
  70049. declare module BABYLON {
  70050. /**
  70051. * Class used to store and describe the pipeline context associated with an effect
  70052. */
  70053. export interface IPipelineContext {
  70054. /**
  70055. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70056. */
  70057. isAsync: boolean;
  70058. /**
  70059. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70060. */
  70061. isReady: boolean;
  70062. /** @hidden */
  70063. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70064. }
  70065. }
  70066. declare module BABYLON {
  70067. /**
  70068. * Class used to store gfx data (like WebGLBuffer)
  70069. */
  70070. export class DataBuffer {
  70071. /**
  70072. * Gets or sets the number of objects referencing this buffer
  70073. */
  70074. references: number;
  70075. /** Gets or sets the size of the underlying buffer */
  70076. capacity: number;
  70077. /**
  70078. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  70079. */
  70080. is32Bits: boolean;
  70081. /**
  70082. * Gets the underlying buffer
  70083. */
  70084. readonly underlyingResource: any;
  70085. }
  70086. }
  70087. declare module BABYLON {
  70088. /** @hidden */
  70089. export interface IShaderProcessor {
  70090. attributeProcessor?: (attribute: string) => string;
  70091. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70092. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70093. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70094. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70095. lineProcessor?: (line: string, isFragment: boolean) => string;
  70096. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70097. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70098. }
  70099. }
  70100. declare module BABYLON {
  70101. /** @hidden */
  70102. export interface ProcessingOptions {
  70103. defines: string[];
  70104. indexParameters: any;
  70105. isFragment: boolean;
  70106. shouldUseHighPrecisionShader: boolean;
  70107. supportsUniformBuffers: boolean;
  70108. shadersRepository: string;
  70109. includesShadersStore: {
  70110. [key: string]: string;
  70111. };
  70112. processor?: IShaderProcessor;
  70113. version: string;
  70114. platformName: string;
  70115. lookForClosingBracketForUniformBuffer?: boolean;
  70116. }
  70117. }
  70118. declare module BABYLON {
  70119. /** @hidden */
  70120. export class ShaderCodeNode {
  70121. line: string;
  70122. children: ShaderCodeNode[];
  70123. additionalDefineKey?: string;
  70124. additionalDefineValue?: string;
  70125. isValid(preprocessors: {
  70126. [key: string]: string;
  70127. }): boolean;
  70128. process(preprocessors: {
  70129. [key: string]: string;
  70130. }, options: ProcessingOptions): string;
  70131. }
  70132. }
  70133. declare module BABYLON {
  70134. /** @hidden */
  70135. export class ShaderCodeCursor {
  70136. private _lines;
  70137. lineIndex: number;
  70138. readonly currentLine: string;
  70139. readonly canRead: boolean;
  70140. lines: string[];
  70141. }
  70142. }
  70143. declare module BABYLON {
  70144. /** @hidden */
  70145. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70146. process(preprocessors: {
  70147. [key: string]: string;
  70148. }, options: ProcessingOptions): string;
  70149. }
  70150. }
  70151. declare module BABYLON {
  70152. /** @hidden */
  70153. export class ShaderDefineExpression {
  70154. isTrue(preprocessors: {
  70155. [key: string]: string;
  70156. }): boolean;
  70157. }
  70158. }
  70159. declare module BABYLON {
  70160. /** @hidden */
  70161. export class ShaderCodeTestNode extends ShaderCodeNode {
  70162. testExpression: ShaderDefineExpression;
  70163. isValid(preprocessors: {
  70164. [key: string]: string;
  70165. }): boolean;
  70166. }
  70167. }
  70168. declare module BABYLON {
  70169. /** @hidden */
  70170. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70171. define: string;
  70172. not: boolean;
  70173. constructor(define: string, not?: boolean);
  70174. isTrue(preprocessors: {
  70175. [key: string]: string;
  70176. }): boolean;
  70177. }
  70178. }
  70179. declare module BABYLON {
  70180. /** @hidden */
  70181. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70182. leftOperand: ShaderDefineExpression;
  70183. rightOperand: ShaderDefineExpression;
  70184. isTrue(preprocessors: {
  70185. [key: string]: string;
  70186. }): boolean;
  70187. }
  70188. }
  70189. declare module BABYLON {
  70190. /** @hidden */
  70191. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70192. leftOperand: ShaderDefineExpression;
  70193. rightOperand: ShaderDefineExpression;
  70194. isTrue(preprocessors: {
  70195. [key: string]: string;
  70196. }): boolean;
  70197. }
  70198. }
  70199. declare module BABYLON {
  70200. /** @hidden */
  70201. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70202. define: string;
  70203. operand: string;
  70204. testValue: string;
  70205. constructor(define: string, operand: string, testValue: string);
  70206. isTrue(preprocessors: {
  70207. [key: string]: string;
  70208. }): boolean;
  70209. }
  70210. }
  70211. declare module BABYLON {
  70212. /**
  70213. * Class used to enable access to offline support
  70214. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70215. */
  70216. export interface IOfflineProvider {
  70217. /**
  70218. * Gets a boolean indicating if scene must be saved in the database
  70219. */
  70220. enableSceneOffline: boolean;
  70221. /**
  70222. * Gets a boolean indicating if textures must be saved in the database
  70223. */
  70224. enableTexturesOffline: boolean;
  70225. /**
  70226. * Open the offline support and make it available
  70227. * @param successCallback defines the callback to call on success
  70228. * @param errorCallback defines the callback to call on error
  70229. */
  70230. open(successCallback: () => void, errorCallback: () => void): void;
  70231. /**
  70232. * Loads an image from the offline support
  70233. * @param url defines the url to load from
  70234. * @param image defines the target DOM image
  70235. */
  70236. loadImage(url: string, image: HTMLImageElement): void;
  70237. /**
  70238. * Loads a file from offline support
  70239. * @param url defines the URL to load from
  70240. * @param sceneLoaded defines a callback to call on success
  70241. * @param progressCallBack defines a callback to call when progress changed
  70242. * @param errorCallback defines a callback to call on error
  70243. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70244. */
  70245. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70246. }
  70247. }
  70248. declare module BABYLON {
  70249. /**
  70250. * Class used to help managing file picking and drag'n'drop
  70251. * File Storage
  70252. */
  70253. export class FilesInputStore {
  70254. /**
  70255. * List of files ready to be loaded
  70256. */
  70257. static FilesToLoad: {
  70258. [key: string]: File;
  70259. };
  70260. }
  70261. }
  70262. declare module BABYLON {
  70263. /**
  70264. * Class used to define a retry strategy when error happens while loading assets
  70265. */
  70266. export class RetryStrategy {
  70267. /**
  70268. * Function used to defines an exponential back off strategy
  70269. * @param maxRetries defines the maximum number of retries (3 by default)
  70270. * @param baseInterval defines the interval between retries
  70271. * @returns the strategy function to use
  70272. */
  70273. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70274. }
  70275. }
  70276. declare module BABYLON {
  70277. /**
  70278. * @ignore
  70279. * Application error to support additional information when loading a file
  70280. */
  70281. export abstract class BaseError extends Error {
  70282. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  70283. }
  70284. }
  70285. declare module BABYLON {
  70286. /** @ignore */
  70287. export class LoadFileError extends BaseError {
  70288. request?: WebRequest;
  70289. file?: File;
  70290. /**
  70291. * Creates a new LoadFileError
  70292. * @param message defines the message of the error
  70293. * @param request defines the optional web request
  70294. * @param file defines the optional file
  70295. */
  70296. constructor(message: string, object?: WebRequest | File);
  70297. }
  70298. /** @ignore */
  70299. export class RequestFileError extends BaseError {
  70300. request: WebRequest;
  70301. /**
  70302. * Creates a new LoadFileError
  70303. * @param message defines the message of the error
  70304. * @param request defines the optional web request
  70305. */
  70306. constructor(message: string, request: WebRequest);
  70307. }
  70308. /** @ignore */
  70309. export class ReadFileError extends BaseError {
  70310. file: File;
  70311. /**
  70312. * Creates a new ReadFileError
  70313. * @param message defines the message of the error
  70314. * @param file defines the optional file
  70315. */
  70316. constructor(message: string, file: File);
  70317. }
  70318. /**
  70319. * @hidden
  70320. */
  70321. export class FileTools {
  70322. /**
  70323. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70324. */
  70325. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70326. /**
  70327. * Gets or sets the base URL to use to load assets
  70328. */
  70329. static BaseUrl: string;
  70330. /**
  70331. * Default behaviour for cors in the application.
  70332. * It can be a string if the expected behavior is identical in the entire app.
  70333. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70334. */
  70335. static CorsBehavior: string | ((url: string | string[]) => string);
  70336. /**
  70337. * Gets or sets a function used to pre-process url before using them to load assets
  70338. */
  70339. static PreprocessUrl: (url: string) => string;
  70340. /**
  70341. * Removes unwanted characters from an url
  70342. * @param url defines the url to clean
  70343. * @returns the cleaned url
  70344. */
  70345. private static _CleanUrl;
  70346. /**
  70347. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70348. * @param url define the url we are trying
  70349. * @param element define the dom element where to configure the cors policy
  70350. */
  70351. static SetCorsBehavior(url: string | string[], element: {
  70352. crossOrigin: string | null;
  70353. }): void;
  70354. /**
  70355. * Loads an image as an HTMLImageElement.
  70356. * @param input url string, ArrayBuffer, or Blob to load
  70357. * @param onLoad callback called when the image successfully loads
  70358. * @param onError callback called when the image fails to load
  70359. * @param offlineProvider offline provider for caching
  70360. * @param mimeType optional mime type
  70361. * @returns the HTMLImageElement of the loaded image
  70362. */
  70363. 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>;
  70364. /**
  70365. * Reads a file from a File object
  70366. * @param file defines the file to load
  70367. * @param onSuccess defines the callback to call when data is loaded
  70368. * @param onProgress defines the callback to call during loading process
  70369. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70370. * @param onError defines the callback to call when an error occurs
  70371. * @returns a file request object
  70372. */
  70373. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  70374. /**
  70375. * Loads a file from a url
  70376. * @param url url to load
  70377. * @param onSuccess callback called when the file successfully loads
  70378. * @param onProgress callback called while file is loading (if the server supports this mode)
  70379. * @param offlineProvider defines the offline provider for caching
  70380. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70381. * @param onError callback called when the file fails to load
  70382. * @returns a file request object
  70383. */
  70384. 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;
  70385. /**
  70386. * Loads a file
  70387. * @param url url to load
  70388. * @param onSuccess callback called when the file successfully loads
  70389. * @param onProgress callback called while file is loading (if the server supports this mode)
  70390. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70391. * @param onError callback called when the file fails to load
  70392. * @param onOpened callback called when the web request is opened
  70393. * @returns a file request object
  70394. */
  70395. 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;
  70396. /**
  70397. * Checks if the loaded document was accessed via `file:`-Protocol.
  70398. * @returns boolean
  70399. */
  70400. static IsFileURL(): boolean;
  70401. }
  70402. }
  70403. declare module BABYLON {
  70404. /** @hidden */
  70405. export class ShaderProcessor {
  70406. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70407. private static _ProcessPrecision;
  70408. private static _ExtractOperation;
  70409. private static _BuildSubExpression;
  70410. private static _BuildExpression;
  70411. private static _MoveCursorWithinIf;
  70412. private static _MoveCursor;
  70413. private static _EvaluatePreProcessors;
  70414. private static _PreparePreProcessors;
  70415. private static _ProcessShaderConversion;
  70416. private static _ProcessIncludes;
  70417. }
  70418. }
  70419. declare module BABYLON {
  70420. /**
  70421. * @hidden
  70422. */
  70423. export interface IColor4Like {
  70424. r: float;
  70425. g: float;
  70426. b: float;
  70427. a: float;
  70428. }
  70429. /**
  70430. * @hidden
  70431. */
  70432. export interface IColor3Like {
  70433. r: float;
  70434. g: float;
  70435. b: float;
  70436. }
  70437. /**
  70438. * @hidden
  70439. */
  70440. export interface IVector4Like {
  70441. x: float;
  70442. y: float;
  70443. z: float;
  70444. w: float;
  70445. }
  70446. /**
  70447. * @hidden
  70448. */
  70449. export interface IVector3Like {
  70450. x: float;
  70451. y: float;
  70452. z: float;
  70453. }
  70454. /**
  70455. * @hidden
  70456. */
  70457. export interface IVector2Like {
  70458. x: float;
  70459. y: float;
  70460. }
  70461. /**
  70462. * @hidden
  70463. */
  70464. export interface IMatrixLike {
  70465. toArray(): DeepImmutable<Float32Array>;
  70466. updateFlag: int;
  70467. }
  70468. /**
  70469. * @hidden
  70470. */
  70471. export interface IViewportLike {
  70472. x: float;
  70473. y: float;
  70474. width: float;
  70475. height: float;
  70476. }
  70477. /**
  70478. * @hidden
  70479. */
  70480. export interface IPlaneLike {
  70481. normal: IVector3Like;
  70482. d: float;
  70483. normalize(): void;
  70484. }
  70485. }
  70486. declare module BABYLON {
  70487. /**
  70488. * Interface used to define common properties for effect fallbacks
  70489. */
  70490. export interface IEffectFallbacks {
  70491. /**
  70492. * Removes the defines that should be removed when falling back.
  70493. * @param currentDefines defines the current define statements for the shader.
  70494. * @param effect defines the current effect we try to compile
  70495. * @returns The resulting defines with defines of the current rank removed.
  70496. */
  70497. reduce(currentDefines: string, effect: Effect): string;
  70498. /**
  70499. * Removes the fallback from the bound mesh.
  70500. */
  70501. unBindMesh(): void;
  70502. /**
  70503. * Checks to see if more fallbacks are still availible.
  70504. */
  70505. hasMoreFallbacks: boolean;
  70506. }
  70507. }
  70508. declare module BABYLON {
  70509. /**
  70510. * Class used to evalaute queries containing `and` and `or` operators
  70511. */
  70512. export class AndOrNotEvaluator {
  70513. /**
  70514. * Evaluate a query
  70515. * @param query defines the query to evaluate
  70516. * @param evaluateCallback defines the callback used to filter result
  70517. * @returns true if the query matches
  70518. */
  70519. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70520. private static _HandleParenthesisContent;
  70521. private static _SimplifyNegation;
  70522. }
  70523. }
  70524. declare module BABYLON {
  70525. /**
  70526. * Class used to store custom tags
  70527. */
  70528. export class Tags {
  70529. /**
  70530. * Adds support for tags on the given object
  70531. * @param obj defines the object to use
  70532. */
  70533. static EnableFor(obj: any): void;
  70534. /**
  70535. * Removes tags support
  70536. * @param obj defines the object to use
  70537. */
  70538. static DisableFor(obj: any): void;
  70539. /**
  70540. * Gets a boolean indicating if the given object has tags
  70541. * @param obj defines the object to use
  70542. * @returns a boolean
  70543. */
  70544. static HasTags(obj: any): boolean;
  70545. /**
  70546. * Gets the tags available on a given object
  70547. * @param obj defines the object to use
  70548. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70549. * @returns the tags
  70550. */
  70551. static GetTags(obj: any, asString?: boolean): any;
  70552. /**
  70553. * Adds tags to an object
  70554. * @param obj defines the object to use
  70555. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70556. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70557. */
  70558. static AddTagsTo(obj: any, tagsString: string): void;
  70559. /**
  70560. * @hidden
  70561. */
  70562. static _AddTagTo(obj: any, tag: string): void;
  70563. /**
  70564. * Removes specific tags from a specific object
  70565. * @param obj defines the object to use
  70566. * @param tagsString defines the tags to remove
  70567. */
  70568. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70569. /**
  70570. * @hidden
  70571. */
  70572. static _RemoveTagFrom(obj: any, tag: string): void;
  70573. /**
  70574. * Defines if tags hosted on an object match a given query
  70575. * @param obj defines the object to use
  70576. * @param tagsQuery defines the tag query
  70577. * @returns a boolean
  70578. */
  70579. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70580. }
  70581. }
  70582. declare module BABYLON {
  70583. /**
  70584. * Scalar computation library
  70585. */
  70586. export class Scalar {
  70587. /**
  70588. * Two pi constants convenient for computation.
  70589. */
  70590. static TwoPi: number;
  70591. /**
  70592. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70593. * @param a number
  70594. * @param b number
  70595. * @param epsilon (default = 1.401298E-45)
  70596. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70597. */
  70598. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  70599. /**
  70600. * Returns a string : the upper case translation of the number i to hexadecimal.
  70601. * @param i number
  70602. * @returns the upper case translation of the number i to hexadecimal.
  70603. */
  70604. static ToHex(i: number): string;
  70605. /**
  70606. * Returns -1 if value is negative and +1 is value is positive.
  70607. * @param value the value
  70608. * @returns the value itself if it's equal to zero.
  70609. */
  70610. static Sign(value: number): number;
  70611. /**
  70612. * Returns the value itself if it's between min and max.
  70613. * Returns min if the value is lower than min.
  70614. * Returns max if the value is greater than max.
  70615. * @param value the value to clmap
  70616. * @param min the min value to clamp to (default: 0)
  70617. * @param max the max value to clamp to (default: 1)
  70618. * @returns the clamped value
  70619. */
  70620. static Clamp(value: number, min?: number, max?: number): number;
  70621. /**
  70622. * the log2 of value.
  70623. * @param value the value to compute log2 of
  70624. * @returns the log2 of value.
  70625. */
  70626. static Log2(value: number): number;
  70627. /**
  70628. * Loops the value, so that it is never larger than length and never smaller than 0.
  70629. *
  70630. * This is similar to the modulo operator but it works with floating point numbers.
  70631. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70632. * With t = 5 and length = 2.5, the result would be 0.0.
  70633. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70634. * @param value the value
  70635. * @param length the length
  70636. * @returns the looped value
  70637. */
  70638. static Repeat(value: number, length: number): number;
  70639. /**
  70640. * Normalize the value between 0.0 and 1.0 using min and max values
  70641. * @param value value to normalize
  70642. * @param min max to normalize between
  70643. * @param max min to normalize between
  70644. * @returns the normalized value
  70645. */
  70646. static Normalize(value: number, min: number, max: number): number;
  70647. /**
  70648. * Denormalize the value from 0.0 and 1.0 using min and max values
  70649. * @param normalized value to denormalize
  70650. * @param min max to denormalize between
  70651. * @param max min to denormalize between
  70652. * @returns the denormalized value
  70653. */
  70654. static Denormalize(normalized: number, min: number, max: number): number;
  70655. /**
  70656. * Calculates the shortest difference between two given angles given in degrees.
  70657. * @param current current angle in degrees
  70658. * @param target target angle in degrees
  70659. * @returns the delta
  70660. */
  70661. static DeltaAngle(current: number, target: number): number;
  70662. /**
  70663. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70664. * @param tx value
  70665. * @param length length
  70666. * @returns The returned value will move back and forth between 0 and length
  70667. */
  70668. static PingPong(tx: number, length: number): number;
  70669. /**
  70670. * Interpolates between min and max with smoothing at the limits.
  70671. *
  70672. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70673. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70674. * @param from from
  70675. * @param to to
  70676. * @param tx value
  70677. * @returns the smooth stepped value
  70678. */
  70679. static SmoothStep(from: number, to: number, tx: number): number;
  70680. /**
  70681. * Moves a value current towards target.
  70682. *
  70683. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70684. * Negative values of maxDelta pushes the value away from target.
  70685. * @param current current value
  70686. * @param target target value
  70687. * @param maxDelta max distance to move
  70688. * @returns resulting value
  70689. */
  70690. static MoveTowards(current: number, target: number, maxDelta: number): number;
  70691. /**
  70692. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70693. *
  70694. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70695. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70696. * @param current current value
  70697. * @param target target value
  70698. * @param maxDelta max distance to move
  70699. * @returns resulting angle
  70700. */
  70701. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  70702. /**
  70703. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70704. * @param start start value
  70705. * @param end target value
  70706. * @param amount amount to lerp between
  70707. * @returns the lerped value
  70708. */
  70709. static Lerp(start: number, end: number, amount: number): number;
  70710. /**
  70711. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70712. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70713. * @param start start value
  70714. * @param end target value
  70715. * @param amount amount to lerp between
  70716. * @returns the lerped value
  70717. */
  70718. static LerpAngle(start: number, end: number, amount: number): number;
  70719. /**
  70720. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70721. * @param a start value
  70722. * @param b target value
  70723. * @param value value between a and b
  70724. * @returns the inverseLerp value
  70725. */
  70726. static InverseLerp(a: number, b: number, value: number): number;
  70727. /**
  70728. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70729. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70730. * @param value1 spline value
  70731. * @param tangent1 spline value
  70732. * @param value2 spline value
  70733. * @param tangent2 spline value
  70734. * @param amount input value
  70735. * @returns hermite result
  70736. */
  70737. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  70738. /**
  70739. * Returns a random float number between and min and max values
  70740. * @param min min value of random
  70741. * @param max max value of random
  70742. * @returns random value
  70743. */
  70744. static RandomRange(min: number, max: number): number;
  70745. /**
  70746. * This function returns percentage of a number in a given range.
  70747. *
  70748. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70749. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70750. * @param number to convert to percentage
  70751. * @param min min range
  70752. * @param max max range
  70753. * @returns the percentage
  70754. */
  70755. static RangeToPercent(number: number, min: number, max: number): number;
  70756. /**
  70757. * This function returns number that corresponds to the percentage in a given range.
  70758. *
  70759. * PercentToRange(0.34,0,100) will return 34.
  70760. * @param percent to convert to number
  70761. * @param min min range
  70762. * @param max max range
  70763. * @returns the number
  70764. */
  70765. static PercentToRange(percent: number, min: number, max: number): number;
  70766. /**
  70767. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70768. * @param angle The angle to normalize in radian.
  70769. * @return The converted angle.
  70770. */
  70771. static NormalizeRadians(angle: number): number;
  70772. }
  70773. }
  70774. declare module BABYLON {
  70775. /**
  70776. * Constant used to convert a value to gamma space
  70777. * @ignorenaming
  70778. */
  70779. export const ToGammaSpace: number;
  70780. /**
  70781. * Constant used to convert a value to linear space
  70782. * @ignorenaming
  70783. */
  70784. export const ToLinearSpace = 2.2;
  70785. /**
  70786. * Constant used to define the minimal number value in Babylon.js
  70787. * @ignorenaming
  70788. */
  70789. let Epsilon: number;
  70790. }
  70791. declare module BABYLON {
  70792. /**
  70793. * Class used to represent a viewport on screen
  70794. */
  70795. export class Viewport {
  70796. /** viewport left coordinate */
  70797. x: number;
  70798. /** viewport top coordinate */
  70799. y: number;
  70800. /**viewport width */
  70801. width: number;
  70802. /** viewport height */
  70803. height: number;
  70804. /**
  70805. * Creates a Viewport object located at (x, y) and sized (width, height)
  70806. * @param x defines viewport left coordinate
  70807. * @param y defines viewport top coordinate
  70808. * @param width defines the viewport width
  70809. * @param height defines the viewport height
  70810. */
  70811. constructor(
  70812. /** viewport left coordinate */
  70813. x: number,
  70814. /** viewport top coordinate */
  70815. y: number,
  70816. /**viewport width */
  70817. width: number,
  70818. /** viewport height */
  70819. height: number);
  70820. /**
  70821. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70822. * @param renderWidth defines the rendering width
  70823. * @param renderHeight defines the rendering height
  70824. * @returns a new Viewport
  70825. */
  70826. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70827. /**
  70828. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70829. * @param renderWidth defines the rendering width
  70830. * @param renderHeight defines the rendering height
  70831. * @param ref defines the target viewport
  70832. * @returns the current viewport
  70833. */
  70834. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70835. /**
  70836. * Returns a new Viewport copied from the current one
  70837. * @returns a new Viewport
  70838. */
  70839. clone(): Viewport;
  70840. }
  70841. }
  70842. declare module BABYLON {
  70843. /**
  70844. * Class containing a set of static utilities functions for arrays.
  70845. */
  70846. export class ArrayTools {
  70847. /**
  70848. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70849. * @param size the number of element to construct and put in the array
  70850. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70851. * @returns a new array filled with new objects
  70852. */
  70853. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70854. }
  70855. }
  70856. declare module BABYLON {
  70857. /**
  70858. * Class representing a vector containing 2 coordinates
  70859. */
  70860. export class Vector2 {
  70861. /** defines the first coordinate */
  70862. x: number;
  70863. /** defines the second coordinate */
  70864. y: number;
  70865. /**
  70866. * Creates a new Vector2 from the given x and y coordinates
  70867. * @param x defines the first coordinate
  70868. * @param y defines the second coordinate
  70869. */
  70870. constructor(
  70871. /** defines the first coordinate */
  70872. x?: number,
  70873. /** defines the second coordinate */
  70874. y?: number);
  70875. /**
  70876. * Gets a string with the Vector2 coordinates
  70877. * @returns a string with the Vector2 coordinates
  70878. */
  70879. toString(): string;
  70880. /**
  70881. * Gets class name
  70882. * @returns the string "Vector2"
  70883. */
  70884. getClassName(): string;
  70885. /**
  70886. * Gets current vector hash code
  70887. * @returns the Vector2 hash code as a number
  70888. */
  70889. getHashCode(): number;
  70890. /**
  70891. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70892. * @param array defines the source array
  70893. * @param index defines the offset in source array
  70894. * @returns the current Vector2
  70895. */
  70896. toArray(array: FloatArray, index?: number): Vector2;
  70897. /**
  70898. * Copy the current vector to an array
  70899. * @returns a new array with 2 elements: the Vector2 coordinates.
  70900. */
  70901. asArray(): number[];
  70902. /**
  70903. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70904. * @param source defines the source Vector2
  70905. * @returns the current updated Vector2
  70906. */
  70907. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70908. /**
  70909. * Sets the Vector2 coordinates with the given floats
  70910. * @param x defines the first coordinate
  70911. * @param y defines the second coordinate
  70912. * @returns the current updated Vector2
  70913. */
  70914. copyFromFloats(x: number, y: number): Vector2;
  70915. /**
  70916. * Sets the Vector2 coordinates with the given floats
  70917. * @param x defines the first coordinate
  70918. * @param y defines the second coordinate
  70919. * @returns the current updated Vector2
  70920. */
  70921. set(x: number, y: number): Vector2;
  70922. /**
  70923. * Add another vector with the current one
  70924. * @param otherVector defines the other vector
  70925. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70926. */
  70927. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70928. /**
  70929. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70930. * @param otherVector defines the other vector
  70931. * @param result defines the target vector
  70932. * @returns the unmodified current Vector2
  70933. */
  70934. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70935. /**
  70936. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70937. * @param otherVector defines the other vector
  70938. * @returns the current updated Vector2
  70939. */
  70940. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70941. /**
  70942. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70943. * @param otherVector defines the other vector
  70944. * @returns a new Vector2
  70945. */
  70946. addVector3(otherVector: Vector3): Vector2;
  70947. /**
  70948. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70949. * @param otherVector defines the other vector
  70950. * @returns a new Vector2
  70951. */
  70952. subtract(otherVector: Vector2): Vector2;
  70953. /**
  70954. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70955. * @param otherVector defines the other vector
  70956. * @param result defines the target vector
  70957. * @returns the unmodified current Vector2
  70958. */
  70959. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70960. /**
  70961. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70962. * @param otherVector defines the other vector
  70963. * @returns the current updated Vector2
  70964. */
  70965. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70966. /**
  70967. * Multiplies in place the current Vector2 coordinates by the given ones
  70968. * @param otherVector defines the other vector
  70969. * @returns the current updated Vector2
  70970. */
  70971. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70972. /**
  70973. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70974. * @param otherVector defines the other vector
  70975. * @returns a new Vector2
  70976. */
  70977. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70978. /**
  70979. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70980. * @param otherVector defines the other vector
  70981. * @param result defines the target vector
  70982. * @returns the unmodified current Vector2
  70983. */
  70984. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70985. /**
  70986. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70987. * @param x defines the first coordinate
  70988. * @param y defines the second coordinate
  70989. * @returns a new Vector2
  70990. */
  70991. multiplyByFloats(x: number, y: number): Vector2;
  70992. /**
  70993. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70994. * @param otherVector defines the other vector
  70995. * @returns a new Vector2
  70996. */
  70997. divide(otherVector: Vector2): Vector2;
  70998. /**
  70999. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  71000. * @param otherVector defines the other vector
  71001. * @param result defines the target vector
  71002. * @returns the unmodified current Vector2
  71003. */
  71004. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71005. /**
  71006. * Divides the current Vector2 coordinates by the given ones
  71007. * @param otherVector defines the other vector
  71008. * @returns the current updated Vector2
  71009. */
  71010. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71011. /**
  71012. * Gets a new Vector2 with current Vector2 negated coordinates
  71013. * @returns a new Vector2
  71014. */
  71015. negate(): Vector2;
  71016. /**
  71017. * Multiply the Vector2 coordinates by scale
  71018. * @param scale defines the scaling factor
  71019. * @returns the current updated Vector2
  71020. */
  71021. scaleInPlace(scale: number): Vector2;
  71022. /**
  71023. * Returns a new Vector2 scaled by "scale" from the current Vector2
  71024. * @param scale defines the scaling factor
  71025. * @returns a new Vector2
  71026. */
  71027. scale(scale: number): Vector2;
  71028. /**
  71029. * Scale the current Vector2 values by a factor to a given Vector2
  71030. * @param scale defines the scale factor
  71031. * @param result defines the Vector2 object where to store the result
  71032. * @returns the unmodified current Vector2
  71033. */
  71034. scaleToRef(scale: number, result: Vector2): Vector2;
  71035. /**
  71036. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  71037. * @param scale defines the scale factor
  71038. * @param result defines the Vector2 object where to store the result
  71039. * @returns the unmodified current Vector2
  71040. */
  71041. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  71042. /**
  71043. * Gets a boolean if two vectors are equals
  71044. * @param otherVector defines the other vector
  71045. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  71046. */
  71047. equals(otherVector: DeepImmutable<Vector2>): boolean;
  71048. /**
  71049. * Gets a boolean if two vectors are equals (using an epsilon value)
  71050. * @param otherVector defines the other vector
  71051. * @param epsilon defines the minimal distance to consider equality
  71052. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  71053. */
  71054. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  71055. /**
  71056. * Gets a new Vector2 from current Vector2 floored values
  71057. * @returns a new Vector2
  71058. */
  71059. floor(): Vector2;
  71060. /**
  71061. * Gets a new Vector2 from current Vector2 floored values
  71062. * @returns a new Vector2
  71063. */
  71064. fract(): Vector2;
  71065. /**
  71066. * Gets the length of the vector
  71067. * @returns the vector length (float)
  71068. */
  71069. length(): number;
  71070. /**
  71071. * Gets the vector squared length
  71072. * @returns the vector squared length (float)
  71073. */
  71074. lengthSquared(): number;
  71075. /**
  71076. * Normalize the vector
  71077. * @returns the current updated Vector2
  71078. */
  71079. normalize(): Vector2;
  71080. /**
  71081. * Gets a new Vector2 copied from the Vector2
  71082. * @returns a new Vector2
  71083. */
  71084. clone(): Vector2;
  71085. /**
  71086. * Gets a new Vector2(0, 0)
  71087. * @returns a new Vector2
  71088. */
  71089. static Zero(): Vector2;
  71090. /**
  71091. * Gets a new Vector2(1, 1)
  71092. * @returns a new Vector2
  71093. */
  71094. static One(): Vector2;
  71095. /**
  71096. * Gets a new Vector2 set from the given index element of the given array
  71097. * @param array defines the data source
  71098. * @param offset defines the offset in the data source
  71099. * @returns a new Vector2
  71100. */
  71101. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  71102. /**
  71103. * Sets "result" from the given index element of the given array
  71104. * @param array defines the data source
  71105. * @param offset defines the offset in the data source
  71106. * @param result defines the target vector
  71107. */
  71108. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  71109. /**
  71110. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  71111. * @param value1 defines 1st point of control
  71112. * @param value2 defines 2nd point of control
  71113. * @param value3 defines 3rd point of control
  71114. * @param value4 defines 4th point of control
  71115. * @param amount defines the interpolation factor
  71116. * @returns a new Vector2
  71117. */
  71118. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  71119. /**
  71120. * 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".
  71121. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  71122. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  71123. * @param value defines the value to clamp
  71124. * @param min defines the lower limit
  71125. * @param max defines the upper limit
  71126. * @returns a new Vector2
  71127. */
  71128. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  71129. /**
  71130. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  71131. * @param value1 defines the 1st control point
  71132. * @param tangent1 defines the outgoing tangent
  71133. * @param value2 defines the 2nd control point
  71134. * @param tangent2 defines the incoming tangent
  71135. * @param amount defines the interpolation factor
  71136. * @returns a new Vector2
  71137. */
  71138. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  71139. /**
  71140. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  71141. * @param start defines the start vector
  71142. * @param end defines the end vector
  71143. * @param amount defines the interpolation factor
  71144. * @returns a new Vector2
  71145. */
  71146. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  71147. /**
  71148. * Gets the dot product of the vector "left" and the vector "right"
  71149. * @param left defines first vector
  71150. * @param right defines second vector
  71151. * @returns the dot product (float)
  71152. */
  71153. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  71154. /**
  71155. * Returns a new Vector2 equal to the normalized given vector
  71156. * @param vector defines the vector to normalize
  71157. * @returns a new Vector2
  71158. */
  71159. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  71160. /**
  71161. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  71162. * @param left defines 1st vector
  71163. * @param right defines 2nd vector
  71164. * @returns a new Vector2
  71165. */
  71166. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71167. /**
  71168. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  71169. * @param left defines 1st vector
  71170. * @param right defines 2nd vector
  71171. * @returns a new Vector2
  71172. */
  71173. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71174. /**
  71175. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  71176. * @param vector defines the vector to transform
  71177. * @param transformation defines the matrix to apply
  71178. * @returns a new Vector2
  71179. */
  71180. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  71181. /**
  71182. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  71183. * @param vector defines the vector to transform
  71184. * @param transformation defines the matrix to apply
  71185. * @param result defines the target vector
  71186. */
  71187. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  71188. /**
  71189. * Determines if a given vector is included in a triangle
  71190. * @param p defines the vector to test
  71191. * @param p0 defines 1st triangle point
  71192. * @param p1 defines 2nd triangle point
  71193. * @param p2 defines 3rd triangle point
  71194. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71195. */
  71196. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  71197. /**
  71198. * Gets the distance between the vectors "value1" and "value2"
  71199. * @param value1 defines first vector
  71200. * @param value2 defines second vector
  71201. * @returns the distance between vectors
  71202. */
  71203. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71204. /**
  71205. * Returns the squared distance between the vectors "value1" and "value2"
  71206. * @param value1 defines first vector
  71207. * @param value2 defines second vector
  71208. * @returns the squared distance between vectors
  71209. */
  71210. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71211. /**
  71212. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71213. * @param value1 defines first vector
  71214. * @param value2 defines second vector
  71215. * @returns a new Vector2
  71216. */
  71217. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  71218. /**
  71219. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71220. * @param p defines the middle point
  71221. * @param segA defines one point of the segment
  71222. * @param segB defines the other point of the segment
  71223. * @returns the shortest distance
  71224. */
  71225. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  71226. }
  71227. /**
  71228. * Class used to store (x,y,z) vector representation
  71229. * A Vector3 is the main object used in 3D geometry
  71230. * It can represent etiher the coordinates of a point the space, either a direction
  71231. * Reminder: js uses a left handed forward facing system
  71232. */
  71233. export class Vector3 {
  71234. /**
  71235. * Defines the first coordinates (on X axis)
  71236. */
  71237. x: number;
  71238. /**
  71239. * Defines the second coordinates (on Y axis)
  71240. */
  71241. y: number;
  71242. /**
  71243. * Defines the third coordinates (on Z axis)
  71244. */
  71245. z: number;
  71246. private static _UpReadOnly;
  71247. private static _ZeroReadOnly;
  71248. /**
  71249. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71250. * @param x defines the first coordinates (on X axis)
  71251. * @param y defines the second coordinates (on Y axis)
  71252. * @param z defines the third coordinates (on Z axis)
  71253. */
  71254. constructor(
  71255. /**
  71256. * Defines the first coordinates (on X axis)
  71257. */
  71258. x?: number,
  71259. /**
  71260. * Defines the second coordinates (on Y axis)
  71261. */
  71262. y?: number,
  71263. /**
  71264. * Defines the third coordinates (on Z axis)
  71265. */
  71266. z?: number);
  71267. /**
  71268. * Creates a string representation of the Vector3
  71269. * @returns a string with the Vector3 coordinates.
  71270. */
  71271. toString(): string;
  71272. /**
  71273. * Gets the class name
  71274. * @returns the string "Vector3"
  71275. */
  71276. getClassName(): string;
  71277. /**
  71278. * Creates the Vector3 hash code
  71279. * @returns a number which tends to be unique between Vector3 instances
  71280. */
  71281. getHashCode(): number;
  71282. /**
  71283. * Creates an array containing three elements : the coordinates of the Vector3
  71284. * @returns a new array of numbers
  71285. */
  71286. asArray(): number[];
  71287. /**
  71288. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  71289. * @param array defines the destination array
  71290. * @param index defines the offset in the destination array
  71291. * @returns the current Vector3
  71292. */
  71293. toArray(array: FloatArray, index?: number): Vector3;
  71294. /**
  71295. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  71296. * @returns a new Quaternion object, computed from the Vector3 coordinates
  71297. */
  71298. toQuaternion(): Quaternion;
  71299. /**
  71300. * Adds the given vector to the current Vector3
  71301. * @param otherVector defines the second operand
  71302. * @returns the current updated Vector3
  71303. */
  71304. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71305. /**
  71306. * Adds the given coordinates to the current Vector3
  71307. * @param x defines the x coordinate of the operand
  71308. * @param y defines the y coordinate of the operand
  71309. * @param z defines the z coordinate of the operand
  71310. * @returns the current updated Vector3
  71311. */
  71312. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71313. /**
  71314. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71315. * @param otherVector defines the second operand
  71316. * @returns the resulting Vector3
  71317. */
  71318. add(otherVector: DeepImmutable<Vector3>): Vector3;
  71319. /**
  71320. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71321. * @param otherVector defines the second operand
  71322. * @param result defines the Vector3 object where to store the result
  71323. * @returns the current Vector3
  71324. */
  71325. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71326. /**
  71327. * Subtract the given vector from the current Vector3
  71328. * @param otherVector defines the second operand
  71329. * @returns the current updated Vector3
  71330. */
  71331. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71332. /**
  71333. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71334. * @param otherVector defines the second operand
  71335. * @returns the resulting Vector3
  71336. */
  71337. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  71338. /**
  71339. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71340. * @param otherVector defines the second operand
  71341. * @param result defines the Vector3 object where to store the result
  71342. * @returns the current Vector3
  71343. */
  71344. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71345. /**
  71346. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71347. * @param x defines the x coordinate of the operand
  71348. * @param y defines the y coordinate of the operand
  71349. * @param z defines the z coordinate of the operand
  71350. * @returns the resulting Vector3
  71351. */
  71352. subtractFromFloats(x: number, y: number, z: number): Vector3;
  71353. /**
  71354. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71355. * @param x defines the x coordinate of the operand
  71356. * @param y defines the y coordinate of the operand
  71357. * @param z defines the z coordinate of the operand
  71358. * @param result defines the Vector3 object where to store the result
  71359. * @returns the current Vector3
  71360. */
  71361. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  71362. /**
  71363. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71364. * @returns a new Vector3
  71365. */
  71366. negate(): Vector3;
  71367. /**
  71368. * Multiplies the Vector3 coordinates by the float "scale"
  71369. * @param scale defines the multiplier factor
  71370. * @returns the current updated Vector3
  71371. */
  71372. scaleInPlace(scale: number): Vector3;
  71373. /**
  71374. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71375. * @param scale defines the multiplier factor
  71376. * @returns a new Vector3
  71377. */
  71378. scale(scale: number): Vector3;
  71379. /**
  71380. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71381. * @param scale defines the multiplier factor
  71382. * @param result defines the Vector3 object where to store the result
  71383. * @returns the current Vector3
  71384. */
  71385. scaleToRef(scale: number, result: Vector3): Vector3;
  71386. /**
  71387. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71388. * @param scale defines the scale factor
  71389. * @param result defines the Vector3 object where to store the result
  71390. * @returns the unmodified current Vector3
  71391. */
  71392. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  71393. /**
  71394. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71395. * @param otherVector defines the second operand
  71396. * @returns true if both vectors are equals
  71397. */
  71398. equals(otherVector: DeepImmutable<Vector3>): boolean;
  71399. /**
  71400. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71401. * @param otherVector defines the second operand
  71402. * @param epsilon defines the minimal distance to define values as equals
  71403. * @returns true if both vectors are distant less than epsilon
  71404. */
  71405. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  71406. /**
  71407. * Returns true if the current Vector3 coordinates equals the given floats
  71408. * @param x defines the x coordinate of the operand
  71409. * @param y defines the y coordinate of the operand
  71410. * @param z defines the z coordinate of the operand
  71411. * @returns true if both vectors are equals
  71412. */
  71413. equalsToFloats(x: number, y: number, z: number): boolean;
  71414. /**
  71415. * Multiplies the current Vector3 coordinates by the given ones
  71416. * @param otherVector defines the second operand
  71417. * @returns the current updated Vector3
  71418. */
  71419. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71420. /**
  71421. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71422. * @param otherVector defines the second operand
  71423. * @returns the new Vector3
  71424. */
  71425. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  71426. /**
  71427. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71428. * @param otherVector defines the second operand
  71429. * @param result defines the Vector3 object where to store the result
  71430. * @returns the current Vector3
  71431. */
  71432. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71433. /**
  71434. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71435. * @param x defines the x coordinate of the operand
  71436. * @param y defines the y coordinate of the operand
  71437. * @param z defines the z coordinate of the operand
  71438. * @returns the new Vector3
  71439. */
  71440. multiplyByFloats(x: number, y: number, z: number): Vector3;
  71441. /**
  71442. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71443. * @param otherVector defines the second operand
  71444. * @returns the new Vector3
  71445. */
  71446. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  71447. /**
  71448. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71449. * @param otherVector defines the second operand
  71450. * @param result defines the Vector3 object where to store the result
  71451. * @returns the current Vector3
  71452. */
  71453. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71454. /**
  71455. * Divides the current Vector3 coordinates by the given ones.
  71456. * @param otherVector defines the second operand
  71457. * @returns the current updated Vector3
  71458. */
  71459. divideInPlace(otherVector: Vector3): Vector3;
  71460. /**
  71461. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71462. * @param other defines the second operand
  71463. * @returns the current updated Vector3
  71464. */
  71465. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71466. /**
  71467. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71468. * @param other defines the second operand
  71469. * @returns the current updated Vector3
  71470. */
  71471. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71472. /**
  71473. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71474. * @param x defines the x coordinate of the operand
  71475. * @param y defines the y coordinate of the operand
  71476. * @param z defines the z coordinate of the operand
  71477. * @returns the current updated Vector3
  71478. */
  71479. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71480. /**
  71481. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71482. * @param x defines the x coordinate of the operand
  71483. * @param y defines the y coordinate of the operand
  71484. * @param z defines the z coordinate of the operand
  71485. * @returns the current updated Vector3
  71486. */
  71487. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71488. /**
  71489. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71490. * Check if is non uniform within a certain amount of decimal places to account for this
  71491. * @param epsilon the amount the values can differ
  71492. * @returns if the the vector is non uniform to a certain number of decimal places
  71493. */
  71494. isNonUniformWithinEpsilon(epsilon: number): boolean;
  71495. /**
  71496. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71497. */
  71498. readonly isNonUniform: boolean;
  71499. /**
  71500. * Gets a new Vector3 from current Vector3 floored values
  71501. * @returns a new Vector3
  71502. */
  71503. floor(): Vector3;
  71504. /**
  71505. * Gets a new Vector3 from current Vector3 floored values
  71506. * @returns a new Vector3
  71507. */
  71508. fract(): Vector3;
  71509. /**
  71510. * Gets the length of the Vector3
  71511. * @returns the length of the Vector3
  71512. */
  71513. length(): number;
  71514. /**
  71515. * Gets the squared length of the Vector3
  71516. * @returns squared length of the Vector3
  71517. */
  71518. lengthSquared(): number;
  71519. /**
  71520. * Normalize the current Vector3.
  71521. * Please note that this is an in place operation.
  71522. * @returns the current updated Vector3
  71523. */
  71524. normalize(): Vector3;
  71525. /**
  71526. * Reorders the x y z properties of the vector in place
  71527. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71528. * @returns the current updated vector
  71529. */
  71530. reorderInPlace(order: string): this;
  71531. /**
  71532. * Rotates the vector around 0,0,0 by a quaternion
  71533. * @param quaternion the rotation quaternion
  71534. * @param result vector to store the result
  71535. * @returns the resulting vector
  71536. */
  71537. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  71538. /**
  71539. * Rotates a vector around a given point
  71540. * @param quaternion the rotation quaternion
  71541. * @param point the point to rotate around
  71542. * @param result vector to store the result
  71543. * @returns the resulting vector
  71544. */
  71545. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  71546. /**
  71547. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  71548. * The cross product is then orthogonal to both current and "other"
  71549. * @param other defines the right operand
  71550. * @returns the cross product
  71551. */
  71552. cross(other: Vector3): Vector3;
  71553. /**
  71554. * Normalize the current Vector3 with the given input length.
  71555. * Please note that this is an in place operation.
  71556. * @param len the length of the vector
  71557. * @returns the current updated Vector3
  71558. */
  71559. normalizeFromLength(len: number): Vector3;
  71560. /**
  71561. * Normalize the current Vector3 to a new vector
  71562. * @returns the new Vector3
  71563. */
  71564. normalizeToNew(): Vector3;
  71565. /**
  71566. * Normalize the current Vector3 to the reference
  71567. * @param reference define the Vector3 to update
  71568. * @returns the updated Vector3
  71569. */
  71570. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  71571. /**
  71572. * Creates a new Vector3 copied from the current Vector3
  71573. * @returns the new Vector3
  71574. */
  71575. clone(): Vector3;
  71576. /**
  71577. * Copies the given vector coordinates to the current Vector3 ones
  71578. * @param source defines the source Vector3
  71579. * @returns the current updated Vector3
  71580. */
  71581. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  71582. /**
  71583. * Copies the given floats to the current Vector3 coordinates
  71584. * @param x defines the x coordinate of the operand
  71585. * @param y defines the y coordinate of the operand
  71586. * @param z defines the z coordinate of the operand
  71587. * @returns the current updated Vector3
  71588. */
  71589. copyFromFloats(x: number, y: number, z: number): Vector3;
  71590. /**
  71591. * Copies the given floats to the current Vector3 coordinates
  71592. * @param x defines the x coordinate of the operand
  71593. * @param y defines the y coordinate of the operand
  71594. * @param z defines the z coordinate of the operand
  71595. * @returns the current updated Vector3
  71596. */
  71597. set(x: number, y: number, z: number): Vector3;
  71598. /**
  71599. * Copies the given float to the current Vector3 coordinates
  71600. * @param v defines the x, y and z coordinates of the operand
  71601. * @returns the current updated Vector3
  71602. */
  71603. setAll(v: number): Vector3;
  71604. /**
  71605. * Get the clip factor between two vectors
  71606. * @param vector0 defines the first operand
  71607. * @param vector1 defines the second operand
  71608. * @param axis defines the axis to use
  71609. * @param size defines the size along the axis
  71610. * @returns the clip factor
  71611. */
  71612. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  71613. /**
  71614. * Get angle between two vectors
  71615. * @param vector0 angle between vector0 and vector1
  71616. * @param vector1 angle between vector0 and vector1
  71617. * @param normal direction of the normal
  71618. * @return the angle between vector0 and vector1
  71619. */
  71620. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  71621. /**
  71622. * Returns a new Vector3 set from the index "offset" of the given array
  71623. * @param array defines the source array
  71624. * @param offset defines the offset in the source array
  71625. * @returns the new Vector3
  71626. */
  71627. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  71628. /**
  71629. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71630. * @param array defines the source array
  71631. * @param offset defines the offset in the source array
  71632. * @returns the new Vector3
  71633. * @deprecated Please use FromArray instead.
  71634. */
  71635. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  71636. /**
  71637. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71638. * @param array defines the source array
  71639. * @param offset defines the offset in the source array
  71640. * @param result defines the Vector3 where to store the result
  71641. */
  71642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  71643. /**
  71644. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71645. * @param array defines the source array
  71646. * @param offset defines the offset in the source array
  71647. * @param result defines the Vector3 where to store the result
  71648. * @deprecated Please use FromArrayToRef instead.
  71649. */
  71650. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  71651. /**
  71652. * Sets the given vector "result" with the given floats.
  71653. * @param x defines the x coordinate of the source
  71654. * @param y defines the y coordinate of the source
  71655. * @param z defines the z coordinate of the source
  71656. * @param result defines the Vector3 where to store the result
  71657. */
  71658. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  71659. /**
  71660. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71661. * @returns a new empty Vector3
  71662. */
  71663. static Zero(): Vector3;
  71664. /**
  71665. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71666. * @returns a new unit Vector3
  71667. */
  71668. static One(): Vector3;
  71669. /**
  71670. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71671. * @returns a new up Vector3
  71672. */
  71673. static Up(): Vector3;
  71674. /**
  71675. * Gets a up Vector3 that must not be updated
  71676. */
  71677. static readonly UpReadOnly: DeepImmutable<Vector3>;
  71678. /**
  71679. * Gets a zero Vector3 that must not be updated
  71680. */
  71681. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  71682. /**
  71683. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71684. * @returns a new down Vector3
  71685. */
  71686. static Down(): Vector3;
  71687. /**
  71688. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71689. * @returns a new forward Vector3
  71690. */
  71691. static Forward(): Vector3;
  71692. /**
  71693. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71694. * @returns a new forward Vector3
  71695. */
  71696. static Backward(): Vector3;
  71697. /**
  71698. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71699. * @returns a new right Vector3
  71700. */
  71701. static Right(): Vector3;
  71702. /**
  71703. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71704. * @returns a new left Vector3
  71705. */
  71706. static Left(): Vector3;
  71707. /**
  71708. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71709. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71710. * @param vector defines the Vector3 to transform
  71711. * @param transformation defines the transformation matrix
  71712. * @returns the transformed Vector3
  71713. */
  71714. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71715. /**
  71716. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71717. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71718. * @param vector defines the Vector3 to transform
  71719. * @param transformation defines the transformation matrix
  71720. * @param result defines the Vector3 where to store the result
  71721. */
  71722. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71723. /**
  71724. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71725. * This method computes tranformed coordinates only, not transformed direction vectors
  71726. * @param x define the x coordinate of the source vector
  71727. * @param y define the y coordinate of the source vector
  71728. * @param z define the z coordinate of the source vector
  71729. * @param transformation defines the transformation matrix
  71730. * @param result defines the Vector3 where to store the result
  71731. */
  71732. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71733. /**
  71734. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71736. * @param vector defines the Vector3 to transform
  71737. * @param transformation defines the transformation matrix
  71738. * @returns the new Vector3
  71739. */
  71740. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71741. /**
  71742. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71743. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71744. * @param vector defines the Vector3 to transform
  71745. * @param transformation defines the transformation matrix
  71746. * @param result defines the Vector3 where to store the result
  71747. */
  71748. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71749. /**
  71750. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71751. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71752. * @param x define the x coordinate of the source vector
  71753. * @param y define the y coordinate of the source vector
  71754. * @param z define the z coordinate of the source vector
  71755. * @param transformation defines the transformation matrix
  71756. * @param result defines the Vector3 where to store the result
  71757. */
  71758. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71759. /**
  71760. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71761. * @param value1 defines the first control point
  71762. * @param value2 defines the second control point
  71763. * @param value3 defines the third control point
  71764. * @param value4 defines the fourth control point
  71765. * @param amount defines the amount on the spline to use
  71766. * @returns the new Vector3
  71767. */
  71768. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  71769. /**
  71770. * 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"
  71771. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71772. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71773. * @param value defines the current value
  71774. * @param min defines the lower range value
  71775. * @param max defines the upper range value
  71776. * @returns the new Vector3
  71777. */
  71778. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  71779. /**
  71780. * 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"
  71781. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71782. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71783. * @param value defines the current value
  71784. * @param min defines the lower range value
  71785. * @param max defines the upper range value
  71786. * @param result defines the Vector3 where to store the result
  71787. */
  71788. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  71789. /**
  71790. * Checks if a given vector is inside a specific range
  71791. * @param v defines the vector to test
  71792. * @param min defines the minimum range
  71793. * @param max defines the maximum range
  71794. */
  71795. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  71796. /**
  71797. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71798. * @param value1 defines the first control point
  71799. * @param tangent1 defines the first tangent vector
  71800. * @param value2 defines the second control point
  71801. * @param tangent2 defines the second tangent vector
  71802. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71803. * @returns the new Vector3
  71804. */
  71805. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  71806. /**
  71807. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71808. * @param start defines the start value
  71809. * @param end defines the end value
  71810. * @param amount max defines amount between both (between 0 and 1)
  71811. * @returns the new Vector3
  71812. */
  71813. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71814. /**
  71815. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71816. * @param start defines the start value
  71817. * @param end defines the end value
  71818. * @param amount max defines amount between both (between 0 and 1)
  71819. * @param result defines the Vector3 where to store the result
  71820. */
  71821. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71822. /**
  71823. * Returns the dot product (float) between the vectors "left" and "right"
  71824. * @param left defines the left operand
  71825. * @param right defines the right operand
  71826. * @returns the dot product
  71827. */
  71828. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71829. /**
  71830. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71831. * The cross product is then orthogonal to both "left" and "right"
  71832. * @param left defines the left operand
  71833. * @param right defines the right operand
  71834. * @returns the cross product
  71835. */
  71836. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71837. /**
  71838. * Sets the given vector "result" with the cross product of "left" and "right"
  71839. * The cross product is then orthogonal to both "left" and "right"
  71840. * @param left defines the left operand
  71841. * @param right defines the right operand
  71842. * @param result defines the Vector3 where to store the result
  71843. */
  71844. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71845. /**
  71846. * Returns a new Vector3 as the normalization of the given vector
  71847. * @param vector defines the Vector3 to normalize
  71848. * @returns the new Vector3
  71849. */
  71850. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71851. /**
  71852. * Sets the given vector "result" with the normalization of the given first vector
  71853. * @param vector defines the Vector3 to normalize
  71854. * @param result defines the Vector3 where to store the result
  71855. */
  71856. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71857. /**
  71858. * Project a Vector3 onto screen space
  71859. * @param vector defines the Vector3 to project
  71860. * @param world defines the world matrix to use
  71861. * @param transform defines the transform (view x projection) matrix to use
  71862. * @param viewport defines the screen viewport to use
  71863. * @returns the new Vector3
  71864. */
  71865. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71866. /** @hidden */
  71867. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71868. /**
  71869. * Unproject from screen space to object space
  71870. * @param source defines the screen space Vector3 to use
  71871. * @param viewportWidth defines the current width of the viewport
  71872. * @param viewportHeight defines the current height of the viewport
  71873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71874. * @param transform defines the transform (view x projection) matrix to use
  71875. * @returns the new Vector3
  71876. */
  71877. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71878. /**
  71879. * Unproject from screen space to object space
  71880. * @param source defines the screen space Vector3 to use
  71881. * @param viewportWidth defines the current width of the viewport
  71882. * @param viewportHeight defines the current height of the viewport
  71883. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71884. * @param view defines the view matrix to use
  71885. * @param projection defines the projection matrix to use
  71886. * @returns the new Vector3
  71887. */
  71888. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71889. /**
  71890. * Unproject from screen space to object space
  71891. * @param source defines the screen space Vector3 to use
  71892. * @param viewportWidth defines the current width of the viewport
  71893. * @param viewportHeight defines the current height of the viewport
  71894. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71895. * @param view defines the view matrix to use
  71896. * @param projection defines the projection matrix to use
  71897. * @param result defines the Vector3 where to store the result
  71898. */
  71899. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71900. /**
  71901. * Unproject from screen space to object space
  71902. * @param sourceX defines the screen space x coordinate to use
  71903. * @param sourceY defines the screen space y coordinate to use
  71904. * @param sourceZ defines the screen space z coordinate to use
  71905. * @param viewportWidth defines the current width of the viewport
  71906. * @param viewportHeight defines the current height of the viewport
  71907. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71908. * @param view defines the view matrix to use
  71909. * @param projection defines the projection matrix to use
  71910. * @param result defines the Vector3 where to store the result
  71911. */
  71912. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71913. /**
  71914. * Gets the minimal coordinate values between two Vector3
  71915. * @param left defines the first operand
  71916. * @param right defines the second operand
  71917. * @returns the new Vector3
  71918. */
  71919. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71920. /**
  71921. * Gets the maximal coordinate values between two Vector3
  71922. * @param left defines the first operand
  71923. * @param right defines the second operand
  71924. * @returns the new Vector3
  71925. */
  71926. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71927. /**
  71928. * Returns the distance between the vectors "value1" and "value2"
  71929. * @param value1 defines the first operand
  71930. * @param value2 defines the second operand
  71931. * @returns the distance
  71932. */
  71933. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71934. /**
  71935. * Returns the squared distance between the vectors "value1" and "value2"
  71936. * @param value1 defines the first operand
  71937. * @param value2 defines the second operand
  71938. * @returns the squared distance
  71939. */
  71940. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71941. /**
  71942. * Returns a new Vector3 located at the center between "value1" and "value2"
  71943. * @param value1 defines the first operand
  71944. * @param value2 defines the second operand
  71945. * @returns the new Vector3
  71946. */
  71947. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71948. /**
  71949. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71950. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71951. * to something in order to rotate it from its local system to the given target system
  71952. * Note: axis1, axis2 and axis3 are normalized during this operation
  71953. * @param axis1 defines the first axis
  71954. * @param axis2 defines the second axis
  71955. * @param axis3 defines the third axis
  71956. * @returns a new Vector3
  71957. */
  71958. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71959. /**
  71960. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71961. * @param axis1 defines the first axis
  71962. * @param axis2 defines the second axis
  71963. * @param axis3 defines the third axis
  71964. * @param ref defines the Vector3 where to store the result
  71965. */
  71966. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71967. }
  71968. /**
  71969. * Vector4 class created for EulerAngle class conversion to Quaternion
  71970. */
  71971. export class Vector4 {
  71972. /** x value of the vector */
  71973. x: number;
  71974. /** y value of the vector */
  71975. y: number;
  71976. /** z value of the vector */
  71977. z: number;
  71978. /** w value of the vector */
  71979. w: number;
  71980. /**
  71981. * Creates a Vector4 object from the given floats.
  71982. * @param x x value of the vector
  71983. * @param y y value of the vector
  71984. * @param z z value of the vector
  71985. * @param w w value of the vector
  71986. */
  71987. constructor(
  71988. /** x value of the vector */
  71989. x: number,
  71990. /** y value of the vector */
  71991. y: number,
  71992. /** z value of the vector */
  71993. z: number,
  71994. /** w value of the vector */
  71995. w: number);
  71996. /**
  71997. * Returns the string with the Vector4 coordinates.
  71998. * @returns a string containing all the vector values
  71999. */
  72000. toString(): string;
  72001. /**
  72002. * Returns the string "Vector4".
  72003. * @returns "Vector4"
  72004. */
  72005. getClassName(): string;
  72006. /**
  72007. * Returns the Vector4 hash code.
  72008. * @returns a unique hash code
  72009. */
  72010. getHashCode(): number;
  72011. /**
  72012. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  72013. * @returns the resulting array
  72014. */
  72015. asArray(): number[];
  72016. /**
  72017. * Populates the given array from the given index with the Vector4 coordinates.
  72018. * @param array array to populate
  72019. * @param index index of the array to start at (default: 0)
  72020. * @returns the Vector4.
  72021. */
  72022. toArray(array: FloatArray, index?: number): Vector4;
  72023. /**
  72024. * Adds the given vector to the current Vector4.
  72025. * @param otherVector the vector to add
  72026. * @returns the updated Vector4.
  72027. */
  72028. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72029. /**
  72030. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  72031. * @param otherVector the vector to add
  72032. * @returns the resulting vector
  72033. */
  72034. add(otherVector: DeepImmutable<Vector4>): Vector4;
  72035. /**
  72036. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  72037. * @param otherVector the vector to add
  72038. * @param result the vector to store the result
  72039. * @returns the current Vector4.
  72040. */
  72041. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72042. /**
  72043. * Subtract in place the given vector from the current Vector4.
  72044. * @param otherVector the vector to subtract
  72045. * @returns the updated Vector4.
  72046. */
  72047. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72048. /**
  72049. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  72050. * @param otherVector the vector to add
  72051. * @returns the new vector with the result
  72052. */
  72053. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  72054. /**
  72055. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  72056. * @param otherVector the vector to subtract
  72057. * @param result the vector to store the result
  72058. * @returns the current Vector4.
  72059. */
  72060. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72061. /**
  72062. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72063. */
  72064. /**
  72065. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72066. * @param x value to subtract
  72067. * @param y value to subtract
  72068. * @param z value to subtract
  72069. * @param w value to subtract
  72070. * @returns new vector containing the result
  72071. */
  72072. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72073. /**
  72074. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72075. * @param x value to subtract
  72076. * @param y value to subtract
  72077. * @param z value to subtract
  72078. * @param w value to subtract
  72079. * @param result the vector to store the result in
  72080. * @returns the current Vector4.
  72081. */
  72082. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  72083. /**
  72084. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  72085. * @returns a new vector with the negated values
  72086. */
  72087. negate(): Vector4;
  72088. /**
  72089. * Multiplies the current Vector4 coordinates by scale (float).
  72090. * @param scale the number to scale with
  72091. * @returns the updated Vector4.
  72092. */
  72093. scaleInPlace(scale: number): Vector4;
  72094. /**
  72095. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  72096. * @param scale the number to scale with
  72097. * @returns a new vector with the result
  72098. */
  72099. scale(scale: number): Vector4;
  72100. /**
  72101. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  72102. * @param scale the number to scale with
  72103. * @param result a vector to store the result in
  72104. * @returns the current Vector4.
  72105. */
  72106. scaleToRef(scale: number, result: Vector4): Vector4;
  72107. /**
  72108. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  72109. * @param scale defines the scale factor
  72110. * @param result defines the Vector4 object where to store the result
  72111. * @returns the unmodified current Vector4
  72112. */
  72113. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  72114. /**
  72115. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  72116. * @param otherVector the vector to compare against
  72117. * @returns true if they are equal
  72118. */
  72119. equals(otherVector: DeepImmutable<Vector4>): boolean;
  72120. /**
  72121. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  72122. * @param otherVector vector to compare against
  72123. * @param epsilon (Default: very small number)
  72124. * @returns true if they are equal
  72125. */
  72126. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  72127. /**
  72128. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  72129. * @param x x value to compare against
  72130. * @param y y value to compare against
  72131. * @param z z value to compare against
  72132. * @param w w value to compare against
  72133. * @returns true if equal
  72134. */
  72135. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  72136. /**
  72137. * Multiplies in place the current Vector4 by the given one.
  72138. * @param otherVector vector to multiple with
  72139. * @returns the updated Vector4.
  72140. */
  72141. multiplyInPlace(otherVector: Vector4): Vector4;
  72142. /**
  72143. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  72144. * @param otherVector vector to multiple with
  72145. * @returns resulting new vector
  72146. */
  72147. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  72148. /**
  72149. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  72150. * @param otherVector vector to multiple with
  72151. * @param result vector to store the result
  72152. * @returns the current Vector4.
  72153. */
  72154. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72155. /**
  72156. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  72157. * @param x x value multiply with
  72158. * @param y y value multiply with
  72159. * @param z z value multiply with
  72160. * @param w w value multiply with
  72161. * @returns resulting new vector
  72162. */
  72163. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  72164. /**
  72165. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  72166. * @param otherVector vector to devide with
  72167. * @returns resulting new vector
  72168. */
  72169. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  72170. /**
  72171. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  72172. * @param otherVector vector to devide with
  72173. * @param result vector to store the result
  72174. * @returns the current Vector4.
  72175. */
  72176. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72177. /**
  72178. * Divides the current Vector3 coordinates by the given ones.
  72179. * @param otherVector vector to devide with
  72180. * @returns the updated Vector3.
  72181. */
  72182. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72183. /**
  72184. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  72185. * @param other defines the second operand
  72186. * @returns the current updated Vector4
  72187. */
  72188. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72189. /**
  72190. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  72191. * @param other defines the second operand
  72192. * @returns the current updated Vector4
  72193. */
  72194. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72195. /**
  72196. * Gets a new Vector4 from current Vector4 floored values
  72197. * @returns a new Vector4
  72198. */
  72199. floor(): Vector4;
  72200. /**
  72201. * Gets a new Vector4 from current Vector3 floored values
  72202. * @returns a new Vector4
  72203. */
  72204. fract(): Vector4;
  72205. /**
  72206. * Returns the Vector4 length (float).
  72207. * @returns the length
  72208. */
  72209. length(): number;
  72210. /**
  72211. * Returns the Vector4 squared length (float).
  72212. * @returns the length squared
  72213. */
  72214. lengthSquared(): number;
  72215. /**
  72216. * Normalizes in place the Vector4.
  72217. * @returns the updated Vector4.
  72218. */
  72219. normalize(): Vector4;
  72220. /**
  72221. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  72222. * @returns this converted to a new vector3
  72223. */
  72224. toVector3(): Vector3;
  72225. /**
  72226. * Returns a new Vector4 copied from the current one.
  72227. * @returns the new cloned vector
  72228. */
  72229. clone(): Vector4;
  72230. /**
  72231. * Updates the current Vector4 with the given one coordinates.
  72232. * @param source the source vector to copy from
  72233. * @returns the updated Vector4.
  72234. */
  72235. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  72236. /**
  72237. * Updates the current Vector4 coordinates with the given floats.
  72238. * @param x float to copy from
  72239. * @param y float to copy from
  72240. * @param z float to copy from
  72241. * @param w float to copy from
  72242. * @returns the updated Vector4.
  72243. */
  72244. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72245. /**
  72246. * Updates the current Vector4 coordinates with the given floats.
  72247. * @param x float to set from
  72248. * @param y float to set from
  72249. * @param z float to set from
  72250. * @param w float to set from
  72251. * @returns the updated Vector4.
  72252. */
  72253. set(x: number, y: number, z: number, w: number): Vector4;
  72254. /**
  72255. * Copies the given float to the current Vector3 coordinates
  72256. * @param v defines the x, y, z and w coordinates of the operand
  72257. * @returns the current updated Vector3
  72258. */
  72259. setAll(v: number): Vector4;
  72260. /**
  72261. * Returns a new Vector4 set from the starting index of the given array.
  72262. * @param array the array to pull values from
  72263. * @param offset the offset into the array to start at
  72264. * @returns the new vector
  72265. */
  72266. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  72267. /**
  72268. * Updates the given vector "result" from the starting index of the given array.
  72269. * @param array the array to pull values from
  72270. * @param offset the offset into the array to start at
  72271. * @param result the vector to store the result in
  72272. */
  72273. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  72274. /**
  72275. * Updates the given vector "result" from the starting index of the given Float32Array.
  72276. * @param array the array to pull values from
  72277. * @param offset the offset into the array to start at
  72278. * @param result the vector to store the result in
  72279. */
  72280. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  72281. /**
  72282. * Updates the given vector "result" coordinates from the given floats.
  72283. * @param x float to set from
  72284. * @param y float to set from
  72285. * @param z float to set from
  72286. * @param w float to set from
  72287. * @param result the vector to the floats in
  72288. */
  72289. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  72290. /**
  72291. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  72292. * @returns the new vector
  72293. */
  72294. static Zero(): Vector4;
  72295. /**
  72296. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  72297. * @returns the new vector
  72298. */
  72299. static One(): Vector4;
  72300. /**
  72301. * Returns a new normalized Vector4 from the given one.
  72302. * @param vector the vector to normalize
  72303. * @returns the vector
  72304. */
  72305. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  72306. /**
  72307. * Updates the given vector "result" from the normalization of the given one.
  72308. * @param vector the vector to normalize
  72309. * @param result the vector to store the result in
  72310. */
  72311. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  72312. /**
  72313. * Returns a vector with the minimum values from the left and right vectors
  72314. * @param left left vector to minimize
  72315. * @param right right vector to minimize
  72316. * @returns a new vector with the minimum of the left and right vector values
  72317. */
  72318. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72319. /**
  72320. * Returns a vector with the maximum values from the left and right vectors
  72321. * @param left left vector to maximize
  72322. * @param right right vector to maximize
  72323. * @returns a new vector with the maximum of the left and right vector values
  72324. */
  72325. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72326. /**
  72327. * Returns the distance (float) between the vectors "value1" and "value2".
  72328. * @param value1 value to calulate the distance between
  72329. * @param value2 value to calulate the distance between
  72330. * @return the distance between the two vectors
  72331. */
  72332. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72333. /**
  72334. * Returns the squared distance (float) between the vectors "value1" and "value2".
  72335. * @param value1 value to calulate the distance between
  72336. * @param value2 value to calulate the distance between
  72337. * @return the distance between the two vectors squared
  72338. */
  72339. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72340. /**
  72341. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  72342. * @param value1 value to calulate the center between
  72343. * @param value2 value to calulate the center between
  72344. * @return the center between the two vectors
  72345. */
  72346. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  72347. /**
  72348. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  72349. * This methods computes transformed normalized direction vectors only.
  72350. * @param vector the vector to transform
  72351. * @param transformation the transformation matrix to apply
  72352. * @returns the new vector
  72353. */
  72354. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  72355. /**
  72356. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  72357. * This methods computes transformed normalized direction vectors only.
  72358. * @param vector the vector to transform
  72359. * @param transformation the transformation matrix to apply
  72360. * @param result the vector to store the result in
  72361. */
  72362. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72363. /**
  72364. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  72365. * This methods computes transformed normalized direction vectors only.
  72366. * @param x value to transform
  72367. * @param y value to transform
  72368. * @param z value to transform
  72369. * @param w value to transform
  72370. * @param transformation the transformation matrix to apply
  72371. * @param result the vector to store the results in
  72372. */
  72373. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72374. /**
  72375. * Creates a new Vector4 from a Vector3
  72376. * @param source defines the source data
  72377. * @param w defines the 4th component (default is 0)
  72378. * @returns a new Vector4
  72379. */
  72380. static FromVector3(source: Vector3, w?: number): Vector4;
  72381. }
  72382. /**
  72383. * Class used to store quaternion data
  72384. * @see https://en.wikipedia.org/wiki/Quaternion
  72385. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  72386. */
  72387. export class Quaternion {
  72388. /** defines the first component (0 by default) */
  72389. x: number;
  72390. /** defines the second component (0 by default) */
  72391. y: number;
  72392. /** defines the third component (0 by default) */
  72393. z: number;
  72394. /** defines the fourth component (1.0 by default) */
  72395. w: number;
  72396. /**
  72397. * Creates a new Quaternion from the given floats
  72398. * @param x defines the first component (0 by default)
  72399. * @param y defines the second component (0 by default)
  72400. * @param z defines the third component (0 by default)
  72401. * @param w defines the fourth component (1.0 by default)
  72402. */
  72403. constructor(
  72404. /** defines the first component (0 by default) */
  72405. x?: number,
  72406. /** defines the second component (0 by default) */
  72407. y?: number,
  72408. /** defines the third component (0 by default) */
  72409. z?: number,
  72410. /** defines the fourth component (1.0 by default) */
  72411. w?: number);
  72412. /**
  72413. * Gets a string representation for the current quaternion
  72414. * @returns a string with the Quaternion coordinates
  72415. */
  72416. toString(): string;
  72417. /**
  72418. * Gets the class name of the quaternion
  72419. * @returns the string "Quaternion"
  72420. */
  72421. getClassName(): string;
  72422. /**
  72423. * Gets a hash code for this quaternion
  72424. * @returns the quaternion hash code
  72425. */
  72426. getHashCode(): number;
  72427. /**
  72428. * Copy the quaternion to an array
  72429. * @returns a new array populated with 4 elements from the quaternion coordinates
  72430. */
  72431. asArray(): number[];
  72432. /**
  72433. * Check if two quaternions are equals
  72434. * @param otherQuaternion defines the second operand
  72435. * @return true if the current quaternion and the given one coordinates are strictly equals
  72436. */
  72437. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  72438. /**
  72439. * Clone the current quaternion
  72440. * @returns a new quaternion copied from the current one
  72441. */
  72442. clone(): Quaternion;
  72443. /**
  72444. * Copy a quaternion to the current one
  72445. * @param other defines the other quaternion
  72446. * @returns the updated current quaternion
  72447. */
  72448. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  72449. /**
  72450. * Updates the current quaternion with the given float coordinates
  72451. * @param x defines the x coordinate
  72452. * @param y defines the y coordinate
  72453. * @param z defines the z coordinate
  72454. * @param w defines the w coordinate
  72455. * @returns the updated current quaternion
  72456. */
  72457. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  72458. /**
  72459. * Updates the current quaternion from the given float coordinates
  72460. * @param x defines the x coordinate
  72461. * @param y defines the y coordinate
  72462. * @param z defines the z coordinate
  72463. * @param w defines the w coordinate
  72464. * @returns the updated current quaternion
  72465. */
  72466. set(x: number, y: number, z: number, w: number): Quaternion;
  72467. /**
  72468. * Adds two quaternions
  72469. * @param other defines the second operand
  72470. * @returns a new quaternion as the addition result of the given one and the current quaternion
  72471. */
  72472. add(other: DeepImmutable<Quaternion>): Quaternion;
  72473. /**
  72474. * Add a quaternion to the current one
  72475. * @param other defines the quaternion to add
  72476. * @returns the current quaternion
  72477. */
  72478. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  72479. /**
  72480. * Subtract two quaternions
  72481. * @param other defines the second operand
  72482. * @returns a new quaternion as the subtraction result of the given one from the current one
  72483. */
  72484. subtract(other: Quaternion): Quaternion;
  72485. /**
  72486. * Multiplies the current quaternion by a scale factor
  72487. * @param value defines the scale factor
  72488. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  72489. */
  72490. scale(value: number): Quaternion;
  72491. /**
  72492. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  72493. * @param scale defines the scale factor
  72494. * @param result defines the Quaternion object where to store the result
  72495. * @returns the unmodified current quaternion
  72496. */
  72497. scaleToRef(scale: number, result: Quaternion): Quaternion;
  72498. /**
  72499. * Multiplies in place the current quaternion by a scale factor
  72500. * @param value defines the scale factor
  72501. * @returns the current modified quaternion
  72502. */
  72503. scaleInPlace(value: number): Quaternion;
  72504. /**
  72505. * Scale the current quaternion values by a factor and add the result to a given quaternion
  72506. * @param scale defines the scale factor
  72507. * @param result defines the Quaternion object where to store the result
  72508. * @returns the unmodified current quaternion
  72509. */
  72510. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  72511. /**
  72512. * Multiplies two quaternions
  72513. * @param q1 defines the second operand
  72514. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  72515. */
  72516. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  72517. /**
  72518. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  72519. * @param q1 defines the second operand
  72520. * @param result defines the target quaternion
  72521. * @returns the current quaternion
  72522. */
  72523. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  72524. /**
  72525. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  72526. * @param q1 defines the second operand
  72527. * @returns the currentupdated quaternion
  72528. */
  72529. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  72530. /**
  72531. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  72532. * @param ref defines the target quaternion
  72533. * @returns the current quaternion
  72534. */
  72535. conjugateToRef(ref: Quaternion): Quaternion;
  72536. /**
  72537. * Conjugates in place (1-q) the current quaternion
  72538. * @returns the current updated quaternion
  72539. */
  72540. conjugateInPlace(): Quaternion;
  72541. /**
  72542. * Conjugates in place (1-q) the current quaternion
  72543. * @returns a new quaternion
  72544. */
  72545. conjugate(): Quaternion;
  72546. /**
  72547. * Gets length of current quaternion
  72548. * @returns the quaternion length (float)
  72549. */
  72550. length(): number;
  72551. /**
  72552. * Normalize in place the current quaternion
  72553. * @returns the current updated quaternion
  72554. */
  72555. normalize(): Quaternion;
  72556. /**
  72557. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  72558. * @param order is a reserved parameter and is ignore for now
  72559. * @returns a new Vector3 containing the Euler angles
  72560. */
  72561. toEulerAngles(order?: string): Vector3;
  72562. /**
  72563. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  72564. * @param result defines the vector which will be filled with the Euler angles
  72565. * @param order is a reserved parameter and is ignore for now
  72566. * @returns the current unchanged quaternion
  72567. */
  72568. toEulerAnglesToRef(result: Vector3): Quaternion;
  72569. /**
  72570. * Updates the given rotation matrix with the current quaternion values
  72571. * @param result defines the target matrix
  72572. * @returns the current unchanged quaternion
  72573. */
  72574. toRotationMatrix(result: Matrix): Quaternion;
  72575. /**
  72576. * Updates the current quaternion from the given rotation matrix values
  72577. * @param matrix defines the source matrix
  72578. * @returns the current updated quaternion
  72579. */
  72580. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72581. /**
  72582. * Creates a new quaternion from a rotation matrix
  72583. * @param matrix defines the source matrix
  72584. * @returns a new quaternion created from the given rotation matrix values
  72585. */
  72586. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72587. /**
  72588. * Updates the given quaternion with the given rotation matrix values
  72589. * @param matrix defines the source matrix
  72590. * @param result defines the target quaternion
  72591. */
  72592. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  72593. /**
  72594. * Returns the dot product (float) between the quaternions "left" and "right"
  72595. * @param left defines the left operand
  72596. * @param right defines the right operand
  72597. * @returns the dot product
  72598. */
  72599. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  72600. /**
  72601. * Checks if the two quaternions are close to each other
  72602. * @param quat0 defines the first quaternion to check
  72603. * @param quat1 defines the second quaternion to check
  72604. * @returns true if the two quaternions are close to each other
  72605. */
  72606. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  72607. /**
  72608. * Creates an empty quaternion
  72609. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  72610. */
  72611. static Zero(): Quaternion;
  72612. /**
  72613. * Inverse a given quaternion
  72614. * @param q defines the source quaternion
  72615. * @returns a new quaternion as the inverted current quaternion
  72616. */
  72617. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  72618. /**
  72619. * Inverse a given quaternion
  72620. * @param q defines the source quaternion
  72621. * @param result the quaternion the result will be stored in
  72622. * @returns the result quaternion
  72623. */
  72624. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  72625. /**
  72626. * Creates an identity quaternion
  72627. * @returns the identity quaternion
  72628. */
  72629. static Identity(): Quaternion;
  72630. /**
  72631. * Gets a boolean indicating if the given quaternion is identity
  72632. * @param quaternion defines the quaternion to check
  72633. * @returns true if the quaternion is identity
  72634. */
  72635. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  72636. /**
  72637. * Creates a quaternion from a rotation around an axis
  72638. * @param axis defines the axis to use
  72639. * @param angle defines the angle to use
  72640. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  72641. */
  72642. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  72643. /**
  72644. * Creates a rotation around an axis and stores it into the given quaternion
  72645. * @param axis defines the axis to use
  72646. * @param angle defines the angle to use
  72647. * @param result defines the target quaternion
  72648. * @returns the target quaternion
  72649. */
  72650. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  72651. /**
  72652. * Creates a new quaternion from data stored into an array
  72653. * @param array defines the data source
  72654. * @param offset defines the offset in the source array where the data starts
  72655. * @returns a new quaternion
  72656. */
  72657. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  72658. /**
  72659. * Create a quaternion from Euler rotation angles
  72660. * @param x Pitch
  72661. * @param y Yaw
  72662. * @param z Roll
  72663. * @returns the new Quaternion
  72664. */
  72665. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  72666. /**
  72667. * Updates a quaternion from Euler rotation angles
  72668. * @param x Pitch
  72669. * @param y Yaw
  72670. * @param z Roll
  72671. * @param result the quaternion to store the result
  72672. * @returns the updated quaternion
  72673. */
  72674. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  72675. /**
  72676. * Create a quaternion from Euler rotation vector
  72677. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72678. * @returns the new Quaternion
  72679. */
  72680. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  72681. /**
  72682. * Updates a quaternion from Euler rotation vector
  72683. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72684. * @param result the quaternion to store the result
  72685. * @returns the updated quaternion
  72686. */
  72687. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  72688. /**
  72689. * Creates a new quaternion from the given Euler float angles (y, x, z)
  72690. * @param yaw defines the rotation around Y axis
  72691. * @param pitch defines the rotation around X axis
  72692. * @param roll defines the rotation around Z axis
  72693. * @returns the new quaternion
  72694. */
  72695. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  72696. /**
  72697. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72698. * @param yaw defines the rotation around Y axis
  72699. * @param pitch defines the rotation around X axis
  72700. * @param roll defines the rotation around Z axis
  72701. * @param result defines the target quaternion
  72702. */
  72703. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  72704. /**
  72705. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  72706. * @param alpha defines the rotation around first axis
  72707. * @param beta defines the rotation around second axis
  72708. * @param gamma defines the rotation around third axis
  72709. * @returns the new quaternion
  72710. */
  72711. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  72712. /**
  72713. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  72714. * @param alpha defines the rotation around first axis
  72715. * @param beta defines the rotation around second axis
  72716. * @param gamma defines the rotation around third axis
  72717. * @param result defines the target quaternion
  72718. */
  72719. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  72720. /**
  72721. * 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)
  72722. * @param axis1 defines the first axis
  72723. * @param axis2 defines the second axis
  72724. * @param axis3 defines the third axis
  72725. * @returns the new quaternion
  72726. */
  72727. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  72728. /**
  72729. * 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
  72730. * @param axis1 defines the first axis
  72731. * @param axis2 defines the second axis
  72732. * @param axis3 defines the third axis
  72733. * @param ref defines the target quaternion
  72734. */
  72735. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  72736. /**
  72737. * Interpolates between two quaternions
  72738. * @param left defines first quaternion
  72739. * @param right defines second quaternion
  72740. * @param amount defines the gradient to use
  72741. * @returns the new interpolated quaternion
  72742. */
  72743. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72744. /**
  72745. * Interpolates between two quaternions and stores it into a target quaternion
  72746. * @param left defines first quaternion
  72747. * @param right defines second quaternion
  72748. * @param amount defines the gradient to use
  72749. * @param result defines the target quaternion
  72750. */
  72751. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  72752. /**
  72753. * Interpolate between two quaternions using Hermite interpolation
  72754. * @param value1 defines first quaternion
  72755. * @param tangent1 defines the incoming tangent
  72756. * @param value2 defines second quaternion
  72757. * @param tangent2 defines the outgoing tangent
  72758. * @param amount defines the target quaternion
  72759. * @returns the new interpolated quaternion
  72760. */
  72761. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72762. }
  72763. /**
  72764. * Class used to store matrix data (4x4)
  72765. */
  72766. export class Matrix {
  72767. private static _updateFlagSeed;
  72768. private static _identityReadOnly;
  72769. private _isIdentity;
  72770. private _isIdentityDirty;
  72771. private _isIdentity3x2;
  72772. private _isIdentity3x2Dirty;
  72773. /**
  72774. * Gets the update flag of the matrix which is an unique number for the matrix.
  72775. * It will be incremented every time the matrix data change.
  72776. * You can use it to speed the comparison between two versions of the same matrix.
  72777. */
  72778. updateFlag: number;
  72779. private readonly _m;
  72780. /**
  72781. * Gets the internal data of the matrix
  72782. */
  72783. readonly m: DeepImmutable<Float32Array>;
  72784. /** @hidden */
  72785. _markAsUpdated(): void;
  72786. /** @hidden */
  72787. private _updateIdentityStatus;
  72788. /**
  72789. * Creates an empty matrix (filled with zeros)
  72790. */
  72791. constructor();
  72792. /**
  72793. * Check if the current matrix is identity
  72794. * @returns true is the matrix is the identity matrix
  72795. */
  72796. isIdentity(): boolean;
  72797. /**
  72798. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72799. * @returns true is the matrix is the identity matrix
  72800. */
  72801. isIdentityAs3x2(): boolean;
  72802. /**
  72803. * Gets the determinant of the matrix
  72804. * @returns the matrix determinant
  72805. */
  72806. determinant(): number;
  72807. /**
  72808. * Returns the matrix as a Float32Array
  72809. * @returns the matrix underlying array
  72810. */
  72811. toArray(): DeepImmutable<Float32Array>;
  72812. /**
  72813. * Returns the matrix as a Float32Array
  72814. * @returns the matrix underlying array.
  72815. */
  72816. asArray(): DeepImmutable<Float32Array>;
  72817. /**
  72818. * Inverts the current matrix in place
  72819. * @returns the current inverted matrix
  72820. */
  72821. invert(): Matrix;
  72822. /**
  72823. * Sets all the matrix elements to zero
  72824. * @returns the current matrix
  72825. */
  72826. reset(): Matrix;
  72827. /**
  72828. * Adds the current matrix with a second one
  72829. * @param other defines the matrix to add
  72830. * @returns a new matrix as the addition of the current matrix and the given one
  72831. */
  72832. add(other: DeepImmutable<Matrix>): Matrix;
  72833. /**
  72834. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72835. * @param other defines the matrix to add
  72836. * @param result defines the target matrix
  72837. * @returns the current matrix
  72838. */
  72839. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72840. /**
  72841. * Adds in place the given matrix to the current matrix
  72842. * @param other defines the second operand
  72843. * @returns the current updated matrix
  72844. */
  72845. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72846. /**
  72847. * Sets the given matrix to the current inverted Matrix
  72848. * @param other defines the target matrix
  72849. * @returns the unmodified current matrix
  72850. */
  72851. invertToRef(other: Matrix): Matrix;
  72852. /**
  72853. * add a value at the specified position in the current Matrix
  72854. * @param index the index of the value within the matrix. between 0 and 15.
  72855. * @param value the value to be added
  72856. * @returns the current updated matrix
  72857. */
  72858. addAtIndex(index: number, value: number): Matrix;
  72859. /**
  72860. * mutiply the specified position in the current Matrix by a value
  72861. * @param index the index of the value within the matrix. between 0 and 15.
  72862. * @param value the value to be added
  72863. * @returns the current updated matrix
  72864. */
  72865. multiplyAtIndex(index: number, value: number): Matrix;
  72866. /**
  72867. * Inserts the translation vector (using 3 floats) in the current matrix
  72868. * @param x defines the 1st component of the translation
  72869. * @param y defines the 2nd component of the translation
  72870. * @param z defines the 3rd component of the translation
  72871. * @returns the current updated matrix
  72872. */
  72873. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72874. /**
  72875. * Adds the translation vector (using 3 floats) in the current matrix
  72876. * @param x defines the 1st component of the translation
  72877. * @param y defines the 2nd component of the translation
  72878. * @param z defines the 3rd component of the translation
  72879. * @returns the current updated matrix
  72880. */
  72881. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72882. /**
  72883. * Inserts the translation vector in the current matrix
  72884. * @param vector3 defines the translation to insert
  72885. * @returns the current updated matrix
  72886. */
  72887. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72888. /**
  72889. * Gets the translation value of the current matrix
  72890. * @returns a new Vector3 as the extracted translation from the matrix
  72891. */
  72892. getTranslation(): Vector3;
  72893. /**
  72894. * Fill a Vector3 with the extracted translation from the matrix
  72895. * @param result defines the Vector3 where to store the translation
  72896. * @returns the current matrix
  72897. */
  72898. getTranslationToRef(result: Vector3): Matrix;
  72899. /**
  72900. * Remove rotation and scaling part from the matrix
  72901. * @returns the updated matrix
  72902. */
  72903. removeRotationAndScaling(): Matrix;
  72904. /**
  72905. * Multiply two matrices
  72906. * @param other defines the second operand
  72907. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72908. */
  72909. multiply(other: DeepImmutable<Matrix>): Matrix;
  72910. /**
  72911. * Copy the current matrix from the given one
  72912. * @param other defines the source matrix
  72913. * @returns the current updated matrix
  72914. */
  72915. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72916. /**
  72917. * Populates the given array from the starting index with the current matrix values
  72918. * @param array defines the target array
  72919. * @param offset defines the offset in the target array where to start storing values
  72920. * @returns the current matrix
  72921. */
  72922. copyToArray(array: Float32Array, offset?: number): Matrix;
  72923. /**
  72924. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72925. * @param other defines the second operand
  72926. * @param result defines the matrix where to store the multiplication
  72927. * @returns the current matrix
  72928. */
  72929. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72930. /**
  72931. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72932. * @param other defines the second operand
  72933. * @param result defines the array where to store the multiplication
  72934. * @param offset defines the offset in the target array where to start storing values
  72935. * @returns the current matrix
  72936. */
  72937. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72938. /**
  72939. * Check equality between this matrix and a second one
  72940. * @param value defines the second matrix to compare
  72941. * @returns true is the current matrix and the given one values are strictly equal
  72942. */
  72943. equals(value: DeepImmutable<Matrix>): boolean;
  72944. /**
  72945. * Clone the current matrix
  72946. * @returns a new matrix from the current matrix
  72947. */
  72948. clone(): Matrix;
  72949. /**
  72950. * Returns the name of the current matrix class
  72951. * @returns the string "Matrix"
  72952. */
  72953. getClassName(): string;
  72954. /**
  72955. * Gets the hash code of the current matrix
  72956. * @returns the hash code
  72957. */
  72958. getHashCode(): number;
  72959. /**
  72960. * Decomposes the current Matrix into a translation, rotation and scaling components
  72961. * @param scale defines the scale vector3 given as a reference to update
  72962. * @param rotation defines the rotation quaternion given as a reference to update
  72963. * @param translation defines the translation vector3 given as a reference to update
  72964. * @returns true if operation was successful
  72965. */
  72966. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72967. /**
  72968. * Gets specific row of the matrix
  72969. * @param index defines the number of the row to get
  72970. * @returns the index-th row of the current matrix as a new Vector4
  72971. */
  72972. getRow(index: number): Nullable<Vector4>;
  72973. /**
  72974. * Sets the index-th row of the current matrix to the vector4 values
  72975. * @param index defines the number of the row to set
  72976. * @param row defines the target vector4
  72977. * @returns the updated current matrix
  72978. */
  72979. setRow(index: number, row: Vector4): Matrix;
  72980. /**
  72981. * Compute the transpose of the matrix
  72982. * @returns the new transposed matrix
  72983. */
  72984. transpose(): Matrix;
  72985. /**
  72986. * Compute the transpose of the matrix and store it in a given matrix
  72987. * @param result defines the target matrix
  72988. * @returns the current matrix
  72989. */
  72990. transposeToRef(result: Matrix): Matrix;
  72991. /**
  72992. * Sets the index-th row of the current matrix with the given 4 x float values
  72993. * @param index defines the row index
  72994. * @param x defines the x component to set
  72995. * @param y defines the y component to set
  72996. * @param z defines the z component to set
  72997. * @param w defines the w component to set
  72998. * @returns the updated current matrix
  72999. */
  73000. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  73001. /**
  73002. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  73003. * @param scale defines the scale factor
  73004. * @returns a new matrix
  73005. */
  73006. scale(scale: number): Matrix;
  73007. /**
  73008. * Scale the current matrix values by a factor to a given result matrix
  73009. * @param scale defines the scale factor
  73010. * @param result defines the matrix to store the result
  73011. * @returns the current matrix
  73012. */
  73013. scaleToRef(scale: number, result: Matrix): Matrix;
  73014. /**
  73015. * Scale the current matrix values by a factor and add the result to a given matrix
  73016. * @param scale defines the scale factor
  73017. * @param result defines the Matrix to store the result
  73018. * @returns the current matrix
  73019. */
  73020. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  73021. /**
  73022. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  73023. * @param ref matrix to store the result
  73024. */
  73025. toNormalMatrix(ref: Matrix): void;
  73026. /**
  73027. * Gets only rotation part of the current matrix
  73028. * @returns a new matrix sets to the extracted rotation matrix from the current one
  73029. */
  73030. getRotationMatrix(): Matrix;
  73031. /**
  73032. * Extracts the rotation matrix from the current one and sets it as the given "result"
  73033. * @param result defines the target matrix to store data to
  73034. * @returns the current matrix
  73035. */
  73036. getRotationMatrixToRef(result: Matrix): Matrix;
  73037. /**
  73038. * Toggles model matrix from being right handed to left handed in place and vice versa
  73039. */
  73040. toggleModelMatrixHandInPlace(): void;
  73041. /**
  73042. * Toggles projection matrix from being right handed to left handed in place and vice versa
  73043. */
  73044. toggleProjectionMatrixHandInPlace(): void;
  73045. /**
  73046. * Creates a matrix from an array
  73047. * @param array defines the source array
  73048. * @param offset defines an offset in the source array
  73049. * @returns a new Matrix set from the starting index of the given array
  73050. */
  73051. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  73052. /**
  73053. * Copy the content of an array into a given matrix
  73054. * @param array defines the source array
  73055. * @param offset defines an offset in the source array
  73056. * @param result defines the target matrix
  73057. */
  73058. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  73059. /**
  73060. * Stores an array into a matrix after having multiplied each component by a given factor
  73061. * @param array defines the source array
  73062. * @param offset defines the offset in the source array
  73063. * @param scale defines the scaling factor
  73064. * @param result defines the target matrix
  73065. */
  73066. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  73067. /**
  73068. * Gets an identity matrix that must not be updated
  73069. */
  73070. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  73071. /**
  73072. * Stores a list of values (16) inside a given matrix
  73073. * @param initialM11 defines 1st value of 1st row
  73074. * @param initialM12 defines 2nd value of 1st row
  73075. * @param initialM13 defines 3rd value of 1st row
  73076. * @param initialM14 defines 4th value of 1st row
  73077. * @param initialM21 defines 1st value of 2nd row
  73078. * @param initialM22 defines 2nd value of 2nd row
  73079. * @param initialM23 defines 3rd value of 2nd row
  73080. * @param initialM24 defines 4th value of 2nd row
  73081. * @param initialM31 defines 1st value of 3rd row
  73082. * @param initialM32 defines 2nd value of 3rd row
  73083. * @param initialM33 defines 3rd value of 3rd row
  73084. * @param initialM34 defines 4th value of 3rd row
  73085. * @param initialM41 defines 1st value of 4th row
  73086. * @param initialM42 defines 2nd value of 4th row
  73087. * @param initialM43 defines 3rd value of 4th row
  73088. * @param initialM44 defines 4th value of 4th row
  73089. * @param result defines the target matrix
  73090. */
  73091. 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;
  73092. /**
  73093. * Creates new matrix from a list of values (16)
  73094. * @param initialM11 defines 1st value of 1st row
  73095. * @param initialM12 defines 2nd value of 1st row
  73096. * @param initialM13 defines 3rd value of 1st row
  73097. * @param initialM14 defines 4th value of 1st row
  73098. * @param initialM21 defines 1st value of 2nd row
  73099. * @param initialM22 defines 2nd value of 2nd row
  73100. * @param initialM23 defines 3rd value of 2nd row
  73101. * @param initialM24 defines 4th value of 2nd row
  73102. * @param initialM31 defines 1st value of 3rd row
  73103. * @param initialM32 defines 2nd value of 3rd row
  73104. * @param initialM33 defines 3rd value of 3rd row
  73105. * @param initialM34 defines 4th value of 3rd row
  73106. * @param initialM41 defines 1st value of 4th row
  73107. * @param initialM42 defines 2nd value of 4th row
  73108. * @param initialM43 defines 3rd value of 4th row
  73109. * @param initialM44 defines 4th value of 4th row
  73110. * @returns the new matrix
  73111. */
  73112. 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;
  73113. /**
  73114. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73115. * @param scale defines the scale vector3
  73116. * @param rotation defines the rotation quaternion
  73117. * @param translation defines the translation vector3
  73118. * @returns a new matrix
  73119. */
  73120. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  73121. /**
  73122. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73123. * @param scale defines the scale vector3
  73124. * @param rotation defines the rotation quaternion
  73125. * @param translation defines the translation vector3
  73126. * @param result defines the target matrix
  73127. */
  73128. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  73129. /**
  73130. * Creates a new identity matrix
  73131. * @returns a new identity matrix
  73132. */
  73133. static Identity(): Matrix;
  73134. /**
  73135. * Creates a new identity matrix and stores the result in a given matrix
  73136. * @param result defines the target matrix
  73137. */
  73138. static IdentityToRef(result: Matrix): void;
  73139. /**
  73140. * Creates a new zero matrix
  73141. * @returns a new zero matrix
  73142. */
  73143. static Zero(): Matrix;
  73144. /**
  73145. * Creates a new rotation matrix for "angle" radians around the X axis
  73146. * @param angle defines the angle (in radians) to use
  73147. * @return the new matrix
  73148. */
  73149. static RotationX(angle: number): Matrix;
  73150. /**
  73151. * Creates a new matrix as the invert of a given matrix
  73152. * @param source defines the source matrix
  73153. * @returns the new matrix
  73154. */
  73155. static Invert(source: DeepImmutable<Matrix>): Matrix;
  73156. /**
  73157. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  73158. * @param angle defines the angle (in radians) to use
  73159. * @param result defines the target matrix
  73160. */
  73161. static RotationXToRef(angle: number, result: Matrix): void;
  73162. /**
  73163. * Creates a new rotation matrix for "angle" radians around the Y axis
  73164. * @param angle defines the angle (in radians) to use
  73165. * @return the new matrix
  73166. */
  73167. static RotationY(angle: number): Matrix;
  73168. /**
  73169. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  73170. * @param angle defines the angle (in radians) to use
  73171. * @param result defines the target matrix
  73172. */
  73173. static RotationYToRef(angle: number, result: Matrix): void;
  73174. /**
  73175. * Creates a new rotation matrix for "angle" radians around the Z axis
  73176. * @param angle defines the angle (in radians) to use
  73177. * @return the new matrix
  73178. */
  73179. static RotationZ(angle: number): Matrix;
  73180. /**
  73181. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  73182. * @param angle defines the angle (in radians) to use
  73183. * @param result defines the target matrix
  73184. */
  73185. static RotationZToRef(angle: number, result: Matrix): void;
  73186. /**
  73187. * Creates a new rotation matrix for "angle" radians around the given axis
  73188. * @param axis defines the axis to use
  73189. * @param angle defines the angle (in radians) to use
  73190. * @return the new matrix
  73191. */
  73192. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  73193. /**
  73194. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  73195. * @param axis defines the axis to use
  73196. * @param angle defines the angle (in radians) to use
  73197. * @param result defines the target matrix
  73198. */
  73199. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  73200. /**
  73201. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  73202. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  73203. * @param from defines the vector to align
  73204. * @param to defines the vector to align to
  73205. * @param result defines the target matrix
  73206. */
  73207. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  73208. /**
  73209. * Creates a rotation matrix
  73210. * @param yaw defines the yaw angle in radians (Y axis)
  73211. * @param pitch defines the pitch angle in radians (X axis)
  73212. * @param roll defines the roll angle in radians (X axis)
  73213. * @returns the new rotation matrix
  73214. */
  73215. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  73216. /**
  73217. * Creates a rotation matrix and stores it in a given matrix
  73218. * @param yaw defines the yaw angle in radians (Y axis)
  73219. * @param pitch defines the pitch angle in radians (X axis)
  73220. * @param roll defines the roll angle in radians (X axis)
  73221. * @param result defines the target matrix
  73222. */
  73223. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  73224. /**
  73225. * Creates a scaling matrix
  73226. * @param x defines the scale factor on X axis
  73227. * @param y defines the scale factor on Y axis
  73228. * @param z defines the scale factor on Z axis
  73229. * @returns the new matrix
  73230. */
  73231. static Scaling(x: number, y: number, z: number): Matrix;
  73232. /**
  73233. * Creates a scaling matrix and stores it in a given matrix
  73234. * @param x defines the scale factor on X axis
  73235. * @param y defines the scale factor on Y axis
  73236. * @param z defines the scale factor on Z axis
  73237. * @param result defines the target matrix
  73238. */
  73239. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  73240. /**
  73241. * Creates a translation matrix
  73242. * @param x defines the translation on X axis
  73243. * @param y defines the translation on Y axis
  73244. * @param z defines the translationon Z axis
  73245. * @returns the new matrix
  73246. */
  73247. static Translation(x: number, y: number, z: number): Matrix;
  73248. /**
  73249. * Creates a translation matrix and stores it in a given matrix
  73250. * @param x defines the translation on X axis
  73251. * @param y defines the translation on Y axis
  73252. * @param z defines the translationon Z axis
  73253. * @param result defines the target matrix
  73254. */
  73255. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  73256. /**
  73257. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73258. * @param startValue defines the start value
  73259. * @param endValue defines the end value
  73260. * @param gradient defines the gradient factor
  73261. * @returns the new matrix
  73262. */
  73263. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73264. /**
  73265. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73266. * @param startValue defines the start value
  73267. * @param endValue defines the end value
  73268. * @param gradient defines the gradient factor
  73269. * @param result defines the Matrix object where to store data
  73270. */
  73271. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73272. /**
  73273. * Builds a new matrix whose values are computed by:
  73274. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73275. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73276. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73277. * @param startValue defines the first matrix
  73278. * @param endValue defines the second matrix
  73279. * @param gradient defines the gradient between the two matrices
  73280. * @returns the new matrix
  73281. */
  73282. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73283. /**
  73284. * Update a matrix to values which are computed by:
  73285. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73286. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73287. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73288. * @param startValue defines the first matrix
  73289. * @param endValue defines the second matrix
  73290. * @param gradient defines the gradient between the two matrices
  73291. * @param result defines the target matrix
  73292. */
  73293. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73294. /**
  73295. * 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"
  73296. * This function works in left handed mode
  73297. * @param eye defines the final position of the entity
  73298. * @param target defines where the entity should look at
  73299. * @param up defines the up vector for the entity
  73300. * @returns the new matrix
  73301. */
  73302. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73303. /**
  73304. * 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".
  73305. * This function works in left handed mode
  73306. * @param eye defines the final position of the entity
  73307. * @param target defines where the entity should look at
  73308. * @param up defines the up vector for the entity
  73309. * @param result defines the target matrix
  73310. */
  73311. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73312. /**
  73313. * 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"
  73314. * This function works in right handed mode
  73315. * @param eye defines the final position of the entity
  73316. * @param target defines where the entity should look at
  73317. * @param up defines the up vector for the entity
  73318. * @returns the new matrix
  73319. */
  73320. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73321. /**
  73322. * 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".
  73323. * This function works in right handed mode
  73324. * @param eye defines the final position of the entity
  73325. * @param target defines where the entity should look at
  73326. * @param up defines the up vector for the entity
  73327. * @param result defines the target matrix
  73328. */
  73329. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73330. /**
  73331. * Create a left-handed orthographic projection matrix
  73332. * @param width defines the viewport width
  73333. * @param height defines the viewport height
  73334. * @param znear defines the near clip plane
  73335. * @param zfar defines the far clip plane
  73336. * @returns a new matrix as a left-handed orthographic projection matrix
  73337. */
  73338. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73339. /**
  73340. * Store a left-handed orthographic projection to a given matrix
  73341. * @param width defines the viewport width
  73342. * @param height defines the viewport height
  73343. * @param znear defines the near clip plane
  73344. * @param zfar defines the far clip plane
  73345. * @param result defines the target matrix
  73346. */
  73347. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  73348. /**
  73349. * Create a left-handed orthographic projection matrix
  73350. * @param left defines the viewport left coordinate
  73351. * @param right defines the viewport right coordinate
  73352. * @param bottom defines the viewport bottom coordinate
  73353. * @param top defines the viewport top coordinate
  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 orthographic projection matrix
  73357. */
  73358. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73359. /**
  73360. * Stores a left-handed orthographic projection into a given matrix
  73361. * @param left defines the viewport left coordinate
  73362. * @param right defines the viewport right coordinate
  73363. * @param bottom defines the viewport bottom coordinate
  73364. * @param top defines the viewport top coordinate
  73365. * @param znear defines the near clip plane
  73366. * @param zfar defines the far clip plane
  73367. * @param result defines the target matrix
  73368. */
  73369. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73370. /**
  73371. * Creates a right-handed orthographic projection matrix
  73372. * @param left defines the viewport left coordinate
  73373. * @param right defines the viewport right coordinate
  73374. * @param bottom defines the viewport bottom coordinate
  73375. * @param top defines the viewport top coordinate
  73376. * @param znear defines the near clip plane
  73377. * @param zfar defines the far clip plane
  73378. * @returns a new matrix as a right-handed orthographic projection matrix
  73379. */
  73380. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73381. /**
  73382. * Stores a right-handed orthographic projection into a given matrix
  73383. * @param left defines the viewport left coordinate
  73384. * @param right defines the viewport right coordinate
  73385. * @param bottom defines the viewport bottom coordinate
  73386. * @param top defines the viewport top coordinate
  73387. * @param znear defines the near clip plane
  73388. * @param zfar defines the far clip plane
  73389. * @param result defines the target matrix
  73390. */
  73391. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73392. /**
  73393. * Creates a left-handed perspective projection matrix
  73394. * @param width defines the viewport width
  73395. * @param height defines the viewport height
  73396. * @param znear defines the near clip plane
  73397. * @param zfar defines the far clip plane
  73398. * @returns a new matrix as a left-handed perspective projection matrix
  73399. */
  73400. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73401. /**
  73402. * Creates a left-handed perspective projection matrix
  73403. * @param fov defines the horizontal field of view
  73404. * @param aspect defines the aspect ratio
  73405. * @param znear defines the near clip plane
  73406. * @param zfar defines the far clip plane
  73407. * @returns a new matrix as a left-handed perspective projection matrix
  73408. */
  73409. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73410. /**
  73411. * Stores a left-handed perspective projection into a given matrix
  73412. * @param fov defines the horizontal field of view
  73413. * @param aspect defines the aspect ratio
  73414. * @param znear defines the near clip plane
  73415. * @param zfar defines the far clip plane
  73416. * @param result defines the target matrix
  73417. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73418. */
  73419. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73420. /**
  73421. * Stores a left-handed perspective projection into a given matrix with depth reversed
  73422. * @param fov defines the horizontal field of view
  73423. * @param aspect defines the aspect ratio
  73424. * @param znear defines the near clip plane
  73425. * @param zfar not used as infinity is used as far clip
  73426. * @param result defines the target matrix
  73427. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73428. */
  73429. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73430. /**
  73431. * Creates a right-handed perspective projection matrix
  73432. * @param fov defines the horizontal field of view
  73433. * @param aspect defines the aspect ratio
  73434. * @param znear defines the near clip plane
  73435. * @param zfar defines the far clip plane
  73436. * @returns a new matrix as a right-handed perspective projection matrix
  73437. */
  73438. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73439. /**
  73440. * Stores a right-handed perspective projection into a given matrix
  73441. * @param fov defines the horizontal field of view
  73442. * @param aspect defines the aspect ratio
  73443. * @param znear defines the near clip plane
  73444. * @param zfar defines the far clip plane
  73445. * @param result defines the target matrix
  73446. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73447. */
  73448. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73449. /**
  73450. * Stores a right-handed perspective projection into a given matrix
  73451. * @param fov defines the horizontal field of view
  73452. * @param aspect defines the aspect ratio
  73453. * @param znear defines the near clip plane
  73454. * @param zfar not used as infinity is used as far clip
  73455. * @param result defines the target matrix
  73456. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73457. */
  73458. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73459. /**
  73460. * Stores a perspective projection for WebVR info a given matrix
  73461. * @param fov defines the field of view
  73462. * @param znear defines the near clip plane
  73463. * @param zfar defines the far clip plane
  73464. * @param result defines the target matrix
  73465. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73466. */
  73467. static PerspectiveFovWebVRToRef(fov: {
  73468. upDegrees: number;
  73469. downDegrees: number;
  73470. leftDegrees: number;
  73471. rightDegrees: number;
  73472. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  73473. /**
  73474. * Computes a complete transformation matrix
  73475. * @param viewport defines the viewport to use
  73476. * @param world defines the world matrix
  73477. * @param view defines the view matrix
  73478. * @param projection defines the projection matrix
  73479. * @param zmin defines the near clip plane
  73480. * @param zmax defines the far clip plane
  73481. * @returns the transformation matrix
  73482. */
  73483. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  73484. /**
  73485. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73486. * @param matrix defines the matrix to use
  73487. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73488. */
  73489. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  73490. /**
  73491. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73492. * @param matrix defines the matrix to use
  73493. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73494. */
  73495. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  73496. /**
  73497. * Compute the transpose of a given matrix
  73498. * @param matrix defines the matrix to transpose
  73499. * @returns the new matrix
  73500. */
  73501. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  73502. /**
  73503. * Compute the transpose of a matrix and store it in a target matrix
  73504. * @param matrix defines the matrix to transpose
  73505. * @param result defines the target matrix
  73506. */
  73507. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  73508. /**
  73509. * Computes a reflection matrix from a plane
  73510. * @param plane defines the reflection plane
  73511. * @returns a new matrix
  73512. */
  73513. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  73514. /**
  73515. * Computes a reflection matrix from a plane
  73516. * @param plane defines the reflection plane
  73517. * @param result defines the target matrix
  73518. */
  73519. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  73520. /**
  73521. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73522. * @param xaxis defines the value of the 1st axis
  73523. * @param yaxis defines the value of the 2nd axis
  73524. * @param zaxis defines the value of the 3rd axis
  73525. * @param result defines the target matrix
  73526. */
  73527. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  73528. /**
  73529. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73530. * @param quat defines the quaternion to use
  73531. * @param result defines the target matrix
  73532. */
  73533. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  73534. }
  73535. /**
  73536. * @hidden
  73537. */
  73538. export class TmpVectors {
  73539. static Vector2: Vector2[];
  73540. static Vector3: Vector3[];
  73541. static Vector4: Vector4[];
  73542. static Quaternion: Quaternion[];
  73543. static Matrix: Matrix[];
  73544. }
  73545. }
  73546. declare module BABYLON {
  73547. /**
  73548. * Defines potential orientation for back face culling
  73549. */
  73550. export enum Orientation {
  73551. /**
  73552. * Clockwise
  73553. */
  73554. CW = 0,
  73555. /** Counter clockwise */
  73556. CCW = 1
  73557. }
  73558. /** Class used to represent a Bezier curve */
  73559. export class BezierCurve {
  73560. /**
  73561. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73562. * @param t defines the time
  73563. * @param x1 defines the left coordinate on X axis
  73564. * @param y1 defines the left coordinate on Y axis
  73565. * @param x2 defines the right coordinate on X axis
  73566. * @param y2 defines the right coordinate on Y axis
  73567. * @returns the interpolated value
  73568. */
  73569. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  73570. }
  73571. /**
  73572. * Defines angle representation
  73573. */
  73574. export class Angle {
  73575. private _radians;
  73576. /**
  73577. * Creates an Angle object of "radians" radians (float).
  73578. * @param radians the angle in radians
  73579. */
  73580. constructor(radians: number);
  73581. /**
  73582. * Get value in degrees
  73583. * @returns the Angle value in degrees (float)
  73584. */
  73585. degrees(): number;
  73586. /**
  73587. * Get value in radians
  73588. * @returns the Angle value in radians (float)
  73589. */
  73590. radians(): number;
  73591. /**
  73592. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73593. * @param a defines first vector
  73594. * @param b defines second vector
  73595. * @returns a new Angle
  73596. */
  73597. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  73598. /**
  73599. * Gets a new Angle object from the given float in radians
  73600. * @param radians defines the angle value in radians
  73601. * @returns a new Angle
  73602. */
  73603. static FromRadians(radians: number): Angle;
  73604. /**
  73605. * Gets a new Angle object from the given float in degrees
  73606. * @param degrees defines the angle value in degrees
  73607. * @returns a new Angle
  73608. */
  73609. static FromDegrees(degrees: number): Angle;
  73610. }
  73611. /**
  73612. * This represents an arc in a 2d space.
  73613. */
  73614. export class Arc2 {
  73615. /** Defines the start point of the arc */
  73616. startPoint: Vector2;
  73617. /** Defines the mid point of the arc */
  73618. midPoint: Vector2;
  73619. /** Defines the end point of the arc */
  73620. endPoint: Vector2;
  73621. /**
  73622. * Defines the center point of the arc.
  73623. */
  73624. centerPoint: Vector2;
  73625. /**
  73626. * Defines the radius of the arc.
  73627. */
  73628. radius: number;
  73629. /**
  73630. * Defines the angle of the arc (from mid point to end point).
  73631. */
  73632. angle: Angle;
  73633. /**
  73634. * Defines the start angle of the arc (from start point to middle point).
  73635. */
  73636. startAngle: Angle;
  73637. /**
  73638. * Defines the orientation of the arc (clock wise/counter clock wise).
  73639. */
  73640. orientation: Orientation;
  73641. /**
  73642. * Creates an Arc object from the three given points : start, middle and end.
  73643. * @param startPoint Defines the start point of the arc
  73644. * @param midPoint Defines the midlle point of the arc
  73645. * @param endPoint Defines the end point of the arc
  73646. */
  73647. constructor(
  73648. /** Defines the start point of the arc */
  73649. startPoint: Vector2,
  73650. /** Defines the mid point of the arc */
  73651. midPoint: Vector2,
  73652. /** Defines the end point of the arc */
  73653. endPoint: Vector2);
  73654. }
  73655. /**
  73656. * Represents a 2D path made up of multiple 2D points
  73657. */
  73658. export class Path2 {
  73659. private _points;
  73660. private _length;
  73661. /**
  73662. * If the path start and end point are the same
  73663. */
  73664. closed: boolean;
  73665. /**
  73666. * Creates a Path2 object from the starting 2D coordinates x and y.
  73667. * @param x the starting points x value
  73668. * @param y the starting points y value
  73669. */
  73670. constructor(x: number, y: number);
  73671. /**
  73672. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73673. * @param x the added points x value
  73674. * @param y the added points y value
  73675. * @returns the updated Path2.
  73676. */
  73677. addLineTo(x: number, y: number): Path2;
  73678. /**
  73679. * 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.
  73680. * @param midX middle point x value
  73681. * @param midY middle point y value
  73682. * @param endX end point x value
  73683. * @param endY end point y value
  73684. * @param numberOfSegments (default: 36)
  73685. * @returns the updated Path2.
  73686. */
  73687. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  73688. /**
  73689. * Closes the Path2.
  73690. * @returns the Path2.
  73691. */
  73692. close(): Path2;
  73693. /**
  73694. * Gets the sum of the distance between each sequential point in the path
  73695. * @returns the Path2 total length (float).
  73696. */
  73697. length(): number;
  73698. /**
  73699. * Gets the points which construct the path
  73700. * @returns the Path2 internal array of points.
  73701. */
  73702. getPoints(): Vector2[];
  73703. /**
  73704. * Retreives the point at the distance aways from the starting point
  73705. * @param normalizedLengthPosition the length along the path to retreive the point from
  73706. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73707. */
  73708. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  73709. /**
  73710. * Creates a new path starting from an x and y position
  73711. * @param x starting x value
  73712. * @param y starting y value
  73713. * @returns a new Path2 starting at the coordinates (x, y).
  73714. */
  73715. static StartingAt(x: number, y: number): Path2;
  73716. }
  73717. /**
  73718. * Represents a 3D path made up of multiple 3D points
  73719. */
  73720. export class Path3D {
  73721. /**
  73722. * an array of Vector3, the curve axis of the Path3D
  73723. */
  73724. path: Vector3[];
  73725. private _curve;
  73726. private _distances;
  73727. private _tangents;
  73728. private _normals;
  73729. private _binormals;
  73730. private _raw;
  73731. private _alignTangentsWithPath;
  73732. private readonly _pointAtData;
  73733. /**
  73734. * new Path3D(path, normal, raw)
  73735. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73736. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73737. * @param path an array of Vector3, the curve axis of the Path3D
  73738. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73739. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73740. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  73741. */
  73742. constructor(
  73743. /**
  73744. * an array of Vector3, the curve axis of the Path3D
  73745. */
  73746. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  73747. /**
  73748. * Returns the Path3D array of successive Vector3 designing its curve.
  73749. * @returns the Path3D array of successive Vector3 designing its curve.
  73750. */
  73751. getCurve(): Vector3[];
  73752. /**
  73753. * Returns the Path3D array of successive Vector3 designing its curve.
  73754. * @returns the Path3D array of successive Vector3 designing its curve.
  73755. */
  73756. getPoints(): Vector3[];
  73757. /**
  73758. * @returns the computed length (float) of the path.
  73759. */
  73760. length(): number;
  73761. /**
  73762. * Returns an array populated with tangent vectors on each Path3D curve point.
  73763. * @returns an array populated with tangent vectors on each Path3D curve point.
  73764. */
  73765. getTangents(): Vector3[];
  73766. /**
  73767. * Returns an array populated with normal vectors on each Path3D curve point.
  73768. * @returns an array populated with normal vectors on each Path3D curve point.
  73769. */
  73770. getNormals(): Vector3[];
  73771. /**
  73772. * Returns an array populated with binormal vectors on each Path3D curve point.
  73773. * @returns an array populated with binormal vectors on each Path3D curve point.
  73774. */
  73775. getBinormals(): Vector3[];
  73776. /**
  73777. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73778. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73779. */
  73780. getDistances(): number[];
  73781. /**
  73782. * Returns an interpolated point along this path
  73783. * @param position the position of the point along this path, from 0.0 to 1.0
  73784. * @returns a new Vector3 as the point
  73785. */
  73786. getPointAt(position: number): Vector3;
  73787. /**
  73788. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73789. * @param position the position of the point along this path, from 0.0 to 1.0
  73790. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  73791. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  73792. */
  73793. getTangentAt(position: number, interpolated?: boolean): Vector3;
  73794. /**
  73795. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73796. * @param position the position of the point along this path, from 0.0 to 1.0
  73797. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  73798. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  73799. */
  73800. getNormalAt(position: number, interpolated?: boolean): Vector3;
  73801. /**
  73802. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  73803. * @param position the position of the point along this path, from 0.0 to 1.0
  73804. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  73805. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  73806. */
  73807. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  73808. /**
  73809. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  73810. * @param position the position of the point along this path, from 0.0 to 1.0
  73811. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  73812. */
  73813. getDistanceAt(position: number): number;
  73814. /**
  73815. * Returns the array index of the previous point of an interpolated point along this path
  73816. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73817. * @returns the array index
  73818. */
  73819. getPreviousPointIndexAt(position: number): number;
  73820. /**
  73821. * 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)
  73822. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73823. * @returns the sub position
  73824. */
  73825. getSubPositionAt(position: number): number;
  73826. /**
  73827. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  73828. * @param target the vector of which to get the closest position to
  73829. * @returns the position of the closest virtual point on this path to the target vector
  73830. */
  73831. getClosestPositionTo(target: Vector3): number;
  73832. /**
  73833. * Returns a sub path (slice) of this path
  73834. * @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
  73835. * @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
  73836. * @returns a sub path (slice) of this path
  73837. */
  73838. slice(start?: number, end?: number): Path3D;
  73839. /**
  73840. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73841. * @param path path which all values are copied into the curves points
  73842. * @param firstNormal which should be projected onto the curve
  73843. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73844. * @returns the same object updated.
  73845. */
  73846. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73847. private _compute;
  73848. private _getFirstNonNullVector;
  73849. private _getLastNonNullVector;
  73850. private _normalVector;
  73851. /**
  73852. * Updates the point at data for an interpolated point along this curve
  73853. * @param position the position of the point along this curve, from 0.0 to 1.0
  73854. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73855. * @returns the (updated) point at data
  73856. */
  73857. private _updatePointAtData;
  73858. /**
  73859. * Updates the point at data from the specified parameters
  73860. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73861. * @param point the interpolated point
  73862. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73863. */
  73864. private _setPointAtData;
  73865. /**
  73866. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73867. */
  73868. private _updateInterpolationMatrix;
  73869. }
  73870. /**
  73871. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73872. * A Curve3 is designed from a series of successive Vector3.
  73873. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73874. */
  73875. export class Curve3 {
  73876. private _points;
  73877. private _length;
  73878. /**
  73879. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73880. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73881. * @param v1 (Vector3) the control point
  73882. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73883. * @param nbPoints (integer) the wanted number of points in the curve
  73884. * @returns the created Curve3
  73885. */
  73886. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73887. /**
  73888. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73889. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73890. * @param v1 (Vector3) the first control point
  73891. * @param v2 (Vector3) the second control point
  73892. * @param v3 (Vector3) the end point of the Cubic Bezier
  73893. * @param nbPoints (integer) the wanted number of points in the curve
  73894. * @returns the created Curve3
  73895. */
  73896. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73897. /**
  73898. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73899. * @param p1 (Vector3) the origin point of the Hermite Spline
  73900. * @param t1 (Vector3) the tangent vector at the origin point
  73901. * @param p2 (Vector3) the end point of the Hermite Spline
  73902. * @param t2 (Vector3) the tangent vector at the end point
  73903. * @param nbPoints (integer) the wanted number of points in the curve
  73904. * @returns the created Curve3
  73905. */
  73906. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73907. /**
  73908. * Returns a Curve3 object along a CatmullRom Spline curve :
  73909. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73910. * @param nbPoints (integer) the wanted number of points between each curve control points
  73911. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73912. * @returns the created Curve3
  73913. */
  73914. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73915. /**
  73916. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73917. * A Curve3 is designed from a series of successive Vector3.
  73918. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73919. * @param points points which make up the curve
  73920. */
  73921. constructor(points: Vector3[]);
  73922. /**
  73923. * @returns the Curve3 stored array of successive Vector3
  73924. */
  73925. getPoints(): Vector3[];
  73926. /**
  73927. * @returns the computed length (float) of the curve.
  73928. */
  73929. length(): number;
  73930. /**
  73931. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73932. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73933. * curveA and curveB keep unchanged.
  73934. * @param curve the curve to continue from this curve
  73935. * @returns the newly constructed curve
  73936. */
  73937. continue(curve: DeepImmutable<Curve3>): Curve3;
  73938. private _computeLength;
  73939. }
  73940. }
  73941. declare module BABYLON {
  73942. /**
  73943. * This represents the main contract an easing function should follow.
  73944. * Easing functions are used throughout the animation system.
  73945. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73946. */
  73947. export interface IEasingFunction {
  73948. /**
  73949. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73950. * of the easing function.
  73951. * The link below provides some of the most common examples of easing functions.
  73952. * @see https://easings.net/
  73953. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73954. * @returns the corresponding value on the curve defined by the easing function
  73955. */
  73956. ease(gradient: number): number;
  73957. }
  73958. /**
  73959. * Base class used for every default easing function.
  73960. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73961. */
  73962. export class EasingFunction implements IEasingFunction {
  73963. /**
  73964. * Interpolation follows the mathematical formula associated with the easing function.
  73965. */
  73966. static readonly EASINGMODE_EASEIN: number;
  73967. /**
  73968. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73969. */
  73970. static readonly EASINGMODE_EASEOUT: number;
  73971. /**
  73972. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73973. */
  73974. static readonly EASINGMODE_EASEINOUT: number;
  73975. private _easingMode;
  73976. /**
  73977. * Sets the easing mode of the current function.
  73978. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73979. */
  73980. setEasingMode(easingMode: number): void;
  73981. /**
  73982. * Gets the current easing mode.
  73983. * @returns the easing mode
  73984. */
  73985. getEasingMode(): number;
  73986. /**
  73987. * @hidden
  73988. */
  73989. easeInCore(gradient: number): number;
  73990. /**
  73991. * Given an input gradient between 0 and 1, this returns the corresponding value
  73992. * of the easing function.
  73993. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73994. * @returns the corresponding value on the curve defined by the easing function
  73995. */
  73996. ease(gradient: number): number;
  73997. }
  73998. /**
  73999. * Easing function with a circle shape (see link below).
  74000. * @see https://easings.net/#easeInCirc
  74001. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74002. */
  74003. export class CircleEase extends EasingFunction implements IEasingFunction {
  74004. /** @hidden */
  74005. easeInCore(gradient: number): number;
  74006. }
  74007. /**
  74008. * Easing function with a ease back shape (see link below).
  74009. * @see https://easings.net/#easeInBack
  74010. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74011. */
  74012. export class BackEase extends EasingFunction implements IEasingFunction {
  74013. /** Defines the amplitude of the function */
  74014. amplitude: number;
  74015. /**
  74016. * Instantiates a back ease easing
  74017. * @see https://easings.net/#easeInBack
  74018. * @param amplitude Defines the amplitude of the function
  74019. */
  74020. constructor(
  74021. /** Defines the amplitude of the function */
  74022. amplitude?: number);
  74023. /** @hidden */
  74024. easeInCore(gradient: number): number;
  74025. }
  74026. /**
  74027. * Easing function with a bouncing shape (see link below).
  74028. * @see https://easings.net/#easeInBounce
  74029. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74030. */
  74031. export class BounceEase extends EasingFunction implements IEasingFunction {
  74032. /** Defines the number of bounces */
  74033. bounces: number;
  74034. /** Defines the amplitude of the bounce */
  74035. bounciness: number;
  74036. /**
  74037. * Instantiates a bounce easing
  74038. * @see https://easings.net/#easeInBounce
  74039. * @param bounces Defines the number of bounces
  74040. * @param bounciness Defines the amplitude of the bounce
  74041. */
  74042. constructor(
  74043. /** Defines the number of bounces */
  74044. bounces?: number,
  74045. /** Defines the amplitude of the bounce */
  74046. bounciness?: number);
  74047. /** @hidden */
  74048. easeInCore(gradient: number): number;
  74049. }
  74050. /**
  74051. * Easing function with a power of 3 shape (see link below).
  74052. * @see https://easings.net/#easeInCubic
  74053. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74054. */
  74055. export class CubicEase extends EasingFunction implements IEasingFunction {
  74056. /** @hidden */
  74057. easeInCore(gradient: number): number;
  74058. }
  74059. /**
  74060. * Easing function with an elastic shape (see link below).
  74061. * @see https://easings.net/#easeInElastic
  74062. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74063. */
  74064. export class ElasticEase extends EasingFunction implements IEasingFunction {
  74065. /** Defines the number of oscillations*/
  74066. oscillations: number;
  74067. /** Defines the amplitude of the oscillations*/
  74068. springiness: number;
  74069. /**
  74070. * Instantiates an elastic easing function
  74071. * @see https://easings.net/#easeInElastic
  74072. * @param oscillations Defines the number of oscillations
  74073. * @param springiness Defines the amplitude of the oscillations
  74074. */
  74075. constructor(
  74076. /** Defines the number of oscillations*/
  74077. oscillations?: number,
  74078. /** Defines the amplitude of the oscillations*/
  74079. springiness?: number);
  74080. /** @hidden */
  74081. easeInCore(gradient: number): number;
  74082. }
  74083. /**
  74084. * Easing function with an exponential shape (see link below).
  74085. * @see https://easings.net/#easeInExpo
  74086. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74087. */
  74088. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  74089. /** Defines the exponent of the function */
  74090. exponent: number;
  74091. /**
  74092. * Instantiates an exponential easing function
  74093. * @see https://easings.net/#easeInExpo
  74094. * @param exponent Defines the exponent of the function
  74095. */
  74096. constructor(
  74097. /** Defines the exponent of the function */
  74098. exponent?: number);
  74099. /** @hidden */
  74100. easeInCore(gradient: number): number;
  74101. }
  74102. /**
  74103. * Easing function with a power shape (see link below).
  74104. * @see https://easings.net/#easeInQuad
  74105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74106. */
  74107. export class PowerEase extends EasingFunction implements IEasingFunction {
  74108. /** Defines the power of the function */
  74109. power: number;
  74110. /**
  74111. * Instantiates an power base easing function
  74112. * @see https://easings.net/#easeInQuad
  74113. * @param power Defines the power of the function
  74114. */
  74115. constructor(
  74116. /** Defines the power of the function */
  74117. power?: number);
  74118. /** @hidden */
  74119. easeInCore(gradient: number): number;
  74120. }
  74121. /**
  74122. * Easing function with a power of 2 shape (see link below).
  74123. * @see https://easings.net/#easeInQuad
  74124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74125. */
  74126. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  74127. /** @hidden */
  74128. easeInCore(gradient: number): number;
  74129. }
  74130. /**
  74131. * Easing function with a power of 4 shape (see link below).
  74132. * @see https://easings.net/#easeInQuart
  74133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74134. */
  74135. export class QuarticEase extends EasingFunction implements IEasingFunction {
  74136. /** @hidden */
  74137. easeInCore(gradient: number): number;
  74138. }
  74139. /**
  74140. * Easing function with a power of 5 shape (see link below).
  74141. * @see https://easings.net/#easeInQuint
  74142. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74143. */
  74144. export class QuinticEase extends EasingFunction implements IEasingFunction {
  74145. /** @hidden */
  74146. easeInCore(gradient: number): number;
  74147. }
  74148. /**
  74149. * Easing function with a sin shape (see link below).
  74150. * @see https://easings.net/#easeInSine
  74151. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74152. */
  74153. export class SineEase extends EasingFunction implements IEasingFunction {
  74154. /** @hidden */
  74155. easeInCore(gradient: number): number;
  74156. }
  74157. /**
  74158. * Easing function with a bezier shape (see link below).
  74159. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74161. */
  74162. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  74163. /** Defines the x component of the start tangent in the bezier curve */
  74164. x1: number;
  74165. /** Defines the y component of the start tangent in the bezier curve */
  74166. y1: number;
  74167. /** Defines the x component of the end tangent in the bezier curve */
  74168. x2: number;
  74169. /** Defines the y component of the end tangent in the bezier curve */
  74170. y2: number;
  74171. /**
  74172. * Instantiates a bezier function
  74173. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74174. * @param x1 Defines the x component of the start tangent in the bezier curve
  74175. * @param y1 Defines the y component of the start tangent in the bezier curve
  74176. * @param x2 Defines the x component of the end tangent in the bezier curve
  74177. * @param y2 Defines the y component of the end tangent in the bezier curve
  74178. */
  74179. constructor(
  74180. /** Defines the x component of the start tangent in the bezier curve */
  74181. x1?: number,
  74182. /** Defines the y component of the start tangent in the bezier curve */
  74183. y1?: number,
  74184. /** Defines the x component of the end tangent in the bezier curve */
  74185. x2?: number,
  74186. /** Defines the y component of the end tangent in the bezier curve */
  74187. y2?: number);
  74188. /** @hidden */
  74189. easeInCore(gradient: number): number;
  74190. }
  74191. }
  74192. declare module BABYLON {
  74193. /**
  74194. * Class used to hold a RBG color
  74195. */
  74196. export class Color3 {
  74197. /**
  74198. * Defines the red component (between 0 and 1, default is 0)
  74199. */
  74200. r: number;
  74201. /**
  74202. * Defines the green component (between 0 and 1, default is 0)
  74203. */
  74204. g: number;
  74205. /**
  74206. * Defines the blue component (between 0 and 1, default is 0)
  74207. */
  74208. b: number;
  74209. /**
  74210. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  74211. * @param r defines the red component (between 0 and 1, default is 0)
  74212. * @param g defines the green component (between 0 and 1, default is 0)
  74213. * @param b defines the blue component (between 0 and 1, default is 0)
  74214. */
  74215. constructor(
  74216. /**
  74217. * Defines the red component (between 0 and 1, default is 0)
  74218. */
  74219. r?: number,
  74220. /**
  74221. * Defines the green component (between 0 and 1, default is 0)
  74222. */
  74223. g?: number,
  74224. /**
  74225. * Defines the blue component (between 0 and 1, default is 0)
  74226. */
  74227. b?: number);
  74228. /**
  74229. * Creates a string with the Color3 current values
  74230. * @returns the string representation of the Color3 object
  74231. */
  74232. toString(): string;
  74233. /**
  74234. * Returns the string "Color3"
  74235. * @returns "Color3"
  74236. */
  74237. getClassName(): string;
  74238. /**
  74239. * Compute the Color3 hash code
  74240. * @returns an unique number that can be used to hash Color3 objects
  74241. */
  74242. getHashCode(): number;
  74243. /**
  74244. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  74245. * @param array defines the array where to store the r,g,b components
  74246. * @param index defines an optional index in the target array to define where to start storing values
  74247. * @returns the current Color3 object
  74248. */
  74249. toArray(array: FloatArray, index?: number): Color3;
  74250. /**
  74251. * Returns a new Color4 object from the current Color3 and the given alpha
  74252. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  74253. * @returns a new Color4 object
  74254. */
  74255. toColor4(alpha?: number): Color4;
  74256. /**
  74257. * Returns a new array populated with 3 numeric elements : red, green and blue values
  74258. * @returns the new array
  74259. */
  74260. asArray(): number[];
  74261. /**
  74262. * Returns the luminance value
  74263. * @returns a float value
  74264. */
  74265. toLuminance(): number;
  74266. /**
  74267. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  74268. * @param otherColor defines the second operand
  74269. * @returns the new Color3 object
  74270. */
  74271. multiply(otherColor: DeepImmutable<Color3>): Color3;
  74272. /**
  74273. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  74274. * @param otherColor defines the second operand
  74275. * @param result defines the Color3 object where to store the result
  74276. * @returns the current Color3
  74277. */
  74278. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74279. /**
  74280. * Determines equality between Color3 objects
  74281. * @param otherColor defines the second operand
  74282. * @returns true if the rgb values are equal to the given ones
  74283. */
  74284. equals(otherColor: DeepImmutable<Color3>): boolean;
  74285. /**
  74286. * Determines equality between the current Color3 object and a set of r,b,g values
  74287. * @param r defines the red component to check
  74288. * @param g defines the green component to check
  74289. * @param b defines the blue component to check
  74290. * @returns true if the rgb values are equal to the given ones
  74291. */
  74292. equalsFloats(r: number, g: number, b: number): boolean;
  74293. /**
  74294. * Multiplies in place each rgb value by scale
  74295. * @param scale defines the scaling factor
  74296. * @returns the updated Color3
  74297. */
  74298. scale(scale: number): Color3;
  74299. /**
  74300. * Multiplies the rgb values by scale and stores the result into "result"
  74301. * @param scale defines the scaling factor
  74302. * @param result defines the Color3 object where to store the result
  74303. * @returns the unmodified current Color3
  74304. */
  74305. scaleToRef(scale: number, result: Color3): Color3;
  74306. /**
  74307. * Scale the current Color3 values by a factor and add the result to a given Color3
  74308. * @param scale defines the scale factor
  74309. * @param result defines color to store the result into
  74310. * @returns the unmodified current Color3
  74311. */
  74312. scaleAndAddToRef(scale: number, result: Color3): Color3;
  74313. /**
  74314. * Clamps the rgb values by the min and max values and stores the result into "result"
  74315. * @param min defines minimum clamping value (default is 0)
  74316. * @param max defines maximum clamping value (default is 1)
  74317. * @param result defines color to store the result into
  74318. * @returns the original Color3
  74319. */
  74320. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  74321. /**
  74322. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  74323. * @param otherColor defines the second operand
  74324. * @returns the new Color3
  74325. */
  74326. add(otherColor: DeepImmutable<Color3>): Color3;
  74327. /**
  74328. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  74329. * @param otherColor defines the second operand
  74330. * @param result defines Color3 object to store the result into
  74331. * @returns the unmodified current Color3
  74332. */
  74333. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74334. /**
  74335. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  74336. * @param otherColor defines the second operand
  74337. * @returns the new Color3
  74338. */
  74339. subtract(otherColor: DeepImmutable<Color3>): Color3;
  74340. /**
  74341. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  74342. * @param otherColor defines the second operand
  74343. * @param result defines Color3 object to store the result into
  74344. * @returns the unmodified current Color3
  74345. */
  74346. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74347. /**
  74348. * Copy the current object
  74349. * @returns a new Color3 copied the current one
  74350. */
  74351. clone(): Color3;
  74352. /**
  74353. * Copies the rgb values from the source in the current Color3
  74354. * @param source defines the source Color3 object
  74355. * @returns the updated Color3 object
  74356. */
  74357. copyFrom(source: DeepImmutable<Color3>): Color3;
  74358. /**
  74359. * Updates the Color3 rgb values from the given floats
  74360. * @param r defines the red component to read from
  74361. * @param g defines the green component to read from
  74362. * @param b defines the blue component to read from
  74363. * @returns the current Color3 object
  74364. */
  74365. copyFromFloats(r: number, g: number, b: number): Color3;
  74366. /**
  74367. * Updates the Color3 rgb values from the given floats
  74368. * @param r defines the red component to read from
  74369. * @param g defines the green component to read from
  74370. * @param b defines the blue component to read from
  74371. * @returns the current Color3 object
  74372. */
  74373. set(r: number, g: number, b: number): Color3;
  74374. /**
  74375. * Compute the Color3 hexadecimal code as a string
  74376. * @returns a string containing the hexadecimal representation of the Color3 object
  74377. */
  74378. toHexString(): string;
  74379. /**
  74380. * Computes a new Color3 converted from the current one to linear space
  74381. * @returns a new Color3 object
  74382. */
  74383. toLinearSpace(): Color3;
  74384. /**
  74385. * Converts current color in rgb space to HSV values
  74386. * @returns a new color3 representing the HSV values
  74387. */
  74388. toHSV(): Color3;
  74389. /**
  74390. * Converts current color in rgb space to HSV values
  74391. * @param result defines the Color3 where to store the HSV values
  74392. */
  74393. toHSVToRef(result: Color3): void;
  74394. /**
  74395. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  74396. * @param convertedColor defines the Color3 object where to store the linear space version
  74397. * @returns the unmodified Color3
  74398. */
  74399. toLinearSpaceToRef(convertedColor: Color3): Color3;
  74400. /**
  74401. * Computes a new Color3 converted from the current one to gamma space
  74402. * @returns a new Color3 object
  74403. */
  74404. toGammaSpace(): Color3;
  74405. /**
  74406. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  74407. * @param convertedColor defines the Color3 object where to store the gamma space version
  74408. * @returns the unmodified Color3
  74409. */
  74410. toGammaSpaceToRef(convertedColor: Color3): Color3;
  74411. private static _BlackReadOnly;
  74412. /**
  74413. * Convert Hue, saturation and value to a Color3 (RGB)
  74414. * @param hue defines the hue
  74415. * @param saturation defines the saturation
  74416. * @param value defines the value
  74417. * @param result defines the Color3 where to store the RGB values
  74418. */
  74419. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  74420. /**
  74421. * Creates a new Color3 from the string containing valid hexadecimal values
  74422. * @param hex defines a string containing valid hexadecimal values
  74423. * @returns a new Color3 object
  74424. */
  74425. static FromHexString(hex: string): Color3;
  74426. /**
  74427. * Creates a new Color3 from the starting index of the given array
  74428. * @param array defines the source array
  74429. * @param offset defines an offset in the source array
  74430. * @returns a new Color3 object
  74431. */
  74432. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  74433. /**
  74434. * Creates a new Color3 from integer values (< 256)
  74435. * @param r defines the red component to read from (value between 0 and 255)
  74436. * @param g defines the green component to read from (value between 0 and 255)
  74437. * @param b defines the blue component to read from (value between 0 and 255)
  74438. * @returns a new Color3 object
  74439. */
  74440. static FromInts(r: number, g: number, b: number): Color3;
  74441. /**
  74442. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74443. * @param start defines the start Color3 value
  74444. * @param end defines the end Color3 value
  74445. * @param amount defines the gradient value between start and end
  74446. * @returns a new Color3 object
  74447. */
  74448. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  74449. /**
  74450. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74451. * @param left defines the start value
  74452. * @param right defines the end value
  74453. * @param amount defines the gradient factor
  74454. * @param result defines the Color3 object where to store the result
  74455. */
  74456. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  74457. /**
  74458. * Returns a Color3 value containing a red color
  74459. * @returns a new Color3 object
  74460. */
  74461. static Red(): Color3;
  74462. /**
  74463. * Returns a Color3 value containing a green color
  74464. * @returns a new Color3 object
  74465. */
  74466. static Green(): Color3;
  74467. /**
  74468. * Returns a Color3 value containing a blue color
  74469. * @returns a new Color3 object
  74470. */
  74471. static Blue(): Color3;
  74472. /**
  74473. * Returns a Color3 value containing a black color
  74474. * @returns a new Color3 object
  74475. */
  74476. static Black(): Color3;
  74477. /**
  74478. * Gets a Color3 value containing a black color that must not be updated
  74479. */
  74480. static readonly BlackReadOnly: DeepImmutable<Color3>;
  74481. /**
  74482. * Returns a Color3 value containing a white color
  74483. * @returns a new Color3 object
  74484. */
  74485. static White(): Color3;
  74486. /**
  74487. * Returns a Color3 value containing a purple color
  74488. * @returns a new Color3 object
  74489. */
  74490. static Purple(): Color3;
  74491. /**
  74492. * Returns a Color3 value containing a magenta color
  74493. * @returns a new Color3 object
  74494. */
  74495. static Magenta(): Color3;
  74496. /**
  74497. * Returns a Color3 value containing a yellow color
  74498. * @returns a new Color3 object
  74499. */
  74500. static Yellow(): Color3;
  74501. /**
  74502. * Returns a Color3 value containing a gray color
  74503. * @returns a new Color3 object
  74504. */
  74505. static Gray(): Color3;
  74506. /**
  74507. * Returns a Color3 value containing a teal color
  74508. * @returns a new Color3 object
  74509. */
  74510. static Teal(): Color3;
  74511. /**
  74512. * Returns a Color3 value containing a random color
  74513. * @returns a new Color3 object
  74514. */
  74515. static Random(): Color3;
  74516. }
  74517. /**
  74518. * Class used to hold a RBGA color
  74519. */
  74520. export class Color4 {
  74521. /**
  74522. * Defines the red component (between 0 and 1, default is 0)
  74523. */
  74524. r: number;
  74525. /**
  74526. * Defines the green component (between 0 and 1, default is 0)
  74527. */
  74528. g: number;
  74529. /**
  74530. * Defines the blue component (between 0 and 1, default is 0)
  74531. */
  74532. b: number;
  74533. /**
  74534. * Defines the alpha component (between 0 and 1, default is 1)
  74535. */
  74536. a: number;
  74537. /**
  74538. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  74539. * @param r defines the red component (between 0 and 1, default is 0)
  74540. * @param g defines the green component (between 0 and 1, default is 0)
  74541. * @param b defines the blue component (between 0 and 1, default is 0)
  74542. * @param a defines the alpha component (between 0 and 1, default is 1)
  74543. */
  74544. constructor(
  74545. /**
  74546. * Defines the red component (between 0 and 1, default is 0)
  74547. */
  74548. r?: number,
  74549. /**
  74550. * Defines the green component (between 0 and 1, default is 0)
  74551. */
  74552. g?: number,
  74553. /**
  74554. * Defines the blue component (between 0 and 1, default is 0)
  74555. */
  74556. b?: number,
  74557. /**
  74558. * Defines the alpha component (between 0 and 1, default is 1)
  74559. */
  74560. a?: number);
  74561. /**
  74562. * Adds in place the given Color4 values to the current Color4 object
  74563. * @param right defines the second operand
  74564. * @returns the current updated Color4 object
  74565. */
  74566. addInPlace(right: DeepImmutable<Color4>): Color4;
  74567. /**
  74568. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  74569. * @returns the new array
  74570. */
  74571. asArray(): number[];
  74572. /**
  74573. * Stores from the starting index in the given array the Color4 successive values
  74574. * @param array defines the array where to store the r,g,b components
  74575. * @param index defines an optional index in the target array to define where to start storing values
  74576. * @returns the current Color4 object
  74577. */
  74578. toArray(array: number[], index?: number): Color4;
  74579. /**
  74580. * Determines equality between Color4 objects
  74581. * @param otherColor defines the second operand
  74582. * @returns true if the rgba values are equal to the given ones
  74583. */
  74584. equals(otherColor: DeepImmutable<Color4>): boolean;
  74585. /**
  74586. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  74587. * @param right defines the second operand
  74588. * @returns a new Color4 object
  74589. */
  74590. add(right: DeepImmutable<Color4>): Color4;
  74591. /**
  74592. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  74593. * @param right defines the second operand
  74594. * @returns a new Color4 object
  74595. */
  74596. subtract(right: DeepImmutable<Color4>): Color4;
  74597. /**
  74598. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  74599. * @param right defines the second operand
  74600. * @param result defines the Color4 object where to store the result
  74601. * @returns the current Color4 object
  74602. */
  74603. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  74604. /**
  74605. * Creates a new Color4 with the current Color4 values multiplied by scale
  74606. * @param scale defines the scaling factor to apply
  74607. * @returns a new Color4 object
  74608. */
  74609. scale(scale: number): Color4;
  74610. /**
  74611. * Multiplies the current Color4 values by scale and stores the result in "result"
  74612. * @param scale defines the scaling factor to apply
  74613. * @param result defines the Color4 object where to store the result
  74614. * @returns the current unmodified Color4
  74615. */
  74616. scaleToRef(scale: number, result: Color4): Color4;
  74617. /**
  74618. * Scale the current Color4 values by a factor and add the result to a given Color4
  74619. * @param scale defines the scale factor
  74620. * @param result defines the Color4 object where to store the result
  74621. * @returns the unmodified current Color4
  74622. */
  74623. scaleAndAddToRef(scale: number, result: Color4): Color4;
  74624. /**
  74625. * Clamps the rgb values by the min and max values and stores the result into "result"
  74626. * @param min defines minimum clamping value (default is 0)
  74627. * @param max defines maximum clamping value (default is 1)
  74628. * @param result defines color to store the result into.
  74629. * @returns the cuurent Color4
  74630. */
  74631. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  74632. /**
  74633. * Multipy an Color4 value by another and return a new Color4 object
  74634. * @param color defines the Color4 value to multiply by
  74635. * @returns a new Color4 object
  74636. */
  74637. multiply(color: Color4): Color4;
  74638. /**
  74639. * Multipy a Color4 value by another and push the result in a reference value
  74640. * @param color defines the Color4 value to multiply by
  74641. * @param result defines the Color4 to fill the result in
  74642. * @returns the result Color4
  74643. */
  74644. multiplyToRef(color: Color4, result: Color4): Color4;
  74645. /**
  74646. * Creates a string with the Color4 current values
  74647. * @returns the string representation of the Color4 object
  74648. */
  74649. toString(): string;
  74650. /**
  74651. * Returns the string "Color4"
  74652. * @returns "Color4"
  74653. */
  74654. getClassName(): string;
  74655. /**
  74656. * Compute the Color4 hash code
  74657. * @returns an unique number that can be used to hash Color4 objects
  74658. */
  74659. getHashCode(): number;
  74660. /**
  74661. * Creates a new Color4 copied from the current one
  74662. * @returns a new Color4 object
  74663. */
  74664. clone(): Color4;
  74665. /**
  74666. * Copies the given Color4 values into the current one
  74667. * @param source defines the source Color4 object
  74668. * @returns the current updated Color4 object
  74669. */
  74670. copyFrom(source: Color4): Color4;
  74671. /**
  74672. * Copies the given float values into the current one
  74673. * @param r defines the red component to read from
  74674. * @param g defines the green component to read from
  74675. * @param b defines the blue component to read from
  74676. * @param a defines the alpha component to read from
  74677. * @returns the current updated Color4 object
  74678. */
  74679. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  74680. /**
  74681. * Copies the given float values into the current one
  74682. * @param r defines the red component to read from
  74683. * @param g defines the green component to read from
  74684. * @param b defines the blue component to read from
  74685. * @param a defines the alpha component to read from
  74686. * @returns the current updated Color4 object
  74687. */
  74688. set(r: number, g: number, b: number, a: number): Color4;
  74689. /**
  74690. * Compute the Color4 hexadecimal code as a string
  74691. * @returns a string containing the hexadecimal representation of the Color4 object
  74692. */
  74693. toHexString(): string;
  74694. /**
  74695. * Computes a new Color4 converted from the current one to linear space
  74696. * @returns a new Color4 object
  74697. */
  74698. toLinearSpace(): Color4;
  74699. /**
  74700. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  74701. * @param convertedColor defines the Color4 object where to store the linear space version
  74702. * @returns the unmodified Color4
  74703. */
  74704. toLinearSpaceToRef(convertedColor: Color4): Color4;
  74705. /**
  74706. * Computes a new Color4 converted from the current one to gamma space
  74707. * @returns a new Color4 object
  74708. */
  74709. toGammaSpace(): Color4;
  74710. /**
  74711. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  74712. * @param convertedColor defines the Color4 object where to store the gamma space version
  74713. * @returns the unmodified Color4
  74714. */
  74715. toGammaSpaceToRef(convertedColor: Color4): Color4;
  74716. /**
  74717. * Creates a new Color4 from the string containing valid hexadecimal values
  74718. * @param hex defines a string containing valid hexadecimal values
  74719. * @returns a new Color4 object
  74720. */
  74721. static FromHexString(hex: string): Color4;
  74722. /**
  74723. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74724. * @param left defines the start value
  74725. * @param right defines the end value
  74726. * @param amount defines the gradient factor
  74727. * @returns a new Color4 object
  74728. */
  74729. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  74730. /**
  74731. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74732. * @param left defines the start value
  74733. * @param right defines the end value
  74734. * @param amount defines the gradient factor
  74735. * @param result defines the Color4 object where to store data
  74736. */
  74737. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  74738. /**
  74739. * Creates a new Color4 from a Color3 and an alpha value
  74740. * @param color3 defines the source Color3 to read from
  74741. * @param alpha defines the alpha component (1.0 by default)
  74742. * @returns a new Color4 object
  74743. */
  74744. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  74745. /**
  74746. * Creates a new Color4 from the starting index element of the given array
  74747. * @param array defines the source array to read from
  74748. * @param offset defines the offset in the source array
  74749. * @returns a new Color4 object
  74750. */
  74751. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  74752. /**
  74753. * Creates a new Color3 from integer values (< 256)
  74754. * @param r defines the red component to read from (value between 0 and 255)
  74755. * @param g defines the green component to read from (value between 0 and 255)
  74756. * @param b defines the blue component to read from (value between 0 and 255)
  74757. * @param a defines the alpha component to read from (value between 0 and 255)
  74758. * @returns a new Color3 object
  74759. */
  74760. static FromInts(r: number, g: number, b: number, a: number): Color4;
  74761. /**
  74762. * Check the content of a given array and convert it to an array containing RGBA data
  74763. * If the original array was already containing count * 4 values then it is returned directly
  74764. * @param colors defines the array to check
  74765. * @param count defines the number of RGBA data to expect
  74766. * @returns an array containing count * 4 values (RGBA)
  74767. */
  74768. static CheckColors4(colors: number[], count: number): number[];
  74769. }
  74770. /**
  74771. * @hidden
  74772. */
  74773. export class TmpColors {
  74774. static Color3: Color3[];
  74775. static Color4: Color4[];
  74776. }
  74777. }
  74778. declare module BABYLON {
  74779. /**
  74780. * Defines an interface which represents an animation key frame
  74781. */
  74782. export interface IAnimationKey {
  74783. /**
  74784. * Frame of the key frame
  74785. */
  74786. frame: number;
  74787. /**
  74788. * Value at the specifies key frame
  74789. */
  74790. value: any;
  74791. /**
  74792. * The input tangent for the cubic hermite spline
  74793. */
  74794. inTangent?: any;
  74795. /**
  74796. * The output tangent for the cubic hermite spline
  74797. */
  74798. outTangent?: any;
  74799. /**
  74800. * The animation interpolation type
  74801. */
  74802. interpolation?: AnimationKeyInterpolation;
  74803. }
  74804. /**
  74805. * Enum for the animation key frame interpolation type
  74806. */
  74807. export enum AnimationKeyInterpolation {
  74808. /**
  74809. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  74810. */
  74811. STEP = 1
  74812. }
  74813. }
  74814. declare module BABYLON {
  74815. /**
  74816. * Represents the range of an animation
  74817. */
  74818. export class AnimationRange {
  74819. /**The name of the animation range**/
  74820. name: string;
  74821. /**The starting frame of the animation */
  74822. from: number;
  74823. /**The ending frame of the animation*/
  74824. to: number;
  74825. /**
  74826. * Initializes the range of an animation
  74827. * @param name The name of the animation range
  74828. * @param from The starting frame of the animation
  74829. * @param to The ending frame of the animation
  74830. */
  74831. constructor(
  74832. /**The name of the animation range**/
  74833. name: string,
  74834. /**The starting frame of the animation */
  74835. from: number,
  74836. /**The ending frame of the animation*/
  74837. to: number);
  74838. /**
  74839. * Makes a copy of the animation range
  74840. * @returns A copy of the animation range
  74841. */
  74842. clone(): AnimationRange;
  74843. }
  74844. }
  74845. declare module BABYLON {
  74846. /**
  74847. * Composed of a frame, and an action function
  74848. */
  74849. export class AnimationEvent {
  74850. /** The frame for which the event is triggered **/
  74851. frame: number;
  74852. /** The event to perform when triggered **/
  74853. action: (currentFrame: number) => void;
  74854. /** Specifies if the event should be triggered only once**/
  74855. onlyOnce?: boolean | undefined;
  74856. /**
  74857. * Specifies if the animation event is done
  74858. */
  74859. isDone: boolean;
  74860. /**
  74861. * Initializes the animation event
  74862. * @param frame The frame for which the event is triggered
  74863. * @param action The event to perform when triggered
  74864. * @param onlyOnce Specifies if the event should be triggered only once
  74865. */
  74866. constructor(
  74867. /** The frame for which the event is triggered **/
  74868. frame: number,
  74869. /** The event to perform when triggered **/
  74870. action: (currentFrame: number) => void,
  74871. /** Specifies if the event should be triggered only once**/
  74872. onlyOnce?: boolean | undefined);
  74873. /** @hidden */
  74874. _clone(): AnimationEvent;
  74875. }
  74876. }
  74877. declare module BABYLON {
  74878. /**
  74879. * Interface used to define a behavior
  74880. */
  74881. export interface Behavior<T> {
  74882. /** gets or sets behavior's name */
  74883. name: string;
  74884. /**
  74885. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74886. */
  74887. init(): void;
  74888. /**
  74889. * Called when the behavior is attached to a target
  74890. * @param target defines the target where the behavior is attached to
  74891. */
  74892. attach(target: T): void;
  74893. /**
  74894. * Called when the behavior is detached from its target
  74895. */
  74896. detach(): void;
  74897. }
  74898. /**
  74899. * Interface implemented by classes supporting behaviors
  74900. */
  74901. export interface IBehaviorAware<T> {
  74902. /**
  74903. * Attach a behavior
  74904. * @param behavior defines the behavior to attach
  74905. * @returns the current host
  74906. */
  74907. addBehavior(behavior: Behavior<T>): T;
  74908. /**
  74909. * Remove a behavior from the current object
  74910. * @param behavior defines the behavior to detach
  74911. * @returns the current host
  74912. */
  74913. removeBehavior(behavior: Behavior<T>): T;
  74914. /**
  74915. * Gets a behavior using its name to search
  74916. * @param name defines the name to search
  74917. * @returns the behavior or null if not found
  74918. */
  74919. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74920. }
  74921. }
  74922. declare module BABYLON {
  74923. /**
  74924. * Defines an array and its length.
  74925. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74926. */
  74927. export interface ISmartArrayLike<T> {
  74928. /**
  74929. * The data of the array.
  74930. */
  74931. data: Array<T>;
  74932. /**
  74933. * The active length of the array.
  74934. */
  74935. length: number;
  74936. }
  74937. /**
  74938. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74939. */
  74940. export class SmartArray<T> implements ISmartArrayLike<T> {
  74941. /**
  74942. * The full set of data from the array.
  74943. */
  74944. data: Array<T>;
  74945. /**
  74946. * The active length of the array.
  74947. */
  74948. length: number;
  74949. protected _id: number;
  74950. /**
  74951. * Instantiates a Smart Array.
  74952. * @param capacity defines the default capacity of the array.
  74953. */
  74954. constructor(capacity: number);
  74955. /**
  74956. * Pushes a value at the end of the active data.
  74957. * @param value defines the object to push in the array.
  74958. */
  74959. push(value: T): void;
  74960. /**
  74961. * Iterates over the active data and apply the lambda to them.
  74962. * @param func defines the action to apply on each value.
  74963. */
  74964. forEach(func: (content: T) => void): void;
  74965. /**
  74966. * Sorts the full sets of data.
  74967. * @param compareFn defines the comparison function to apply.
  74968. */
  74969. sort(compareFn: (a: T, b: T) => number): void;
  74970. /**
  74971. * Resets the active data to an empty array.
  74972. */
  74973. reset(): void;
  74974. /**
  74975. * Releases all the data from the array as well as the array.
  74976. */
  74977. dispose(): void;
  74978. /**
  74979. * Concats the active data with a given array.
  74980. * @param array defines the data to concatenate with.
  74981. */
  74982. concat(array: any): void;
  74983. /**
  74984. * Returns the position of a value in the active data.
  74985. * @param value defines the value to find the index for
  74986. * @returns the index if found in the active data otherwise -1
  74987. */
  74988. indexOf(value: T): number;
  74989. /**
  74990. * Returns whether an element is part of the active data.
  74991. * @param value defines the value to look for
  74992. * @returns true if found in the active data otherwise false
  74993. */
  74994. contains(value: T): boolean;
  74995. private static _GlobalId;
  74996. }
  74997. /**
  74998. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74999. * The data in this array can only be present once
  75000. */
  75001. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  75002. private _duplicateId;
  75003. /**
  75004. * Pushes a value at the end of the active data.
  75005. * THIS DOES NOT PREVENT DUPPLICATE DATA
  75006. * @param value defines the object to push in the array.
  75007. */
  75008. push(value: T): void;
  75009. /**
  75010. * Pushes a value at the end of the active data.
  75011. * If the data is already present, it won t be added again
  75012. * @param value defines the object to push in the array.
  75013. * @returns true if added false if it was already present
  75014. */
  75015. pushNoDuplicate(value: T): boolean;
  75016. /**
  75017. * Resets the active data to an empty array.
  75018. */
  75019. reset(): void;
  75020. /**
  75021. * Concats the active data with a given array.
  75022. * This ensures no dupplicate will be present in the result.
  75023. * @param array defines the data to concatenate with.
  75024. */
  75025. concatWithNoDuplicate(array: any): void;
  75026. }
  75027. }
  75028. declare module BABYLON {
  75029. /**
  75030. * @ignore
  75031. * This is a list of all the different input types that are available in the application.
  75032. * Fo instance: ArcRotateCameraGamepadInput...
  75033. */
  75034. export var CameraInputTypes: {};
  75035. /**
  75036. * This is the contract to implement in order to create a new input class.
  75037. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  75038. */
  75039. export interface ICameraInput<TCamera extends Camera> {
  75040. /**
  75041. * Defines the camera the input is attached to.
  75042. */
  75043. camera: Nullable<TCamera>;
  75044. /**
  75045. * Gets the class name of the current intput.
  75046. * @returns the class name
  75047. */
  75048. getClassName(): string;
  75049. /**
  75050. * Get the friendly name associated with the input class.
  75051. * @returns the input friendly name
  75052. */
  75053. getSimpleName(): string;
  75054. /**
  75055. * Attach the input controls to a specific dom element to get the input from.
  75056. * @param element Defines the element the controls should be listened from
  75057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75058. */
  75059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75060. /**
  75061. * Detach the current controls from the specified dom element.
  75062. * @param element Defines the element to stop listening the inputs from
  75063. */
  75064. detachControl(element: Nullable<HTMLElement>): void;
  75065. /**
  75066. * Update the current camera state depending on the inputs that have been used this frame.
  75067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75068. */
  75069. checkInputs?: () => void;
  75070. }
  75071. /**
  75072. * Represents a map of input types to input instance or input index to input instance.
  75073. */
  75074. export interface CameraInputsMap<TCamera extends Camera> {
  75075. /**
  75076. * Accessor to the input by input type.
  75077. */
  75078. [name: string]: ICameraInput<TCamera>;
  75079. /**
  75080. * Accessor to the input by input index.
  75081. */
  75082. [idx: number]: ICameraInput<TCamera>;
  75083. }
  75084. /**
  75085. * This represents the input manager used within a camera.
  75086. * It helps dealing with all the different kind of input attached to a camera.
  75087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75088. */
  75089. export class CameraInputsManager<TCamera extends Camera> {
  75090. /**
  75091. * Defines the list of inputs attahed to the camera.
  75092. */
  75093. attached: CameraInputsMap<TCamera>;
  75094. /**
  75095. * Defines the dom element the camera is collecting inputs from.
  75096. * This is null if the controls have not been attached.
  75097. */
  75098. attachedElement: Nullable<HTMLElement>;
  75099. /**
  75100. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75101. */
  75102. noPreventDefault: boolean;
  75103. /**
  75104. * Defined the camera the input manager belongs to.
  75105. */
  75106. camera: TCamera;
  75107. /**
  75108. * Update the current camera state depending on the inputs that have been used this frame.
  75109. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75110. */
  75111. checkInputs: () => void;
  75112. /**
  75113. * Instantiate a new Camera Input Manager.
  75114. * @param camera Defines the camera the input manager blongs to
  75115. */
  75116. constructor(camera: TCamera);
  75117. /**
  75118. * Add an input method to a camera
  75119. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75120. * @param input camera input method
  75121. */
  75122. add(input: ICameraInput<TCamera>): void;
  75123. /**
  75124. * Remove a specific input method from a camera
  75125. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  75126. * @param inputToRemove camera input method
  75127. */
  75128. remove(inputToRemove: ICameraInput<TCamera>): void;
  75129. /**
  75130. * Remove a specific input type from a camera
  75131. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  75132. * @param inputType the type of the input to remove
  75133. */
  75134. removeByType(inputType: string): void;
  75135. private _addCheckInputs;
  75136. /**
  75137. * Attach the input controls to the currently attached dom element to listen the events from.
  75138. * @param input Defines the input to attach
  75139. */
  75140. attachInput(input: ICameraInput<TCamera>): void;
  75141. /**
  75142. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  75143. * @param element Defines the dom element to collect the events from
  75144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75145. */
  75146. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  75147. /**
  75148. * Detach the current manager inputs controls from a specific dom element.
  75149. * @param element Defines the dom element to collect the events from
  75150. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  75151. */
  75152. detachElement(element: HTMLElement, disconnect?: boolean): void;
  75153. /**
  75154. * Rebuild the dynamic inputCheck function from the current list of
  75155. * defined inputs in the manager.
  75156. */
  75157. rebuildInputCheck(): void;
  75158. /**
  75159. * Remove all attached input methods from a camera
  75160. */
  75161. clear(): void;
  75162. /**
  75163. * Serialize the current input manager attached to a camera.
  75164. * This ensures than once parsed,
  75165. * the input associated to the camera will be identical to the current ones
  75166. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  75167. */
  75168. serialize(serializedCamera: any): void;
  75169. /**
  75170. * Parses an input manager serialized JSON to restore the previous list of inputs
  75171. * and states associated to a camera.
  75172. * @param parsedCamera Defines the JSON to parse
  75173. */
  75174. parse(parsedCamera: any): void;
  75175. }
  75176. }
  75177. declare module BABYLON {
  75178. /**
  75179. * Class used to store data that will be store in GPU memory
  75180. */
  75181. export class Buffer {
  75182. private _engine;
  75183. private _buffer;
  75184. /** @hidden */
  75185. _data: Nullable<DataArray>;
  75186. private _updatable;
  75187. private _instanced;
  75188. private _divisor;
  75189. /**
  75190. * Gets the byte stride.
  75191. */
  75192. readonly byteStride: number;
  75193. /**
  75194. * Constructor
  75195. * @param engine the engine
  75196. * @param data the data to use for this buffer
  75197. * @param updatable whether the data is updatable
  75198. * @param stride the stride (optional)
  75199. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75200. * @param instanced whether the buffer is instanced (optional)
  75201. * @param useBytes set to true if the stride in in bytes (optional)
  75202. * @param divisor sets an optional divisor for instances (1 by default)
  75203. */
  75204. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  75205. /**
  75206. * Create a new VertexBuffer based on the current buffer
  75207. * @param kind defines the vertex buffer kind (position, normal, etc.)
  75208. * @param offset defines offset in the buffer (0 by default)
  75209. * @param size defines the size in floats of attributes (position is 3 for instance)
  75210. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  75211. * @param instanced defines if the vertex buffer contains indexed data
  75212. * @param useBytes defines if the offset and stride are in bytes *
  75213. * @param divisor sets an optional divisor for instances (1 by default)
  75214. * @returns the new vertex buffer
  75215. */
  75216. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  75217. /**
  75218. * Gets a boolean indicating if the Buffer is updatable?
  75219. * @returns true if the buffer is updatable
  75220. */
  75221. isUpdatable(): boolean;
  75222. /**
  75223. * Gets current buffer's data
  75224. * @returns a DataArray or null
  75225. */
  75226. getData(): Nullable<DataArray>;
  75227. /**
  75228. * Gets underlying native buffer
  75229. * @returns underlying native buffer
  75230. */
  75231. getBuffer(): Nullable<DataBuffer>;
  75232. /**
  75233. * Gets the stride in float32 units (i.e. byte stride / 4).
  75234. * May not be an integer if the byte stride is not divisible by 4.
  75235. * @returns the stride in float32 units
  75236. * @deprecated Please use byteStride instead.
  75237. */
  75238. getStrideSize(): number;
  75239. /**
  75240. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75241. * @param data defines the data to store
  75242. */
  75243. create(data?: Nullable<DataArray>): void;
  75244. /** @hidden */
  75245. _rebuild(): void;
  75246. /**
  75247. * Update current buffer data
  75248. * @param data defines the data to store
  75249. */
  75250. update(data: DataArray): void;
  75251. /**
  75252. * Updates the data directly.
  75253. * @param data the new data
  75254. * @param offset the new offset
  75255. * @param vertexCount the vertex count (optional)
  75256. * @param useBytes set to true if the offset is in bytes
  75257. */
  75258. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  75259. /**
  75260. * Release all resources
  75261. */
  75262. dispose(): void;
  75263. }
  75264. /**
  75265. * Specialized buffer used to store vertex data
  75266. */
  75267. export class VertexBuffer {
  75268. /** @hidden */
  75269. _buffer: Buffer;
  75270. private _kind;
  75271. private _size;
  75272. private _ownsBuffer;
  75273. private _instanced;
  75274. private _instanceDivisor;
  75275. /**
  75276. * The byte type.
  75277. */
  75278. static readonly BYTE: number;
  75279. /**
  75280. * The unsigned byte type.
  75281. */
  75282. static readonly UNSIGNED_BYTE: number;
  75283. /**
  75284. * The short type.
  75285. */
  75286. static readonly SHORT: number;
  75287. /**
  75288. * The unsigned short type.
  75289. */
  75290. static readonly UNSIGNED_SHORT: number;
  75291. /**
  75292. * The integer type.
  75293. */
  75294. static readonly INT: number;
  75295. /**
  75296. * The unsigned integer type.
  75297. */
  75298. static readonly UNSIGNED_INT: number;
  75299. /**
  75300. * The float type.
  75301. */
  75302. static readonly FLOAT: number;
  75303. /**
  75304. * Gets or sets the instance divisor when in instanced mode
  75305. */
  75306. instanceDivisor: number;
  75307. /**
  75308. * Gets the byte stride.
  75309. */
  75310. readonly byteStride: number;
  75311. /**
  75312. * Gets the byte offset.
  75313. */
  75314. readonly byteOffset: number;
  75315. /**
  75316. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  75317. */
  75318. readonly normalized: boolean;
  75319. /**
  75320. * Gets the data type of each component in the array.
  75321. */
  75322. readonly type: number;
  75323. /**
  75324. * Constructor
  75325. * @param engine the engine
  75326. * @param data the data to use for this vertex buffer
  75327. * @param kind the vertex buffer kind
  75328. * @param updatable whether the data is updatable
  75329. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75330. * @param stride the stride (optional)
  75331. * @param instanced whether the buffer is instanced (optional)
  75332. * @param offset the offset of the data (optional)
  75333. * @param size the number of components (optional)
  75334. * @param type the type of the component (optional)
  75335. * @param normalized whether the data contains normalized data (optional)
  75336. * @param useBytes set to true if stride and offset are in bytes (optional)
  75337. * @param divisor defines the instance divisor to use (1 by default)
  75338. */
  75339. 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);
  75340. /** @hidden */
  75341. _rebuild(): void;
  75342. /**
  75343. * Returns the kind of the VertexBuffer (string)
  75344. * @returns a string
  75345. */
  75346. getKind(): string;
  75347. /**
  75348. * Gets a boolean indicating if the VertexBuffer is updatable?
  75349. * @returns true if the buffer is updatable
  75350. */
  75351. isUpdatable(): boolean;
  75352. /**
  75353. * Gets current buffer's data
  75354. * @returns a DataArray or null
  75355. */
  75356. getData(): Nullable<DataArray>;
  75357. /**
  75358. * Gets underlying native buffer
  75359. * @returns underlying native buffer
  75360. */
  75361. getBuffer(): Nullable<DataBuffer>;
  75362. /**
  75363. * Gets the stride in float32 units (i.e. byte stride / 4).
  75364. * May not be an integer if the byte stride is not divisible by 4.
  75365. * @returns the stride in float32 units
  75366. * @deprecated Please use byteStride instead.
  75367. */
  75368. getStrideSize(): number;
  75369. /**
  75370. * Returns the offset as a multiple of the type byte length.
  75371. * @returns the offset in bytes
  75372. * @deprecated Please use byteOffset instead.
  75373. */
  75374. getOffset(): number;
  75375. /**
  75376. * Returns the number of components per vertex attribute (integer)
  75377. * @returns the size in float
  75378. */
  75379. getSize(): number;
  75380. /**
  75381. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  75382. * @returns true if this buffer is instanced
  75383. */
  75384. getIsInstanced(): boolean;
  75385. /**
  75386. * Returns the instancing divisor, zero for non-instanced (integer).
  75387. * @returns a number
  75388. */
  75389. getInstanceDivisor(): number;
  75390. /**
  75391. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75392. * @param data defines the data to store
  75393. */
  75394. create(data?: DataArray): void;
  75395. /**
  75396. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  75397. * This function will create a new buffer if the current one is not updatable
  75398. * @param data defines the data to store
  75399. */
  75400. update(data: DataArray): void;
  75401. /**
  75402. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  75403. * Returns the directly updated WebGLBuffer.
  75404. * @param data the new data
  75405. * @param offset the new offset
  75406. * @param useBytes set to true if the offset is in bytes
  75407. */
  75408. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  75409. /**
  75410. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  75411. */
  75412. dispose(): void;
  75413. /**
  75414. * Enumerates each value of this vertex buffer as numbers.
  75415. * @param count the number of values to enumerate
  75416. * @param callback the callback function called for each value
  75417. */
  75418. forEach(count: number, callback: (value: number, index: number) => void): void;
  75419. /**
  75420. * Positions
  75421. */
  75422. static readonly PositionKind: string;
  75423. /**
  75424. * Normals
  75425. */
  75426. static readonly NormalKind: string;
  75427. /**
  75428. * Tangents
  75429. */
  75430. static readonly TangentKind: string;
  75431. /**
  75432. * Texture coordinates
  75433. */
  75434. static readonly UVKind: string;
  75435. /**
  75436. * Texture coordinates 2
  75437. */
  75438. static readonly UV2Kind: string;
  75439. /**
  75440. * Texture coordinates 3
  75441. */
  75442. static readonly UV3Kind: string;
  75443. /**
  75444. * Texture coordinates 4
  75445. */
  75446. static readonly UV4Kind: string;
  75447. /**
  75448. * Texture coordinates 5
  75449. */
  75450. static readonly UV5Kind: string;
  75451. /**
  75452. * Texture coordinates 6
  75453. */
  75454. static readonly UV6Kind: string;
  75455. /**
  75456. * Colors
  75457. */
  75458. static readonly ColorKind: string;
  75459. /**
  75460. * Matrix indices (for bones)
  75461. */
  75462. static readonly MatricesIndicesKind: string;
  75463. /**
  75464. * Matrix weights (for bones)
  75465. */
  75466. static readonly MatricesWeightsKind: string;
  75467. /**
  75468. * Additional matrix indices (for bones)
  75469. */
  75470. static readonly MatricesIndicesExtraKind: string;
  75471. /**
  75472. * Additional matrix weights (for bones)
  75473. */
  75474. static readonly MatricesWeightsExtraKind: string;
  75475. /**
  75476. * Deduces the stride given a kind.
  75477. * @param kind The kind string to deduce
  75478. * @returns The deduced stride
  75479. */
  75480. static DeduceStride(kind: string): number;
  75481. /**
  75482. * Gets the byte length of the given type.
  75483. * @param type the type
  75484. * @returns the number of bytes
  75485. */
  75486. static GetTypeByteLength(type: number): number;
  75487. /**
  75488. * Enumerates each value of the given parameters as numbers.
  75489. * @param data the data to enumerate
  75490. * @param byteOffset the byte offset of the data
  75491. * @param byteStride the byte stride of the data
  75492. * @param componentCount the number of components per element
  75493. * @param componentType the type of the component
  75494. * @param count the number of values to enumerate
  75495. * @param normalized whether the data is normalized
  75496. * @param callback the callback function called for each value
  75497. */
  75498. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  75499. private static _GetFloatValue;
  75500. }
  75501. }
  75502. declare module BABYLON {
  75503. /**
  75504. * @hidden
  75505. */
  75506. export class IntersectionInfo {
  75507. bu: Nullable<number>;
  75508. bv: Nullable<number>;
  75509. distance: number;
  75510. faceId: number;
  75511. subMeshId: number;
  75512. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  75513. }
  75514. }
  75515. declare module BABYLON {
  75516. /**
  75517. * Represens a plane by the equation ax + by + cz + d = 0
  75518. */
  75519. export class Plane {
  75520. private static _TmpMatrix;
  75521. /**
  75522. * Normal of the plane (a,b,c)
  75523. */
  75524. normal: Vector3;
  75525. /**
  75526. * d component of the plane
  75527. */
  75528. d: number;
  75529. /**
  75530. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75531. * @param a a component of the plane
  75532. * @param b b component of the plane
  75533. * @param c c component of the plane
  75534. * @param d d component of the plane
  75535. */
  75536. constructor(a: number, b: number, c: number, d: number);
  75537. /**
  75538. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75539. */
  75540. asArray(): number[];
  75541. /**
  75542. * @returns a new plane copied from the current Plane.
  75543. */
  75544. clone(): Plane;
  75545. /**
  75546. * @returns the string "Plane".
  75547. */
  75548. getClassName(): string;
  75549. /**
  75550. * @returns the Plane hash code.
  75551. */
  75552. getHashCode(): number;
  75553. /**
  75554. * Normalize the current Plane in place.
  75555. * @returns the updated Plane.
  75556. */
  75557. normalize(): Plane;
  75558. /**
  75559. * Applies a transformation the plane and returns the result
  75560. * @param transformation the transformation matrix to be applied to the plane
  75561. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75562. */
  75563. transform(transformation: DeepImmutable<Matrix>): Plane;
  75564. /**
  75565. * Calcualtte the dot product between the point and the plane normal
  75566. * @param point point to calculate the dot product with
  75567. * @returns the dot product (float) of the point coordinates and the plane normal.
  75568. */
  75569. dotCoordinate(point: DeepImmutable<Vector3>): number;
  75570. /**
  75571. * Updates the current Plane from the plane defined by the three given points.
  75572. * @param point1 one of the points used to contruct the plane
  75573. * @param point2 one of the points used to contruct the plane
  75574. * @param point3 one of the points used to contruct the plane
  75575. * @returns the updated Plane.
  75576. */
  75577. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75578. /**
  75579. * Checks if the plane is facing a given direction
  75580. * @param direction the direction to check if the plane is facing
  75581. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75582. * @returns True is the vector "direction" is the same side than the plane normal.
  75583. */
  75584. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  75585. /**
  75586. * Calculates the distance to a point
  75587. * @param point point to calculate distance to
  75588. * @returns the signed distance (float) from the given point to the Plane.
  75589. */
  75590. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  75591. /**
  75592. * Creates a plane from an array
  75593. * @param array the array to create a plane from
  75594. * @returns a new Plane from the given array.
  75595. */
  75596. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  75597. /**
  75598. * Creates a plane from three points
  75599. * @param point1 point used to create the plane
  75600. * @param point2 point used to create the plane
  75601. * @param point3 point used to create the plane
  75602. * @returns a new Plane defined by the three given points.
  75603. */
  75604. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75605. /**
  75606. * Creates a plane from an origin point and a normal
  75607. * @param origin origin of the plane to be constructed
  75608. * @param normal normal of the plane to be constructed
  75609. * @returns a new Plane the normal vector to this plane at the given origin point.
  75610. * Note : the vector "normal" is updated because normalized.
  75611. */
  75612. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  75613. /**
  75614. * Calculates the distance from a plane and a point
  75615. * @param origin origin of the plane to be constructed
  75616. * @param normal normal of the plane to be constructed
  75617. * @param point point to calculate distance to
  75618. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75619. */
  75620. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  75621. }
  75622. }
  75623. declare module BABYLON {
  75624. /**
  75625. * Class used to store bounding sphere information
  75626. */
  75627. export class BoundingSphere {
  75628. /**
  75629. * Gets the center of the bounding sphere in local space
  75630. */
  75631. readonly center: Vector3;
  75632. /**
  75633. * Radius of the bounding sphere in local space
  75634. */
  75635. radius: number;
  75636. /**
  75637. * Gets the center of the bounding sphere in world space
  75638. */
  75639. readonly centerWorld: Vector3;
  75640. /**
  75641. * Radius of the bounding sphere in world space
  75642. */
  75643. radiusWorld: number;
  75644. /**
  75645. * Gets the minimum vector in local space
  75646. */
  75647. readonly minimum: Vector3;
  75648. /**
  75649. * Gets the maximum vector in local space
  75650. */
  75651. readonly maximum: Vector3;
  75652. private _worldMatrix;
  75653. private static readonly TmpVector3;
  75654. /**
  75655. * Creates a new bounding sphere
  75656. * @param min defines the minimum vector (in local space)
  75657. * @param max defines the maximum vector (in local space)
  75658. * @param worldMatrix defines the new world matrix
  75659. */
  75660. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75661. /**
  75662. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  75663. * @param min defines the new minimum vector (in local space)
  75664. * @param max defines the new maximum vector (in local space)
  75665. * @param worldMatrix defines the new world matrix
  75666. */
  75667. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75668. /**
  75669. * Scale the current bounding sphere by applying a scale factor
  75670. * @param factor defines the scale factor to apply
  75671. * @returns the current bounding box
  75672. */
  75673. scale(factor: number): BoundingSphere;
  75674. /**
  75675. * Gets the world matrix of the bounding box
  75676. * @returns a matrix
  75677. */
  75678. getWorldMatrix(): DeepImmutable<Matrix>;
  75679. /** @hidden */
  75680. _update(worldMatrix: DeepImmutable<Matrix>): void;
  75681. /**
  75682. * Tests if the bounding sphere is intersecting the frustum planes
  75683. * @param frustumPlanes defines the frustum planes to test
  75684. * @returns true if there is an intersection
  75685. */
  75686. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75687. /**
  75688. * Tests if the bounding sphere center is in between the frustum planes.
  75689. * Used for optimistic fast inclusion.
  75690. * @param frustumPlanes defines the frustum planes to test
  75691. * @returns true if the sphere center is in between the frustum planes
  75692. */
  75693. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75694. /**
  75695. * Tests if a point is inside the bounding sphere
  75696. * @param point defines the point to test
  75697. * @returns true if the point is inside the bounding sphere
  75698. */
  75699. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75700. /**
  75701. * Checks if two sphere intersct
  75702. * @param sphere0 sphere 0
  75703. * @param sphere1 sphere 1
  75704. * @returns true if the speres intersect
  75705. */
  75706. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  75707. }
  75708. }
  75709. declare module BABYLON {
  75710. /**
  75711. * Class used to store bounding box information
  75712. */
  75713. export class BoundingBox implements ICullable {
  75714. /**
  75715. * Gets the 8 vectors representing the bounding box in local space
  75716. */
  75717. readonly vectors: Vector3[];
  75718. /**
  75719. * Gets the center of the bounding box in local space
  75720. */
  75721. readonly center: Vector3;
  75722. /**
  75723. * Gets the center of the bounding box in world space
  75724. */
  75725. readonly centerWorld: Vector3;
  75726. /**
  75727. * Gets the extend size in local space
  75728. */
  75729. readonly extendSize: Vector3;
  75730. /**
  75731. * Gets the extend size in world space
  75732. */
  75733. readonly extendSizeWorld: Vector3;
  75734. /**
  75735. * Gets the OBB (object bounding box) directions
  75736. */
  75737. readonly directions: Vector3[];
  75738. /**
  75739. * Gets the 8 vectors representing the bounding box in world space
  75740. */
  75741. readonly vectorsWorld: Vector3[];
  75742. /**
  75743. * Gets the minimum vector in world space
  75744. */
  75745. readonly minimumWorld: Vector3;
  75746. /**
  75747. * Gets the maximum vector in world space
  75748. */
  75749. readonly maximumWorld: Vector3;
  75750. /**
  75751. * Gets the minimum vector in local space
  75752. */
  75753. readonly minimum: Vector3;
  75754. /**
  75755. * Gets the maximum vector in local space
  75756. */
  75757. readonly maximum: Vector3;
  75758. private _worldMatrix;
  75759. private static readonly TmpVector3;
  75760. /**
  75761. * @hidden
  75762. */
  75763. _tag: number;
  75764. /**
  75765. * Creates a new bounding box
  75766. * @param min defines the minimum vector (in local space)
  75767. * @param max defines the maximum vector (in local space)
  75768. * @param worldMatrix defines the new world matrix
  75769. */
  75770. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75771. /**
  75772. * Recreates the entire bounding box from scratch as if we call the constructor in place
  75773. * @param min defines the new minimum vector (in local space)
  75774. * @param max defines the new maximum vector (in local space)
  75775. * @param worldMatrix defines the new world matrix
  75776. */
  75777. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75778. /**
  75779. * Scale the current bounding box by applying a scale factor
  75780. * @param factor defines the scale factor to apply
  75781. * @returns the current bounding box
  75782. */
  75783. scale(factor: number): BoundingBox;
  75784. /**
  75785. * Gets the world matrix of the bounding box
  75786. * @returns a matrix
  75787. */
  75788. getWorldMatrix(): DeepImmutable<Matrix>;
  75789. /** @hidden */
  75790. _update(world: DeepImmutable<Matrix>): void;
  75791. /**
  75792. * Tests if the bounding box is intersecting the frustum planes
  75793. * @param frustumPlanes defines the frustum planes to test
  75794. * @returns true if there is an intersection
  75795. */
  75796. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75797. /**
  75798. * Tests if the bounding box is entirely inside the frustum planes
  75799. * @param frustumPlanes defines the frustum planes to test
  75800. * @returns true if there is an inclusion
  75801. */
  75802. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75803. /**
  75804. * Tests if a point is inside the bounding box
  75805. * @param point defines the point to test
  75806. * @returns true if the point is inside the bounding box
  75807. */
  75808. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75809. /**
  75810. * Tests if the bounding box intersects with a bounding sphere
  75811. * @param sphere defines the sphere to test
  75812. * @returns true if there is an intersection
  75813. */
  75814. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  75815. /**
  75816. * Tests if the bounding box intersects with a box defined by a min and max vectors
  75817. * @param min defines the min vector to use
  75818. * @param max defines the max vector to use
  75819. * @returns true if there is an intersection
  75820. */
  75821. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  75822. /**
  75823. * Tests if two bounding boxes are intersections
  75824. * @param box0 defines the first box to test
  75825. * @param box1 defines the second box to test
  75826. * @returns true if there is an intersection
  75827. */
  75828. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  75829. /**
  75830. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75831. * @param minPoint defines the minimum vector of the bounding box
  75832. * @param maxPoint defines the maximum vector of the bounding box
  75833. * @param sphereCenter defines the sphere center
  75834. * @param sphereRadius defines the sphere radius
  75835. * @returns true if there is an intersection
  75836. */
  75837. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75838. /**
  75839. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75840. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75841. * @param frustumPlanes defines the frustum planes to test
  75842. * @return true if there is an inclusion
  75843. */
  75844. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75845. /**
  75846. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75847. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75848. * @param frustumPlanes defines the frustum planes to test
  75849. * @return true if there is an intersection
  75850. */
  75851. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75852. }
  75853. }
  75854. declare module BABYLON {
  75855. /** @hidden */
  75856. export class Collider {
  75857. /** Define if a collision was found */
  75858. collisionFound: boolean;
  75859. /**
  75860. * Define last intersection point in local space
  75861. */
  75862. intersectionPoint: Vector3;
  75863. /**
  75864. * Define last collided mesh
  75865. */
  75866. collidedMesh: Nullable<AbstractMesh>;
  75867. private _collisionPoint;
  75868. private _planeIntersectionPoint;
  75869. private _tempVector;
  75870. private _tempVector2;
  75871. private _tempVector3;
  75872. private _tempVector4;
  75873. private _edge;
  75874. private _baseToVertex;
  75875. private _destinationPoint;
  75876. private _slidePlaneNormal;
  75877. private _displacementVector;
  75878. /** @hidden */
  75879. _radius: Vector3;
  75880. /** @hidden */
  75881. _retry: number;
  75882. private _velocity;
  75883. private _basePoint;
  75884. private _epsilon;
  75885. /** @hidden */
  75886. _velocityWorldLength: number;
  75887. /** @hidden */
  75888. _basePointWorld: Vector3;
  75889. private _velocityWorld;
  75890. private _normalizedVelocity;
  75891. /** @hidden */
  75892. _initialVelocity: Vector3;
  75893. /** @hidden */
  75894. _initialPosition: Vector3;
  75895. private _nearestDistance;
  75896. private _collisionMask;
  75897. collisionMask: number;
  75898. /**
  75899. * Gets the plane normal used to compute the sliding response (in local space)
  75900. */
  75901. readonly slidePlaneNormal: Vector3;
  75902. /** @hidden */
  75903. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75904. /** @hidden */
  75905. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75906. /** @hidden */
  75907. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75908. /** @hidden */
  75909. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75910. /** @hidden */
  75911. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75912. /** @hidden */
  75913. _getResponse(pos: Vector3, vel: Vector3): void;
  75914. }
  75915. }
  75916. declare module BABYLON {
  75917. /**
  75918. * Interface for cullable objects
  75919. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75920. */
  75921. export interface ICullable {
  75922. /**
  75923. * Checks if the object or part of the object is in the frustum
  75924. * @param frustumPlanes Camera near/planes
  75925. * @returns true if the object is in frustum otherwise false
  75926. */
  75927. isInFrustum(frustumPlanes: Plane[]): boolean;
  75928. /**
  75929. * Checks if a cullable object (mesh...) is in the camera frustum
  75930. * Unlike isInFrustum this cheks the full bounding box
  75931. * @param frustumPlanes Camera near/planes
  75932. * @returns true if the object is in frustum otherwise false
  75933. */
  75934. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75935. }
  75936. /**
  75937. * Info for a bounding data of a mesh
  75938. */
  75939. export class BoundingInfo implements ICullable {
  75940. /**
  75941. * Bounding box for the mesh
  75942. */
  75943. readonly boundingBox: BoundingBox;
  75944. /**
  75945. * Bounding sphere for the mesh
  75946. */
  75947. readonly boundingSphere: BoundingSphere;
  75948. private _isLocked;
  75949. private static readonly TmpVector3;
  75950. /**
  75951. * Constructs bounding info
  75952. * @param minimum min vector of the bounding box/sphere
  75953. * @param maximum max vector of the bounding box/sphere
  75954. * @param worldMatrix defines the new world matrix
  75955. */
  75956. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75957. /**
  75958. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75959. * @param min defines the new minimum vector (in local space)
  75960. * @param max defines the new maximum vector (in local space)
  75961. * @param worldMatrix defines the new world matrix
  75962. */
  75963. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75964. /**
  75965. * min vector of the bounding box/sphere
  75966. */
  75967. readonly minimum: Vector3;
  75968. /**
  75969. * max vector of the bounding box/sphere
  75970. */
  75971. readonly maximum: Vector3;
  75972. /**
  75973. * If the info is locked and won't be updated to avoid perf overhead
  75974. */
  75975. isLocked: boolean;
  75976. /**
  75977. * Updates the bounding sphere and box
  75978. * @param world world matrix to be used to update
  75979. */
  75980. update(world: DeepImmutable<Matrix>): void;
  75981. /**
  75982. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75983. * @param center New center of the bounding info
  75984. * @param extend New extend of the bounding info
  75985. * @returns the current bounding info
  75986. */
  75987. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75988. /**
  75989. * Scale the current bounding info by applying a scale factor
  75990. * @param factor defines the scale factor to apply
  75991. * @returns the current bounding info
  75992. */
  75993. scale(factor: number): BoundingInfo;
  75994. /**
  75995. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75996. * @param frustumPlanes defines the frustum to test
  75997. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75998. * @returns true if the bounding info is in the frustum planes
  75999. */
  76000. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  76001. /**
  76002. * Gets the world distance between the min and max points of the bounding box
  76003. */
  76004. readonly diagonalLength: number;
  76005. /**
  76006. * Checks if a cullable object (mesh...) is in the camera frustum
  76007. * Unlike isInFrustum this cheks the full bounding box
  76008. * @param frustumPlanes Camera near/planes
  76009. * @returns true if the object is in frustum otherwise false
  76010. */
  76011. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76012. /** @hidden */
  76013. _checkCollision(collider: Collider): boolean;
  76014. /**
  76015. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  76016. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  76017. * @param point the point to check intersection with
  76018. * @returns if the point intersects
  76019. */
  76020. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76021. /**
  76022. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  76023. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  76024. * @param boundingInfo the bounding info to check intersection with
  76025. * @param precise if the intersection should be done using OBB
  76026. * @returns if the bounding info intersects
  76027. */
  76028. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  76029. }
  76030. }
  76031. declare module BABYLON {
  76032. /**
  76033. * Extracts minimum and maximum values from a list of indexed positions
  76034. * @param positions defines the positions to use
  76035. * @param indices defines the indices to the positions
  76036. * @param indexStart defines the start index
  76037. * @param indexCount defines the end index
  76038. * @param bias defines bias value to add to the result
  76039. * @return minimum and maximum values
  76040. */
  76041. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  76042. minimum: Vector3;
  76043. maximum: Vector3;
  76044. };
  76045. /**
  76046. * Extracts minimum and maximum values from a list of positions
  76047. * @param positions defines the positions to use
  76048. * @param start defines the start index in the positions array
  76049. * @param count defines the number of positions to handle
  76050. * @param bias defines bias value to add to the result
  76051. * @param stride defines the stride size to use (distance between two positions in the positions array)
  76052. * @return minimum and maximum values
  76053. */
  76054. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  76055. minimum: Vector3;
  76056. maximum: Vector3;
  76057. };
  76058. }
  76059. declare module BABYLON {
  76060. /** @hidden */
  76061. export class WebGLDataBuffer extends DataBuffer {
  76062. private _buffer;
  76063. constructor(resource: WebGLBuffer);
  76064. readonly underlyingResource: any;
  76065. }
  76066. }
  76067. declare module BABYLON {
  76068. /** @hidden */
  76069. export class WebGLPipelineContext implements IPipelineContext {
  76070. engine: ThinEngine;
  76071. program: Nullable<WebGLProgram>;
  76072. context?: WebGLRenderingContext;
  76073. vertexShader?: WebGLShader;
  76074. fragmentShader?: WebGLShader;
  76075. isParallelCompiled: boolean;
  76076. onCompiled?: () => void;
  76077. transformFeedback?: WebGLTransformFeedback | null;
  76078. readonly isAsync: boolean;
  76079. readonly isReady: boolean;
  76080. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  76081. }
  76082. }
  76083. declare module BABYLON {
  76084. interface ThinEngine {
  76085. /**
  76086. * Create an uniform buffer
  76087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76088. * @param elements defines the content of the uniform buffer
  76089. * @returns the webGL uniform buffer
  76090. */
  76091. createUniformBuffer(elements: FloatArray): DataBuffer;
  76092. /**
  76093. * Create a dynamic uniform buffer
  76094. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76095. * @param elements defines the content of the uniform buffer
  76096. * @returns the webGL uniform buffer
  76097. */
  76098. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  76099. /**
  76100. * Update an existing uniform buffer
  76101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76102. * @param uniformBuffer defines the target uniform buffer
  76103. * @param elements defines the content to update
  76104. * @param offset defines the offset in the uniform buffer where update should start
  76105. * @param count defines the size of the data to update
  76106. */
  76107. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  76108. /**
  76109. * Bind an uniform buffer to the current webGL context
  76110. * @param buffer defines the buffer to bind
  76111. */
  76112. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  76113. /**
  76114. * Bind a buffer to the current webGL context at a given location
  76115. * @param buffer defines the buffer to bind
  76116. * @param location defines the index where to bind the buffer
  76117. */
  76118. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  76119. /**
  76120. * Bind a specific block at a given index in a specific shader program
  76121. * @param pipelineContext defines the pipeline context to use
  76122. * @param blockName defines the block name
  76123. * @param index defines the index where to bind the block
  76124. */
  76125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  76126. }
  76127. }
  76128. declare module BABYLON {
  76129. /**
  76130. * Uniform buffer objects.
  76131. *
  76132. * Handles blocks of uniform on the GPU.
  76133. *
  76134. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76135. *
  76136. * For more information, please refer to :
  76137. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76138. */
  76139. export class UniformBuffer {
  76140. private _engine;
  76141. private _buffer;
  76142. private _data;
  76143. private _bufferData;
  76144. private _dynamic?;
  76145. private _uniformLocations;
  76146. private _uniformSizes;
  76147. private _uniformLocationPointer;
  76148. private _needSync;
  76149. private _noUBO;
  76150. private _currentEffect;
  76151. /** @hidden */
  76152. _alreadyBound: boolean;
  76153. private static _MAX_UNIFORM_SIZE;
  76154. private static _tempBuffer;
  76155. /**
  76156. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  76157. * This is dynamic to allow compat with webgl 1 and 2.
  76158. * You will need to pass the name of the uniform as well as the value.
  76159. */
  76160. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  76161. /**
  76162. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  76163. * This is dynamic to allow compat with webgl 1 and 2.
  76164. * You will need to pass the name of the uniform as well as the value.
  76165. */
  76166. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  76167. /**
  76168. * Lambda to Update a single float in a uniform buffer.
  76169. * This is dynamic to allow compat with webgl 1 and 2.
  76170. * You will need to pass the name of the uniform as well as the value.
  76171. */
  76172. updateFloat: (name: string, x: number) => void;
  76173. /**
  76174. * Lambda to Update a vec2 of float in a uniform buffer.
  76175. * This is dynamic to allow compat with webgl 1 and 2.
  76176. * You will need to pass the name of the uniform as well as the value.
  76177. */
  76178. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  76179. /**
  76180. * Lambda to Update a vec3 of float in a uniform buffer.
  76181. * This is dynamic to allow compat with webgl 1 and 2.
  76182. * You will need to pass the name of the uniform as well as the value.
  76183. */
  76184. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  76185. /**
  76186. * Lambda to Update a vec4 of float in a uniform buffer.
  76187. * This is dynamic to allow compat with webgl 1 and 2.
  76188. * You will need to pass the name of the uniform as well as the value.
  76189. */
  76190. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  76191. /**
  76192. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  76193. * This is dynamic to allow compat with webgl 1 and 2.
  76194. * You will need to pass the name of the uniform as well as the value.
  76195. */
  76196. updateMatrix: (name: string, mat: Matrix) => void;
  76197. /**
  76198. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  76199. * This is dynamic to allow compat with webgl 1 and 2.
  76200. * You will need to pass the name of the uniform as well as the value.
  76201. */
  76202. updateVector3: (name: string, vector: Vector3) => void;
  76203. /**
  76204. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  76205. * This is dynamic to allow compat with webgl 1 and 2.
  76206. * You will need to pass the name of the uniform as well as the value.
  76207. */
  76208. updateVector4: (name: string, vector: Vector4) => void;
  76209. /**
  76210. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  76211. * This is dynamic to allow compat with webgl 1 and 2.
  76212. * You will need to pass the name of the uniform as well as the value.
  76213. */
  76214. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  76215. /**
  76216. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  76217. * This is dynamic to allow compat with webgl 1 and 2.
  76218. * You will need to pass the name of the uniform as well as the value.
  76219. */
  76220. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  76221. /**
  76222. * Instantiates a new Uniform buffer objects.
  76223. *
  76224. * Handles blocks of uniform on the GPU.
  76225. *
  76226. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76227. *
  76228. * For more information, please refer to :
  76229. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76230. * @param engine Define the engine the buffer is associated with
  76231. * @param data Define the data contained in the buffer
  76232. * @param dynamic Define if the buffer is updatable
  76233. */
  76234. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  76235. /**
  76236. * Indicates if the buffer is using the WebGL2 UBO implementation,
  76237. * or just falling back on setUniformXXX calls.
  76238. */
  76239. readonly useUbo: boolean;
  76240. /**
  76241. * Indicates if the WebGL underlying uniform buffer is in sync
  76242. * with the javascript cache data.
  76243. */
  76244. readonly isSync: boolean;
  76245. /**
  76246. * Indicates if the WebGL underlying uniform buffer is dynamic.
  76247. * Also, a dynamic UniformBuffer will disable cache verification and always
  76248. * update the underlying WebGL uniform buffer to the GPU.
  76249. * @returns if Dynamic, otherwise false
  76250. */
  76251. isDynamic(): boolean;
  76252. /**
  76253. * The data cache on JS side.
  76254. * @returns the underlying data as a float array
  76255. */
  76256. getData(): Float32Array;
  76257. /**
  76258. * The underlying WebGL Uniform buffer.
  76259. * @returns the webgl buffer
  76260. */
  76261. getBuffer(): Nullable<DataBuffer>;
  76262. /**
  76263. * std140 layout specifies how to align data within an UBO structure.
  76264. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  76265. * for specs.
  76266. */
  76267. private _fillAlignment;
  76268. /**
  76269. * Adds an uniform in the buffer.
  76270. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  76271. * for the layout to be correct !
  76272. * @param name Name of the uniform, as used in the uniform block in the shader.
  76273. * @param size Data size, or data directly.
  76274. */
  76275. addUniform(name: string, size: number | number[]): void;
  76276. /**
  76277. * Adds a Matrix 4x4 to the uniform buffer.
  76278. * @param name Name of the uniform, as used in the uniform block in the shader.
  76279. * @param mat A 4x4 matrix.
  76280. */
  76281. addMatrix(name: string, mat: Matrix): void;
  76282. /**
  76283. * Adds a vec2 to the uniform buffer.
  76284. * @param name Name of the uniform, as used in the uniform block in the shader.
  76285. * @param x Define the x component value of the vec2
  76286. * @param y Define the y component value of the vec2
  76287. */
  76288. addFloat2(name: string, x: number, y: number): void;
  76289. /**
  76290. * Adds a vec3 to the uniform buffer.
  76291. * @param name Name of the uniform, as used in the uniform block in the shader.
  76292. * @param x Define the x component value of the vec3
  76293. * @param y Define the y component value of the vec3
  76294. * @param z Define the z component value of the vec3
  76295. */
  76296. addFloat3(name: string, x: number, y: number, z: number): void;
  76297. /**
  76298. * Adds a vec3 to the uniform buffer.
  76299. * @param name Name of the uniform, as used in the uniform block in the shader.
  76300. * @param color Define the vec3 from a Color
  76301. */
  76302. addColor3(name: string, color: Color3): void;
  76303. /**
  76304. * Adds a vec4 to the uniform buffer.
  76305. * @param name Name of the uniform, as used in the uniform block in the shader.
  76306. * @param color Define the rgb components from a Color
  76307. * @param alpha Define the a component of the vec4
  76308. */
  76309. addColor4(name: string, color: Color3, alpha: number): void;
  76310. /**
  76311. * Adds a vec3 to the uniform buffer.
  76312. * @param name Name of the uniform, as used in the uniform block in the shader.
  76313. * @param vector Define the vec3 components from a Vector
  76314. */
  76315. addVector3(name: string, vector: Vector3): void;
  76316. /**
  76317. * Adds a Matrix 3x3 to the uniform buffer.
  76318. * @param name Name of the uniform, as used in the uniform block in the shader.
  76319. */
  76320. addMatrix3x3(name: string): void;
  76321. /**
  76322. * Adds a Matrix 2x2 to the uniform buffer.
  76323. * @param name Name of the uniform, as used in the uniform block in the shader.
  76324. */
  76325. addMatrix2x2(name: string): void;
  76326. /**
  76327. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  76328. */
  76329. create(): void;
  76330. /** @hidden */
  76331. _rebuild(): void;
  76332. /**
  76333. * Updates the WebGL Uniform Buffer on the GPU.
  76334. * If the `dynamic` flag is set to true, no cache comparison is done.
  76335. * Otherwise, the buffer will be updated only if the cache differs.
  76336. */
  76337. update(): void;
  76338. /**
  76339. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  76340. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76341. * @param data Define the flattened data
  76342. * @param size Define the size of the data.
  76343. */
  76344. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  76345. private _valueCache;
  76346. private _cacheMatrix;
  76347. private _updateMatrix3x3ForUniform;
  76348. private _updateMatrix3x3ForEffect;
  76349. private _updateMatrix2x2ForEffect;
  76350. private _updateMatrix2x2ForUniform;
  76351. private _updateFloatForEffect;
  76352. private _updateFloatForUniform;
  76353. private _updateFloat2ForEffect;
  76354. private _updateFloat2ForUniform;
  76355. private _updateFloat3ForEffect;
  76356. private _updateFloat3ForUniform;
  76357. private _updateFloat4ForEffect;
  76358. private _updateFloat4ForUniform;
  76359. private _updateMatrixForEffect;
  76360. private _updateMatrixForUniform;
  76361. private _updateVector3ForEffect;
  76362. private _updateVector3ForUniform;
  76363. private _updateVector4ForEffect;
  76364. private _updateVector4ForUniform;
  76365. private _updateColor3ForEffect;
  76366. private _updateColor3ForUniform;
  76367. private _updateColor4ForEffect;
  76368. private _updateColor4ForUniform;
  76369. /**
  76370. * Sets a sampler uniform on the effect.
  76371. * @param name Define the name of the sampler.
  76372. * @param texture Define the texture to set in the sampler
  76373. */
  76374. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  76375. /**
  76376. * Directly updates the value of the uniform in the cache AND on the GPU.
  76377. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76378. * @param data Define the flattened data
  76379. */
  76380. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  76381. /**
  76382. * Binds this uniform buffer to an effect.
  76383. * @param effect Define the effect to bind the buffer to
  76384. * @param name Name of the uniform block in the shader.
  76385. */
  76386. bindToEffect(effect: Effect, name: string): void;
  76387. /**
  76388. * Disposes the uniform buffer.
  76389. */
  76390. dispose(): void;
  76391. }
  76392. }
  76393. declare module BABYLON {
  76394. /**
  76395. * Enum that determines the text-wrapping mode to use.
  76396. */
  76397. export enum InspectableType {
  76398. /**
  76399. * Checkbox for booleans
  76400. */
  76401. Checkbox = 0,
  76402. /**
  76403. * Sliders for numbers
  76404. */
  76405. Slider = 1,
  76406. /**
  76407. * Vector3
  76408. */
  76409. Vector3 = 2,
  76410. /**
  76411. * Quaternions
  76412. */
  76413. Quaternion = 3,
  76414. /**
  76415. * Color3
  76416. */
  76417. Color3 = 4,
  76418. /**
  76419. * String
  76420. */
  76421. String = 5
  76422. }
  76423. /**
  76424. * Interface used to define custom inspectable properties.
  76425. * This interface is used by the inspector to display custom property grids
  76426. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76427. */
  76428. export interface IInspectable {
  76429. /**
  76430. * Gets the label to display
  76431. */
  76432. label: string;
  76433. /**
  76434. * Gets the name of the property to edit
  76435. */
  76436. propertyName: string;
  76437. /**
  76438. * Gets the type of the editor to use
  76439. */
  76440. type: InspectableType;
  76441. /**
  76442. * Gets the minimum value of the property when using in "slider" mode
  76443. */
  76444. min?: number;
  76445. /**
  76446. * Gets the maximum value of the property when using in "slider" mode
  76447. */
  76448. max?: number;
  76449. /**
  76450. * Gets the setp to use when using in "slider" mode
  76451. */
  76452. step?: number;
  76453. }
  76454. }
  76455. declare module BABYLON {
  76456. /**
  76457. * Class used to provide helper for timing
  76458. */
  76459. export class TimingTools {
  76460. /**
  76461. * Polyfill for setImmediate
  76462. * @param action defines the action to execute after the current execution block
  76463. */
  76464. static SetImmediate(action: () => void): void;
  76465. }
  76466. }
  76467. declare module BABYLON {
  76468. /**
  76469. * Class used to enable instatition of objects by class name
  76470. */
  76471. export class InstantiationTools {
  76472. /**
  76473. * Use this object to register external classes like custom textures or material
  76474. * to allow the laoders to instantiate them
  76475. */
  76476. static RegisteredExternalClasses: {
  76477. [key: string]: Object;
  76478. };
  76479. /**
  76480. * Tries to instantiate a new object from a given class name
  76481. * @param className defines the class name to instantiate
  76482. * @returns the new object or null if the system was not able to do the instantiation
  76483. */
  76484. static Instantiate(className: string): any;
  76485. }
  76486. }
  76487. declare module BABYLON {
  76488. /**
  76489. * Define options used to create a depth texture
  76490. */
  76491. export class DepthTextureCreationOptions {
  76492. /** Specifies whether or not a stencil should be allocated in the texture */
  76493. generateStencil?: boolean;
  76494. /** Specifies whether or not bilinear filtering is enable on the texture */
  76495. bilinearFiltering?: boolean;
  76496. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  76497. comparisonFunction?: number;
  76498. /** Specifies if the created texture is a cube texture */
  76499. isCube?: boolean;
  76500. }
  76501. }
  76502. declare module BABYLON {
  76503. interface ThinEngine {
  76504. /**
  76505. * Creates a depth stencil cube texture.
  76506. * This is only available in WebGL 2.
  76507. * @param size The size of face edge in the cube texture.
  76508. * @param options The options defining the cube texture.
  76509. * @returns The cube texture
  76510. */
  76511. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  76512. /**
  76513. * Creates a cube texture
  76514. * @param rootUrl defines the url where the files to load is located
  76515. * @param scene defines the current scene
  76516. * @param files defines the list of files to load (1 per face)
  76517. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76518. * @param onLoad defines an optional callback raised when the texture is loaded
  76519. * @param onError defines an optional callback raised if there is an issue to load the texture
  76520. * @param format defines the format of the data
  76521. * @param forcedExtension defines the extension to use to pick the right loader
  76522. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76523. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76524. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76525. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  76526. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  76527. * @returns the cube texture as an InternalTexture
  76528. */
  76529. 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;
  76530. /**
  76531. * Creates a cube texture
  76532. * @param rootUrl defines the url where the files to load is located
  76533. * @param scene defines the current scene
  76534. * @param files defines the list of files to load (1 per face)
  76535. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76536. * @param onLoad defines an optional callback raised when the texture is loaded
  76537. * @param onError defines an optional callback raised if there is an issue to load the texture
  76538. * @param format defines the format of the data
  76539. * @param forcedExtension defines the extension to use to pick the right loader
  76540. * @returns the cube texture as an InternalTexture
  76541. */
  76542. 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;
  76543. /**
  76544. * Creates a cube texture
  76545. * @param rootUrl defines the url where the files to load is located
  76546. * @param scene defines the current scene
  76547. * @param files defines the list of files to load (1 per face)
  76548. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76549. * @param onLoad defines an optional callback raised when the texture is loaded
  76550. * @param onError defines an optional callback raised if there is an issue to load the texture
  76551. * @param format defines the format of the data
  76552. * @param forcedExtension defines the extension to use to pick the right loader
  76553. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76554. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76555. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76556. * @returns the cube texture as an InternalTexture
  76557. */
  76558. 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;
  76559. /** @hidden */
  76560. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  76561. /** @hidden */
  76562. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  76563. /** @hidden */
  76564. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76565. /** @hidden */
  76566. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76567. /**
  76568. * @hidden
  76569. */
  76570. _setCubeMapTextureParams(loadMipmap: boolean): void;
  76571. }
  76572. }
  76573. declare module BABYLON {
  76574. /**
  76575. * Class for creating a cube texture
  76576. */
  76577. export class CubeTexture extends BaseTexture {
  76578. private _delayedOnLoad;
  76579. /**
  76580. * The url of the texture
  76581. */
  76582. url: string;
  76583. /**
  76584. * Gets or sets the center of the bounding box associated with the cube texture.
  76585. * It must define where the camera used to render the texture was set
  76586. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76587. */
  76588. boundingBoxPosition: Vector3;
  76589. private _boundingBoxSize;
  76590. /**
  76591. * Gets or sets the size of the bounding box associated with the cube texture
  76592. * When defined, the cubemap will switch to local mode
  76593. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76594. * @example https://www.babylonjs-playground.com/#RNASML
  76595. */
  76596. /**
  76597. * Returns the bounding box size
  76598. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76599. */
  76600. boundingBoxSize: Vector3;
  76601. protected _rotationY: number;
  76602. /**
  76603. * Sets texture matrix rotation angle around Y axis in radians.
  76604. */
  76605. /**
  76606. * Gets texture matrix rotation angle around Y axis radians.
  76607. */
  76608. rotationY: number;
  76609. /**
  76610. * Are mip maps generated for this texture or not.
  76611. */
  76612. readonly noMipmap: boolean;
  76613. private _noMipmap;
  76614. private _files;
  76615. protected _forcedExtension: Nullable<string>;
  76616. private _extensions;
  76617. private _textureMatrix;
  76618. private _format;
  76619. private _createPolynomials;
  76620. /** @hidden */
  76621. _prefiltered: boolean;
  76622. /**
  76623. * Creates a cube texture from an array of image urls
  76624. * @param files defines an array of image urls
  76625. * @param scene defines the hosting scene
  76626. * @param noMipmap specifies if mip maps are not used
  76627. * @returns a cube texture
  76628. */
  76629. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  76630. /**
  76631. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  76632. * @param url defines the url of the prefiltered texture
  76633. * @param scene defines the scene the texture is attached to
  76634. * @param forcedExtension defines the extension of the file if different from the url
  76635. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76636. * @return the prefiltered texture
  76637. */
  76638. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  76639. /**
  76640. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  76641. * as prefiltered data.
  76642. * @param rootUrl defines the url of the texture or the root name of the six images
  76643. * @param scene defines the scene the texture is attached to
  76644. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  76645. * @param noMipmap defines if mipmaps should be created or not
  76646. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  76647. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  76648. * @param onError defines a callback triggered in case of error during load
  76649. * @param format defines the internal format to use for the texture once loaded
  76650. * @param prefiltered defines whether or not the texture is created from prefiltered data
  76651. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  76652. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76653. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76654. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76655. * @return the cube texture
  76656. */
  76657. 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);
  76658. /**
  76659. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  76660. */
  76661. readonly isPrefiltered: boolean;
  76662. /**
  76663. * Get the current class name of the texture useful for serialization or dynamic coding.
  76664. * @returns "CubeTexture"
  76665. */
  76666. getClassName(): string;
  76667. /**
  76668. * Update the url (and optional buffer) of this texture if url was null during construction.
  76669. * @param url the url of the texture
  76670. * @param forcedExtension defines the extension to use
  76671. * @param onLoad callback called when the texture is loaded (defaults to null)
  76672. */
  76673. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  76674. /**
  76675. * Delays loading of the cube texture
  76676. * @param forcedExtension defines the extension to use
  76677. */
  76678. delayLoad(forcedExtension?: string): void;
  76679. /**
  76680. * Returns the reflection texture matrix
  76681. * @returns the reflection texture matrix
  76682. */
  76683. getReflectionTextureMatrix(): Matrix;
  76684. /**
  76685. * Sets the reflection texture matrix
  76686. * @param value Reflection texture matrix
  76687. */
  76688. setReflectionTextureMatrix(value: Matrix): void;
  76689. /**
  76690. * Parses text to create a cube texture
  76691. * @param parsedTexture define the serialized text to read from
  76692. * @param scene defines the hosting scene
  76693. * @param rootUrl defines the root url of the cube texture
  76694. * @returns a cube texture
  76695. */
  76696. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  76697. /**
  76698. * Makes a clone, or deep copy, of the cube texture
  76699. * @returns a new cube texture
  76700. */
  76701. clone(): CubeTexture;
  76702. }
  76703. }
  76704. declare module BABYLON {
  76705. /**
  76706. * Manages the defines for the Material
  76707. */
  76708. export class MaterialDefines {
  76709. /** @hidden */
  76710. protected _keys: string[];
  76711. private _isDirty;
  76712. /** @hidden */
  76713. _renderId: number;
  76714. /** @hidden */
  76715. _areLightsDirty: boolean;
  76716. /** @hidden */
  76717. _areLightsDisposed: boolean;
  76718. /** @hidden */
  76719. _areAttributesDirty: boolean;
  76720. /** @hidden */
  76721. _areTexturesDirty: boolean;
  76722. /** @hidden */
  76723. _areFresnelDirty: boolean;
  76724. /** @hidden */
  76725. _areMiscDirty: boolean;
  76726. /** @hidden */
  76727. _areImageProcessingDirty: boolean;
  76728. /** @hidden */
  76729. _normals: boolean;
  76730. /** @hidden */
  76731. _uvs: boolean;
  76732. /** @hidden */
  76733. _needNormals: boolean;
  76734. /** @hidden */
  76735. _needUVs: boolean;
  76736. [id: string]: any;
  76737. /**
  76738. * Specifies if the material needs to be re-calculated
  76739. */
  76740. readonly isDirty: boolean;
  76741. /**
  76742. * Marks the material to indicate that it has been re-calculated
  76743. */
  76744. markAsProcessed(): void;
  76745. /**
  76746. * Marks the material to indicate that it needs to be re-calculated
  76747. */
  76748. markAsUnprocessed(): void;
  76749. /**
  76750. * Marks the material to indicate all of its defines need to be re-calculated
  76751. */
  76752. markAllAsDirty(): void;
  76753. /**
  76754. * Marks the material to indicate that image processing needs to be re-calculated
  76755. */
  76756. markAsImageProcessingDirty(): void;
  76757. /**
  76758. * Marks the material to indicate the lights need to be re-calculated
  76759. * @param disposed Defines whether the light is dirty due to dispose or not
  76760. */
  76761. markAsLightDirty(disposed?: boolean): void;
  76762. /**
  76763. * Marks the attribute state as changed
  76764. */
  76765. markAsAttributesDirty(): void;
  76766. /**
  76767. * Marks the texture state as changed
  76768. */
  76769. markAsTexturesDirty(): void;
  76770. /**
  76771. * Marks the fresnel state as changed
  76772. */
  76773. markAsFresnelDirty(): void;
  76774. /**
  76775. * Marks the misc state as changed
  76776. */
  76777. markAsMiscDirty(): void;
  76778. /**
  76779. * Rebuilds the material defines
  76780. */
  76781. rebuild(): void;
  76782. /**
  76783. * Specifies if two material defines are equal
  76784. * @param other - A material define instance to compare to
  76785. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  76786. */
  76787. isEqual(other: MaterialDefines): boolean;
  76788. /**
  76789. * Clones this instance's defines to another instance
  76790. * @param other - material defines to clone values to
  76791. */
  76792. cloneTo(other: MaterialDefines): void;
  76793. /**
  76794. * Resets the material define values
  76795. */
  76796. reset(): void;
  76797. /**
  76798. * Converts the material define values to a string
  76799. * @returns - String of material define information
  76800. */
  76801. toString(): string;
  76802. }
  76803. }
  76804. declare module BABYLON {
  76805. /**
  76806. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  76807. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  76808. * 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;
  76809. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  76810. */
  76811. export class ColorCurves {
  76812. private _dirty;
  76813. private _tempColor;
  76814. private _globalCurve;
  76815. private _highlightsCurve;
  76816. private _midtonesCurve;
  76817. private _shadowsCurve;
  76818. private _positiveCurve;
  76819. private _negativeCurve;
  76820. private _globalHue;
  76821. private _globalDensity;
  76822. private _globalSaturation;
  76823. private _globalExposure;
  76824. /**
  76825. * Gets the global Hue value.
  76826. * 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).
  76827. */
  76828. /**
  76829. * Sets the global Hue value.
  76830. * 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).
  76831. */
  76832. globalHue: number;
  76833. /**
  76834. * Gets the global Density value.
  76835. * 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.
  76836. * Values less than zero provide a filter of opposite hue.
  76837. */
  76838. /**
  76839. * Sets the global Density value.
  76840. * 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.
  76841. * Values less than zero provide a filter of opposite hue.
  76842. */
  76843. globalDensity: number;
  76844. /**
  76845. * Gets the global Saturation 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 saturation and negative values decrease saturation.
  76847. */
  76848. /**
  76849. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  76851. */
  76852. globalSaturation: number;
  76853. /**
  76854. * Gets the global Exposure value.
  76855. * 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.
  76856. */
  76857. /**
  76858. * Sets the global Exposure value.
  76859. * 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.
  76860. */
  76861. globalExposure: number;
  76862. private _highlightsHue;
  76863. private _highlightsDensity;
  76864. private _highlightsSaturation;
  76865. private _highlightsExposure;
  76866. /**
  76867. * Gets the highlights Hue value.
  76868. * 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).
  76869. */
  76870. /**
  76871. * Sets the highlights Hue value.
  76872. * 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).
  76873. */
  76874. highlightsHue: number;
  76875. /**
  76876. * Gets the highlights Density value.
  76877. * 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.
  76878. * Values less than zero provide a filter of opposite hue.
  76879. */
  76880. /**
  76881. * Sets the highlights Density value.
  76882. * 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.
  76883. * Values less than zero provide a filter of opposite hue.
  76884. */
  76885. highlightsDensity: number;
  76886. /**
  76887. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  76889. */
  76890. /**
  76891. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  76893. */
  76894. highlightsSaturation: number;
  76895. /**
  76896. * Gets the highlights Exposure value.
  76897. * 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.
  76898. */
  76899. /**
  76900. * Sets the highlights Exposure value.
  76901. * 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.
  76902. */
  76903. highlightsExposure: number;
  76904. private _midtonesHue;
  76905. private _midtonesDensity;
  76906. private _midtonesSaturation;
  76907. private _midtonesExposure;
  76908. /**
  76909. * Gets the midtones Hue value.
  76910. * 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).
  76911. */
  76912. /**
  76913. * Sets the midtones Hue value.
  76914. * 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).
  76915. */
  76916. midtonesHue: number;
  76917. /**
  76918. * Gets the midtones Density value.
  76919. * 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.
  76920. * Values less than zero provide a filter of opposite hue.
  76921. */
  76922. /**
  76923. * Sets the midtones Density value.
  76924. * 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.
  76925. * Values less than zero provide a filter of opposite hue.
  76926. */
  76927. midtonesDensity: number;
  76928. /**
  76929. * Gets the midtones Saturation 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 saturation and negative values decrease saturation.
  76931. */
  76932. /**
  76933. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  76935. */
  76936. midtonesSaturation: number;
  76937. /**
  76938. * Gets the midtones Exposure value.
  76939. * 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.
  76940. */
  76941. /**
  76942. * Sets the midtones Exposure value.
  76943. * 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.
  76944. */
  76945. midtonesExposure: number;
  76946. private _shadowsHue;
  76947. private _shadowsDensity;
  76948. private _shadowsSaturation;
  76949. private _shadowsExposure;
  76950. /**
  76951. * Gets the shadows Hue value.
  76952. * 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).
  76953. */
  76954. /**
  76955. * Sets the shadows Hue value.
  76956. * 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).
  76957. */
  76958. shadowsHue: number;
  76959. /**
  76960. * Gets the shadows Density value.
  76961. * 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.
  76962. * Values less than zero provide a filter of opposite hue.
  76963. */
  76964. /**
  76965. * Sets the shadows Density value.
  76966. * 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.
  76967. * Values less than zero provide a filter of opposite hue.
  76968. */
  76969. shadowsDensity: number;
  76970. /**
  76971. * Gets the shadows Saturation value.
  76972. * 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.
  76973. */
  76974. /**
  76975. * Sets the shadows Saturation value.
  76976. * 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.
  76977. */
  76978. shadowsSaturation: number;
  76979. /**
  76980. * Gets the shadows Exposure value.
  76981. * 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.
  76982. */
  76983. /**
  76984. * Sets the shadows Exposure value.
  76985. * 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.
  76986. */
  76987. shadowsExposure: number;
  76988. /**
  76989. * Returns the class name
  76990. * @returns The class name
  76991. */
  76992. getClassName(): string;
  76993. /**
  76994. * Binds the color curves to the shader.
  76995. * @param colorCurves The color curve to bind
  76996. * @param effect The effect to bind to
  76997. * @param positiveUniform The positive uniform shader parameter
  76998. * @param neutralUniform The neutral uniform shader parameter
  76999. * @param negativeUniform The negative uniform shader parameter
  77000. */
  77001. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  77002. /**
  77003. * Prepare the list of uniforms associated with the ColorCurves effects.
  77004. * @param uniformsList The list of uniforms used in the effect
  77005. */
  77006. static PrepareUniforms(uniformsList: string[]): void;
  77007. /**
  77008. * Returns color grading data based on a hue, density, saturation and exposure value.
  77009. * @param filterHue The hue of the color filter.
  77010. * @param filterDensity The density of the color filter.
  77011. * @param saturation The saturation.
  77012. * @param exposure The exposure.
  77013. * @param result The result data container.
  77014. */
  77015. private getColorGradingDataToRef;
  77016. /**
  77017. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  77018. * @param value The input slider value in range [-100,100].
  77019. * @returns Adjusted value.
  77020. */
  77021. private static applyColorGradingSliderNonlinear;
  77022. /**
  77023. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  77024. * @param hue The hue (H) input.
  77025. * @param saturation The saturation (S) input.
  77026. * @param brightness The brightness (B) input.
  77027. * @result An RGBA color represented as Vector4.
  77028. */
  77029. private static fromHSBToRef;
  77030. /**
  77031. * Returns a value clamped between min and max
  77032. * @param value The value to clamp
  77033. * @param min The minimum of value
  77034. * @param max The maximum of value
  77035. * @returns The clamped value.
  77036. */
  77037. private static clamp;
  77038. /**
  77039. * Clones the current color curve instance.
  77040. * @return The cloned curves
  77041. */
  77042. clone(): ColorCurves;
  77043. /**
  77044. * Serializes the current color curve instance to a json representation.
  77045. * @return a JSON representation
  77046. */
  77047. serialize(): any;
  77048. /**
  77049. * Parses the color curve from a json representation.
  77050. * @param source the JSON source to parse
  77051. * @return The parsed curves
  77052. */
  77053. static Parse(source: any): ColorCurves;
  77054. }
  77055. }
  77056. declare module BABYLON {
  77057. /**
  77058. * Interface to follow in your material defines to integrate easily the
  77059. * Image proccessing functions.
  77060. * @hidden
  77061. */
  77062. export interface IImageProcessingConfigurationDefines {
  77063. IMAGEPROCESSING: boolean;
  77064. VIGNETTE: boolean;
  77065. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77066. VIGNETTEBLENDMODEOPAQUE: boolean;
  77067. TONEMAPPING: boolean;
  77068. TONEMAPPING_ACES: boolean;
  77069. CONTRAST: boolean;
  77070. EXPOSURE: boolean;
  77071. COLORCURVES: boolean;
  77072. COLORGRADING: boolean;
  77073. COLORGRADING3D: boolean;
  77074. SAMPLER3DGREENDEPTH: boolean;
  77075. SAMPLER3DBGRMAP: boolean;
  77076. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77077. }
  77078. /**
  77079. * @hidden
  77080. */
  77081. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  77082. IMAGEPROCESSING: boolean;
  77083. VIGNETTE: boolean;
  77084. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77085. VIGNETTEBLENDMODEOPAQUE: boolean;
  77086. TONEMAPPING: boolean;
  77087. TONEMAPPING_ACES: boolean;
  77088. CONTRAST: boolean;
  77089. COLORCURVES: boolean;
  77090. COLORGRADING: boolean;
  77091. COLORGRADING3D: boolean;
  77092. SAMPLER3DGREENDEPTH: boolean;
  77093. SAMPLER3DBGRMAP: boolean;
  77094. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77095. EXPOSURE: boolean;
  77096. constructor();
  77097. }
  77098. /**
  77099. * This groups together the common properties used for image processing either in direct forward pass
  77100. * or through post processing effect depending on the use of the image processing pipeline in your scene
  77101. * or not.
  77102. */
  77103. export class ImageProcessingConfiguration {
  77104. /**
  77105. * Default tone mapping applied in BabylonJS.
  77106. */
  77107. static readonly TONEMAPPING_STANDARD: number;
  77108. /**
  77109. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  77110. * to other engines rendering to increase portability.
  77111. */
  77112. static readonly TONEMAPPING_ACES: number;
  77113. /**
  77114. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  77115. */
  77116. colorCurves: Nullable<ColorCurves>;
  77117. private _colorCurvesEnabled;
  77118. /**
  77119. * Gets wether the color curves effect is enabled.
  77120. */
  77121. /**
  77122. * Sets wether the color curves effect is enabled.
  77123. */
  77124. colorCurvesEnabled: boolean;
  77125. private _colorGradingTexture;
  77126. /**
  77127. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77128. */
  77129. /**
  77130. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77131. */
  77132. colorGradingTexture: Nullable<BaseTexture>;
  77133. private _colorGradingEnabled;
  77134. /**
  77135. * Gets wether the color grading effect is enabled.
  77136. */
  77137. /**
  77138. * Sets wether the color grading effect is enabled.
  77139. */
  77140. colorGradingEnabled: boolean;
  77141. private _colorGradingWithGreenDepth;
  77142. /**
  77143. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  77144. */
  77145. /**
  77146. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  77147. */
  77148. colorGradingWithGreenDepth: boolean;
  77149. private _colorGradingBGR;
  77150. /**
  77151. * Gets wether the color grading texture contains BGR values.
  77152. */
  77153. /**
  77154. * Sets wether the color grading texture contains BGR values.
  77155. */
  77156. colorGradingBGR: boolean;
  77157. /** @hidden */
  77158. _exposure: number;
  77159. /**
  77160. * Gets the Exposure used in the effect.
  77161. */
  77162. /**
  77163. * Sets the Exposure used in the effect.
  77164. */
  77165. exposure: number;
  77166. private _toneMappingEnabled;
  77167. /**
  77168. * Gets wether the tone mapping effect is enabled.
  77169. */
  77170. /**
  77171. * Sets wether the tone mapping effect is enabled.
  77172. */
  77173. toneMappingEnabled: boolean;
  77174. private _toneMappingType;
  77175. /**
  77176. * Gets the type of tone mapping effect.
  77177. */
  77178. /**
  77179. * Sets the type of tone mapping effect used in BabylonJS.
  77180. */
  77181. toneMappingType: number;
  77182. protected _contrast: number;
  77183. /**
  77184. * Gets the contrast used in the effect.
  77185. */
  77186. /**
  77187. * Sets the contrast used in the effect.
  77188. */
  77189. contrast: number;
  77190. /**
  77191. * Vignette stretch size.
  77192. */
  77193. vignetteStretch: number;
  77194. /**
  77195. * Vignette centre X Offset.
  77196. */
  77197. vignetteCentreX: number;
  77198. /**
  77199. * Vignette centre Y Offset.
  77200. */
  77201. vignetteCentreY: number;
  77202. /**
  77203. * Vignette weight or intensity of the vignette effect.
  77204. */
  77205. vignetteWeight: number;
  77206. /**
  77207. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  77208. * if vignetteEnabled is set to true.
  77209. */
  77210. vignetteColor: Color4;
  77211. /**
  77212. * Camera field of view used by the Vignette effect.
  77213. */
  77214. vignetteCameraFov: number;
  77215. private _vignetteBlendMode;
  77216. /**
  77217. * Gets the vignette blend mode allowing different kind of effect.
  77218. */
  77219. /**
  77220. * Sets the vignette blend mode allowing different kind of effect.
  77221. */
  77222. vignetteBlendMode: number;
  77223. private _vignetteEnabled;
  77224. /**
  77225. * Gets wether the vignette effect is enabled.
  77226. */
  77227. /**
  77228. * Sets wether the vignette effect is enabled.
  77229. */
  77230. vignetteEnabled: boolean;
  77231. private _applyByPostProcess;
  77232. /**
  77233. * Gets wether the image processing is applied through a post process or not.
  77234. */
  77235. /**
  77236. * Sets wether the image processing is applied through a post process or not.
  77237. */
  77238. applyByPostProcess: boolean;
  77239. private _isEnabled;
  77240. /**
  77241. * Gets wether the image processing is enabled or not.
  77242. */
  77243. /**
  77244. * Sets wether the image processing is enabled or not.
  77245. */
  77246. isEnabled: boolean;
  77247. /**
  77248. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  77249. */
  77250. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  77251. /**
  77252. * Method called each time the image processing information changes requires to recompile the effect.
  77253. */
  77254. protected _updateParameters(): void;
  77255. /**
  77256. * Gets the current class name.
  77257. * @return "ImageProcessingConfiguration"
  77258. */
  77259. getClassName(): string;
  77260. /**
  77261. * Prepare the list of uniforms associated with the Image Processing effects.
  77262. * @param uniforms The list of uniforms used in the effect
  77263. * @param defines the list of defines currently in use
  77264. */
  77265. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  77266. /**
  77267. * Prepare the list of samplers associated with the Image Processing effects.
  77268. * @param samplersList The list of uniforms used in the effect
  77269. * @param defines the list of defines currently in use
  77270. */
  77271. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  77272. /**
  77273. * Prepare the list of defines associated to the shader.
  77274. * @param defines the list of defines to complete
  77275. * @param forPostProcess Define if we are currently in post process mode or not
  77276. */
  77277. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  77278. /**
  77279. * Returns true if all the image processing information are ready.
  77280. * @returns True if ready, otherwise, false
  77281. */
  77282. isReady(): boolean;
  77283. /**
  77284. * Binds the image processing to the shader.
  77285. * @param effect The effect to bind to
  77286. * @param overrideAspectRatio Override the aspect ratio of the effect
  77287. */
  77288. bind(effect: Effect, overrideAspectRatio?: number): void;
  77289. /**
  77290. * Clones the current image processing instance.
  77291. * @return The cloned image processing
  77292. */
  77293. clone(): ImageProcessingConfiguration;
  77294. /**
  77295. * Serializes the current image processing instance to a json representation.
  77296. * @return a JSON representation
  77297. */
  77298. serialize(): any;
  77299. /**
  77300. * Parses the image processing from a json representation.
  77301. * @param source the JSON source to parse
  77302. * @return The parsed image processing
  77303. */
  77304. static Parse(source: any): ImageProcessingConfiguration;
  77305. private static _VIGNETTEMODE_MULTIPLY;
  77306. private static _VIGNETTEMODE_OPAQUE;
  77307. /**
  77308. * Used to apply the vignette as a mix with the pixel color.
  77309. */
  77310. static readonly VIGNETTEMODE_MULTIPLY: number;
  77311. /**
  77312. * Used to apply the vignette as a replacement of the pixel color.
  77313. */
  77314. static readonly VIGNETTEMODE_OPAQUE: number;
  77315. }
  77316. }
  77317. declare module BABYLON {
  77318. /** @hidden */
  77319. export var postprocessVertexShader: {
  77320. name: string;
  77321. shader: string;
  77322. };
  77323. }
  77324. declare module BABYLON {
  77325. interface ThinEngine {
  77326. /**
  77327. * Creates a new render target texture
  77328. * @param size defines the size of the texture
  77329. * @param options defines the options used to create the texture
  77330. * @returns a new render target texture stored in an InternalTexture
  77331. */
  77332. createRenderTargetTexture(size: number | {
  77333. width: number;
  77334. height: number;
  77335. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  77336. /**
  77337. * Creates a depth stencil texture.
  77338. * This is only available in WebGL 2 or with the depth texture extension available.
  77339. * @param size The size of face edge in the texture.
  77340. * @param options The options defining the texture.
  77341. * @returns The texture
  77342. */
  77343. createDepthStencilTexture(size: number | {
  77344. width: number;
  77345. height: number;
  77346. }, options: DepthTextureCreationOptions): InternalTexture;
  77347. /** @hidden */
  77348. _createDepthStencilTexture(size: number | {
  77349. width: number;
  77350. height: number;
  77351. }, options: DepthTextureCreationOptions): InternalTexture;
  77352. }
  77353. }
  77354. declare module BABYLON {
  77355. /** Defines supported spaces */
  77356. export enum Space {
  77357. /** Local (object) space */
  77358. LOCAL = 0,
  77359. /** World space */
  77360. WORLD = 1,
  77361. /** Bone space */
  77362. BONE = 2
  77363. }
  77364. /** Defines the 3 main axes */
  77365. export class Axis {
  77366. /** X axis */
  77367. static X: Vector3;
  77368. /** Y axis */
  77369. static Y: Vector3;
  77370. /** Z axis */
  77371. static Z: Vector3;
  77372. }
  77373. }
  77374. declare module BABYLON {
  77375. /**
  77376. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  77377. * This is the base of the follow, arc rotate cameras and Free camera
  77378. * @see http://doc.babylonjs.com/features/cameras
  77379. */
  77380. export class TargetCamera extends Camera {
  77381. private static _RigCamTransformMatrix;
  77382. private static _TargetTransformMatrix;
  77383. private static _TargetFocalPoint;
  77384. /**
  77385. * Define the current direction the camera is moving to
  77386. */
  77387. cameraDirection: Vector3;
  77388. /**
  77389. * Define the current rotation the camera is rotating to
  77390. */
  77391. cameraRotation: Vector2;
  77392. /**
  77393. * When set, the up vector of the camera will be updated by the rotation of the camera
  77394. */
  77395. updateUpVectorFromRotation: boolean;
  77396. private _tmpQuaternion;
  77397. /**
  77398. * Define the current rotation of the camera
  77399. */
  77400. rotation: Vector3;
  77401. /**
  77402. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  77403. */
  77404. rotationQuaternion: Quaternion;
  77405. /**
  77406. * Define the current speed of the camera
  77407. */
  77408. speed: number;
  77409. /**
  77410. * Add constraint to the camera to prevent it to move freely in all directions and
  77411. * around all axis.
  77412. */
  77413. noRotationConstraint: boolean;
  77414. /**
  77415. * Define the current target of the camera as an object or a position.
  77416. */
  77417. lockedTarget: any;
  77418. /** @hidden */
  77419. _currentTarget: Vector3;
  77420. /** @hidden */
  77421. _initialFocalDistance: number;
  77422. /** @hidden */
  77423. _viewMatrix: Matrix;
  77424. /** @hidden */
  77425. _camMatrix: Matrix;
  77426. /** @hidden */
  77427. _cameraTransformMatrix: Matrix;
  77428. /** @hidden */
  77429. _cameraRotationMatrix: Matrix;
  77430. /** @hidden */
  77431. _referencePoint: Vector3;
  77432. /** @hidden */
  77433. _transformedReferencePoint: Vector3;
  77434. protected _globalCurrentTarget: Vector3;
  77435. protected _globalCurrentUpVector: Vector3;
  77436. /** @hidden */
  77437. _reset: () => void;
  77438. private _defaultUp;
  77439. /**
  77440. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  77441. * This is the base of the follow, arc rotate cameras and Free camera
  77442. * @see http://doc.babylonjs.com/features/cameras
  77443. * @param name Defines the name of the camera in the scene
  77444. * @param position Defines the start position of the camera in the scene
  77445. * @param scene Defines the scene the camera belongs to
  77446. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77447. */
  77448. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77449. /**
  77450. * Gets the position in front of the camera at a given distance.
  77451. * @param distance The distance from the camera we want the position to be
  77452. * @returns the position
  77453. */
  77454. getFrontPosition(distance: number): Vector3;
  77455. /** @hidden */
  77456. _getLockedTargetPosition(): Nullable<Vector3>;
  77457. private _storedPosition;
  77458. private _storedRotation;
  77459. private _storedRotationQuaternion;
  77460. /**
  77461. * Store current camera state of the camera (fov, position, rotation, etc..)
  77462. * @returns the camera
  77463. */
  77464. storeState(): Camera;
  77465. /**
  77466. * Restored camera state. You must call storeState() first
  77467. * @returns whether it was successful or not
  77468. * @hidden
  77469. */
  77470. _restoreStateValues(): boolean;
  77471. /** @hidden */
  77472. _initCache(): void;
  77473. /** @hidden */
  77474. _updateCache(ignoreParentClass?: boolean): void;
  77475. /** @hidden */
  77476. _isSynchronizedViewMatrix(): boolean;
  77477. /** @hidden */
  77478. _computeLocalCameraSpeed(): number;
  77479. /**
  77480. * Defines the target the camera should look at.
  77481. * @param target Defines the new target as a Vector or a mesh
  77482. */
  77483. setTarget(target: Vector3): void;
  77484. /**
  77485. * Return the current target position of the camera. This value is expressed in local space.
  77486. * @returns the target position
  77487. */
  77488. getTarget(): Vector3;
  77489. /** @hidden */
  77490. _decideIfNeedsToMove(): boolean;
  77491. /** @hidden */
  77492. _updatePosition(): void;
  77493. /** @hidden */
  77494. _checkInputs(): void;
  77495. protected _updateCameraRotationMatrix(): void;
  77496. /**
  77497. * 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)
  77498. * @returns the current camera
  77499. */
  77500. private _rotateUpVectorWithCameraRotationMatrix;
  77501. private _cachedRotationZ;
  77502. private _cachedQuaternionRotationZ;
  77503. /** @hidden */
  77504. _getViewMatrix(): Matrix;
  77505. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  77506. /**
  77507. * @hidden
  77508. */
  77509. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  77510. /**
  77511. * @hidden
  77512. */
  77513. _updateRigCameras(): void;
  77514. private _getRigCamPositionAndTarget;
  77515. /**
  77516. * Gets the current object class name.
  77517. * @return the class name
  77518. */
  77519. getClassName(): string;
  77520. }
  77521. }
  77522. declare module BABYLON {
  77523. /**
  77524. * Gather the list of keyboard event types as constants.
  77525. */
  77526. export class KeyboardEventTypes {
  77527. /**
  77528. * The keydown event is fired when a key becomes active (pressed).
  77529. */
  77530. static readonly KEYDOWN: number;
  77531. /**
  77532. * The keyup event is fired when a key has been released.
  77533. */
  77534. static readonly KEYUP: number;
  77535. }
  77536. /**
  77537. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77538. */
  77539. export class KeyboardInfo {
  77540. /**
  77541. * Defines the type of event (KeyboardEventTypes)
  77542. */
  77543. type: number;
  77544. /**
  77545. * Defines the related dom event
  77546. */
  77547. event: KeyboardEvent;
  77548. /**
  77549. * Instantiates a new keyboard info.
  77550. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77551. * @param type Defines the type of event (KeyboardEventTypes)
  77552. * @param event Defines the related dom event
  77553. */
  77554. constructor(
  77555. /**
  77556. * Defines the type of event (KeyboardEventTypes)
  77557. */
  77558. type: number,
  77559. /**
  77560. * Defines the related dom event
  77561. */
  77562. event: KeyboardEvent);
  77563. }
  77564. /**
  77565. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77566. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  77567. */
  77568. export class KeyboardInfoPre extends KeyboardInfo {
  77569. /**
  77570. * Defines the type of event (KeyboardEventTypes)
  77571. */
  77572. type: number;
  77573. /**
  77574. * Defines the related dom event
  77575. */
  77576. event: KeyboardEvent;
  77577. /**
  77578. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  77579. */
  77580. skipOnPointerObservable: boolean;
  77581. /**
  77582. * Instantiates a new keyboard pre info.
  77583. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77584. * @param type Defines the type of event (KeyboardEventTypes)
  77585. * @param event Defines the related dom event
  77586. */
  77587. constructor(
  77588. /**
  77589. * Defines the type of event (KeyboardEventTypes)
  77590. */
  77591. type: number,
  77592. /**
  77593. * Defines the related dom event
  77594. */
  77595. event: KeyboardEvent);
  77596. }
  77597. }
  77598. declare module BABYLON {
  77599. /**
  77600. * Manage the keyboard inputs to control the movement of a free camera.
  77601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77602. */
  77603. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  77604. /**
  77605. * Defines the camera the input is attached to.
  77606. */
  77607. camera: FreeCamera;
  77608. /**
  77609. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77610. */
  77611. keysUp: number[];
  77612. /**
  77613. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77614. */
  77615. keysDown: number[];
  77616. /**
  77617. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77618. */
  77619. keysLeft: number[];
  77620. /**
  77621. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77622. */
  77623. keysRight: number[];
  77624. private _keys;
  77625. private _onCanvasBlurObserver;
  77626. private _onKeyboardObserver;
  77627. private _engine;
  77628. private _scene;
  77629. /**
  77630. * Attach the input controls to a specific dom element to get the input from.
  77631. * @param element Defines the element the controls should be listened from
  77632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77633. */
  77634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77635. /**
  77636. * Detach the current controls from the specified dom element.
  77637. * @param element Defines the element to stop listening the inputs from
  77638. */
  77639. detachControl(element: Nullable<HTMLElement>): void;
  77640. /**
  77641. * Update the current camera state depending on the inputs that have been used this frame.
  77642. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77643. */
  77644. checkInputs(): void;
  77645. /**
  77646. * Gets the class name of the current intput.
  77647. * @returns the class name
  77648. */
  77649. getClassName(): string;
  77650. /** @hidden */
  77651. _onLostFocus(): void;
  77652. /**
  77653. * Get the friendly name associated with the input class.
  77654. * @returns the input friendly name
  77655. */
  77656. getSimpleName(): string;
  77657. }
  77658. }
  77659. declare module BABYLON {
  77660. /**
  77661. * Interface describing all the common properties and methods a shadow light needs to implement.
  77662. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  77663. * as well as binding the different shadow properties to the effects.
  77664. */
  77665. export interface IShadowLight extends Light {
  77666. /**
  77667. * The light id in the scene (used in scene.findLighById for instance)
  77668. */
  77669. id: string;
  77670. /**
  77671. * The position the shdow will be casted from.
  77672. */
  77673. position: Vector3;
  77674. /**
  77675. * In 2d mode (needCube being false), the direction used to cast the shadow.
  77676. */
  77677. direction: Vector3;
  77678. /**
  77679. * The transformed position. Position of the light in world space taking parenting in account.
  77680. */
  77681. transformedPosition: Vector3;
  77682. /**
  77683. * The transformed direction. Direction of the light in world space taking parenting in account.
  77684. */
  77685. transformedDirection: Vector3;
  77686. /**
  77687. * The friendly name of the light in the scene.
  77688. */
  77689. name: string;
  77690. /**
  77691. * Defines the shadow projection clipping minimum z value.
  77692. */
  77693. shadowMinZ: number;
  77694. /**
  77695. * Defines the shadow projection clipping maximum z value.
  77696. */
  77697. shadowMaxZ: number;
  77698. /**
  77699. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77700. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77701. */
  77702. computeTransformedInformation(): boolean;
  77703. /**
  77704. * Gets the scene the light belongs to.
  77705. * @returns The scene
  77706. */
  77707. getScene(): Scene;
  77708. /**
  77709. * Callback defining a custom Projection Matrix Builder.
  77710. * This can be used to override the default projection matrix computation.
  77711. */
  77712. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77713. /**
  77714. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77715. * @param matrix The materix to updated with the projection information
  77716. * @param viewMatrix The transform matrix of the light
  77717. * @param renderList The list of mesh to render in the map
  77718. * @returns The current light
  77719. */
  77720. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77721. /**
  77722. * Gets the current depth scale used in ESM.
  77723. * @returns The scale
  77724. */
  77725. getDepthScale(): number;
  77726. /**
  77727. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77728. * @returns true if a cube texture needs to be use
  77729. */
  77730. needCube(): boolean;
  77731. /**
  77732. * Detects if the projection matrix requires to be recomputed this frame.
  77733. * @returns true if it requires to be recomputed otherwise, false.
  77734. */
  77735. needProjectionMatrixCompute(): boolean;
  77736. /**
  77737. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77738. */
  77739. forceProjectionMatrixCompute(): void;
  77740. /**
  77741. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77742. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77743. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77744. */
  77745. getShadowDirection(faceIndex?: number): Vector3;
  77746. /**
  77747. * Gets the minZ used for shadow according to both the scene and the light.
  77748. * @param activeCamera The camera we are returning the min for
  77749. * @returns the depth min z
  77750. */
  77751. getDepthMinZ(activeCamera: Camera): number;
  77752. /**
  77753. * Gets the maxZ used for shadow according to both the scene and the light.
  77754. * @param activeCamera The camera we are returning the max for
  77755. * @returns the depth max z
  77756. */
  77757. getDepthMaxZ(activeCamera: Camera): number;
  77758. }
  77759. /**
  77760. * Base implementation IShadowLight
  77761. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  77762. */
  77763. export abstract class ShadowLight extends Light implements IShadowLight {
  77764. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  77765. protected _position: Vector3;
  77766. protected _setPosition(value: Vector3): void;
  77767. /**
  77768. * Sets the position the shadow will be casted from. Also use as the light position for both
  77769. * point and spot lights.
  77770. */
  77771. /**
  77772. * Sets the position the shadow will be casted from. Also use as the light position for both
  77773. * point and spot lights.
  77774. */
  77775. position: Vector3;
  77776. protected _direction: Vector3;
  77777. protected _setDirection(value: Vector3): void;
  77778. /**
  77779. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  77780. * Also use as the light direction on spot and directional lights.
  77781. */
  77782. /**
  77783. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  77784. * Also use as the light direction on spot and directional lights.
  77785. */
  77786. direction: Vector3;
  77787. private _shadowMinZ;
  77788. /**
  77789. * Gets the shadow projection clipping minimum z value.
  77790. */
  77791. /**
  77792. * Sets the shadow projection clipping minimum z value.
  77793. */
  77794. shadowMinZ: number;
  77795. private _shadowMaxZ;
  77796. /**
  77797. * Sets the shadow projection clipping maximum z value.
  77798. */
  77799. /**
  77800. * Gets the shadow projection clipping maximum z value.
  77801. */
  77802. shadowMaxZ: number;
  77803. /**
  77804. * Callback defining a custom Projection Matrix Builder.
  77805. * This can be used to override the default projection matrix computation.
  77806. */
  77807. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77808. /**
  77809. * The transformed position. Position of the light in world space taking parenting in account.
  77810. */
  77811. transformedPosition: Vector3;
  77812. /**
  77813. * The transformed direction. Direction of the light in world space taking parenting in account.
  77814. */
  77815. transformedDirection: Vector3;
  77816. private _needProjectionMatrixCompute;
  77817. /**
  77818. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77819. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77820. */
  77821. computeTransformedInformation(): boolean;
  77822. /**
  77823. * Return the depth scale used for the shadow map.
  77824. * @returns the depth scale.
  77825. */
  77826. getDepthScale(): number;
  77827. /**
  77828. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77829. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77830. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77831. */
  77832. getShadowDirection(faceIndex?: number): Vector3;
  77833. /**
  77834. * Returns the ShadowLight absolute position in the World.
  77835. * @returns the position vector in world space
  77836. */
  77837. getAbsolutePosition(): Vector3;
  77838. /**
  77839. * Sets the ShadowLight direction toward the passed target.
  77840. * @param target The point to target in local space
  77841. * @returns the updated ShadowLight direction
  77842. */
  77843. setDirectionToTarget(target: Vector3): Vector3;
  77844. /**
  77845. * Returns the light rotation in euler definition.
  77846. * @returns the x y z rotation in local space.
  77847. */
  77848. getRotation(): Vector3;
  77849. /**
  77850. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77851. * @returns true if a cube texture needs to be use
  77852. */
  77853. needCube(): boolean;
  77854. /**
  77855. * Detects if the projection matrix requires to be recomputed this frame.
  77856. * @returns true if it requires to be recomputed otherwise, false.
  77857. */
  77858. needProjectionMatrixCompute(): boolean;
  77859. /**
  77860. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77861. */
  77862. forceProjectionMatrixCompute(): void;
  77863. /** @hidden */
  77864. _initCache(): void;
  77865. /** @hidden */
  77866. _isSynchronized(): boolean;
  77867. /**
  77868. * Computes the world matrix of the node
  77869. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77870. * @returns the world matrix
  77871. */
  77872. computeWorldMatrix(force?: boolean): Matrix;
  77873. /**
  77874. * Gets the minZ used for shadow according to both the scene and the light.
  77875. * @param activeCamera The camera we are returning the min for
  77876. * @returns the depth min z
  77877. */
  77878. getDepthMinZ(activeCamera: Camera): number;
  77879. /**
  77880. * Gets the maxZ used for shadow according to both the scene and the light.
  77881. * @param activeCamera The camera we are returning the max for
  77882. * @returns the depth max z
  77883. */
  77884. getDepthMaxZ(activeCamera: Camera): number;
  77885. /**
  77886. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77887. * @param matrix The materix to updated with the projection information
  77888. * @param viewMatrix The transform matrix of the light
  77889. * @param renderList The list of mesh to render in the map
  77890. * @returns The current light
  77891. */
  77892. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77893. }
  77894. }
  77895. declare module BABYLON {
  77896. /**
  77897. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77898. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77899. */
  77900. export class EffectFallbacks implements IEffectFallbacks {
  77901. private _defines;
  77902. private _currentRank;
  77903. private _maxRank;
  77904. private _mesh;
  77905. /**
  77906. * Removes the fallback from the bound mesh.
  77907. */
  77908. unBindMesh(): void;
  77909. /**
  77910. * Adds a fallback on the specified property.
  77911. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77912. * @param define The name of the define in the shader
  77913. */
  77914. addFallback(rank: number, define: string): void;
  77915. /**
  77916. * Sets the mesh to use CPU skinning when needing to fallback.
  77917. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77918. * @param mesh The mesh to use the fallbacks.
  77919. */
  77920. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77921. /**
  77922. * Checks to see if more fallbacks are still availible.
  77923. */
  77924. readonly hasMoreFallbacks: boolean;
  77925. /**
  77926. * Removes the defines that should be removed when falling back.
  77927. * @param currentDefines defines the current define statements for the shader.
  77928. * @param effect defines the current effect we try to compile
  77929. * @returns The resulting defines with defines of the current rank removed.
  77930. */
  77931. reduce(currentDefines: string, effect: Effect): string;
  77932. }
  77933. }
  77934. declare module BABYLON {
  77935. /**
  77936. * "Static Class" containing the most commonly used helper while dealing with material for
  77937. * rendering purpose.
  77938. *
  77939. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77940. *
  77941. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77942. */
  77943. export class MaterialHelper {
  77944. /**
  77945. * Bind the current view position to an effect.
  77946. * @param effect The effect to be bound
  77947. * @param scene The scene the eyes position is used from
  77948. */
  77949. static BindEyePosition(effect: Effect, scene: Scene): void;
  77950. /**
  77951. * Helps preparing the defines values about the UVs in used in the effect.
  77952. * UVs are shared as much as we can accross channels in the shaders.
  77953. * @param texture The texture we are preparing the UVs for
  77954. * @param defines The defines to update
  77955. * @param key The channel key "diffuse", "specular"... used in the shader
  77956. */
  77957. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77958. /**
  77959. * Binds a texture matrix value to its corrsponding uniform
  77960. * @param texture The texture to bind the matrix for
  77961. * @param uniformBuffer The uniform buffer receivin the data
  77962. * @param key The channel key "diffuse", "specular"... used in the shader
  77963. */
  77964. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77965. /**
  77966. * Gets the current status of the fog (should it be enabled?)
  77967. * @param mesh defines the mesh to evaluate for fog support
  77968. * @param scene defines the hosting scene
  77969. * @returns true if fog must be enabled
  77970. */
  77971. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77972. /**
  77973. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77974. * @param mesh defines the current mesh
  77975. * @param scene defines the current scene
  77976. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77977. * @param pointsCloud defines if point cloud rendering has to be turned on
  77978. * @param fogEnabled defines if fog has to be turned on
  77979. * @param alphaTest defines if alpha testing has to be turned on
  77980. * @param defines defines the current list of defines
  77981. */
  77982. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77983. /**
  77984. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77985. * @param scene defines the current scene
  77986. * @param engine defines the current engine
  77987. * @param defines specifies the list of active defines
  77988. * @param useInstances defines if instances have to be turned on
  77989. * @param useClipPlane defines if clip plane have to be turned on
  77990. */
  77991. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77992. /**
  77993. * Prepares the defines for bones
  77994. * @param mesh The mesh containing the geometry data we will draw
  77995. * @param defines The defines to update
  77996. */
  77997. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77998. /**
  77999. * Prepares the defines for morph targets
  78000. * @param mesh The mesh containing the geometry data we will draw
  78001. * @param defines The defines to update
  78002. */
  78003. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  78004. /**
  78005. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  78006. * @param mesh The mesh containing the geometry data we will draw
  78007. * @param defines The defines to update
  78008. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  78009. * @param useBones Precise whether bones should be used or not (override mesh info)
  78010. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  78011. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  78012. * @returns false if defines are considered not dirty and have not been checked
  78013. */
  78014. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  78015. /**
  78016. * Prepares the defines related to multiview
  78017. * @param scene The scene we are intending to draw
  78018. * @param defines The defines to update
  78019. */
  78020. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  78021. /**
  78022. * Prepares the defines related to the light information passed in parameter
  78023. * @param scene The scene we are intending to draw
  78024. * @param mesh The mesh the effect is compiling for
  78025. * @param light The light the effect is compiling for
  78026. * @param lightIndex The index of the light
  78027. * @param defines The defines to update
  78028. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  78029. * @param state Defines the current state regarding what is needed (normals, etc...)
  78030. */
  78031. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  78032. needNormals: boolean;
  78033. needRebuild: boolean;
  78034. shadowEnabled: boolean;
  78035. specularEnabled: boolean;
  78036. lightmapMode: boolean;
  78037. }): void;
  78038. /**
  78039. * Prepares the defines related to the light information passed in parameter
  78040. * @param scene The scene we are intending to draw
  78041. * @param mesh The mesh the effect is compiling for
  78042. * @param defines The defines to update
  78043. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  78044. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  78045. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  78046. * @returns true if normals will be required for the rest of the effect
  78047. */
  78048. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  78049. /**
  78050. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  78051. * @param lightIndex defines the light index
  78052. * @param uniformsList The uniform list
  78053. * @param samplersList The sampler list
  78054. * @param projectedLightTexture defines if projected texture must be used
  78055. * @param uniformBuffersList defines an optional list of uniform buffers
  78056. */
  78057. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  78058. /**
  78059. * Prepares the uniforms and samplers list to be used in the effect
  78060. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  78061. * @param samplersList The sampler list
  78062. * @param defines The defines helping in the list generation
  78063. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  78064. */
  78065. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  78066. /**
  78067. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  78068. * @param defines The defines to update while falling back
  78069. * @param fallbacks The authorized effect fallbacks
  78070. * @param maxSimultaneousLights The maximum number of lights allowed
  78071. * @param rank the current rank of the Effect
  78072. * @returns The newly affected rank
  78073. */
  78074. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  78075. private static _TmpMorphInfluencers;
  78076. /**
  78077. * Prepares the list of attributes required for morph targets according to the effect defines.
  78078. * @param attribs The current list of supported attribs
  78079. * @param mesh The mesh to prepare the morph targets attributes for
  78080. * @param influencers The number of influencers
  78081. */
  78082. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  78083. /**
  78084. * Prepares the list of attributes required for morph targets according to the effect defines.
  78085. * @param attribs The current list of supported attribs
  78086. * @param mesh The mesh to prepare the morph targets attributes for
  78087. * @param defines The current Defines of the effect
  78088. */
  78089. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  78090. /**
  78091. * Prepares the list of attributes required for bones according to the effect defines.
  78092. * @param attribs The current list of supported attribs
  78093. * @param mesh The mesh to prepare the bones attributes for
  78094. * @param defines The current Defines of the effect
  78095. * @param fallbacks The current efffect fallback strategy
  78096. */
  78097. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  78098. /**
  78099. * Check and prepare the list of attributes required for instances according to the effect defines.
  78100. * @param attribs The current list of supported attribs
  78101. * @param defines The current MaterialDefines of the effect
  78102. */
  78103. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  78104. /**
  78105. * Add the list of attributes required for instances to the attribs array.
  78106. * @param attribs The current list of supported attribs
  78107. */
  78108. static PushAttributesForInstances(attribs: string[]): void;
  78109. /**
  78110. * Binds the light information to the effect.
  78111. * @param light The light containing the generator
  78112. * @param effect The effect we are binding the data to
  78113. * @param lightIndex The light index in the effect used to render
  78114. */
  78115. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  78116. /**
  78117. * Binds the lights information from the scene to the effect for the given mesh.
  78118. * @param light Light to bind
  78119. * @param lightIndex Light index
  78120. * @param scene The scene where the light belongs to
  78121. * @param effect The effect we are binding the data to
  78122. * @param useSpecular Defines if specular is supported
  78123. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78124. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78125. */
  78126. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78127. /**
  78128. * Binds the lights information from the scene to the effect for the given mesh.
  78129. * @param scene The scene the lights belongs to
  78130. * @param mesh The mesh we are binding the information to render
  78131. * @param effect The effect we are binding the data to
  78132. * @param defines The generated defines for the effect
  78133. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  78134. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78135. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78136. */
  78137. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78138. private static _tempFogColor;
  78139. /**
  78140. * Binds the fog information from the scene to the effect for the given mesh.
  78141. * @param scene The scene the lights belongs to
  78142. * @param mesh The mesh we are binding the information to render
  78143. * @param effect The effect we are binding the data to
  78144. * @param linearSpace Defines if the fog effect is applied in linear space
  78145. */
  78146. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  78147. /**
  78148. * Binds the bones information from the mesh to the effect.
  78149. * @param mesh The mesh we are binding the information to render
  78150. * @param effect The effect we are binding the data to
  78151. */
  78152. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  78153. /**
  78154. * Binds the morph targets information from the mesh to the effect.
  78155. * @param abstractMesh The mesh we are binding the information to render
  78156. * @param effect The effect we are binding the data to
  78157. */
  78158. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  78159. /**
  78160. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  78161. * @param defines The generated defines used in the effect
  78162. * @param effect The effect we are binding the data to
  78163. * @param scene The scene we are willing to render with logarithmic scale for
  78164. */
  78165. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  78166. /**
  78167. * Binds the clip plane information from the scene to the effect.
  78168. * @param scene The scene the clip plane information are extracted from
  78169. * @param effect The effect we are binding the data to
  78170. */
  78171. static BindClipPlane(effect: Effect, scene: Scene): void;
  78172. }
  78173. }
  78174. declare module BABYLON {
  78175. /** @hidden */
  78176. export var packingFunctions: {
  78177. name: string;
  78178. shader: string;
  78179. };
  78180. }
  78181. declare module BABYLON {
  78182. /** @hidden */
  78183. export var shadowMapPixelShader: {
  78184. name: string;
  78185. shader: string;
  78186. };
  78187. }
  78188. declare module BABYLON {
  78189. /** @hidden */
  78190. export var bonesDeclaration: {
  78191. name: string;
  78192. shader: string;
  78193. };
  78194. }
  78195. declare module BABYLON {
  78196. /** @hidden */
  78197. export var morphTargetsVertexGlobalDeclaration: {
  78198. name: string;
  78199. shader: string;
  78200. };
  78201. }
  78202. declare module BABYLON {
  78203. /** @hidden */
  78204. export var morphTargetsVertexDeclaration: {
  78205. name: string;
  78206. shader: string;
  78207. };
  78208. }
  78209. declare module BABYLON {
  78210. /** @hidden */
  78211. export var instancesDeclaration: {
  78212. name: string;
  78213. shader: string;
  78214. };
  78215. }
  78216. declare module BABYLON {
  78217. /** @hidden */
  78218. export var helperFunctions: {
  78219. name: string;
  78220. shader: string;
  78221. };
  78222. }
  78223. declare module BABYLON {
  78224. /** @hidden */
  78225. export var morphTargetsVertex: {
  78226. name: string;
  78227. shader: string;
  78228. };
  78229. }
  78230. declare module BABYLON {
  78231. /** @hidden */
  78232. export var instancesVertex: {
  78233. name: string;
  78234. shader: string;
  78235. };
  78236. }
  78237. declare module BABYLON {
  78238. /** @hidden */
  78239. export var bonesVertex: {
  78240. name: string;
  78241. shader: string;
  78242. };
  78243. }
  78244. declare module BABYLON {
  78245. /** @hidden */
  78246. export var shadowMapVertexShader: {
  78247. name: string;
  78248. shader: string;
  78249. };
  78250. }
  78251. declare module BABYLON {
  78252. /** @hidden */
  78253. export var depthBoxBlurPixelShader: {
  78254. name: string;
  78255. shader: string;
  78256. };
  78257. }
  78258. declare module BABYLON {
  78259. /**
  78260. * Defines the options associated with the creation of a custom shader for a shadow generator.
  78261. */
  78262. export interface ICustomShaderOptions {
  78263. /**
  78264. * Gets or sets the custom shader name to use
  78265. */
  78266. shaderName: string;
  78267. /**
  78268. * The list of attribute names used in the shader
  78269. */
  78270. attributes?: string[];
  78271. /**
  78272. * The list of unifrom names used in the shader
  78273. */
  78274. uniforms?: string[];
  78275. /**
  78276. * The list of sampler names used in the shader
  78277. */
  78278. samplers?: string[];
  78279. /**
  78280. * The list of defines used in the shader
  78281. */
  78282. defines?: string[];
  78283. }
  78284. /**
  78285. * Interface to implement to create a shadow generator compatible with BJS.
  78286. */
  78287. export interface IShadowGenerator {
  78288. /**
  78289. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78290. * @returns The render target texture if present otherwise, null
  78291. */
  78292. getShadowMap(): Nullable<RenderTargetTexture>;
  78293. /**
  78294. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78295. * @returns The render target texture if the shadow map is present otherwise, null
  78296. */
  78297. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78298. /**
  78299. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78300. * @param subMesh The submesh we want to render in the shadow map
  78301. * @param useInstances Defines wether will draw in the map using instances
  78302. * @returns true if ready otherwise, false
  78303. */
  78304. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78305. /**
  78306. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78307. * @param defines Defines of the material we want to update
  78308. * @param lightIndex Index of the light in the enabled light list of the material
  78309. */
  78310. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  78311. /**
  78312. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78313. * defined in the generator but impacting the effect).
  78314. * It implies the unifroms available on the materials are the standard BJS ones.
  78315. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78316. * @param effect The effect we are binfing the information for
  78317. */
  78318. bindShadowLight(lightIndex: string, effect: Effect): void;
  78319. /**
  78320. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78321. * (eq to shadow prjection matrix * light transform matrix)
  78322. * @returns The transform matrix used to create the shadow map
  78323. */
  78324. getTransformMatrix(): Matrix;
  78325. /**
  78326. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78327. * Cube and 2D textures for instance.
  78328. */
  78329. recreateShadowMap(): void;
  78330. /**
  78331. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78332. * @param onCompiled Callback triggered at the and of the effects compilation
  78333. * @param options Sets of optional options forcing the compilation with different modes
  78334. */
  78335. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78336. useInstances: boolean;
  78337. }>): void;
  78338. /**
  78339. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78340. * @param options Sets of optional options forcing the compilation with different modes
  78341. * @returns A promise that resolves when the compilation completes
  78342. */
  78343. forceCompilationAsync(options?: Partial<{
  78344. useInstances: boolean;
  78345. }>): Promise<void>;
  78346. /**
  78347. * Serializes the shadow generator setup to a json object.
  78348. * @returns The serialized JSON object
  78349. */
  78350. serialize(): any;
  78351. /**
  78352. * Disposes the Shadow map and related Textures and effects.
  78353. */
  78354. dispose(): void;
  78355. }
  78356. /**
  78357. * Default implementation IShadowGenerator.
  78358. * This is the main object responsible of generating shadows in the framework.
  78359. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  78360. */
  78361. export class ShadowGenerator implements IShadowGenerator {
  78362. /**
  78363. * Shadow generator mode None: no filtering applied.
  78364. */
  78365. static readonly FILTER_NONE: number;
  78366. /**
  78367. * Shadow generator mode ESM: Exponential Shadow Mapping.
  78368. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78369. */
  78370. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  78371. /**
  78372. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  78373. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  78374. */
  78375. static readonly FILTER_POISSONSAMPLING: number;
  78376. /**
  78377. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  78378. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78379. */
  78380. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  78381. /**
  78382. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  78383. * edge artifacts on steep falloff.
  78384. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78385. */
  78386. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  78387. /**
  78388. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  78389. * edge artifacts on steep falloff.
  78390. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78391. */
  78392. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  78393. /**
  78394. * Shadow generator mode PCF: Percentage Closer Filtering
  78395. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78396. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  78397. */
  78398. static readonly FILTER_PCF: number;
  78399. /**
  78400. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  78401. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78402. * Contact Hardening
  78403. */
  78404. static readonly FILTER_PCSS: number;
  78405. /**
  78406. * Reserved for PCF and PCSS
  78407. * Highest Quality.
  78408. *
  78409. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  78410. *
  78411. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  78412. */
  78413. static readonly QUALITY_HIGH: number;
  78414. /**
  78415. * Reserved for PCF and PCSS
  78416. * Good tradeoff for quality/perf cross devices
  78417. *
  78418. * Execute PCF on a 3*3 kernel.
  78419. *
  78420. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  78421. */
  78422. static readonly QUALITY_MEDIUM: number;
  78423. /**
  78424. * Reserved for PCF and PCSS
  78425. * The lowest quality but the fastest.
  78426. *
  78427. * Execute PCF on a 1*1 kernel.
  78428. *
  78429. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  78430. */
  78431. static readonly QUALITY_LOW: number;
  78432. /** Gets or sets the custom shader name to use */
  78433. customShaderOptions: ICustomShaderOptions;
  78434. /**
  78435. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  78436. */
  78437. onBeforeShadowMapRenderObservable: Observable<Effect>;
  78438. /**
  78439. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  78440. */
  78441. onAfterShadowMapRenderObservable: Observable<Effect>;
  78442. /**
  78443. * Observable triggered before a mesh is rendered in the shadow map.
  78444. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  78445. */
  78446. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  78447. /**
  78448. * Observable triggered after a mesh is rendered in the shadow map.
  78449. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  78450. */
  78451. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  78452. private _bias;
  78453. /**
  78454. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  78455. */
  78456. /**
  78457. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  78458. */
  78459. bias: number;
  78460. private _normalBias;
  78461. /**
  78462. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78463. */
  78464. /**
  78465. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78466. */
  78467. normalBias: number;
  78468. private _blurBoxOffset;
  78469. /**
  78470. * Gets the blur box offset: offset applied during the blur pass.
  78471. * Only useful if useKernelBlur = false
  78472. */
  78473. /**
  78474. * Sets the blur box offset: offset applied during the blur pass.
  78475. * Only useful if useKernelBlur = false
  78476. */
  78477. blurBoxOffset: number;
  78478. private _blurScale;
  78479. /**
  78480. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  78481. * 2 means half of the size.
  78482. */
  78483. /**
  78484. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  78485. * 2 means half of the size.
  78486. */
  78487. blurScale: number;
  78488. private _blurKernel;
  78489. /**
  78490. * Gets the blur kernel: kernel size of the blur pass.
  78491. * Only useful if useKernelBlur = true
  78492. */
  78493. /**
  78494. * Sets the blur kernel: kernel size of the blur pass.
  78495. * Only useful if useKernelBlur = true
  78496. */
  78497. blurKernel: number;
  78498. private _useKernelBlur;
  78499. /**
  78500. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  78501. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78502. */
  78503. /**
  78504. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  78505. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78506. */
  78507. useKernelBlur: boolean;
  78508. private _depthScale;
  78509. /**
  78510. * Gets the depth scale used in ESM mode.
  78511. */
  78512. /**
  78513. * Sets the depth scale used in ESM mode.
  78514. * This can override the scale stored on the light.
  78515. */
  78516. depthScale: number;
  78517. private _filter;
  78518. /**
  78519. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  78520. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78521. */
  78522. /**
  78523. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  78524. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78525. */
  78526. filter: number;
  78527. /**
  78528. * Gets if the current filter is set to Poisson Sampling.
  78529. */
  78530. /**
  78531. * Sets the current filter to Poisson Sampling.
  78532. */
  78533. usePoissonSampling: boolean;
  78534. /**
  78535. * Gets if the current filter is set to ESM.
  78536. */
  78537. /**
  78538. * Sets the current filter is to ESM.
  78539. */
  78540. useExponentialShadowMap: boolean;
  78541. /**
  78542. * Gets if the current filter is set to filtered ESM.
  78543. */
  78544. /**
  78545. * Gets if the current filter is set to filtered ESM.
  78546. */
  78547. useBlurExponentialShadowMap: boolean;
  78548. /**
  78549. * Gets if the current filter is set to "close ESM" (using the inverse of the
  78550. * exponential to prevent steep falloff artifacts).
  78551. */
  78552. /**
  78553. * Sets the current filter to "close ESM" (using the inverse of the
  78554. * exponential to prevent steep falloff artifacts).
  78555. */
  78556. useCloseExponentialShadowMap: boolean;
  78557. /**
  78558. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  78559. * exponential to prevent steep falloff artifacts).
  78560. */
  78561. /**
  78562. * Sets the current filter to filtered "close ESM" (using the inverse of the
  78563. * exponential to prevent steep falloff artifacts).
  78564. */
  78565. useBlurCloseExponentialShadowMap: boolean;
  78566. /**
  78567. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  78568. */
  78569. /**
  78570. * Sets the current filter to "PCF" (percentage closer filtering).
  78571. */
  78572. usePercentageCloserFiltering: boolean;
  78573. private _filteringQuality;
  78574. /**
  78575. * Gets the PCF or PCSS Quality.
  78576. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78577. */
  78578. /**
  78579. * Sets the PCF or PCSS Quality.
  78580. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78581. */
  78582. filteringQuality: number;
  78583. /**
  78584. * Gets if the current filter is set to "PCSS" (contact hardening).
  78585. */
  78586. /**
  78587. * Sets the current filter to "PCSS" (contact hardening).
  78588. */
  78589. useContactHardeningShadow: boolean;
  78590. private _contactHardeningLightSizeUVRatio;
  78591. /**
  78592. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78593. * Using a ratio helps keeping shape stability independently of the map size.
  78594. *
  78595. * It does not account for the light projection as it was having too much
  78596. * instability during the light setup or during light position changes.
  78597. *
  78598. * Only valid if useContactHardeningShadow is true.
  78599. */
  78600. /**
  78601. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78602. * Using a ratio helps keeping shape stability independently of the map size.
  78603. *
  78604. * It does not account for the light projection as it was having too much
  78605. * instability during the light setup or during light position changes.
  78606. *
  78607. * Only valid if useContactHardeningShadow is true.
  78608. */
  78609. contactHardeningLightSizeUVRatio: number;
  78610. private _darkness;
  78611. /** Gets or sets the actual darkness of a shadow */
  78612. darkness: number;
  78613. /**
  78614. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  78615. * 0 means strongest and 1 would means no shadow.
  78616. * @returns the darkness.
  78617. */
  78618. getDarkness(): number;
  78619. /**
  78620. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  78621. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  78622. * @returns the shadow generator allowing fluent coding.
  78623. */
  78624. setDarkness(darkness: number): ShadowGenerator;
  78625. private _transparencyShadow;
  78626. /** Gets or sets the ability to have transparent shadow */
  78627. transparencyShadow: boolean;
  78628. /**
  78629. * Sets the ability to have transparent shadow (boolean).
  78630. * @param transparent True if transparent else False
  78631. * @returns the shadow generator allowing fluent coding
  78632. */
  78633. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  78634. private _shadowMap;
  78635. private _shadowMap2;
  78636. /**
  78637. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78638. * @returns The render target texture if present otherwise, null
  78639. */
  78640. getShadowMap(): Nullable<RenderTargetTexture>;
  78641. /**
  78642. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78643. * @returns The render target texture if the shadow map is present otherwise, null
  78644. */
  78645. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78646. /**
  78647. * Gets the class name of that object
  78648. * @returns "ShadowGenerator"
  78649. */
  78650. getClassName(): string;
  78651. /**
  78652. * Helper function to add a mesh and its descendants to the list of shadow casters.
  78653. * @param mesh Mesh to add
  78654. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  78655. * @returns the Shadow Generator itself
  78656. */
  78657. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78658. /**
  78659. * Helper function to remove a mesh and its descendants from the list of shadow casters
  78660. * @param mesh Mesh to remove
  78661. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  78662. * @returns the Shadow Generator itself
  78663. */
  78664. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78665. /**
  78666. * Controls the extent to which the shadows fade out at the edge of the frustum
  78667. * Used only by directionals and spots
  78668. */
  78669. frustumEdgeFalloff: number;
  78670. private _light;
  78671. /**
  78672. * Returns the associated light object.
  78673. * @returns the light generating the shadow
  78674. */
  78675. getLight(): IShadowLight;
  78676. /**
  78677. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  78678. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  78679. * It might on the other hand introduce peter panning.
  78680. */
  78681. forceBackFacesOnly: boolean;
  78682. private _scene;
  78683. private _lightDirection;
  78684. private _effect;
  78685. private _viewMatrix;
  78686. private _projectionMatrix;
  78687. private _transformMatrix;
  78688. private _cachedPosition;
  78689. private _cachedDirection;
  78690. private _cachedDefines;
  78691. private _currentRenderID;
  78692. private _boxBlurPostprocess;
  78693. private _kernelBlurXPostprocess;
  78694. private _kernelBlurYPostprocess;
  78695. private _blurPostProcesses;
  78696. private _mapSize;
  78697. private _currentFaceIndex;
  78698. private _currentFaceIndexCache;
  78699. private _textureType;
  78700. private _defaultTextureMatrix;
  78701. private _storedUniqueId;
  78702. /** @hidden */
  78703. static _SceneComponentInitialization: (scene: Scene) => void;
  78704. /**
  78705. * Creates a ShadowGenerator object.
  78706. * A ShadowGenerator is the required tool to use the shadows.
  78707. * Each light casting shadows needs to use its own ShadowGenerator.
  78708. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  78709. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  78710. * @param light The light object generating the shadows.
  78711. * @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.
  78712. */
  78713. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  78714. private _initializeGenerator;
  78715. private _initializeShadowMap;
  78716. private _initializeBlurRTTAndPostProcesses;
  78717. private _renderForShadowMap;
  78718. private _renderSubMeshForShadowMap;
  78719. private _applyFilterValues;
  78720. /**
  78721. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78722. * @param onCompiled Callback triggered at the and of the effects compilation
  78723. * @param options Sets of optional options forcing the compilation with different modes
  78724. */
  78725. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78726. useInstances: boolean;
  78727. }>): void;
  78728. /**
  78729. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78730. * @param options Sets of optional options forcing the compilation with different modes
  78731. * @returns A promise that resolves when the compilation completes
  78732. */
  78733. forceCompilationAsync(options?: Partial<{
  78734. useInstances: boolean;
  78735. }>): Promise<void>;
  78736. /**
  78737. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78738. * @param subMesh The submesh we want to render in the shadow map
  78739. * @param useInstances Defines wether will draw in the map using instances
  78740. * @returns true if ready otherwise, false
  78741. */
  78742. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78743. /**
  78744. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78745. * @param defines Defines of the material we want to update
  78746. * @param lightIndex Index of the light in the enabled light list of the material
  78747. */
  78748. prepareDefines(defines: any, lightIndex: number): void;
  78749. /**
  78750. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78751. * defined in the generator but impacting the effect).
  78752. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78753. * @param effect The effect we are binfing the information for
  78754. */
  78755. bindShadowLight(lightIndex: string, effect: Effect): void;
  78756. /**
  78757. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78758. * (eq to shadow prjection matrix * light transform matrix)
  78759. * @returns The transform matrix used to create the shadow map
  78760. */
  78761. getTransformMatrix(): Matrix;
  78762. /**
  78763. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78764. * Cube and 2D textures for instance.
  78765. */
  78766. recreateShadowMap(): void;
  78767. private _disposeBlurPostProcesses;
  78768. private _disposeRTTandPostProcesses;
  78769. /**
  78770. * Disposes the ShadowGenerator.
  78771. * Returns nothing.
  78772. */
  78773. dispose(): void;
  78774. /**
  78775. * Serializes the shadow generator setup to a json object.
  78776. * @returns The serialized JSON object
  78777. */
  78778. serialize(): any;
  78779. /**
  78780. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  78781. * @param parsedShadowGenerator The JSON object to parse
  78782. * @param scene The scene to create the shadow map for
  78783. * @returns The parsed shadow generator
  78784. */
  78785. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  78786. }
  78787. }
  78788. declare module BABYLON {
  78789. /**
  78790. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  78791. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  78792. * 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.
  78793. */
  78794. export abstract class Light extends Node {
  78795. /**
  78796. * Falloff Default: light is falling off following the material specification:
  78797. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  78798. */
  78799. static readonly FALLOFF_DEFAULT: number;
  78800. /**
  78801. * Falloff Physical: light is falling off following the inverse squared distance law.
  78802. */
  78803. static readonly FALLOFF_PHYSICAL: number;
  78804. /**
  78805. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  78806. * to enhance interoperability with other engines.
  78807. */
  78808. static readonly FALLOFF_GLTF: number;
  78809. /**
  78810. * Falloff Standard: light is falling off like in the standard material
  78811. * to enhance interoperability with other materials.
  78812. */
  78813. static readonly FALLOFF_STANDARD: number;
  78814. /**
  78815. * If every light affecting the material is in this lightmapMode,
  78816. * material.lightmapTexture adds or multiplies
  78817. * (depends on material.useLightmapAsShadowmap)
  78818. * after every other light calculations.
  78819. */
  78820. static readonly LIGHTMAP_DEFAULT: number;
  78821. /**
  78822. * material.lightmapTexture as only diffuse lighting from this light
  78823. * adds only specular lighting from this light
  78824. * adds dynamic shadows
  78825. */
  78826. static readonly LIGHTMAP_SPECULAR: number;
  78827. /**
  78828. * material.lightmapTexture as only lighting
  78829. * no light calculation from this light
  78830. * only adds dynamic shadows from this light
  78831. */
  78832. static readonly LIGHTMAP_SHADOWSONLY: number;
  78833. /**
  78834. * Each light type uses the default quantity according to its type:
  78835. * point/spot lights use luminous intensity
  78836. * directional lights use illuminance
  78837. */
  78838. static readonly INTENSITYMODE_AUTOMATIC: number;
  78839. /**
  78840. * lumen (lm)
  78841. */
  78842. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78843. /**
  78844. * candela (lm/sr)
  78845. */
  78846. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78847. /**
  78848. * lux (lm/m^2)
  78849. */
  78850. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78851. /**
  78852. * nit (cd/m^2)
  78853. */
  78854. static readonly INTENSITYMODE_LUMINANCE: number;
  78855. /**
  78856. * Light type const id of the point light.
  78857. */
  78858. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78859. /**
  78860. * Light type const id of the directional light.
  78861. */
  78862. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78863. /**
  78864. * Light type const id of the spot light.
  78865. */
  78866. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78867. /**
  78868. * Light type const id of the hemispheric light.
  78869. */
  78870. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78871. /**
  78872. * Diffuse gives the basic color to an object.
  78873. */
  78874. diffuse: Color3;
  78875. /**
  78876. * Specular produces a highlight color on an object.
  78877. * Note: This is note affecting PBR materials.
  78878. */
  78879. specular: Color3;
  78880. /**
  78881. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78882. * falling off base on range or angle.
  78883. * This can be set to any values in Light.FALLOFF_x.
  78884. *
  78885. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78886. * other types of materials.
  78887. */
  78888. falloffType: number;
  78889. /**
  78890. * Strength of the light.
  78891. * Note: By default it is define in the framework own unit.
  78892. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78893. */
  78894. intensity: number;
  78895. private _range;
  78896. protected _inverseSquaredRange: number;
  78897. /**
  78898. * Defines how far from the source the light is impacting in scene units.
  78899. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78900. */
  78901. /**
  78902. * Defines how far from the source the light is impacting in scene units.
  78903. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78904. */
  78905. range: number;
  78906. /**
  78907. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78908. * of light.
  78909. */
  78910. private _photometricScale;
  78911. private _intensityMode;
  78912. /**
  78913. * Gets the photometric scale used to interpret the intensity.
  78914. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78915. */
  78916. /**
  78917. * Sets the photometric scale used to interpret the intensity.
  78918. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78919. */
  78920. intensityMode: number;
  78921. private _radius;
  78922. /**
  78923. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78924. */
  78925. /**
  78926. * sets the light radius used by PBR Materials to simulate soft area lights.
  78927. */
  78928. radius: number;
  78929. private _renderPriority;
  78930. /**
  78931. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78932. * exceeding the number allowed of the materials.
  78933. */
  78934. renderPriority: number;
  78935. private _shadowEnabled;
  78936. /**
  78937. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78938. * the current shadow generator.
  78939. */
  78940. /**
  78941. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78942. * the current shadow generator.
  78943. */
  78944. shadowEnabled: boolean;
  78945. private _includedOnlyMeshes;
  78946. /**
  78947. * Gets the only meshes impacted by this light.
  78948. */
  78949. /**
  78950. * Sets the only meshes impacted by this light.
  78951. */
  78952. includedOnlyMeshes: AbstractMesh[];
  78953. private _excludedMeshes;
  78954. /**
  78955. * Gets the meshes not impacted by this light.
  78956. */
  78957. /**
  78958. * Sets the meshes not impacted by this light.
  78959. */
  78960. excludedMeshes: AbstractMesh[];
  78961. private _excludeWithLayerMask;
  78962. /**
  78963. * Gets the layer id use to find what meshes are not impacted by the light.
  78964. * Inactive if 0
  78965. */
  78966. /**
  78967. * Sets the layer id use to find what meshes are not impacted by the light.
  78968. * Inactive if 0
  78969. */
  78970. excludeWithLayerMask: number;
  78971. private _includeOnlyWithLayerMask;
  78972. /**
  78973. * Gets the layer id use to find what meshes are impacted by the light.
  78974. * Inactive if 0
  78975. */
  78976. /**
  78977. * Sets the layer id use to find what meshes are impacted by the light.
  78978. * Inactive if 0
  78979. */
  78980. includeOnlyWithLayerMask: number;
  78981. private _lightmapMode;
  78982. /**
  78983. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78984. */
  78985. /**
  78986. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78987. */
  78988. lightmapMode: number;
  78989. /**
  78990. * Shadow generator associted to the light.
  78991. * @hidden Internal use only.
  78992. */
  78993. _shadowGenerator: Nullable<IShadowGenerator>;
  78994. /**
  78995. * @hidden Internal use only.
  78996. */
  78997. _excludedMeshesIds: string[];
  78998. /**
  78999. * @hidden Internal use only.
  79000. */
  79001. _includedOnlyMeshesIds: string[];
  79002. /**
  79003. * The current light unifom buffer.
  79004. * @hidden Internal use only.
  79005. */
  79006. _uniformBuffer: UniformBuffer;
  79007. /** @hidden */
  79008. _renderId: number;
  79009. /**
  79010. * Creates a Light object in the scene.
  79011. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79012. * @param name The firendly name of the light
  79013. * @param scene The scene the light belongs too
  79014. */
  79015. constructor(name: string, scene: Scene);
  79016. protected abstract _buildUniformLayout(): void;
  79017. /**
  79018. * Sets the passed Effect "effect" with the Light information.
  79019. * @param effect The effect to update
  79020. * @param lightIndex The index of the light in the effect to update
  79021. * @returns The light
  79022. */
  79023. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  79024. /**
  79025. * Sets the passed Effect "effect" with the Light textures.
  79026. * @param effect The effect to update
  79027. * @param lightIndex The index of the light in the effect to update
  79028. * @returns The light
  79029. */
  79030. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  79031. /**
  79032. * Binds the lights information from the scene to the effect for the given mesh.
  79033. * @param lightIndex Light index
  79034. * @param scene The scene where the light belongs to
  79035. * @param effect The effect we are binding the data to
  79036. * @param useSpecular Defines if specular is supported
  79037. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79038. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79039. */
  79040. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79041. /**
  79042. * Sets the passed Effect "effect" with the Light information.
  79043. * @param effect The effect to update
  79044. * @param lightDataUniformName The uniform used to store light data (position or direction)
  79045. * @returns The light
  79046. */
  79047. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  79048. /**
  79049. * Returns the string "Light".
  79050. * @returns the class name
  79051. */
  79052. getClassName(): string;
  79053. /** @hidden */
  79054. readonly _isLight: boolean;
  79055. /**
  79056. * Converts the light information to a readable string for debug purpose.
  79057. * @param fullDetails Supports for multiple levels of logging within scene loading
  79058. * @returns the human readable light info
  79059. */
  79060. toString(fullDetails?: boolean): string;
  79061. /** @hidden */
  79062. protected _syncParentEnabledState(): void;
  79063. /**
  79064. * Set the enabled state of this node.
  79065. * @param value - the new enabled state
  79066. */
  79067. setEnabled(value: boolean): void;
  79068. /**
  79069. * Returns the Light associated shadow generator if any.
  79070. * @return the associated shadow generator.
  79071. */
  79072. getShadowGenerator(): Nullable<IShadowGenerator>;
  79073. /**
  79074. * Returns a Vector3, the absolute light position in the World.
  79075. * @returns the world space position of the light
  79076. */
  79077. getAbsolutePosition(): Vector3;
  79078. /**
  79079. * Specifies if the light will affect the passed mesh.
  79080. * @param mesh The mesh to test against the light
  79081. * @return true the mesh is affected otherwise, false.
  79082. */
  79083. canAffectMesh(mesh: AbstractMesh): boolean;
  79084. /**
  79085. * Sort function to order lights for rendering.
  79086. * @param a First Light object to compare to second.
  79087. * @param b Second Light object to compare first.
  79088. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  79089. */
  79090. static CompareLightsPriority(a: Light, b: Light): number;
  79091. /**
  79092. * Releases resources associated with this node.
  79093. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79094. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79095. */
  79096. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79097. /**
  79098. * Returns the light type ID (integer).
  79099. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79100. */
  79101. getTypeID(): number;
  79102. /**
  79103. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  79104. * @returns the scaled intensity in intensity mode unit
  79105. */
  79106. getScaledIntensity(): number;
  79107. /**
  79108. * Returns a new Light object, named "name", from the current one.
  79109. * @param name The name of the cloned light
  79110. * @returns the new created light
  79111. */
  79112. clone(name: string): Nullable<Light>;
  79113. /**
  79114. * Serializes the current light into a Serialization object.
  79115. * @returns the serialized object.
  79116. */
  79117. serialize(): any;
  79118. /**
  79119. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  79120. * This new light is named "name" and added to the passed scene.
  79121. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  79122. * @param name The friendly name of the light
  79123. * @param scene The scene the new light will belong to
  79124. * @returns the constructor function
  79125. */
  79126. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  79127. /**
  79128. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  79129. * @param parsedLight The JSON representation of the light
  79130. * @param scene The scene to create the parsed light in
  79131. * @returns the created light after parsing
  79132. */
  79133. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  79134. private _hookArrayForExcluded;
  79135. private _hookArrayForIncludedOnly;
  79136. private _resyncMeshes;
  79137. /**
  79138. * Forces the meshes to update their light related information in their rendering used effects
  79139. * @hidden Internal Use Only
  79140. */
  79141. _markMeshesAsLightDirty(): void;
  79142. /**
  79143. * Recomputes the cached photometric scale if needed.
  79144. */
  79145. private _computePhotometricScale;
  79146. /**
  79147. * Returns the Photometric Scale according to the light type and intensity mode.
  79148. */
  79149. private _getPhotometricScale;
  79150. /**
  79151. * Reorder the light in the scene according to their defined priority.
  79152. * @hidden Internal Use Only
  79153. */
  79154. _reorderLightsInScene(): void;
  79155. /**
  79156. * Prepares the list of defines specific to the light type.
  79157. * @param defines the list of defines
  79158. * @param lightIndex defines the index of the light for the effect
  79159. */
  79160. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79161. }
  79162. }
  79163. declare module BABYLON {
  79164. /**
  79165. * Interface used to define Action
  79166. */
  79167. export interface IAction {
  79168. /**
  79169. * Trigger for the action
  79170. */
  79171. trigger: number;
  79172. /** Options of the trigger */
  79173. triggerOptions: any;
  79174. /**
  79175. * Gets the trigger parameters
  79176. * @returns the trigger parameters
  79177. */
  79178. getTriggerParameter(): any;
  79179. /**
  79180. * Internal only - executes current action event
  79181. * @hidden
  79182. */
  79183. _executeCurrent(evt?: ActionEvent): void;
  79184. /**
  79185. * Serialize placeholder for child classes
  79186. * @param parent of child
  79187. * @returns the serialized object
  79188. */
  79189. serialize(parent: any): any;
  79190. /**
  79191. * Internal only
  79192. * @hidden
  79193. */
  79194. _prepare(): void;
  79195. /**
  79196. * Internal only - manager for action
  79197. * @hidden
  79198. */
  79199. _actionManager: AbstractActionManager;
  79200. /**
  79201. * Adds action to chain of actions, may be a DoNothingAction
  79202. * @param action defines the next action to execute
  79203. * @returns The action passed in
  79204. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79205. */
  79206. then(action: IAction): IAction;
  79207. }
  79208. /**
  79209. * The action to be carried out following a trigger
  79210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  79211. */
  79212. export class Action implements IAction {
  79213. /** the trigger, with or without parameters, for the action */
  79214. triggerOptions: any;
  79215. /**
  79216. * Trigger for the action
  79217. */
  79218. trigger: number;
  79219. /**
  79220. * Internal only - manager for action
  79221. * @hidden
  79222. */
  79223. _actionManager: ActionManager;
  79224. private _nextActiveAction;
  79225. private _child;
  79226. private _condition?;
  79227. private _triggerParameter;
  79228. /**
  79229. * An event triggered prior to action being executed.
  79230. */
  79231. onBeforeExecuteObservable: Observable<Action>;
  79232. /**
  79233. * Creates a new Action
  79234. * @param triggerOptions the trigger, with or without parameters, for the action
  79235. * @param condition an optional determinant of action
  79236. */
  79237. constructor(
  79238. /** the trigger, with or without parameters, for the action */
  79239. triggerOptions: any, condition?: Condition);
  79240. /**
  79241. * Internal only
  79242. * @hidden
  79243. */
  79244. _prepare(): void;
  79245. /**
  79246. * Gets the trigger parameters
  79247. * @returns the trigger parameters
  79248. */
  79249. getTriggerParameter(): any;
  79250. /**
  79251. * Internal only - executes current action event
  79252. * @hidden
  79253. */
  79254. _executeCurrent(evt?: ActionEvent): void;
  79255. /**
  79256. * Execute placeholder for child classes
  79257. * @param evt optional action event
  79258. */
  79259. execute(evt?: ActionEvent): void;
  79260. /**
  79261. * Skips to next active action
  79262. */
  79263. skipToNextActiveAction(): void;
  79264. /**
  79265. * Adds action to chain of actions, may be a DoNothingAction
  79266. * @param action defines the next action to execute
  79267. * @returns The action passed in
  79268. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79269. */
  79270. then(action: Action): Action;
  79271. /**
  79272. * Internal only
  79273. * @hidden
  79274. */
  79275. _getProperty(propertyPath: string): string;
  79276. /**
  79277. * Internal only
  79278. * @hidden
  79279. */
  79280. _getEffectiveTarget(target: any, propertyPath: string): any;
  79281. /**
  79282. * Serialize placeholder for child classes
  79283. * @param parent of child
  79284. * @returns the serialized object
  79285. */
  79286. serialize(parent: any): any;
  79287. /**
  79288. * Internal only called by serialize
  79289. * @hidden
  79290. */
  79291. protected _serialize(serializedAction: any, parent?: any): any;
  79292. /**
  79293. * Internal only
  79294. * @hidden
  79295. */
  79296. static _SerializeValueAsString: (value: any) => string;
  79297. /**
  79298. * Internal only
  79299. * @hidden
  79300. */
  79301. static _GetTargetProperty: (target: Node | Scene) => {
  79302. name: string;
  79303. targetType: string;
  79304. value: string;
  79305. };
  79306. }
  79307. }
  79308. declare module BABYLON {
  79309. /**
  79310. * A Condition applied to an Action
  79311. */
  79312. export class Condition {
  79313. /**
  79314. * Internal only - manager for action
  79315. * @hidden
  79316. */
  79317. _actionManager: ActionManager;
  79318. /**
  79319. * Internal only
  79320. * @hidden
  79321. */
  79322. _evaluationId: number;
  79323. /**
  79324. * Internal only
  79325. * @hidden
  79326. */
  79327. _currentResult: boolean;
  79328. /**
  79329. * Creates a new Condition
  79330. * @param actionManager the manager of the action the condition is applied to
  79331. */
  79332. constructor(actionManager: ActionManager);
  79333. /**
  79334. * Check if the current condition is valid
  79335. * @returns a boolean
  79336. */
  79337. isValid(): boolean;
  79338. /**
  79339. * Internal only
  79340. * @hidden
  79341. */
  79342. _getProperty(propertyPath: string): string;
  79343. /**
  79344. * Internal only
  79345. * @hidden
  79346. */
  79347. _getEffectiveTarget(target: any, propertyPath: string): any;
  79348. /**
  79349. * Serialize placeholder for child classes
  79350. * @returns the serialized object
  79351. */
  79352. serialize(): any;
  79353. /**
  79354. * Internal only
  79355. * @hidden
  79356. */
  79357. protected _serialize(serializedCondition: any): any;
  79358. }
  79359. /**
  79360. * Defines specific conditional operators as extensions of Condition
  79361. */
  79362. export class ValueCondition extends Condition {
  79363. /** path to specify the property of the target the conditional operator uses */
  79364. propertyPath: string;
  79365. /** the value compared by the conditional operator against the current value of the property */
  79366. value: any;
  79367. /** the conditional operator, default ValueCondition.IsEqual */
  79368. operator: number;
  79369. /**
  79370. * Internal only
  79371. * @hidden
  79372. */
  79373. private static _IsEqual;
  79374. /**
  79375. * Internal only
  79376. * @hidden
  79377. */
  79378. private static _IsDifferent;
  79379. /**
  79380. * Internal only
  79381. * @hidden
  79382. */
  79383. private static _IsGreater;
  79384. /**
  79385. * Internal only
  79386. * @hidden
  79387. */
  79388. private static _IsLesser;
  79389. /**
  79390. * returns the number for IsEqual
  79391. */
  79392. static readonly IsEqual: number;
  79393. /**
  79394. * Returns the number for IsDifferent
  79395. */
  79396. static readonly IsDifferent: number;
  79397. /**
  79398. * Returns the number for IsGreater
  79399. */
  79400. static readonly IsGreater: number;
  79401. /**
  79402. * Returns the number for IsLesser
  79403. */
  79404. static readonly IsLesser: number;
  79405. /**
  79406. * Internal only The action manager for the condition
  79407. * @hidden
  79408. */
  79409. _actionManager: ActionManager;
  79410. /**
  79411. * Internal only
  79412. * @hidden
  79413. */
  79414. private _target;
  79415. /**
  79416. * Internal only
  79417. * @hidden
  79418. */
  79419. private _effectiveTarget;
  79420. /**
  79421. * Internal only
  79422. * @hidden
  79423. */
  79424. private _property;
  79425. /**
  79426. * Creates a new ValueCondition
  79427. * @param actionManager manager for the action the condition applies to
  79428. * @param target for the action
  79429. * @param propertyPath path to specify the property of the target the conditional operator uses
  79430. * @param value the value compared by the conditional operator against the current value of the property
  79431. * @param operator the conditional operator, default ValueCondition.IsEqual
  79432. */
  79433. constructor(actionManager: ActionManager, target: any,
  79434. /** path to specify the property of the target the conditional operator uses */
  79435. propertyPath: string,
  79436. /** the value compared by the conditional operator against the current value of the property */
  79437. value: any,
  79438. /** the conditional operator, default ValueCondition.IsEqual */
  79439. operator?: number);
  79440. /**
  79441. * Compares the given value with the property value for the specified conditional operator
  79442. * @returns the result of the comparison
  79443. */
  79444. isValid(): boolean;
  79445. /**
  79446. * Serialize the ValueCondition into a JSON compatible object
  79447. * @returns serialization object
  79448. */
  79449. serialize(): any;
  79450. /**
  79451. * Gets the name of the conditional operator for the ValueCondition
  79452. * @param operator the conditional operator
  79453. * @returns the name
  79454. */
  79455. static GetOperatorName(operator: number): string;
  79456. }
  79457. /**
  79458. * Defines a predicate condition as an extension of Condition
  79459. */
  79460. export class PredicateCondition extends Condition {
  79461. /** defines the predicate function used to validate the condition */
  79462. predicate: () => boolean;
  79463. /**
  79464. * Internal only - manager for action
  79465. * @hidden
  79466. */
  79467. _actionManager: ActionManager;
  79468. /**
  79469. * Creates a new PredicateCondition
  79470. * @param actionManager manager for the action the condition applies to
  79471. * @param predicate defines the predicate function used to validate the condition
  79472. */
  79473. constructor(actionManager: ActionManager,
  79474. /** defines the predicate function used to validate the condition */
  79475. predicate: () => boolean);
  79476. /**
  79477. * @returns the validity of the predicate condition
  79478. */
  79479. isValid(): boolean;
  79480. }
  79481. /**
  79482. * Defines a state condition as an extension of Condition
  79483. */
  79484. export class StateCondition extends Condition {
  79485. /** Value to compare with target state */
  79486. value: string;
  79487. /**
  79488. * Internal only - manager for action
  79489. * @hidden
  79490. */
  79491. _actionManager: ActionManager;
  79492. /**
  79493. * Internal only
  79494. * @hidden
  79495. */
  79496. private _target;
  79497. /**
  79498. * Creates a new StateCondition
  79499. * @param actionManager manager for the action the condition applies to
  79500. * @param target of the condition
  79501. * @param value to compare with target state
  79502. */
  79503. constructor(actionManager: ActionManager, target: any,
  79504. /** Value to compare with target state */
  79505. value: string);
  79506. /**
  79507. * Gets a boolean indicating if the current condition is met
  79508. * @returns the validity of the state
  79509. */
  79510. isValid(): boolean;
  79511. /**
  79512. * Serialize the StateCondition into a JSON compatible object
  79513. * @returns serialization object
  79514. */
  79515. serialize(): any;
  79516. }
  79517. }
  79518. declare module BABYLON {
  79519. /**
  79520. * This defines an action responsible to toggle a boolean once triggered.
  79521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79522. */
  79523. export class SwitchBooleanAction extends Action {
  79524. /**
  79525. * The path to the boolean property in the target object
  79526. */
  79527. propertyPath: string;
  79528. private _target;
  79529. private _effectiveTarget;
  79530. private _property;
  79531. /**
  79532. * Instantiate the action
  79533. * @param triggerOptions defines the trigger options
  79534. * @param target defines the object containing the boolean
  79535. * @param propertyPath defines the path to the boolean property in the target object
  79536. * @param condition defines the trigger related conditions
  79537. */
  79538. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  79539. /** @hidden */
  79540. _prepare(): void;
  79541. /**
  79542. * Execute the action toggle the boolean value.
  79543. */
  79544. execute(): void;
  79545. /**
  79546. * Serializes the actions and its related information.
  79547. * @param parent defines the object to serialize in
  79548. * @returns the serialized object
  79549. */
  79550. serialize(parent: any): any;
  79551. }
  79552. /**
  79553. * This defines an action responsible to set a the state field of the target
  79554. * to a desired value once triggered.
  79555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79556. */
  79557. export class SetStateAction extends Action {
  79558. /**
  79559. * The value to store in the state field.
  79560. */
  79561. value: string;
  79562. private _target;
  79563. /**
  79564. * Instantiate the action
  79565. * @param triggerOptions defines the trigger options
  79566. * @param target defines the object containing the state property
  79567. * @param value defines the value to store in the state field
  79568. * @param condition defines the trigger related conditions
  79569. */
  79570. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  79571. /**
  79572. * Execute the action and store the value on the target state property.
  79573. */
  79574. execute(): void;
  79575. /**
  79576. * Serializes the actions and its related information.
  79577. * @param parent defines the object to serialize in
  79578. * @returns the serialized object
  79579. */
  79580. serialize(parent: any): any;
  79581. }
  79582. /**
  79583. * This defines an action responsible to set a property of the target
  79584. * to a desired value once triggered.
  79585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79586. */
  79587. export class SetValueAction extends Action {
  79588. /**
  79589. * The path of the property to set in the target.
  79590. */
  79591. propertyPath: string;
  79592. /**
  79593. * The value to set in the property
  79594. */
  79595. value: any;
  79596. private _target;
  79597. private _effectiveTarget;
  79598. private _property;
  79599. /**
  79600. * Instantiate the action
  79601. * @param triggerOptions defines the trigger options
  79602. * @param target defines the object containing the property
  79603. * @param propertyPath defines the path of the property to set in the target
  79604. * @param value defines the value to set in the property
  79605. * @param condition defines the trigger related conditions
  79606. */
  79607. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79608. /** @hidden */
  79609. _prepare(): void;
  79610. /**
  79611. * Execute the action and set the targetted property to the desired value.
  79612. */
  79613. execute(): void;
  79614. /**
  79615. * Serializes the actions and its related information.
  79616. * @param parent defines the object to serialize in
  79617. * @returns the serialized object
  79618. */
  79619. serialize(parent: any): any;
  79620. }
  79621. /**
  79622. * This defines an action responsible to increment the target value
  79623. * to a desired value once triggered.
  79624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79625. */
  79626. export class IncrementValueAction extends Action {
  79627. /**
  79628. * The path of the property to increment in the target.
  79629. */
  79630. propertyPath: string;
  79631. /**
  79632. * The value we should increment the property by.
  79633. */
  79634. value: any;
  79635. private _target;
  79636. private _effectiveTarget;
  79637. private _property;
  79638. /**
  79639. * Instantiate the action
  79640. * @param triggerOptions defines the trigger options
  79641. * @param target defines the object containing the property
  79642. * @param propertyPath defines the path of the property to increment in the target
  79643. * @param value defines the value value we should increment the property by
  79644. * @param condition defines the trigger related conditions
  79645. */
  79646. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79647. /** @hidden */
  79648. _prepare(): void;
  79649. /**
  79650. * Execute the action and increment the target of the value amount.
  79651. */
  79652. execute(): void;
  79653. /**
  79654. * Serializes the actions and its related information.
  79655. * @param parent defines the object to serialize in
  79656. * @returns the serialized object
  79657. */
  79658. serialize(parent: any): any;
  79659. }
  79660. /**
  79661. * This defines an action responsible to start an animation once triggered.
  79662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79663. */
  79664. export class PlayAnimationAction extends Action {
  79665. /**
  79666. * Where the animation should start (animation frame)
  79667. */
  79668. from: number;
  79669. /**
  79670. * Where the animation should stop (animation frame)
  79671. */
  79672. to: number;
  79673. /**
  79674. * Define if the animation should loop or stop after the first play.
  79675. */
  79676. loop?: boolean;
  79677. private _target;
  79678. /**
  79679. * Instantiate the action
  79680. * @param triggerOptions defines the trigger options
  79681. * @param target defines the target animation or animation name
  79682. * @param from defines from where the animation should start (animation frame)
  79683. * @param end defines where the animation should stop (animation frame)
  79684. * @param loop defines if the animation should loop or stop after the first play
  79685. * @param condition defines the trigger related conditions
  79686. */
  79687. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  79688. /** @hidden */
  79689. _prepare(): void;
  79690. /**
  79691. * Execute the action and play the animation.
  79692. */
  79693. execute(): void;
  79694. /**
  79695. * Serializes the actions and its related information.
  79696. * @param parent defines the object to serialize in
  79697. * @returns the serialized object
  79698. */
  79699. serialize(parent: any): any;
  79700. }
  79701. /**
  79702. * This defines an action responsible to stop an animation once triggered.
  79703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79704. */
  79705. export class StopAnimationAction extends Action {
  79706. private _target;
  79707. /**
  79708. * Instantiate the action
  79709. * @param triggerOptions defines the trigger options
  79710. * @param target defines the target animation or animation name
  79711. * @param condition defines the trigger related conditions
  79712. */
  79713. constructor(triggerOptions: any, target: any, condition?: Condition);
  79714. /** @hidden */
  79715. _prepare(): void;
  79716. /**
  79717. * Execute the action and stop the animation.
  79718. */
  79719. execute(): 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 that does nothing once triggered.
  79729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79730. */
  79731. export class DoNothingAction extends Action {
  79732. /**
  79733. * Instantiate the action
  79734. * @param triggerOptions defines the trigger options
  79735. * @param condition defines the trigger related conditions
  79736. */
  79737. constructor(triggerOptions?: any, condition?: Condition);
  79738. /**
  79739. * Execute the action and do nothing.
  79740. */
  79741. execute(): void;
  79742. /**
  79743. * Serializes the actions and its related information.
  79744. * @param parent defines the object to serialize in
  79745. * @returns the serialized object
  79746. */
  79747. serialize(parent: any): any;
  79748. }
  79749. /**
  79750. * This defines an action responsible to trigger several actions once triggered.
  79751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79752. */
  79753. export class CombineAction extends Action {
  79754. /**
  79755. * The list of aggregated animations to run.
  79756. */
  79757. children: Action[];
  79758. /**
  79759. * Instantiate the action
  79760. * @param triggerOptions defines the trigger options
  79761. * @param children defines the list of aggregated animations to run
  79762. * @param condition defines the trigger related conditions
  79763. */
  79764. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  79765. /** @hidden */
  79766. _prepare(): void;
  79767. /**
  79768. * Execute the action and executes all the aggregated actions.
  79769. */
  79770. execute(evt: ActionEvent): void;
  79771. /**
  79772. * Serializes the actions and its related information.
  79773. * @param parent defines the object to serialize in
  79774. * @returns the serialized object
  79775. */
  79776. serialize(parent: any): any;
  79777. }
  79778. /**
  79779. * This defines an action responsible to run code (external event) once triggered.
  79780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79781. */
  79782. export class ExecuteCodeAction extends Action {
  79783. /**
  79784. * The callback function to run.
  79785. */
  79786. func: (evt: ActionEvent) => void;
  79787. /**
  79788. * Instantiate the action
  79789. * @param triggerOptions defines the trigger options
  79790. * @param func defines the callback function to run
  79791. * @param condition defines the trigger related conditions
  79792. */
  79793. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  79794. /**
  79795. * Execute the action and run the attached code.
  79796. */
  79797. execute(evt: ActionEvent): void;
  79798. }
  79799. /**
  79800. * This defines an action responsible to set the parent property of the target once triggered.
  79801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79802. */
  79803. export class SetParentAction extends Action {
  79804. private _parent;
  79805. private _target;
  79806. /**
  79807. * Instantiate the action
  79808. * @param triggerOptions defines the trigger options
  79809. * @param target defines the target containing the parent property
  79810. * @param parent defines from where the animation should start (animation frame)
  79811. * @param condition defines the trigger related conditions
  79812. */
  79813. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  79814. /** @hidden */
  79815. _prepare(): void;
  79816. /**
  79817. * Execute the action and set the parent property.
  79818. */
  79819. execute(): void;
  79820. /**
  79821. * Serializes the actions and its related information.
  79822. * @param parent defines the object to serialize in
  79823. * @returns the serialized object
  79824. */
  79825. serialize(parent: any): any;
  79826. }
  79827. }
  79828. declare module BABYLON {
  79829. /**
  79830. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  79831. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  79832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79833. */
  79834. export class ActionManager extends AbstractActionManager {
  79835. /**
  79836. * Nothing
  79837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79838. */
  79839. static readonly NothingTrigger: number;
  79840. /**
  79841. * On pick
  79842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79843. */
  79844. static readonly OnPickTrigger: number;
  79845. /**
  79846. * On left pick
  79847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79848. */
  79849. static readonly OnLeftPickTrigger: number;
  79850. /**
  79851. * On right pick
  79852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79853. */
  79854. static readonly OnRightPickTrigger: number;
  79855. /**
  79856. * On center pick
  79857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79858. */
  79859. static readonly OnCenterPickTrigger: number;
  79860. /**
  79861. * On pick down
  79862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79863. */
  79864. static readonly OnPickDownTrigger: number;
  79865. /**
  79866. * On double pick
  79867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79868. */
  79869. static readonly OnDoublePickTrigger: number;
  79870. /**
  79871. * On pick up
  79872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79873. */
  79874. static readonly OnPickUpTrigger: number;
  79875. /**
  79876. * On pick out.
  79877. * This trigger will only be raised if you also declared a OnPickDown
  79878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79879. */
  79880. static readonly OnPickOutTrigger: number;
  79881. /**
  79882. * On long press
  79883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79884. */
  79885. static readonly OnLongPressTrigger: number;
  79886. /**
  79887. * On pointer over
  79888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79889. */
  79890. static readonly OnPointerOverTrigger: number;
  79891. /**
  79892. * On pointer out
  79893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79894. */
  79895. static readonly OnPointerOutTrigger: number;
  79896. /**
  79897. * On every frame
  79898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79899. */
  79900. static readonly OnEveryFrameTrigger: number;
  79901. /**
  79902. * On intersection enter
  79903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79904. */
  79905. static readonly OnIntersectionEnterTrigger: number;
  79906. /**
  79907. * On intersection exit
  79908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79909. */
  79910. static readonly OnIntersectionExitTrigger: number;
  79911. /**
  79912. * On key down
  79913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79914. */
  79915. static readonly OnKeyDownTrigger: number;
  79916. /**
  79917. * On key up
  79918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79919. */
  79920. static readonly OnKeyUpTrigger: number;
  79921. private _scene;
  79922. /**
  79923. * Creates a new action manager
  79924. * @param scene defines the hosting scene
  79925. */
  79926. constructor(scene: Scene);
  79927. /**
  79928. * Releases all associated resources
  79929. */
  79930. dispose(): void;
  79931. /**
  79932. * Gets hosting scene
  79933. * @returns the hosting scene
  79934. */
  79935. getScene(): Scene;
  79936. /**
  79937. * Does this action manager handles actions of any of the given triggers
  79938. * @param triggers defines the triggers to be tested
  79939. * @return a boolean indicating whether one (or more) of the triggers is handled
  79940. */
  79941. hasSpecificTriggers(triggers: number[]): boolean;
  79942. /**
  79943. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79944. * speed.
  79945. * @param triggerA defines the trigger to be tested
  79946. * @param triggerB defines the trigger to be tested
  79947. * @return a boolean indicating whether one (or more) of the triggers is handled
  79948. */
  79949. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79950. /**
  79951. * Does this action manager handles actions of a given trigger
  79952. * @param trigger defines the trigger to be tested
  79953. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79954. * @return whether the trigger is handled
  79955. */
  79956. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79957. /**
  79958. * Does this action manager has pointer triggers
  79959. */
  79960. readonly hasPointerTriggers: boolean;
  79961. /**
  79962. * Does this action manager has pick triggers
  79963. */
  79964. readonly hasPickTriggers: boolean;
  79965. /**
  79966. * Registers an action to this action manager
  79967. * @param action defines the action to be registered
  79968. * @return the action amended (prepared) after registration
  79969. */
  79970. registerAction(action: IAction): Nullable<IAction>;
  79971. /**
  79972. * Unregisters an action to this action manager
  79973. * @param action defines the action to be unregistered
  79974. * @return a boolean indicating whether the action has been unregistered
  79975. */
  79976. unregisterAction(action: IAction): Boolean;
  79977. /**
  79978. * Process a specific trigger
  79979. * @param trigger defines the trigger to process
  79980. * @param evt defines the event details to be processed
  79981. */
  79982. processTrigger(trigger: number, evt?: IActionEvent): void;
  79983. /** @hidden */
  79984. _getEffectiveTarget(target: any, propertyPath: string): any;
  79985. /** @hidden */
  79986. _getProperty(propertyPath: string): string;
  79987. /**
  79988. * Serialize this manager to a JSON object
  79989. * @param name defines the property name to store this manager
  79990. * @returns a JSON representation of this manager
  79991. */
  79992. serialize(name: string): any;
  79993. /**
  79994. * Creates a new ActionManager from a JSON data
  79995. * @param parsedActions defines the JSON data to read from
  79996. * @param object defines the hosting mesh
  79997. * @param scene defines the hosting scene
  79998. */
  79999. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  80000. /**
  80001. * Get a trigger name by index
  80002. * @param trigger defines the trigger index
  80003. * @returns a trigger name
  80004. */
  80005. static GetTriggerName(trigger: number): string;
  80006. }
  80007. }
  80008. declare module BABYLON {
  80009. /**
  80010. * Class representing a ray with position and direction
  80011. */
  80012. export class Ray {
  80013. /** origin point */
  80014. origin: Vector3;
  80015. /** direction */
  80016. direction: Vector3;
  80017. /** length of the ray */
  80018. length: number;
  80019. private static readonly TmpVector3;
  80020. private _tmpRay;
  80021. /**
  80022. * Creates a new ray
  80023. * @param origin origin point
  80024. * @param direction direction
  80025. * @param length length of the ray
  80026. */
  80027. constructor(
  80028. /** origin point */
  80029. origin: Vector3,
  80030. /** direction */
  80031. direction: Vector3,
  80032. /** length of the ray */
  80033. length?: number);
  80034. /**
  80035. * Checks if the ray intersects a box
  80036. * @param minimum bound of the box
  80037. * @param maximum bound of the box
  80038. * @param intersectionTreshold extra extend to be added to the box in all direction
  80039. * @returns if the box was hit
  80040. */
  80041. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  80042. /**
  80043. * Checks if the ray intersects a box
  80044. * @param box the bounding box to check
  80045. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  80046. * @returns if the box was hit
  80047. */
  80048. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  80049. /**
  80050. * If the ray hits a sphere
  80051. * @param sphere the bounding sphere to check
  80052. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  80053. * @returns true if it hits the sphere
  80054. */
  80055. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  80056. /**
  80057. * If the ray hits a triange
  80058. * @param vertex0 triangle vertex
  80059. * @param vertex1 triangle vertex
  80060. * @param vertex2 triangle vertex
  80061. * @returns intersection information if hit
  80062. */
  80063. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  80064. /**
  80065. * Checks if ray intersects a plane
  80066. * @param plane the plane to check
  80067. * @returns the distance away it was hit
  80068. */
  80069. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  80070. /**
  80071. * Calculate the intercept of a ray on a given axis
  80072. * @param axis to check 'x' | 'y' | 'z'
  80073. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  80074. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  80075. */
  80076. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  80077. /**
  80078. * Checks if ray intersects a mesh
  80079. * @param mesh the mesh to check
  80080. * @param fastCheck if only the bounding box should checked
  80081. * @returns picking info of the intersecton
  80082. */
  80083. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  80084. /**
  80085. * Checks if ray intersects a mesh
  80086. * @param meshes the meshes to check
  80087. * @param fastCheck if only the bounding box should checked
  80088. * @param results array to store result in
  80089. * @returns Array of picking infos
  80090. */
  80091. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  80092. private _comparePickingInfo;
  80093. private static smallnum;
  80094. private static rayl;
  80095. /**
  80096. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  80097. * @param sega the first point of the segment to test the intersection against
  80098. * @param segb the second point of the segment to test the intersection against
  80099. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  80100. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  80101. */
  80102. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  80103. /**
  80104. * Update the ray from viewport position
  80105. * @param x position
  80106. * @param y y position
  80107. * @param viewportWidth viewport width
  80108. * @param viewportHeight viewport height
  80109. * @param world world matrix
  80110. * @param view view matrix
  80111. * @param projection projection matrix
  80112. * @returns this ray updated
  80113. */
  80114. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80115. /**
  80116. * Creates a ray with origin and direction of 0,0,0
  80117. * @returns the new ray
  80118. */
  80119. static Zero(): Ray;
  80120. /**
  80121. * Creates a new ray from screen space and viewport
  80122. * @param x position
  80123. * @param y y position
  80124. * @param viewportWidth viewport width
  80125. * @param viewportHeight viewport height
  80126. * @param world world matrix
  80127. * @param view view matrix
  80128. * @param projection projection matrix
  80129. * @returns new ray
  80130. */
  80131. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80132. /**
  80133. * 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
  80134. * transformed to the given world matrix.
  80135. * @param origin The origin point
  80136. * @param end The end point
  80137. * @param world a matrix to transform the ray to. Default is the identity matrix.
  80138. * @returns the new ray
  80139. */
  80140. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  80141. /**
  80142. * Transforms a ray by a matrix
  80143. * @param ray ray to transform
  80144. * @param matrix matrix to apply
  80145. * @returns the resulting new ray
  80146. */
  80147. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  80148. /**
  80149. * Transforms a ray by a matrix
  80150. * @param ray ray to transform
  80151. * @param matrix matrix to apply
  80152. * @param result ray to store result in
  80153. */
  80154. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  80155. /**
  80156. * Unproject a ray from screen space to object space
  80157. * @param sourceX defines the screen space x coordinate to use
  80158. * @param sourceY defines the screen space y coordinate to use
  80159. * @param viewportWidth defines the current width of the viewport
  80160. * @param viewportHeight defines the current height of the viewport
  80161. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80162. * @param view defines the view matrix to use
  80163. * @param projection defines the projection matrix to use
  80164. */
  80165. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  80166. }
  80167. /**
  80168. * Type used to define predicate used to select faces when a mesh intersection is detected
  80169. */
  80170. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  80171. interface Scene {
  80172. /** @hidden */
  80173. _tempPickingRay: Nullable<Ray>;
  80174. /** @hidden */
  80175. _cachedRayForTransform: Ray;
  80176. /** @hidden */
  80177. _pickWithRayInverseMatrix: Matrix;
  80178. /** @hidden */
  80179. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  80180. /** @hidden */
  80181. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  80182. }
  80183. }
  80184. declare module BABYLON {
  80185. /**
  80186. * Groups all the scene component constants in one place to ease maintenance.
  80187. * @hidden
  80188. */
  80189. export class SceneComponentConstants {
  80190. static readonly NAME_EFFECTLAYER: string;
  80191. static readonly NAME_LAYER: string;
  80192. static readonly NAME_LENSFLARESYSTEM: string;
  80193. static readonly NAME_BOUNDINGBOXRENDERER: string;
  80194. static readonly NAME_PARTICLESYSTEM: string;
  80195. static readonly NAME_GAMEPAD: string;
  80196. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  80197. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  80198. static readonly NAME_DEPTHRENDERER: string;
  80199. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  80200. static readonly NAME_SPRITE: string;
  80201. static readonly NAME_OUTLINERENDERER: string;
  80202. static readonly NAME_PROCEDURALTEXTURE: string;
  80203. static readonly NAME_SHADOWGENERATOR: string;
  80204. static readonly NAME_OCTREE: string;
  80205. static readonly NAME_PHYSICSENGINE: string;
  80206. static readonly NAME_AUDIO: string;
  80207. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  80208. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80209. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  80210. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80211. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  80212. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  80213. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  80214. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  80215. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  80216. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  80217. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  80218. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  80219. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  80220. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  80221. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  80222. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  80223. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  80224. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  80225. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  80226. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  80227. static readonly STEP_AFTERRENDER_AUDIO: number;
  80228. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  80229. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  80230. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  80231. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  80232. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  80233. static readonly STEP_POINTERMOVE_SPRITE: number;
  80234. static readonly STEP_POINTERDOWN_SPRITE: number;
  80235. static readonly STEP_POINTERUP_SPRITE: number;
  80236. }
  80237. /**
  80238. * This represents a scene component.
  80239. *
  80240. * This is used to decouple the dependency the scene is having on the different workloads like
  80241. * layers, post processes...
  80242. */
  80243. export interface ISceneComponent {
  80244. /**
  80245. * The name of the component. Each component must have a unique name.
  80246. */
  80247. name: string;
  80248. /**
  80249. * The scene the component belongs to.
  80250. */
  80251. scene: Scene;
  80252. /**
  80253. * Register the component to one instance of a scene.
  80254. */
  80255. register(): void;
  80256. /**
  80257. * Rebuilds the elements related to this component in case of
  80258. * context lost for instance.
  80259. */
  80260. rebuild(): void;
  80261. /**
  80262. * Disposes the component and the associated ressources.
  80263. */
  80264. dispose(): void;
  80265. }
  80266. /**
  80267. * This represents a SERIALIZABLE scene component.
  80268. *
  80269. * This extends Scene Component to add Serialization methods on top.
  80270. */
  80271. export interface ISceneSerializableComponent extends ISceneComponent {
  80272. /**
  80273. * Adds all the elements from the container to the scene
  80274. * @param container the container holding the elements
  80275. */
  80276. addFromContainer(container: AbstractScene): void;
  80277. /**
  80278. * Removes all the elements in the container from the scene
  80279. * @param container contains the elements to remove
  80280. * @param dispose if the removed element should be disposed (default: false)
  80281. */
  80282. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80283. /**
  80284. * Serializes the component data to the specified json object
  80285. * @param serializationObject The object to serialize to
  80286. */
  80287. serialize(serializationObject: any): void;
  80288. }
  80289. /**
  80290. * Strong typing of a Mesh related stage step action
  80291. */
  80292. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  80293. /**
  80294. * Strong typing of a Evaluate Sub Mesh related stage step action
  80295. */
  80296. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  80297. /**
  80298. * Strong typing of a Active Mesh related stage step action
  80299. */
  80300. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  80301. /**
  80302. * Strong typing of a Camera related stage step action
  80303. */
  80304. export type CameraStageAction = (camera: Camera) => void;
  80305. /**
  80306. * Strong typing of a Camera Frame buffer related stage step action
  80307. */
  80308. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  80309. /**
  80310. * Strong typing of a Render Target related stage step action
  80311. */
  80312. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  80313. /**
  80314. * Strong typing of a RenderingGroup related stage step action
  80315. */
  80316. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  80317. /**
  80318. * Strong typing of a Mesh Render related stage step action
  80319. */
  80320. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  80321. /**
  80322. * Strong typing of a simple stage step action
  80323. */
  80324. export type SimpleStageAction = () => void;
  80325. /**
  80326. * Strong typing of a render target action.
  80327. */
  80328. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  80329. /**
  80330. * Strong typing of a pointer move action.
  80331. */
  80332. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  80333. /**
  80334. * Strong typing of a pointer up/down action.
  80335. */
  80336. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  80337. /**
  80338. * Representation of a stage in the scene (Basically a list of ordered steps)
  80339. * @hidden
  80340. */
  80341. export class Stage<T extends Function> extends Array<{
  80342. index: number;
  80343. component: ISceneComponent;
  80344. action: T;
  80345. }> {
  80346. /**
  80347. * Hide ctor from the rest of the world.
  80348. * @param items The items to add.
  80349. */
  80350. private constructor();
  80351. /**
  80352. * Creates a new Stage.
  80353. * @returns A new instance of a Stage
  80354. */
  80355. static Create<T extends Function>(): Stage<T>;
  80356. /**
  80357. * Registers a step in an ordered way in the targeted stage.
  80358. * @param index Defines the position to register the step in
  80359. * @param component Defines the component attached to the step
  80360. * @param action Defines the action to launch during the step
  80361. */
  80362. registerStep(index: number, component: ISceneComponent, action: T): void;
  80363. /**
  80364. * Clears all the steps from the stage.
  80365. */
  80366. clear(): void;
  80367. }
  80368. }
  80369. declare module BABYLON {
  80370. interface Scene {
  80371. /** @hidden */
  80372. _pointerOverSprite: Nullable<Sprite>;
  80373. /** @hidden */
  80374. _pickedDownSprite: Nullable<Sprite>;
  80375. /** @hidden */
  80376. _tempSpritePickingRay: Nullable<Ray>;
  80377. /**
  80378. * All of the sprite managers added to this scene
  80379. * @see http://doc.babylonjs.com/babylon101/sprites
  80380. */
  80381. spriteManagers: Array<ISpriteManager>;
  80382. /**
  80383. * An event triggered when sprites rendering is about to start
  80384. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80385. */
  80386. onBeforeSpritesRenderingObservable: Observable<Scene>;
  80387. /**
  80388. * An event triggered when sprites rendering is done
  80389. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80390. */
  80391. onAfterSpritesRenderingObservable: Observable<Scene>;
  80392. /** @hidden */
  80393. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80394. /** Launch a ray to try to pick a sprite in the scene
  80395. * @param x position on screen
  80396. * @param y position on screen
  80397. * @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
  80398. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80399. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80400. * @returns a PickingInfo
  80401. */
  80402. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80403. /** Use the given ray to pick a sprite in the scene
  80404. * @param ray The ray (in world space) to use to pick meshes
  80405. * @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
  80406. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80407. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80408. * @returns a PickingInfo
  80409. */
  80410. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80411. /** @hidden */
  80412. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80413. /** Launch a ray to try to pick sprites in the scene
  80414. * @param x position on screen
  80415. * @param y position on screen
  80416. * @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
  80417. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80418. * @returns a PickingInfo array
  80419. */
  80420. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80421. /** Use the given ray to pick sprites in the scene
  80422. * @param ray The ray (in world space) to use to pick meshes
  80423. * @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
  80424. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80425. * @returns a PickingInfo array
  80426. */
  80427. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80428. /**
  80429. * Force the sprite under the pointer
  80430. * @param sprite defines the sprite to use
  80431. */
  80432. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  80433. /**
  80434. * Gets the sprite under the pointer
  80435. * @returns a Sprite or null if no sprite is under the pointer
  80436. */
  80437. getPointerOverSprite(): Nullable<Sprite>;
  80438. }
  80439. /**
  80440. * Defines the sprite scene component responsible to manage sprites
  80441. * in a given scene.
  80442. */
  80443. export class SpriteSceneComponent implements ISceneComponent {
  80444. /**
  80445. * The component name helpfull to identify the component in the list of scene components.
  80446. */
  80447. readonly name: string;
  80448. /**
  80449. * The scene the component belongs to.
  80450. */
  80451. scene: Scene;
  80452. /** @hidden */
  80453. private _spritePredicate;
  80454. /**
  80455. * Creates a new instance of the component for the given scene
  80456. * @param scene Defines the scene to register the component in
  80457. */
  80458. constructor(scene: Scene);
  80459. /**
  80460. * Registers the component in a given scene
  80461. */
  80462. register(): void;
  80463. /**
  80464. * Rebuilds the elements related to this component in case of
  80465. * context lost for instance.
  80466. */
  80467. rebuild(): void;
  80468. /**
  80469. * Disposes the component and the associated ressources.
  80470. */
  80471. dispose(): void;
  80472. private _pickSpriteButKeepRay;
  80473. private _pointerMove;
  80474. private _pointerDown;
  80475. private _pointerUp;
  80476. }
  80477. }
  80478. declare module BABYLON {
  80479. /** @hidden */
  80480. export var fogFragmentDeclaration: {
  80481. name: string;
  80482. shader: string;
  80483. };
  80484. }
  80485. declare module BABYLON {
  80486. /** @hidden */
  80487. export var fogFragment: {
  80488. name: string;
  80489. shader: string;
  80490. };
  80491. }
  80492. declare module BABYLON {
  80493. /** @hidden */
  80494. export var spritesPixelShader: {
  80495. name: string;
  80496. shader: string;
  80497. };
  80498. }
  80499. declare module BABYLON {
  80500. /** @hidden */
  80501. export var fogVertexDeclaration: {
  80502. name: string;
  80503. shader: string;
  80504. };
  80505. }
  80506. declare module BABYLON {
  80507. /** @hidden */
  80508. export var spritesVertexShader: {
  80509. name: string;
  80510. shader: string;
  80511. };
  80512. }
  80513. declare module BABYLON {
  80514. /**
  80515. * Defines the minimum interface to fullfil in order to be a sprite manager.
  80516. */
  80517. export interface ISpriteManager extends IDisposable {
  80518. /**
  80519. * Restricts the camera to viewing objects with the same layerMask.
  80520. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  80521. */
  80522. layerMask: number;
  80523. /**
  80524. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80525. */
  80526. isPickable: boolean;
  80527. /**
  80528. * Specifies the rendering group id for this mesh (0 by default)
  80529. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80530. */
  80531. renderingGroupId: number;
  80532. /**
  80533. * Defines the list of sprites managed by the manager.
  80534. */
  80535. sprites: Array<Sprite>;
  80536. /**
  80537. * Tests the intersection of a sprite with a specific ray.
  80538. * @param ray The ray we are sending to test the collision
  80539. * @param camera The camera space we are sending rays in
  80540. * @param predicate A predicate allowing excluding sprites from the list of object to test
  80541. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  80542. * @returns picking info or null.
  80543. */
  80544. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80545. /**
  80546. * Intersects the sprites with a ray
  80547. * @param ray defines the ray to intersect with
  80548. * @param camera defines the current active camera
  80549. * @param predicate defines a predicate used to select candidate sprites
  80550. * @returns null if no hit or a PickingInfo array
  80551. */
  80552. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80553. /**
  80554. * Renders the list of sprites on screen.
  80555. */
  80556. render(): void;
  80557. }
  80558. /**
  80559. * Class used to manage multiple sprites on the same spritesheet
  80560. * @see http://doc.babylonjs.com/babylon101/sprites
  80561. */
  80562. export class SpriteManager implements ISpriteManager {
  80563. /** defines the manager's name */
  80564. name: string;
  80565. /** Gets the list of sprites */
  80566. sprites: Sprite[];
  80567. /** Gets or sets the rendering group id (0 by default) */
  80568. renderingGroupId: number;
  80569. /** Gets or sets camera layer mask */
  80570. layerMask: number;
  80571. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  80572. fogEnabled: boolean;
  80573. /** Gets or sets a boolean indicating if the sprites are pickable */
  80574. isPickable: boolean;
  80575. /** Defines the default width of a cell in the spritesheet */
  80576. cellWidth: number;
  80577. /** Defines the default height of a cell in the spritesheet */
  80578. cellHeight: number;
  80579. /** Associative array from JSON sprite data file */
  80580. private _cellData;
  80581. /** Array of sprite names from JSON sprite data file */
  80582. private _spriteMap;
  80583. /** True when packed cell data from JSON file is ready*/
  80584. private _packedAndReady;
  80585. /**
  80586. * An event triggered when the manager is disposed.
  80587. */
  80588. onDisposeObservable: Observable<SpriteManager>;
  80589. private _onDisposeObserver;
  80590. /**
  80591. * Callback called when the manager is disposed
  80592. */
  80593. onDispose: () => void;
  80594. private _capacity;
  80595. private _fromPacked;
  80596. private _spriteTexture;
  80597. private _epsilon;
  80598. private _scene;
  80599. private _vertexData;
  80600. private _buffer;
  80601. private _vertexBuffers;
  80602. private _indexBuffer;
  80603. private _effectBase;
  80604. private _effectFog;
  80605. /**
  80606. * Gets or sets the spritesheet texture
  80607. */
  80608. texture: Texture;
  80609. /**
  80610. * Creates a new sprite manager
  80611. * @param name defines the manager's name
  80612. * @param imgUrl defines the sprite sheet url
  80613. * @param capacity defines the maximum allowed number of sprites
  80614. * @param cellSize defines the size of a sprite cell
  80615. * @param scene defines the hosting scene
  80616. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  80617. * @param samplingMode defines the smapling mode to use with spritesheet
  80618. * @param fromPacked set to false; do not alter
  80619. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  80620. */
  80621. constructor(
  80622. /** defines the manager's name */
  80623. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  80624. private _makePacked;
  80625. private _appendSpriteVertex;
  80626. /**
  80627. * Intersects the sprites with a ray
  80628. * @param ray defines the ray to intersect with
  80629. * @param camera defines the current active camera
  80630. * @param predicate defines a predicate used to select candidate sprites
  80631. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  80632. * @returns null if no hit or a PickingInfo
  80633. */
  80634. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80635. /**
  80636. * Intersects the sprites with a ray
  80637. * @param ray defines the ray to intersect with
  80638. * @param camera defines the current active camera
  80639. * @param predicate defines a predicate used to select candidate sprites
  80640. * @returns null if no hit or a PickingInfo array
  80641. */
  80642. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80643. /**
  80644. * Render all child sprites
  80645. */
  80646. render(): void;
  80647. /**
  80648. * Release associated resources
  80649. */
  80650. dispose(): void;
  80651. }
  80652. }
  80653. declare module BABYLON {
  80654. /**
  80655. * Class used to represent a sprite
  80656. * @see http://doc.babylonjs.com/babylon101/sprites
  80657. */
  80658. export class Sprite {
  80659. /** defines the name */
  80660. name: string;
  80661. /** Gets or sets the current world position */
  80662. position: Vector3;
  80663. /** Gets or sets the main color */
  80664. color: Color4;
  80665. /** Gets or sets the width */
  80666. width: number;
  80667. /** Gets or sets the height */
  80668. height: number;
  80669. /** Gets or sets rotation angle */
  80670. angle: number;
  80671. /** Gets or sets the cell index in the sprite sheet */
  80672. cellIndex: number;
  80673. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  80674. cellRef: string;
  80675. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  80676. invertU: number;
  80677. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  80678. invertV: number;
  80679. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  80680. disposeWhenFinishedAnimating: boolean;
  80681. /** Gets the list of attached animations */
  80682. animations: Animation[];
  80683. /** Gets or sets a boolean indicating if the sprite can be picked */
  80684. isPickable: boolean;
  80685. /**
  80686. * Gets or sets the associated action manager
  80687. */
  80688. actionManager: Nullable<ActionManager>;
  80689. private _animationStarted;
  80690. private _loopAnimation;
  80691. private _fromIndex;
  80692. private _toIndex;
  80693. private _delay;
  80694. private _direction;
  80695. private _manager;
  80696. private _time;
  80697. private _onAnimationEnd;
  80698. /**
  80699. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  80700. */
  80701. isVisible: boolean;
  80702. /**
  80703. * Gets or sets the sprite size
  80704. */
  80705. size: number;
  80706. /**
  80707. * Creates a new Sprite
  80708. * @param name defines the name
  80709. * @param manager defines the manager
  80710. */
  80711. constructor(
  80712. /** defines the name */
  80713. name: string, manager: ISpriteManager);
  80714. /**
  80715. * Starts an animation
  80716. * @param from defines the initial key
  80717. * @param to defines the end key
  80718. * @param loop defines if the animation must loop
  80719. * @param delay defines the start delay (in ms)
  80720. * @param onAnimationEnd defines a callback to call when animation ends
  80721. */
  80722. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  80723. /** Stops current animation (if any) */
  80724. stopAnimation(): void;
  80725. /** @hidden */
  80726. _animate(deltaTime: number): void;
  80727. /** Release associated resources */
  80728. dispose(): void;
  80729. }
  80730. }
  80731. declare module BABYLON {
  80732. /**
  80733. * Information about the result of picking within a scene
  80734. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  80735. */
  80736. export class PickingInfo {
  80737. /** @hidden */
  80738. _pickingUnavailable: boolean;
  80739. /**
  80740. * If the pick collided with an object
  80741. */
  80742. hit: boolean;
  80743. /**
  80744. * Distance away where the pick collided
  80745. */
  80746. distance: number;
  80747. /**
  80748. * The location of pick collision
  80749. */
  80750. pickedPoint: Nullable<Vector3>;
  80751. /**
  80752. * The mesh corresponding the the pick collision
  80753. */
  80754. pickedMesh: Nullable<AbstractMesh>;
  80755. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  80756. bu: number;
  80757. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  80758. bv: number;
  80759. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  80760. faceId: number;
  80761. /** Id of the the submesh that was picked */
  80762. subMeshId: number;
  80763. /** If a sprite was picked, this will be the sprite the pick collided with */
  80764. pickedSprite: Nullable<Sprite>;
  80765. /**
  80766. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  80767. */
  80768. originMesh: Nullable<AbstractMesh>;
  80769. /**
  80770. * The ray that was used to perform the picking.
  80771. */
  80772. ray: Nullable<Ray>;
  80773. /**
  80774. * Gets the normal correspodning to the face the pick collided with
  80775. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  80776. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  80777. * @returns The normal correspodning to the face the pick collided with
  80778. */
  80779. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  80780. /**
  80781. * Gets the texture coordinates of where the pick occured
  80782. * @returns the vector containing the coordnates of the texture
  80783. */
  80784. getTextureCoordinates(): Nullable<Vector2>;
  80785. }
  80786. }
  80787. declare module BABYLON {
  80788. /**
  80789. * Gather the list of pointer event types as constants.
  80790. */
  80791. export class PointerEventTypes {
  80792. /**
  80793. * 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.
  80794. */
  80795. static readonly POINTERDOWN: number;
  80796. /**
  80797. * The pointerup event is fired when a pointer is no longer active.
  80798. */
  80799. static readonly POINTERUP: number;
  80800. /**
  80801. * The pointermove event is fired when a pointer changes coordinates.
  80802. */
  80803. static readonly POINTERMOVE: number;
  80804. /**
  80805. * The pointerwheel event is fired when a mouse wheel has been rotated.
  80806. */
  80807. static readonly POINTERWHEEL: number;
  80808. /**
  80809. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  80810. */
  80811. static readonly POINTERPICK: number;
  80812. /**
  80813. * The pointertap event is fired when a the object has been touched and released without drag.
  80814. */
  80815. static readonly POINTERTAP: number;
  80816. /**
  80817. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  80818. */
  80819. static readonly POINTERDOUBLETAP: number;
  80820. }
  80821. /**
  80822. * Base class of pointer info types.
  80823. */
  80824. export class PointerInfoBase {
  80825. /**
  80826. * Defines the type of event (PointerEventTypes)
  80827. */
  80828. type: number;
  80829. /**
  80830. * Defines the related dom event
  80831. */
  80832. event: PointerEvent | MouseWheelEvent;
  80833. /**
  80834. * Instantiates the base class of pointers info.
  80835. * @param type Defines the type of event (PointerEventTypes)
  80836. * @param event Defines the related dom event
  80837. */
  80838. constructor(
  80839. /**
  80840. * Defines the type of event (PointerEventTypes)
  80841. */
  80842. type: number,
  80843. /**
  80844. * Defines the related dom event
  80845. */
  80846. event: PointerEvent | MouseWheelEvent);
  80847. }
  80848. /**
  80849. * This class is used to store pointer related info for the onPrePointerObservable event.
  80850. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80851. */
  80852. export class PointerInfoPre extends PointerInfoBase {
  80853. /**
  80854. * Ray from a pointer if availible (eg. 6dof controller)
  80855. */
  80856. ray: Nullable<Ray>;
  80857. /**
  80858. * Defines the local position of the pointer on the canvas.
  80859. */
  80860. localPosition: Vector2;
  80861. /**
  80862. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80863. */
  80864. skipOnPointerObservable: boolean;
  80865. /**
  80866. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80867. * @param type Defines the type of event (PointerEventTypes)
  80868. * @param event Defines the related dom event
  80869. * @param localX Defines the local x coordinates of the pointer when the event occured
  80870. * @param localY Defines the local y coordinates of the pointer when the event occured
  80871. */
  80872. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80873. }
  80874. /**
  80875. * This type contains all the data related to a pointer event in Babylon.js.
  80876. * 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.
  80877. */
  80878. export class PointerInfo extends PointerInfoBase {
  80879. /**
  80880. * Defines the picking info associated to the info (if any)\
  80881. */
  80882. pickInfo: Nullable<PickingInfo>;
  80883. /**
  80884. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80885. * @param type Defines the type of event (PointerEventTypes)
  80886. * @param event Defines the related dom event
  80887. * @param pickInfo Defines the picking info associated to the info (if any)\
  80888. */
  80889. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80890. /**
  80891. * Defines the picking info associated to the info (if any)\
  80892. */
  80893. pickInfo: Nullable<PickingInfo>);
  80894. }
  80895. /**
  80896. * Data relating to a touch event on the screen.
  80897. */
  80898. export interface PointerTouch {
  80899. /**
  80900. * X coordinate of touch.
  80901. */
  80902. x: number;
  80903. /**
  80904. * Y coordinate of touch.
  80905. */
  80906. y: number;
  80907. /**
  80908. * Id of touch. Unique for each finger.
  80909. */
  80910. pointerId: number;
  80911. /**
  80912. * Event type passed from DOM.
  80913. */
  80914. type: any;
  80915. }
  80916. }
  80917. declare module BABYLON {
  80918. /**
  80919. * Manage the mouse inputs to control the movement of a free camera.
  80920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80921. */
  80922. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80923. /**
  80924. * Define if touch is enabled in the mouse input
  80925. */
  80926. touchEnabled: boolean;
  80927. /**
  80928. * Defines the camera the input is attached to.
  80929. */
  80930. camera: FreeCamera;
  80931. /**
  80932. * Defines the buttons associated with the input to handle camera move.
  80933. */
  80934. buttons: number[];
  80935. /**
  80936. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80937. */
  80938. angularSensibility: number;
  80939. private _pointerInput;
  80940. private _onMouseMove;
  80941. private _observer;
  80942. private previousPosition;
  80943. /**
  80944. * Observable for when a pointer move event occurs containing the move offset
  80945. */
  80946. onPointerMovedObservable: Observable<{
  80947. offsetX: number;
  80948. offsetY: number;
  80949. }>;
  80950. /**
  80951. * @hidden
  80952. * If the camera should be rotated automatically based on pointer movement
  80953. */
  80954. _allowCameraRotation: boolean;
  80955. /**
  80956. * Manage the mouse inputs to control the movement of a free camera.
  80957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80958. * @param touchEnabled Defines if touch is enabled or not
  80959. */
  80960. constructor(
  80961. /**
  80962. * Define if touch is enabled in the mouse input
  80963. */
  80964. touchEnabled?: boolean);
  80965. /**
  80966. * Attach the input controls to a specific dom element to get the input from.
  80967. * @param element Defines the element the controls should be listened from
  80968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80969. */
  80970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80971. /**
  80972. * Called on JS contextmenu event.
  80973. * Override this method to provide functionality.
  80974. */
  80975. protected onContextMenu(evt: PointerEvent): void;
  80976. /**
  80977. * Detach the current controls from the specified dom element.
  80978. * @param element Defines the element to stop listening the inputs from
  80979. */
  80980. detachControl(element: Nullable<HTMLElement>): void;
  80981. /**
  80982. * Gets the class name of the current intput.
  80983. * @returns the class name
  80984. */
  80985. getClassName(): string;
  80986. /**
  80987. * Get the friendly name associated with the input class.
  80988. * @returns the input friendly name
  80989. */
  80990. getSimpleName(): string;
  80991. }
  80992. }
  80993. declare module BABYLON {
  80994. /**
  80995. * Manage the touch inputs to control the movement of a free camera.
  80996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80997. */
  80998. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80999. /**
  81000. * Defines the camera the input is attached to.
  81001. */
  81002. camera: FreeCamera;
  81003. /**
  81004. * Defines the touch sensibility for rotation.
  81005. * The higher the faster.
  81006. */
  81007. touchAngularSensibility: number;
  81008. /**
  81009. * Defines the touch sensibility for move.
  81010. * The higher the faster.
  81011. */
  81012. touchMoveSensibility: number;
  81013. private _offsetX;
  81014. private _offsetY;
  81015. private _pointerPressed;
  81016. private _pointerInput;
  81017. private _observer;
  81018. private _onLostFocus;
  81019. /**
  81020. * Attach the input controls to a specific dom element to get the input from.
  81021. * @param element Defines the element the controls should be listened from
  81022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81023. */
  81024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81025. /**
  81026. * Detach the current controls from the specified dom element.
  81027. * @param element Defines the element to stop listening the inputs from
  81028. */
  81029. detachControl(element: Nullable<HTMLElement>): void;
  81030. /**
  81031. * Update the current camera state depending on the inputs that have been used this frame.
  81032. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81033. */
  81034. checkInputs(): void;
  81035. /**
  81036. * Gets the class name of the current intput.
  81037. * @returns the class name
  81038. */
  81039. getClassName(): string;
  81040. /**
  81041. * Get the friendly name associated with the input class.
  81042. * @returns the input friendly name
  81043. */
  81044. getSimpleName(): string;
  81045. }
  81046. }
  81047. declare module BABYLON {
  81048. /**
  81049. * Default Inputs manager for the FreeCamera.
  81050. * It groups all the default supported inputs for ease of use.
  81051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81052. */
  81053. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  81054. /**
  81055. * @hidden
  81056. */
  81057. _mouseInput: Nullable<FreeCameraMouseInput>;
  81058. /**
  81059. * Instantiates a new FreeCameraInputsManager.
  81060. * @param camera Defines the camera the inputs belong to
  81061. */
  81062. constructor(camera: FreeCamera);
  81063. /**
  81064. * Add keyboard input support to the input manager.
  81065. * @returns the current input manager
  81066. */
  81067. addKeyboard(): FreeCameraInputsManager;
  81068. /**
  81069. * Add mouse input support to the input manager.
  81070. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  81071. * @returns the current input manager
  81072. */
  81073. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  81074. /**
  81075. * Removes the mouse input support from the manager
  81076. * @returns the current input manager
  81077. */
  81078. removeMouse(): FreeCameraInputsManager;
  81079. /**
  81080. * Add touch input support to the input manager.
  81081. * @returns the current input manager
  81082. */
  81083. addTouch(): FreeCameraInputsManager;
  81084. /**
  81085. * Remove all attached input methods from a camera
  81086. */
  81087. clear(): void;
  81088. }
  81089. }
  81090. declare module BABYLON {
  81091. /**
  81092. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81093. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  81094. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81095. */
  81096. export class FreeCamera extends TargetCamera {
  81097. /**
  81098. * Define the collision ellipsoid of the camera.
  81099. * This is helpful to simulate a camera body like the player body around the camera
  81100. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  81101. */
  81102. ellipsoid: Vector3;
  81103. /**
  81104. * Define an offset for the position of the ellipsoid around the camera.
  81105. * This can be helpful to determine the center of the body near the gravity center of the body
  81106. * instead of its head.
  81107. */
  81108. ellipsoidOffset: Vector3;
  81109. /**
  81110. * Enable or disable collisions of the camera with the rest of the scene objects.
  81111. */
  81112. checkCollisions: boolean;
  81113. /**
  81114. * Enable or disable gravity on the camera.
  81115. */
  81116. applyGravity: boolean;
  81117. /**
  81118. * Define the input manager associated to the camera.
  81119. */
  81120. inputs: FreeCameraInputsManager;
  81121. /**
  81122. * Gets the input sensibility for a mouse input. (default is 2000.0)
  81123. * Higher values reduce sensitivity.
  81124. */
  81125. /**
  81126. * Sets the input sensibility for a mouse input. (default is 2000.0)
  81127. * Higher values reduce sensitivity.
  81128. */
  81129. angularSensibility: number;
  81130. /**
  81131. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81132. */
  81133. keysUp: number[];
  81134. /**
  81135. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81136. */
  81137. keysDown: number[];
  81138. /**
  81139. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81140. */
  81141. keysLeft: number[];
  81142. /**
  81143. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81144. */
  81145. keysRight: number[];
  81146. /**
  81147. * Event raised when the camera collide with a mesh in the scene.
  81148. */
  81149. onCollide: (collidedMesh: AbstractMesh) => void;
  81150. private _collider;
  81151. private _needMoveForGravity;
  81152. private _oldPosition;
  81153. private _diffPosition;
  81154. private _newPosition;
  81155. /** @hidden */
  81156. _localDirection: Vector3;
  81157. /** @hidden */
  81158. _transformedDirection: Vector3;
  81159. /**
  81160. * Instantiates a Free Camera.
  81161. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81162. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  81163. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81164. * @param name Define the name of the camera in the scene
  81165. * @param position Define the start position of the camera in the scene
  81166. * @param scene Define the scene the camera belongs to
  81167. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81168. */
  81169. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81170. /**
  81171. * Attached controls to the current camera.
  81172. * @param element Defines the element the controls should be listened from
  81173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81174. */
  81175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81176. /**
  81177. * Detach the current controls from the camera.
  81178. * The camera will stop reacting to inputs.
  81179. * @param element Defines the element to stop listening the inputs from
  81180. */
  81181. detachControl(element: HTMLElement): void;
  81182. private _collisionMask;
  81183. /**
  81184. * Define a collision mask to limit the list of object the camera can collide with
  81185. */
  81186. collisionMask: number;
  81187. /** @hidden */
  81188. _collideWithWorld(displacement: Vector3): void;
  81189. private _onCollisionPositionChange;
  81190. /** @hidden */
  81191. _checkInputs(): void;
  81192. /** @hidden */
  81193. _decideIfNeedsToMove(): boolean;
  81194. /** @hidden */
  81195. _updatePosition(): void;
  81196. /**
  81197. * Destroy the camera and release the current resources hold by it.
  81198. */
  81199. dispose(): void;
  81200. /**
  81201. * Gets the current object class name.
  81202. * @return the class name
  81203. */
  81204. getClassName(): string;
  81205. }
  81206. }
  81207. declare module BABYLON {
  81208. /**
  81209. * Represents a gamepad control stick position
  81210. */
  81211. export class StickValues {
  81212. /**
  81213. * The x component of the control stick
  81214. */
  81215. x: number;
  81216. /**
  81217. * The y component of the control stick
  81218. */
  81219. y: number;
  81220. /**
  81221. * Initializes the gamepad x and y control stick values
  81222. * @param x The x component of the gamepad control stick value
  81223. * @param y The y component of the gamepad control stick value
  81224. */
  81225. constructor(
  81226. /**
  81227. * The x component of the control stick
  81228. */
  81229. x: number,
  81230. /**
  81231. * The y component of the control stick
  81232. */
  81233. y: number);
  81234. }
  81235. /**
  81236. * An interface which manages callbacks for gamepad button changes
  81237. */
  81238. export interface GamepadButtonChanges {
  81239. /**
  81240. * Called when a gamepad has been changed
  81241. */
  81242. changed: boolean;
  81243. /**
  81244. * Called when a gamepad press event has been triggered
  81245. */
  81246. pressChanged: boolean;
  81247. /**
  81248. * Called when a touch event has been triggered
  81249. */
  81250. touchChanged: boolean;
  81251. /**
  81252. * Called when a value has changed
  81253. */
  81254. valueChanged: boolean;
  81255. }
  81256. /**
  81257. * Represents a gamepad
  81258. */
  81259. export class Gamepad {
  81260. /**
  81261. * The id of the gamepad
  81262. */
  81263. id: string;
  81264. /**
  81265. * The index of the gamepad
  81266. */
  81267. index: number;
  81268. /**
  81269. * The browser gamepad
  81270. */
  81271. browserGamepad: any;
  81272. /**
  81273. * Specifies what type of gamepad this represents
  81274. */
  81275. type: number;
  81276. private _leftStick;
  81277. private _rightStick;
  81278. /** @hidden */
  81279. _isConnected: boolean;
  81280. private _leftStickAxisX;
  81281. private _leftStickAxisY;
  81282. private _rightStickAxisX;
  81283. private _rightStickAxisY;
  81284. /**
  81285. * Triggered when the left control stick has been changed
  81286. */
  81287. private _onleftstickchanged;
  81288. /**
  81289. * Triggered when the right control stick has been changed
  81290. */
  81291. private _onrightstickchanged;
  81292. /**
  81293. * Represents a gamepad controller
  81294. */
  81295. static GAMEPAD: number;
  81296. /**
  81297. * Represents a generic controller
  81298. */
  81299. static GENERIC: number;
  81300. /**
  81301. * Represents an XBox controller
  81302. */
  81303. static XBOX: number;
  81304. /**
  81305. * Represents a pose-enabled controller
  81306. */
  81307. static POSE_ENABLED: number;
  81308. /**
  81309. * Represents an Dual Shock controller
  81310. */
  81311. static DUALSHOCK: number;
  81312. /**
  81313. * Specifies whether the left control stick should be Y-inverted
  81314. */
  81315. protected _invertLeftStickY: boolean;
  81316. /**
  81317. * Specifies if the gamepad has been connected
  81318. */
  81319. readonly isConnected: boolean;
  81320. /**
  81321. * Initializes the gamepad
  81322. * @param id The id of the gamepad
  81323. * @param index The index of the gamepad
  81324. * @param browserGamepad The browser gamepad
  81325. * @param leftStickX The x component of the left joystick
  81326. * @param leftStickY The y component of the left joystick
  81327. * @param rightStickX The x component of the right joystick
  81328. * @param rightStickY The y component of the right joystick
  81329. */
  81330. constructor(
  81331. /**
  81332. * The id of the gamepad
  81333. */
  81334. id: string,
  81335. /**
  81336. * The index of the gamepad
  81337. */
  81338. index: number,
  81339. /**
  81340. * The browser gamepad
  81341. */
  81342. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  81343. /**
  81344. * Callback triggered when the left joystick has changed
  81345. * @param callback
  81346. */
  81347. onleftstickchanged(callback: (values: StickValues) => void): void;
  81348. /**
  81349. * Callback triggered when the right joystick has changed
  81350. * @param callback
  81351. */
  81352. onrightstickchanged(callback: (values: StickValues) => void): void;
  81353. /**
  81354. * Gets the left joystick
  81355. */
  81356. /**
  81357. * Sets the left joystick values
  81358. */
  81359. leftStick: StickValues;
  81360. /**
  81361. * Gets the right joystick
  81362. */
  81363. /**
  81364. * Sets the right joystick value
  81365. */
  81366. rightStick: StickValues;
  81367. /**
  81368. * Updates the gamepad joystick positions
  81369. */
  81370. update(): void;
  81371. /**
  81372. * Disposes the gamepad
  81373. */
  81374. dispose(): void;
  81375. }
  81376. /**
  81377. * Represents a generic gamepad
  81378. */
  81379. export class GenericPad extends Gamepad {
  81380. private _buttons;
  81381. private _onbuttondown;
  81382. private _onbuttonup;
  81383. /**
  81384. * Observable triggered when a button has been pressed
  81385. */
  81386. onButtonDownObservable: Observable<number>;
  81387. /**
  81388. * Observable triggered when a button has been released
  81389. */
  81390. onButtonUpObservable: Observable<number>;
  81391. /**
  81392. * Callback triggered when a button has been pressed
  81393. * @param callback Called when a button has been pressed
  81394. */
  81395. onbuttondown(callback: (buttonPressed: number) => void): void;
  81396. /**
  81397. * Callback triggered when a button has been released
  81398. * @param callback Called when a button has been released
  81399. */
  81400. onbuttonup(callback: (buttonReleased: number) => void): void;
  81401. /**
  81402. * Initializes the generic gamepad
  81403. * @param id The id of the generic gamepad
  81404. * @param index The index of the generic gamepad
  81405. * @param browserGamepad The browser gamepad
  81406. */
  81407. constructor(id: string, index: number, browserGamepad: any);
  81408. private _setButtonValue;
  81409. /**
  81410. * Updates the generic gamepad
  81411. */
  81412. update(): void;
  81413. /**
  81414. * Disposes the generic gamepad
  81415. */
  81416. dispose(): void;
  81417. }
  81418. }
  81419. declare module BABYLON {
  81420. interface Engine {
  81421. /**
  81422. * Creates a raw texture
  81423. * @param data defines the data to store in the texture
  81424. * @param width defines the width of the texture
  81425. * @param height defines the height of the texture
  81426. * @param format defines the format of the data
  81427. * @param generateMipMaps defines if the engine should generate the mip levels
  81428. * @param invertY defines if data must be stored with Y axis inverted
  81429. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  81430. * @param compression defines the compression used (null by default)
  81431. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81432. * @returns the raw texture inside an InternalTexture
  81433. */
  81434. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  81435. /**
  81436. * Update a raw texture
  81437. * @param texture defines the texture to update
  81438. * @param data defines the data to store in the texture
  81439. * @param format defines the format of the data
  81440. * @param invertY defines if data must be stored with Y axis inverted
  81441. */
  81442. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81443. /**
  81444. * Update a raw texture
  81445. * @param texture defines the texture to update
  81446. * @param data defines the data to store in the texture
  81447. * @param format defines the format of the data
  81448. * @param invertY defines if data must be stored with Y axis inverted
  81449. * @param compression defines the compression used (null by default)
  81450. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81451. */
  81452. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  81453. /**
  81454. * Creates a new raw cube texture
  81455. * @param data defines the array of data to use to create each face
  81456. * @param size defines the size of the textures
  81457. * @param format defines the format of the data
  81458. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81459. * @param generateMipMaps defines if the engine should generate the mip levels
  81460. * @param invertY defines if data must be stored with Y axis inverted
  81461. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81462. * @param compression defines the compression used (null by default)
  81463. * @returns the cube texture as an InternalTexture
  81464. */
  81465. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  81466. /**
  81467. * Update a raw cube texture
  81468. * @param texture defines the texture to udpdate
  81469. * @param data defines the data to store
  81470. * @param format defines the data format
  81471. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81472. * @param invertY defines if data must be stored with Y axis inverted
  81473. */
  81474. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  81475. /**
  81476. * Update a raw cube texture
  81477. * @param texture defines the texture to udpdate
  81478. * @param data defines the data to store
  81479. * @param format defines the data format
  81480. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81481. * @param invertY defines if data must be stored with Y axis inverted
  81482. * @param compression defines the compression used (null by default)
  81483. */
  81484. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  81485. /**
  81486. * Update a raw cube texture
  81487. * @param texture defines the texture to udpdate
  81488. * @param data defines the data to store
  81489. * @param format defines the data format
  81490. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81491. * @param invertY defines if data must be stored with Y axis inverted
  81492. * @param compression defines the compression used (null by default)
  81493. * @param level defines which level of the texture to update
  81494. */
  81495. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  81496. /**
  81497. * Creates a new raw cube texture from a specified url
  81498. * @param url defines the url where the data is located
  81499. * @param scene defines the current scene
  81500. * @param size defines the size of the textures
  81501. * @param format defines the format of the data
  81502. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81503. * @param noMipmap defines if the engine should avoid generating the mip levels
  81504. * @param callback defines a callback used to extract texture data from loaded data
  81505. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81506. * @param onLoad defines a callback called when texture is loaded
  81507. * @param onError defines a callback called if there is an error
  81508. * @returns the cube texture as an InternalTexture
  81509. */
  81510. 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;
  81511. /**
  81512. * Creates a new raw cube texture from a specified url
  81513. * @param url defines the url where the data is located
  81514. * @param scene defines the current scene
  81515. * @param size defines the size of the textures
  81516. * @param format defines the format of the data
  81517. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81518. * @param noMipmap defines if the engine should avoid generating the mip levels
  81519. * @param callback defines a callback used to extract texture data from loaded data
  81520. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81521. * @param onLoad defines a callback called when texture is loaded
  81522. * @param onError defines a callback called if there is an error
  81523. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81524. * @param invertY defines if data must be stored with Y axis inverted
  81525. * @returns the cube texture as an InternalTexture
  81526. */
  81527. 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;
  81528. /**
  81529. * Creates a new raw 3D texture
  81530. * @param data defines the data used to create the texture
  81531. * @param width defines the width of the texture
  81532. * @param height defines the height of the texture
  81533. * @param depth defines the depth of the texture
  81534. * @param format defines the format of the texture
  81535. * @param generateMipMaps defines if the engine must generate mip levels
  81536. * @param invertY defines if data must be stored with Y axis inverted
  81537. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81538. * @param compression defines the compressed used (can be null)
  81539. * @param textureType defines the compressed used (can be null)
  81540. * @returns a new raw 3D texture (stored in an InternalTexture)
  81541. */
  81542. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81543. /**
  81544. * Update a raw 3D texture
  81545. * @param texture defines the texture to update
  81546. * @param data defines the data to store
  81547. * @param format defines the data format
  81548. * @param invertY defines if data must be stored with Y axis inverted
  81549. */
  81550. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81551. /**
  81552. * Update a raw 3D texture
  81553. * @param texture defines the texture to update
  81554. * @param data defines the data to store
  81555. * @param format defines the data format
  81556. * @param invertY defines if data must be stored with Y axis inverted
  81557. * @param compression defines the used compression (can be null)
  81558. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81559. */
  81560. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81561. /**
  81562. * Creates a new raw 2D array texture
  81563. * @param data defines the data used to create the texture
  81564. * @param width defines the width of the texture
  81565. * @param height defines the height of the texture
  81566. * @param depth defines the number of layers of the texture
  81567. * @param format defines the format of the texture
  81568. * @param generateMipMaps defines if the engine must generate mip levels
  81569. * @param invertY defines if data must be stored with Y axis inverted
  81570. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81571. * @param compression defines the compressed used (can be null)
  81572. * @param textureType defines the compressed used (can be null)
  81573. * @returns a new raw 2D array texture (stored in an InternalTexture)
  81574. */
  81575. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81576. /**
  81577. * Update a raw 2D array texture
  81578. * @param texture defines the texture to update
  81579. * @param data defines the data to store
  81580. * @param format defines the data format
  81581. * @param invertY defines if data must be stored with Y axis inverted
  81582. */
  81583. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81584. /**
  81585. * Update a raw 2D array texture
  81586. * @param texture defines the texture to update
  81587. * @param data defines the data to store
  81588. * @param format defines the data format
  81589. * @param invertY defines if data must be stored with Y axis inverted
  81590. * @param compression defines the used compression (can be null)
  81591. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81592. */
  81593. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81594. }
  81595. }
  81596. declare module BABYLON {
  81597. /**
  81598. * Raw texture can help creating a texture directly from an array of data.
  81599. * This can be super useful if you either get the data from an uncompressed source or
  81600. * if you wish to create your texture pixel by pixel.
  81601. */
  81602. export class RawTexture extends Texture {
  81603. /**
  81604. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81605. */
  81606. format: number;
  81607. private _engine;
  81608. /**
  81609. * Instantiates a new RawTexture.
  81610. * Raw texture can help creating a texture directly from an array of data.
  81611. * This can be super useful if you either get the data from an uncompressed source or
  81612. * if you wish to create your texture pixel by pixel.
  81613. * @param data define the array of data to use to create the texture
  81614. * @param width define the width of the texture
  81615. * @param height define the height of the texture
  81616. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81617. * @param scene define the scene the texture belongs to
  81618. * @param generateMipMaps define whether mip maps should be generated or not
  81619. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81620. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81621. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81622. */
  81623. constructor(data: ArrayBufferView, width: number, height: number,
  81624. /**
  81625. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81626. */
  81627. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  81628. /**
  81629. * Updates the texture underlying data.
  81630. * @param data Define the new data of the texture
  81631. */
  81632. update(data: ArrayBufferView): void;
  81633. /**
  81634. * Creates a luminance texture from some data.
  81635. * @param data Define the texture data
  81636. * @param width Define the width of the texture
  81637. * @param height Define the height of the texture
  81638. * @param scene Define the scene the texture belongs to
  81639. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81640. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81641. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81642. * @returns the luminance texture
  81643. */
  81644. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81645. /**
  81646. * Creates a luminance alpha texture from some data.
  81647. * @param data Define the texture data
  81648. * @param width Define the width of the texture
  81649. * @param height Define the height of the texture
  81650. * @param scene Define the scene the texture belongs to
  81651. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81652. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81653. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81654. * @returns the luminance alpha texture
  81655. */
  81656. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81657. /**
  81658. * Creates an alpha texture from some data.
  81659. * @param data Define the texture data
  81660. * @param width Define the width of the texture
  81661. * @param height Define the height of the texture
  81662. * @param scene Define the scene the texture belongs to
  81663. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81666. * @returns the alpha texture
  81667. */
  81668. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81669. /**
  81670. * Creates a RGB texture from some data.
  81671. * @param data Define the texture data
  81672. * @param width Define the width of the texture
  81673. * @param height Define the height of the texture
  81674. * @param scene Define the scene the texture belongs to
  81675. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81676. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81677. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81678. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81679. * @returns the RGB alpha texture
  81680. */
  81681. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81682. /**
  81683. * Creates a RGBA texture from some data.
  81684. * @param data Define the texture data
  81685. * @param width Define the width of the texture
  81686. * @param height Define the height of the texture
  81687. * @param scene Define the scene the texture belongs to
  81688. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81689. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81690. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81691. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81692. * @returns the RGBA texture
  81693. */
  81694. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81695. /**
  81696. * Creates a R texture from some data.
  81697. * @param data Define the texture data
  81698. * @param width Define the width of the texture
  81699. * @param height Define the height of the texture
  81700. * @param scene Define the scene the texture belongs to
  81701. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81702. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81703. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81704. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81705. * @returns the R texture
  81706. */
  81707. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81708. }
  81709. }
  81710. declare module BABYLON {
  81711. /**
  81712. * Interface for the size containing width and height
  81713. */
  81714. export interface ISize {
  81715. /**
  81716. * Width
  81717. */
  81718. width: number;
  81719. /**
  81720. * Heighht
  81721. */
  81722. height: number;
  81723. }
  81724. /**
  81725. * Size containing widht and height
  81726. */
  81727. export class Size implements ISize {
  81728. /**
  81729. * Width
  81730. */
  81731. width: number;
  81732. /**
  81733. * Height
  81734. */
  81735. height: number;
  81736. /**
  81737. * Creates a Size object from the given width and height (floats).
  81738. * @param width width of the new size
  81739. * @param height height of the new size
  81740. */
  81741. constructor(width: number, height: number);
  81742. /**
  81743. * Returns a string with the Size width and height
  81744. * @returns a string with the Size width and height
  81745. */
  81746. toString(): string;
  81747. /**
  81748. * "Size"
  81749. * @returns the string "Size"
  81750. */
  81751. getClassName(): string;
  81752. /**
  81753. * Returns the Size hash code.
  81754. * @returns a hash code for a unique width and height
  81755. */
  81756. getHashCode(): number;
  81757. /**
  81758. * Updates the current size from the given one.
  81759. * @param src the given size
  81760. */
  81761. copyFrom(src: Size): void;
  81762. /**
  81763. * Updates in place the current Size from the given floats.
  81764. * @param width width of the new size
  81765. * @param height height of the new size
  81766. * @returns the updated Size.
  81767. */
  81768. copyFromFloats(width: number, height: number): Size;
  81769. /**
  81770. * Updates in place the current Size from the given floats.
  81771. * @param width width to set
  81772. * @param height height to set
  81773. * @returns the updated Size.
  81774. */
  81775. set(width: number, height: number): Size;
  81776. /**
  81777. * Multiplies the width and height by numbers
  81778. * @param w factor to multiple the width by
  81779. * @param h factor to multiple the height by
  81780. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  81781. */
  81782. multiplyByFloats(w: number, h: number): Size;
  81783. /**
  81784. * Clones the size
  81785. * @returns a new Size copied from the given one.
  81786. */
  81787. clone(): Size;
  81788. /**
  81789. * True if the current Size and the given one width and height are strictly equal.
  81790. * @param other the other size to compare against
  81791. * @returns True if the current Size and the given one width and height are strictly equal.
  81792. */
  81793. equals(other: Size): boolean;
  81794. /**
  81795. * The surface of the Size : width * height (float).
  81796. */
  81797. readonly surface: number;
  81798. /**
  81799. * Create a new size of zero
  81800. * @returns a new Size set to (0.0, 0.0)
  81801. */
  81802. static Zero(): Size;
  81803. /**
  81804. * Sums the width and height of two sizes
  81805. * @param otherSize size to add to this size
  81806. * @returns a new Size set as the addition result of the current Size and the given one.
  81807. */
  81808. add(otherSize: Size): Size;
  81809. /**
  81810. * Subtracts the width and height of two
  81811. * @param otherSize size to subtract to this size
  81812. * @returns a new Size set as the subtraction result of the given one from the current Size.
  81813. */
  81814. subtract(otherSize: Size): Size;
  81815. /**
  81816. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  81817. * @param start starting size to lerp between
  81818. * @param end end size to lerp between
  81819. * @param amount amount to lerp between the start and end values
  81820. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  81821. */
  81822. static Lerp(start: Size, end: Size, amount: number): Size;
  81823. }
  81824. }
  81825. declare module BABYLON {
  81826. /**
  81827. * Defines a runtime animation
  81828. */
  81829. export class RuntimeAnimation {
  81830. private _events;
  81831. /**
  81832. * The current frame of the runtime animation
  81833. */
  81834. private _currentFrame;
  81835. /**
  81836. * The animation used by the runtime animation
  81837. */
  81838. private _animation;
  81839. /**
  81840. * The target of the runtime animation
  81841. */
  81842. private _target;
  81843. /**
  81844. * The initiating animatable
  81845. */
  81846. private _host;
  81847. /**
  81848. * The original value of the runtime animation
  81849. */
  81850. private _originalValue;
  81851. /**
  81852. * The original blend value of the runtime animation
  81853. */
  81854. private _originalBlendValue;
  81855. /**
  81856. * The offsets cache of the runtime animation
  81857. */
  81858. private _offsetsCache;
  81859. /**
  81860. * The high limits cache of the runtime animation
  81861. */
  81862. private _highLimitsCache;
  81863. /**
  81864. * Specifies if the runtime animation has been stopped
  81865. */
  81866. private _stopped;
  81867. /**
  81868. * The blending factor of the runtime animation
  81869. */
  81870. private _blendingFactor;
  81871. /**
  81872. * The BabylonJS scene
  81873. */
  81874. private _scene;
  81875. /**
  81876. * The current value of the runtime animation
  81877. */
  81878. private _currentValue;
  81879. /** @hidden */
  81880. _animationState: _IAnimationState;
  81881. /**
  81882. * The active target of the runtime animation
  81883. */
  81884. private _activeTargets;
  81885. private _currentActiveTarget;
  81886. private _directTarget;
  81887. /**
  81888. * The target path of the runtime animation
  81889. */
  81890. private _targetPath;
  81891. /**
  81892. * The weight of the runtime animation
  81893. */
  81894. private _weight;
  81895. /**
  81896. * The ratio offset of the runtime animation
  81897. */
  81898. private _ratioOffset;
  81899. /**
  81900. * The previous delay of the runtime animation
  81901. */
  81902. private _previousDelay;
  81903. /**
  81904. * The previous ratio of the runtime animation
  81905. */
  81906. private _previousRatio;
  81907. private _enableBlending;
  81908. private _keys;
  81909. private _minFrame;
  81910. private _maxFrame;
  81911. private _minValue;
  81912. private _maxValue;
  81913. private _targetIsArray;
  81914. /**
  81915. * Gets the current frame of the runtime animation
  81916. */
  81917. readonly currentFrame: number;
  81918. /**
  81919. * Gets the weight of the runtime animation
  81920. */
  81921. readonly weight: number;
  81922. /**
  81923. * Gets the current value of the runtime animation
  81924. */
  81925. readonly currentValue: any;
  81926. /**
  81927. * Gets the target path of the runtime animation
  81928. */
  81929. readonly targetPath: string;
  81930. /**
  81931. * Gets the actual target of the runtime animation
  81932. */
  81933. readonly target: any;
  81934. /** @hidden */
  81935. _onLoop: () => void;
  81936. /**
  81937. * Create a new RuntimeAnimation object
  81938. * @param target defines the target of the animation
  81939. * @param animation defines the source animation object
  81940. * @param scene defines the hosting scene
  81941. * @param host defines the initiating Animatable
  81942. */
  81943. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81944. private _preparePath;
  81945. /**
  81946. * Gets the animation from the runtime animation
  81947. */
  81948. readonly animation: Animation;
  81949. /**
  81950. * Resets the runtime animation to the beginning
  81951. * @param restoreOriginal defines whether to restore the target property to the original value
  81952. */
  81953. reset(restoreOriginal?: boolean): void;
  81954. /**
  81955. * Specifies if the runtime animation is stopped
  81956. * @returns Boolean specifying if the runtime animation is stopped
  81957. */
  81958. isStopped(): boolean;
  81959. /**
  81960. * Disposes of the runtime animation
  81961. */
  81962. dispose(): void;
  81963. /**
  81964. * Apply the interpolated value to the target
  81965. * @param currentValue defines the value computed by the animation
  81966. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81967. */
  81968. setValue(currentValue: any, weight: number): void;
  81969. private _getOriginalValues;
  81970. private _setValue;
  81971. /**
  81972. * Gets the loop pmode of the runtime animation
  81973. * @returns Loop Mode
  81974. */
  81975. private _getCorrectLoopMode;
  81976. /**
  81977. * Move the current animation to a given frame
  81978. * @param frame defines the frame to move to
  81979. */
  81980. goToFrame(frame: number): void;
  81981. /**
  81982. * @hidden Internal use only
  81983. */
  81984. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81985. /**
  81986. * Execute the current animation
  81987. * @param delay defines the delay to add to the current frame
  81988. * @param from defines the lower bound of the animation range
  81989. * @param to defines the upper bound of the animation range
  81990. * @param loop defines if the current animation must loop
  81991. * @param speedRatio defines the current speed ratio
  81992. * @param weight defines the weight of the animation (default is -1 so no weight)
  81993. * @param onLoop optional callback called when animation loops
  81994. * @returns a boolean indicating if the animation is running
  81995. */
  81996. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81997. }
  81998. }
  81999. declare module BABYLON {
  82000. /**
  82001. * Class used to store an actual running animation
  82002. */
  82003. export class Animatable {
  82004. /** defines the target object */
  82005. target: any;
  82006. /** defines the starting frame number (default is 0) */
  82007. fromFrame: number;
  82008. /** defines the ending frame number (default is 100) */
  82009. toFrame: number;
  82010. /** defines if the animation must loop (default is false) */
  82011. loopAnimation: boolean;
  82012. /** defines a callback to call when animation ends if it is not looping */
  82013. onAnimationEnd?: (() => void) | null | undefined;
  82014. /** defines a callback to call when animation loops */
  82015. onAnimationLoop?: (() => void) | null | undefined;
  82016. private _localDelayOffset;
  82017. private _pausedDelay;
  82018. private _runtimeAnimations;
  82019. private _paused;
  82020. private _scene;
  82021. private _speedRatio;
  82022. private _weight;
  82023. private _syncRoot;
  82024. /**
  82025. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  82026. * This will only apply for non looping animation (default is true)
  82027. */
  82028. disposeOnEnd: boolean;
  82029. /**
  82030. * Gets a boolean indicating if the animation has started
  82031. */
  82032. animationStarted: boolean;
  82033. /**
  82034. * Observer raised when the animation ends
  82035. */
  82036. onAnimationEndObservable: Observable<Animatable>;
  82037. /**
  82038. * Observer raised when the animation loops
  82039. */
  82040. onAnimationLoopObservable: Observable<Animatable>;
  82041. /**
  82042. * Gets the root Animatable used to synchronize and normalize animations
  82043. */
  82044. readonly syncRoot: Nullable<Animatable>;
  82045. /**
  82046. * Gets the current frame of the first RuntimeAnimation
  82047. * Used to synchronize Animatables
  82048. */
  82049. readonly masterFrame: number;
  82050. /**
  82051. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  82052. */
  82053. weight: number;
  82054. /**
  82055. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  82056. */
  82057. speedRatio: number;
  82058. /**
  82059. * Creates a new Animatable
  82060. * @param scene defines the hosting scene
  82061. * @param target defines the target object
  82062. * @param fromFrame defines the starting frame number (default is 0)
  82063. * @param toFrame defines the ending frame number (default is 100)
  82064. * @param loopAnimation defines if the animation must loop (default is false)
  82065. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  82066. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  82067. * @param animations defines a group of animation to add to the new Animatable
  82068. * @param onAnimationLoop defines a callback to call when animation loops
  82069. */
  82070. constructor(scene: Scene,
  82071. /** defines the target object */
  82072. target: any,
  82073. /** defines the starting frame number (default is 0) */
  82074. fromFrame?: number,
  82075. /** defines the ending frame number (default is 100) */
  82076. toFrame?: number,
  82077. /** defines if the animation must loop (default is false) */
  82078. loopAnimation?: boolean, speedRatio?: number,
  82079. /** defines a callback to call when animation ends if it is not looping */
  82080. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  82081. /** defines a callback to call when animation loops */
  82082. onAnimationLoop?: (() => void) | null | undefined);
  82083. /**
  82084. * Synchronize and normalize current Animatable with a source Animatable
  82085. * This is useful when using animation weights and when animations are not of the same length
  82086. * @param root defines the root Animatable to synchronize with
  82087. * @returns the current Animatable
  82088. */
  82089. syncWith(root: Animatable): Animatable;
  82090. /**
  82091. * Gets the list of runtime animations
  82092. * @returns an array of RuntimeAnimation
  82093. */
  82094. getAnimations(): RuntimeAnimation[];
  82095. /**
  82096. * Adds more animations to the current animatable
  82097. * @param target defines the target of the animations
  82098. * @param animations defines the new animations to add
  82099. */
  82100. appendAnimations(target: any, animations: Animation[]): void;
  82101. /**
  82102. * Gets the source animation for a specific property
  82103. * @param property defines the propertyu to look for
  82104. * @returns null or the source animation for the given property
  82105. */
  82106. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  82107. /**
  82108. * Gets the runtime animation for a specific property
  82109. * @param property defines the propertyu to look for
  82110. * @returns null or the runtime animation for the given property
  82111. */
  82112. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  82113. /**
  82114. * Resets the animatable to its original state
  82115. */
  82116. reset(): void;
  82117. /**
  82118. * Allows the animatable to blend with current running animations
  82119. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82120. * @param blendingSpeed defines the blending speed to use
  82121. */
  82122. enableBlending(blendingSpeed: number): void;
  82123. /**
  82124. * Disable animation blending
  82125. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82126. */
  82127. disableBlending(): void;
  82128. /**
  82129. * Jump directly to a given frame
  82130. * @param frame defines the frame to jump to
  82131. */
  82132. goToFrame(frame: number): void;
  82133. /**
  82134. * Pause the animation
  82135. */
  82136. pause(): void;
  82137. /**
  82138. * Restart the animation
  82139. */
  82140. restart(): void;
  82141. private _raiseOnAnimationEnd;
  82142. /**
  82143. * Stop and delete the current animation
  82144. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  82145. * @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)
  82146. */
  82147. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  82148. /**
  82149. * Wait asynchronously for the animation to end
  82150. * @returns a promise which will be fullfilled when the animation ends
  82151. */
  82152. waitAsync(): Promise<Animatable>;
  82153. /** @hidden */
  82154. _animate(delay: number): boolean;
  82155. }
  82156. interface Scene {
  82157. /** @hidden */
  82158. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  82159. /** @hidden */
  82160. _processLateAnimationBindingsForMatrices(holder: {
  82161. totalWeight: number;
  82162. animations: RuntimeAnimation[];
  82163. originalValue: Matrix;
  82164. }): any;
  82165. /** @hidden */
  82166. _processLateAnimationBindingsForQuaternions(holder: {
  82167. totalWeight: number;
  82168. animations: RuntimeAnimation[];
  82169. originalValue: Quaternion;
  82170. }, refQuaternion: Quaternion): Quaternion;
  82171. /** @hidden */
  82172. _processLateAnimationBindings(): void;
  82173. /**
  82174. * Will start the animation sequence of a given target
  82175. * @param target defines the target
  82176. * @param from defines from which frame should animation start
  82177. * @param to defines until which frame should animation run.
  82178. * @param weight defines the weight to apply to the animation (1.0 by default)
  82179. * @param loop defines if the animation loops
  82180. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82181. * @param onAnimationEnd defines the function to be executed when the animation ends
  82182. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82183. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82184. * @param onAnimationLoop defines the callback to call when an animation loops
  82185. * @returns the animatable object created for this animation
  82186. */
  82187. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82188. /**
  82189. * Will start the animation sequence of a given target
  82190. * @param target defines the target
  82191. * @param from defines from which frame should animation start
  82192. * @param to defines until which frame should animation run.
  82193. * @param loop defines if the animation loops
  82194. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82195. * @param onAnimationEnd defines the function to be executed when the animation ends
  82196. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82197. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82198. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  82199. * @param onAnimationLoop defines the callback to call when an animation loops
  82200. * @returns the animatable object created for this animation
  82201. */
  82202. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82203. /**
  82204. * Will start the animation sequence of a given target and its hierarchy
  82205. * @param target defines the target
  82206. * @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.
  82207. * @param from defines from which frame should animation start
  82208. * @param to defines until which frame should animation run.
  82209. * @param loop defines if the animation loops
  82210. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82211. * @param onAnimationEnd defines the function to be executed when the animation ends
  82212. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82213. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82214. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82215. * @param onAnimationLoop defines the callback to call when an animation loops
  82216. * @returns the list of created animatables
  82217. */
  82218. 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[];
  82219. /**
  82220. * Begin a new animation on a given node
  82221. * @param target defines the target where the animation will take place
  82222. * @param animations defines the list of animations to start
  82223. * @param from defines the initial value
  82224. * @param to defines the final value
  82225. * @param loop defines if you want animation to loop (off by default)
  82226. * @param speedRatio defines the speed ratio to apply to all animations
  82227. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82228. * @param onAnimationLoop defines the callback to call when an animation loops
  82229. * @returns the list of created animatables
  82230. */
  82231. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  82232. /**
  82233. * Begin a new animation on a given node and its hierarchy
  82234. * @param target defines the root node where the animation will take place
  82235. * @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.
  82236. * @param animations defines the list of animations to start
  82237. * @param from defines the initial value
  82238. * @param to defines the final value
  82239. * @param loop defines if you want animation to loop (off by default)
  82240. * @param speedRatio defines the speed ratio to apply to all animations
  82241. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82242. * @param onAnimationLoop defines the callback to call when an animation loops
  82243. * @returns the list of animatables created for all nodes
  82244. */
  82245. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  82246. /**
  82247. * Gets the animatable associated with a specific target
  82248. * @param target defines the target of the animatable
  82249. * @returns the required animatable if found
  82250. */
  82251. getAnimatableByTarget(target: any): Nullable<Animatable>;
  82252. /**
  82253. * Gets all animatables associated with a given target
  82254. * @param target defines the target to look animatables for
  82255. * @returns an array of Animatables
  82256. */
  82257. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  82258. /**
  82259. * Stops and removes all animations that have been applied to the scene
  82260. */
  82261. stopAllAnimations(): void;
  82262. /**
  82263. * Gets the current delta time used by animation engine
  82264. */
  82265. deltaTime: number;
  82266. }
  82267. interface Bone {
  82268. /**
  82269. * Copy an animation range from another bone
  82270. * @param source defines the source bone
  82271. * @param rangeName defines the range name to copy
  82272. * @param frameOffset defines the frame offset
  82273. * @param rescaleAsRequired defines if rescaling must be applied if required
  82274. * @param skelDimensionsRatio defines the scaling ratio
  82275. * @returns true if operation was successful
  82276. */
  82277. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  82278. }
  82279. }
  82280. declare module BABYLON {
  82281. /**
  82282. * Class used to override all child animations of a given target
  82283. */
  82284. export class AnimationPropertiesOverride {
  82285. /**
  82286. * Gets or sets a value indicating if animation blending must be used
  82287. */
  82288. enableBlending: boolean;
  82289. /**
  82290. * Gets or sets the blending speed to use when enableBlending is true
  82291. */
  82292. blendingSpeed: number;
  82293. /**
  82294. * Gets or sets the default loop mode to use
  82295. */
  82296. loopMode: number;
  82297. }
  82298. }
  82299. declare module BABYLON {
  82300. /**
  82301. * Class used to handle skinning animations
  82302. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82303. */
  82304. export class Skeleton implements IAnimatable {
  82305. /** defines the skeleton name */
  82306. name: string;
  82307. /** defines the skeleton Id */
  82308. id: string;
  82309. /**
  82310. * Defines the list of child bones
  82311. */
  82312. bones: Bone[];
  82313. /**
  82314. * Defines an estimate of the dimension of the skeleton at rest
  82315. */
  82316. dimensionsAtRest: Vector3;
  82317. /**
  82318. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  82319. */
  82320. needInitialSkinMatrix: boolean;
  82321. /**
  82322. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  82323. */
  82324. overrideMesh: Nullable<AbstractMesh>;
  82325. /**
  82326. * Gets the list of animations attached to this skeleton
  82327. */
  82328. animations: Array<Animation>;
  82329. private _scene;
  82330. private _isDirty;
  82331. private _transformMatrices;
  82332. private _transformMatrixTexture;
  82333. private _meshesWithPoseMatrix;
  82334. private _animatables;
  82335. private _identity;
  82336. private _synchronizedWithMesh;
  82337. private _ranges;
  82338. private _lastAbsoluteTransformsUpdateId;
  82339. private _canUseTextureForBones;
  82340. private _uniqueId;
  82341. /** @hidden */
  82342. _numBonesWithLinkedTransformNode: number;
  82343. /** @hidden */
  82344. _hasWaitingData: Nullable<boolean>;
  82345. /**
  82346. * Specifies if the skeleton should be serialized
  82347. */
  82348. doNotSerialize: boolean;
  82349. private _useTextureToStoreBoneMatrices;
  82350. /**
  82351. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  82352. * Please note that this option is not available if the hardware does not support it
  82353. */
  82354. useTextureToStoreBoneMatrices: boolean;
  82355. private _animationPropertiesOverride;
  82356. /**
  82357. * Gets or sets the animation properties override
  82358. */
  82359. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82360. /**
  82361. * List of inspectable custom properties (used by the Inspector)
  82362. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82363. */
  82364. inspectableCustomProperties: IInspectable[];
  82365. /**
  82366. * An observable triggered before computing the skeleton's matrices
  82367. */
  82368. onBeforeComputeObservable: Observable<Skeleton>;
  82369. /**
  82370. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  82371. */
  82372. readonly isUsingTextureForMatrices: boolean;
  82373. /**
  82374. * Gets the unique ID of this skeleton
  82375. */
  82376. readonly uniqueId: number;
  82377. /**
  82378. * Creates a new skeleton
  82379. * @param name defines the skeleton name
  82380. * @param id defines the skeleton Id
  82381. * @param scene defines the hosting scene
  82382. */
  82383. constructor(
  82384. /** defines the skeleton name */
  82385. name: string,
  82386. /** defines the skeleton Id */
  82387. id: string, scene: Scene);
  82388. /**
  82389. * Gets the current object class name.
  82390. * @return the class name
  82391. */
  82392. getClassName(): string;
  82393. /**
  82394. * Returns an array containing the root bones
  82395. * @returns an array containing the root bones
  82396. */
  82397. getChildren(): Array<Bone>;
  82398. /**
  82399. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  82400. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82401. * @returns a Float32Array containing matrices data
  82402. */
  82403. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  82404. /**
  82405. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  82406. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82407. * @returns a raw texture containing the data
  82408. */
  82409. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  82410. /**
  82411. * Gets the current hosting scene
  82412. * @returns a scene object
  82413. */
  82414. getScene(): Scene;
  82415. /**
  82416. * Gets a string representing the current skeleton data
  82417. * @param fullDetails defines a boolean indicating if we want a verbose version
  82418. * @returns a string representing the current skeleton data
  82419. */
  82420. toString(fullDetails?: boolean): string;
  82421. /**
  82422. * Get bone's index searching by name
  82423. * @param name defines bone's name to search for
  82424. * @return the indice of the bone. Returns -1 if not found
  82425. */
  82426. getBoneIndexByName(name: string): number;
  82427. /**
  82428. * Creater a new animation range
  82429. * @param name defines the name of the range
  82430. * @param from defines the start key
  82431. * @param to defines the end key
  82432. */
  82433. createAnimationRange(name: string, from: number, to: number): void;
  82434. /**
  82435. * Delete a specific animation range
  82436. * @param name defines the name of the range
  82437. * @param deleteFrames defines if frames must be removed as well
  82438. */
  82439. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82440. /**
  82441. * Gets a specific animation range
  82442. * @param name defines the name of the range to look for
  82443. * @returns the requested animation range or null if not found
  82444. */
  82445. getAnimationRange(name: string): Nullable<AnimationRange>;
  82446. /**
  82447. * Gets the list of all animation ranges defined on this skeleton
  82448. * @returns an array
  82449. */
  82450. getAnimationRanges(): Nullable<AnimationRange>[];
  82451. /**
  82452. * Copy animation range from a source skeleton.
  82453. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  82454. * @param source defines the source skeleton
  82455. * @param name defines the name of the range to copy
  82456. * @param rescaleAsRequired defines if rescaling must be applied if required
  82457. * @returns true if operation was successful
  82458. */
  82459. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  82460. /**
  82461. * Forces the skeleton to go to rest pose
  82462. */
  82463. returnToRest(): void;
  82464. private _getHighestAnimationFrame;
  82465. /**
  82466. * Begin a specific animation range
  82467. * @param name defines the name of the range to start
  82468. * @param loop defines if looping must be turned on (false by default)
  82469. * @param speedRatio defines the speed ratio to apply (1 by default)
  82470. * @param onAnimationEnd defines a callback which will be called when animation will end
  82471. * @returns a new animatable
  82472. */
  82473. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82474. /** @hidden */
  82475. _markAsDirty(): void;
  82476. /** @hidden */
  82477. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82478. /** @hidden */
  82479. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82480. private _computeTransformMatrices;
  82481. /**
  82482. * Build all resources required to render a skeleton
  82483. */
  82484. prepare(): void;
  82485. /**
  82486. * Gets the list of animatables currently running for this skeleton
  82487. * @returns an array of animatables
  82488. */
  82489. getAnimatables(): IAnimatable[];
  82490. /**
  82491. * Clone the current skeleton
  82492. * @param name defines the name of the new skeleton
  82493. * @param id defines the id of the new skeleton
  82494. * @returns the new skeleton
  82495. */
  82496. clone(name: string, id?: string): Skeleton;
  82497. /**
  82498. * Enable animation blending for this skeleton
  82499. * @param blendingSpeed defines the blending speed to apply
  82500. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82501. */
  82502. enableBlending(blendingSpeed?: number): void;
  82503. /**
  82504. * Releases all resources associated with the current skeleton
  82505. */
  82506. dispose(): void;
  82507. /**
  82508. * Serialize the skeleton in a JSON object
  82509. * @returns a JSON object
  82510. */
  82511. serialize(): any;
  82512. /**
  82513. * Creates a new skeleton from serialized data
  82514. * @param parsedSkeleton defines the serialized data
  82515. * @param scene defines the hosting scene
  82516. * @returns a new skeleton
  82517. */
  82518. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  82519. /**
  82520. * Compute all node absolute transforms
  82521. * @param forceUpdate defines if computation must be done even if cache is up to date
  82522. */
  82523. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  82524. /**
  82525. * Gets the root pose matrix
  82526. * @returns a matrix
  82527. */
  82528. getPoseMatrix(): Nullable<Matrix>;
  82529. /**
  82530. * Sorts bones per internal index
  82531. */
  82532. sortBones(): void;
  82533. private _sortBones;
  82534. }
  82535. }
  82536. declare module BABYLON {
  82537. /**
  82538. * Class used to store bone information
  82539. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82540. */
  82541. export class Bone extends Node {
  82542. /**
  82543. * defines the bone name
  82544. */
  82545. name: string;
  82546. private static _tmpVecs;
  82547. private static _tmpQuat;
  82548. private static _tmpMats;
  82549. /**
  82550. * Gets the list of child bones
  82551. */
  82552. children: Bone[];
  82553. /** Gets the animations associated with this bone */
  82554. animations: Animation[];
  82555. /**
  82556. * Gets or sets bone length
  82557. */
  82558. length: number;
  82559. /**
  82560. * @hidden Internal only
  82561. * Set this value to map this bone to a different index in the transform matrices
  82562. * Set this value to -1 to exclude the bone from the transform matrices
  82563. */
  82564. _index: Nullable<number>;
  82565. private _skeleton;
  82566. private _localMatrix;
  82567. private _restPose;
  82568. private _baseMatrix;
  82569. private _absoluteTransform;
  82570. private _invertedAbsoluteTransform;
  82571. private _parent;
  82572. private _scalingDeterminant;
  82573. private _worldTransform;
  82574. private _localScaling;
  82575. private _localRotation;
  82576. private _localPosition;
  82577. private _needToDecompose;
  82578. private _needToCompose;
  82579. /** @hidden */
  82580. _linkedTransformNode: Nullable<TransformNode>;
  82581. /** @hidden */
  82582. _waitingTransformNodeId: Nullable<string>;
  82583. /** @hidden */
  82584. /** @hidden */
  82585. _matrix: Matrix;
  82586. /**
  82587. * Create a new bone
  82588. * @param name defines the bone name
  82589. * @param skeleton defines the parent skeleton
  82590. * @param parentBone defines the parent (can be null if the bone is the root)
  82591. * @param localMatrix defines the local matrix
  82592. * @param restPose defines the rest pose matrix
  82593. * @param baseMatrix defines the base matrix
  82594. * @param index defines index of the bone in the hiearchy
  82595. */
  82596. constructor(
  82597. /**
  82598. * defines the bone name
  82599. */
  82600. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  82601. /**
  82602. * Gets the current object class name.
  82603. * @return the class name
  82604. */
  82605. getClassName(): string;
  82606. /**
  82607. * Gets the parent skeleton
  82608. * @returns a skeleton
  82609. */
  82610. getSkeleton(): Skeleton;
  82611. /**
  82612. * Gets parent bone
  82613. * @returns a bone or null if the bone is the root of the bone hierarchy
  82614. */
  82615. getParent(): Nullable<Bone>;
  82616. /**
  82617. * Returns an array containing the root bones
  82618. * @returns an array containing the root bones
  82619. */
  82620. getChildren(): Array<Bone>;
  82621. /**
  82622. * Gets the node index in matrix array generated for rendering
  82623. * @returns the node index
  82624. */
  82625. getIndex(): number;
  82626. /**
  82627. * Sets the parent bone
  82628. * @param parent defines the parent (can be null if the bone is the root)
  82629. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82630. */
  82631. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  82632. /**
  82633. * Gets the local matrix
  82634. * @returns a matrix
  82635. */
  82636. getLocalMatrix(): Matrix;
  82637. /**
  82638. * Gets the base matrix (initial matrix which remains unchanged)
  82639. * @returns a matrix
  82640. */
  82641. getBaseMatrix(): Matrix;
  82642. /**
  82643. * Gets the rest pose matrix
  82644. * @returns a matrix
  82645. */
  82646. getRestPose(): Matrix;
  82647. /**
  82648. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  82649. */
  82650. getWorldMatrix(): Matrix;
  82651. /**
  82652. * Sets the local matrix to rest pose matrix
  82653. */
  82654. returnToRest(): void;
  82655. /**
  82656. * Gets the inverse of the absolute transform matrix.
  82657. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  82658. * @returns a matrix
  82659. */
  82660. getInvertedAbsoluteTransform(): Matrix;
  82661. /**
  82662. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  82663. * @returns a matrix
  82664. */
  82665. getAbsoluteTransform(): Matrix;
  82666. /**
  82667. * Links with the given transform node.
  82668. * The local matrix of this bone is copied from the transform node every frame.
  82669. * @param transformNode defines the transform node to link to
  82670. */
  82671. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  82672. /**
  82673. * Gets the node used to drive the bone's transformation
  82674. * @returns a transform node or null
  82675. */
  82676. getTransformNode(): Nullable<TransformNode>;
  82677. /** Gets or sets current position (in local space) */
  82678. position: Vector3;
  82679. /** Gets or sets current rotation (in local space) */
  82680. rotation: Vector3;
  82681. /** Gets or sets current rotation quaternion (in local space) */
  82682. rotationQuaternion: Quaternion;
  82683. /** Gets or sets current scaling (in local space) */
  82684. scaling: Vector3;
  82685. /**
  82686. * Gets the animation properties override
  82687. */
  82688. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82689. private _decompose;
  82690. private _compose;
  82691. /**
  82692. * Update the base and local matrices
  82693. * @param matrix defines the new base or local matrix
  82694. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82695. * @param updateLocalMatrix defines if the local matrix should be updated
  82696. */
  82697. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  82698. /** @hidden */
  82699. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  82700. /**
  82701. * Flag the bone as dirty (Forcing it to update everything)
  82702. */
  82703. markAsDirty(): void;
  82704. /** @hidden */
  82705. _markAsDirtyAndCompose(): void;
  82706. private _markAsDirtyAndDecompose;
  82707. /**
  82708. * Translate the bone in local or world space
  82709. * @param vec The amount to translate the bone
  82710. * @param space The space that the translation is in
  82711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82712. */
  82713. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82714. /**
  82715. * Set the postion of the bone in local or world space
  82716. * @param position The position to set the bone
  82717. * @param space The space that the position is in
  82718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82719. */
  82720. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82721. /**
  82722. * Set the absolute position of the bone (world space)
  82723. * @param position The position to set the bone
  82724. * @param mesh The mesh that this bone is attached to
  82725. */
  82726. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  82727. /**
  82728. * Scale the bone on the x, y and z axes (in local space)
  82729. * @param x The amount to scale the bone on the x axis
  82730. * @param y The amount to scale the bone on the y axis
  82731. * @param z The amount to scale the bone on the z axis
  82732. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  82733. */
  82734. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  82735. /**
  82736. * Set the bone scaling in local space
  82737. * @param scale defines the scaling vector
  82738. */
  82739. setScale(scale: Vector3): void;
  82740. /**
  82741. * Gets the current scaling in local space
  82742. * @returns the current scaling vector
  82743. */
  82744. getScale(): Vector3;
  82745. /**
  82746. * Gets the current scaling in local space and stores it in a target vector
  82747. * @param result defines the target vector
  82748. */
  82749. getScaleToRef(result: Vector3): void;
  82750. /**
  82751. * Set the yaw, pitch, and roll of the bone in local or world space
  82752. * @param yaw The rotation of the bone on the y axis
  82753. * @param pitch The rotation of the bone on the x axis
  82754. * @param roll The rotation of the bone on the z axis
  82755. * @param space The space that the axes of rotation are in
  82756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82757. */
  82758. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  82759. /**
  82760. * Add a rotation to the bone on an axis in local or world space
  82761. * @param axis The axis to rotate the bone on
  82762. * @param amount The amount to rotate the bone
  82763. * @param space The space that the axis is in
  82764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82765. */
  82766. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  82767. /**
  82768. * Set the rotation of the bone to a particular axis angle in local or world space
  82769. * @param axis The axis to rotate the bone on
  82770. * @param angle The angle that the bone should be rotated to
  82771. * @param space The space that the axis is in
  82772. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82773. */
  82774. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  82775. /**
  82776. * Set the euler rotation of the bone in local of world space
  82777. * @param rotation The euler rotation that the bone should be set to
  82778. * @param space The space that the rotation is in
  82779. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82780. */
  82781. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82782. /**
  82783. * Set the quaternion rotation of the bone in local of world space
  82784. * @param quat The quaternion rotation that the bone should be set to
  82785. * @param space The space that the rotation is in
  82786. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82787. */
  82788. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  82789. /**
  82790. * Set the rotation matrix of the bone in local of world space
  82791. * @param rotMat The rotation matrix that the bone should be set to
  82792. * @param space The space that the rotation is in
  82793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82794. */
  82795. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  82796. private _rotateWithMatrix;
  82797. private _getNegativeRotationToRef;
  82798. /**
  82799. * Get the position of the bone in local or world space
  82800. * @param space The space that the returned position is in
  82801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82802. * @returns The position of the bone
  82803. */
  82804. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82805. /**
  82806. * Copy the position of the bone to a vector3 in local or world space
  82807. * @param space The space that the returned position is in
  82808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82809. * @param result The vector3 to copy the position to
  82810. */
  82811. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  82812. /**
  82813. * Get the absolute position of the bone (world space)
  82814. * @param mesh The mesh that this bone is attached to
  82815. * @returns The absolute position of the bone
  82816. */
  82817. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  82818. /**
  82819. * Copy the absolute position of the bone (world space) to the result param
  82820. * @param mesh The mesh that this bone is attached to
  82821. * @param result The vector3 to copy the absolute position to
  82822. */
  82823. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  82824. /**
  82825. * Compute the absolute transforms of this bone and its children
  82826. */
  82827. computeAbsoluteTransforms(): void;
  82828. /**
  82829. * Get the world direction from an axis that is in the local space of the bone
  82830. * @param localAxis The local direction that is used to compute the world direction
  82831. * @param mesh The mesh that this bone is attached to
  82832. * @returns The world direction
  82833. */
  82834. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82835. /**
  82836. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  82837. * @param localAxis The local direction that is used to compute the world direction
  82838. * @param mesh The mesh that this bone is attached to
  82839. * @param result The vector3 that the world direction will be copied to
  82840. */
  82841. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82842. /**
  82843. * Get the euler rotation of the bone in local or world space
  82844. * @param space The space that the rotation should be in
  82845. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82846. * @returns The euler rotation
  82847. */
  82848. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82849. /**
  82850. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82851. * @param space The space that the rotation should be in
  82852. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82853. * @param result The vector3 that the rotation should be copied to
  82854. */
  82855. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82856. /**
  82857. * Get the quaternion rotation of the bone in either local or world space
  82858. * @param space The space that the rotation should be in
  82859. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82860. * @returns The quaternion rotation
  82861. */
  82862. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82863. /**
  82864. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82865. * @param space The space that the rotation should be in
  82866. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82867. * @param result The quaternion that the rotation should be copied to
  82868. */
  82869. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82870. /**
  82871. * Get the rotation matrix of the bone in local or world space
  82872. * @param space The space that the rotation should be in
  82873. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82874. * @returns The rotation matrix
  82875. */
  82876. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82877. /**
  82878. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82879. * @param space The space that the rotation should be in
  82880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82881. * @param result The quaternion that the rotation should be copied to
  82882. */
  82883. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82884. /**
  82885. * Get the world position of a point that is in the local space of the bone
  82886. * @param position The local position
  82887. * @param mesh The mesh that this bone is attached to
  82888. * @returns The world position
  82889. */
  82890. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82891. /**
  82892. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82893. * @param position The local position
  82894. * @param mesh The mesh that this bone is attached to
  82895. * @param result The vector3 that the world position should be copied to
  82896. */
  82897. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82898. /**
  82899. * Get the local position of a point that is in world space
  82900. * @param position The world position
  82901. * @param mesh The mesh that this bone is attached to
  82902. * @returns The local position
  82903. */
  82904. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82905. /**
  82906. * Get the local position of a point that is in world space and copy it to the result param
  82907. * @param position The world position
  82908. * @param mesh The mesh that this bone is attached to
  82909. * @param result The vector3 that the local position should be copied to
  82910. */
  82911. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82912. }
  82913. }
  82914. declare module BABYLON {
  82915. /**
  82916. * 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.
  82917. * @see https://doc.babylonjs.com/how_to/transformnode
  82918. */
  82919. export class TransformNode extends Node {
  82920. /**
  82921. * Object will not rotate to face the camera
  82922. */
  82923. static BILLBOARDMODE_NONE: number;
  82924. /**
  82925. * Object will rotate to face the camera but only on the x axis
  82926. */
  82927. static BILLBOARDMODE_X: number;
  82928. /**
  82929. * Object will rotate to face the camera but only on the y axis
  82930. */
  82931. static BILLBOARDMODE_Y: number;
  82932. /**
  82933. * Object will rotate to face the camera but only on the z axis
  82934. */
  82935. static BILLBOARDMODE_Z: number;
  82936. /**
  82937. * Object will rotate to face the camera
  82938. */
  82939. static BILLBOARDMODE_ALL: number;
  82940. /**
  82941. * Object will rotate to face the camera's position instead of orientation
  82942. */
  82943. static BILLBOARDMODE_USE_POSITION: number;
  82944. private _forward;
  82945. private _forwardInverted;
  82946. private _up;
  82947. private _right;
  82948. private _rightInverted;
  82949. private _position;
  82950. private _rotation;
  82951. private _rotationQuaternion;
  82952. protected _scaling: Vector3;
  82953. protected _isDirty: boolean;
  82954. private _transformToBoneReferal;
  82955. private _isAbsoluteSynced;
  82956. private _billboardMode;
  82957. /**
  82958. * Gets or sets the billboard mode. Default is 0.
  82959. *
  82960. * | Value | Type | Description |
  82961. * | --- | --- | --- |
  82962. * | 0 | BILLBOARDMODE_NONE | |
  82963. * | 1 | BILLBOARDMODE_X | |
  82964. * | 2 | BILLBOARDMODE_Y | |
  82965. * | 4 | BILLBOARDMODE_Z | |
  82966. * | 7 | BILLBOARDMODE_ALL | |
  82967. *
  82968. */
  82969. billboardMode: number;
  82970. private _preserveParentRotationForBillboard;
  82971. /**
  82972. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82973. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82974. */
  82975. preserveParentRotationForBillboard: boolean;
  82976. /**
  82977. * 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
  82978. */
  82979. scalingDeterminant: number;
  82980. private _infiniteDistance;
  82981. /**
  82982. * Gets or sets the distance of the object to max, often used by skybox
  82983. */
  82984. infiniteDistance: boolean;
  82985. /**
  82986. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82987. * By default the system will update normals to compensate
  82988. */
  82989. ignoreNonUniformScaling: boolean;
  82990. /**
  82991. * 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
  82992. */
  82993. reIntegrateRotationIntoRotationQuaternion: boolean;
  82994. /** @hidden */
  82995. _poseMatrix: Nullable<Matrix>;
  82996. /** @hidden */
  82997. _localMatrix: Matrix;
  82998. private _usePivotMatrix;
  82999. private _absolutePosition;
  83000. private _absoluteScaling;
  83001. private _absoluteRotationQuaternion;
  83002. private _pivotMatrix;
  83003. private _pivotMatrixInverse;
  83004. protected _postMultiplyPivotMatrix: boolean;
  83005. protected _isWorldMatrixFrozen: boolean;
  83006. /** @hidden */
  83007. _indexInSceneTransformNodesArray: number;
  83008. /**
  83009. * An event triggered after the world matrix is updated
  83010. */
  83011. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  83012. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  83013. /**
  83014. * Gets a string identifying the name of the class
  83015. * @returns "TransformNode" string
  83016. */
  83017. getClassName(): string;
  83018. /**
  83019. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  83020. */
  83021. position: Vector3;
  83022. /**
  83023. * 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)).
  83024. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  83025. */
  83026. rotation: Vector3;
  83027. /**
  83028. * 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)).
  83029. */
  83030. scaling: Vector3;
  83031. /**
  83032. * 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).
  83033. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  83034. */
  83035. rotationQuaternion: Nullable<Quaternion>;
  83036. /**
  83037. * The forward direction of that transform in world space.
  83038. */
  83039. readonly forward: Vector3;
  83040. /**
  83041. * The up direction of that transform in world space.
  83042. */
  83043. readonly up: Vector3;
  83044. /**
  83045. * The right direction of that transform in world space.
  83046. */
  83047. readonly right: Vector3;
  83048. /**
  83049. * Copies the parameter passed Matrix into the mesh Pose matrix.
  83050. * @param matrix the matrix to copy the pose from
  83051. * @returns this TransformNode.
  83052. */
  83053. updatePoseMatrix(matrix: Matrix): TransformNode;
  83054. /**
  83055. * Returns the mesh Pose matrix.
  83056. * @returns the pose matrix
  83057. */
  83058. getPoseMatrix(): Matrix;
  83059. /** @hidden */
  83060. _isSynchronized(): boolean;
  83061. /** @hidden */
  83062. _initCache(): void;
  83063. /**
  83064. * Flag the transform node as dirty (Forcing it to update everything)
  83065. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  83066. * @returns this transform node
  83067. */
  83068. markAsDirty(property: string): TransformNode;
  83069. /**
  83070. * Returns the current mesh absolute position.
  83071. * Returns a Vector3.
  83072. */
  83073. readonly absolutePosition: Vector3;
  83074. /**
  83075. * Returns the current mesh absolute scaling.
  83076. * Returns a Vector3.
  83077. */
  83078. readonly absoluteScaling: Vector3;
  83079. /**
  83080. * Returns the current mesh absolute rotation.
  83081. * Returns a Quaternion.
  83082. */
  83083. readonly absoluteRotationQuaternion: Quaternion;
  83084. /**
  83085. * Sets a new matrix to apply before all other transformation
  83086. * @param matrix defines the transform matrix
  83087. * @returns the current TransformNode
  83088. */
  83089. setPreTransformMatrix(matrix: Matrix): TransformNode;
  83090. /**
  83091. * Sets a new pivot matrix to the current node
  83092. * @param matrix defines the new pivot matrix to use
  83093. * @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
  83094. * @returns the current TransformNode
  83095. */
  83096. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  83097. /**
  83098. * Returns the mesh pivot matrix.
  83099. * Default : Identity.
  83100. * @returns the matrix
  83101. */
  83102. getPivotMatrix(): Matrix;
  83103. /**
  83104. * Instantiate (when possible) or clone that node with its hierarchy
  83105. * @param newParent defines the new parent to use for the instance (or clone)
  83106. * @param options defines options to configure how copy is done
  83107. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  83108. * @returns an instance (or a clone) of the current node with its hiearchy
  83109. */
  83110. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  83111. doNotInstantiate: boolean;
  83112. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  83113. /**
  83114. * Prevents the World matrix to be computed any longer
  83115. * @param newWorldMatrix defines an optional matrix to use as world matrix
  83116. * @returns the TransformNode.
  83117. */
  83118. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  83119. /**
  83120. * Allows back the World matrix computation.
  83121. * @returns the TransformNode.
  83122. */
  83123. unfreezeWorldMatrix(): this;
  83124. /**
  83125. * True if the World matrix has been frozen.
  83126. */
  83127. readonly isWorldMatrixFrozen: boolean;
  83128. /**
  83129. * Retuns the mesh absolute position in the World.
  83130. * @returns a Vector3.
  83131. */
  83132. getAbsolutePosition(): Vector3;
  83133. /**
  83134. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  83135. * @param absolutePosition the absolute position to set
  83136. * @returns the TransformNode.
  83137. */
  83138. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  83139. /**
  83140. * Sets the mesh position in its local space.
  83141. * @param vector3 the position to set in localspace
  83142. * @returns the TransformNode.
  83143. */
  83144. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  83145. /**
  83146. * Returns the mesh position in the local space from the current World matrix values.
  83147. * @returns a new Vector3.
  83148. */
  83149. getPositionExpressedInLocalSpace(): Vector3;
  83150. /**
  83151. * Translates the mesh along the passed Vector3 in its local space.
  83152. * @param vector3 the distance to translate in localspace
  83153. * @returns the TransformNode.
  83154. */
  83155. locallyTranslate(vector3: Vector3): TransformNode;
  83156. private static _lookAtVectorCache;
  83157. /**
  83158. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  83159. * @param targetPoint the position (must be in same space as current mesh) to look at
  83160. * @param yawCor optional yaw (y-axis) correction in radians
  83161. * @param pitchCor optional pitch (x-axis) correction in radians
  83162. * @param rollCor optional roll (z-axis) correction in radians
  83163. * @param space the choosen space of the target
  83164. * @returns the TransformNode.
  83165. */
  83166. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  83167. /**
  83168. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83169. * This Vector3 is expressed in the World space.
  83170. * @param localAxis axis to rotate
  83171. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83172. */
  83173. getDirection(localAxis: Vector3): Vector3;
  83174. /**
  83175. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  83176. * localAxis is expressed in the mesh local space.
  83177. * result is computed in the Wordl space from the mesh World matrix.
  83178. * @param localAxis axis to rotate
  83179. * @param result the resulting transformnode
  83180. * @returns this TransformNode.
  83181. */
  83182. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  83183. /**
  83184. * Sets this transform node rotation to the given local axis.
  83185. * @param localAxis the axis in local space
  83186. * @param yawCor optional yaw (y-axis) correction in radians
  83187. * @param pitchCor optional pitch (x-axis) correction in radians
  83188. * @param rollCor optional roll (z-axis) correction in radians
  83189. * @returns this TransformNode
  83190. */
  83191. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  83192. /**
  83193. * Sets a new pivot point to the current node
  83194. * @param point defines the new pivot point to use
  83195. * @param space defines if the point is in world or local space (local by default)
  83196. * @returns the current TransformNode
  83197. */
  83198. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  83199. /**
  83200. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  83201. * @returns the pivot point
  83202. */
  83203. getPivotPoint(): Vector3;
  83204. /**
  83205. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  83206. * @param result the vector3 to store the result
  83207. * @returns this TransformNode.
  83208. */
  83209. getPivotPointToRef(result: Vector3): TransformNode;
  83210. /**
  83211. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  83212. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  83213. */
  83214. getAbsolutePivotPoint(): Vector3;
  83215. /**
  83216. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  83217. * @param result vector3 to store the result
  83218. * @returns this TransformNode.
  83219. */
  83220. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  83221. /**
  83222. * Defines the passed node as the parent of the current node.
  83223. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  83224. * @see https://doc.babylonjs.com/how_to/parenting
  83225. * @param node the node ot set as the parent
  83226. * @returns this TransformNode.
  83227. */
  83228. setParent(node: Nullable<Node>): TransformNode;
  83229. private _nonUniformScaling;
  83230. /**
  83231. * True if the scaling property of this object is non uniform eg. (1,2,1)
  83232. */
  83233. readonly nonUniformScaling: boolean;
  83234. /** @hidden */
  83235. _updateNonUniformScalingState(value: boolean): boolean;
  83236. /**
  83237. * Attach the current TransformNode to another TransformNode associated with a bone
  83238. * @param bone Bone affecting the TransformNode
  83239. * @param affectedTransformNode TransformNode associated with the bone
  83240. * @returns this object
  83241. */
  83242. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  83243. /**
  83244. * Detach the transform node if its associated with a bone
  83245. * @returns this object
  83246. */
  83247. detachFromBone(): TransformNode;
  83248. private static _rotationAxisCache;
  83249. /**
  83250. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  83251. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83252. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83253. * The passed axis is also normalized.
  83254. * @param axis the axis to rotate around
  83255. * @param amount the amount to rotate in radians
  83256. * @param space Space to rotate in (Default: local)
  83257. * @returns the TransformNode.
  83258. */
  83259. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  83260. /**
  83261. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  83262. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83263. * The passed axis is also normalized. .
  83264. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  83265. * @param point the point to rotate around
  83266. * @param axis the axis to rotate around
  83267. * @param amount the amount to rotate in radians
  83268. * @returns the TransformNode
  83269. */
  83270. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  83271. /**
  83272. * Translates the mesh along the axis vector for the passed distance in the given space.
  83273. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83274. * @param axis the axis to translate in
  83275. * @param distance the distance to translate
  83276. * @param space Space to rotate in (Default: local)
  83277. * @returns the TransformNode.
  83278. */
  83279. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  83280. /**
  83281. * Adds a rotation step to the mesh current rotation.
  83282. * x, y, z are Euler angles expressed in radians.
  83283. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  83284. * This means this rotation is made in the mesh local space only.
  83285. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  83286. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  83287. * ```javascript
  83288. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  83289. * ```
  83290. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  83291. * 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.
  83292. * @param x Rotation to add
  83293. * @param y Rotation to add
  83294. * @param z Rotation to add
  83295. * @returns the TransformNode.
  83296. */
  83297. addRotation(x: number, y: number, z: number): TransformNode;
  83298. /**
  83299. * @hidden
  83300. */
  83301. protected _getEffectiveParent(): Nullable<Node>;
  83302. /**
  83303. * Computes the world matrix of the node
  83304. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83305. * @returns the world matrix
  83306. */
  83307. computeWorldMatrix(force?: boolean): Matrix;
  83308. protected _afterComputeWorldMatrix(): void;
  83309. /**
  83310. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  83311. * @param func callback function to add
  83312. *
  83313. * @returns the TransformNode.
  83314. */
  83315. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83316. /**
  83317. * Removes a registered callback function.
  83318. * @param func callback function to remove
  83319. * @returns the TransformNode.
  83320. */
  83321. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83322. /**
  83323. * Gets the position of the current mesh in camera space
  83324. * @param camera defines the camera to use
  83325. * @returns a position
  83326. */
  83327. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  83328. /**
  83329. * Returns the distance from the mesh to the active camera
  83330. * @param camera defines the camera to use
  83331. * @returns the distance
  83332. */
  83333. getDistanceToCamera(camera?: Nullable<Camera>): number;
  83334. /**
  83335. * Clone the current transform node
  83336. * @param name Name of the new clone
  83337. * @param newParent New parent for the clone
  83338. * @param doNotCloneChildren Do not clone children hierarchy
  83339. * @returns the new transform node
  83340. */
  83341. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  83342. /**
  83343. * Serializes the objects information.
  83344. * @param currentSerializationObject defines the object to serialize in
  83345. * @returns the serialized object
  83346. */
  83347. serialize(currentSerializationObject?: any): any;
  83348. /**
  83349. * Returns a new TransformNode object parsed from the source provided.
  83350. * @param parsedTransformNode is the source.
  83351. * @param scene the scne the object belongs to
  83352. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  83353. * @returns a new TransformNode object parsed from the source provided.
  83354. */
  83355. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  83356. /**
  83357. * Get all child-transformNodes of this node
  83358. * @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
  83359. * @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
  83360. * @returns an array of TransformNode
  83361. */
  83362. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  83363. /**
  83364. * Releases resources associated with this transform node.
  83365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83367. */
  83368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83369. /**
  83370. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83371. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83372. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83373. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  83374. * @returns the current mesh
  83375. */
  83376. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  83377. private _syncAbsoluteScalingAndRotation;
  83378. }
  83379. }
  83380. declare module BABYLON {
  83381. /**
  83382. * Defines the types of pose enabled controllers that are supported
  83383. */
  83384. export enum PoseEnabledControllerType {
  83385. /**
  83386. * HTC Vive
  83387. */
  83388. VIVE = 0,
  83389. /**
  83390. * Oculus Rift
  83391. */
  83392. OCULUS = 1,
  83393. /**
  83394. * Windows mixed reality
  83395. */
  83396. WINDOWS = 2,
  83397. /**
  83398. * Samsung gear VR
  83399. */
  83400. GEAR_VR = 3,
  83401. /**
  83402. * Google Daydream
  83403. */
  83404. DAYDREAM = 4,
  83405. /**
  83406. * Generic
  83407. */
  83408. GENERIC = 5
  83409. }
  83410. /**
  83411. * Defines the MutableGamepadButton interface for the state of a gamepad button
  83412. */
  83413. export interface MutableGamepadButton {
  83414. /**
  83415. * Value of the button/trigger
  83416. */
  83417. value: number;
  83418. /**
  83419. * If the button/trigger is currently touched
  83420. */
  83421. touched: boolean;
  83422. /**
  83423. * If the button/trigger is currently pressed
  83424. */
  83425. pressed: boolean;
  83426. }
  83427. /**
  83428. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  83429. * @hidden
  83430. */
  83431. export interface ExtendedGamepadButton extends GamepadButton {
  83432. /**
  83433. * If the button/trigger is currently pressed
  83434. */
  83435. readonly pressed: boolean;
  83436. /**
  83437. * If the button/trigger is currently touched
  83438. */
  83439. readonly touched: boolean;
  83440. /**
  83441. * Value of the button/trigger
  83442. */
  83443. readonly value: number;
  83444. }
  83445. /** @hidden */
  83446. export interface _GamePadFactory {
  83447. /**
  83448. * Returns wether or not the current gamepad can be created for this type of controller.
  83449. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83450. * @returns true if it can be created, otherwise false
  83451. */
  83452. canCreate(gamepadInfo: any): boolean;
  83453. /**
  83454. * Creates a new instance of the Gamepad.
  83455. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83456. * @returns the new gamepad instance
  83457. */
  83458. create(gamepadInfo: any): Gamepad;
  83459. }
  83460. /**
  83461. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83462. */
  83463. export class PoseEnabledControllerHelper {
  83464. /** @hidden */
  83465. static _ControllerFactories: _GamePadFactory[];
  83466. /** @hidden */
  83467. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  83468. /**
  83469. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83470. * @param vrGamepad the gamepad to initialized
  83471. * @returns a vr controller of the type the gamepad identified as
  83472. */
  83473. static InitiateController(vrGamepad: any): Gamepad;
  83474. }
  83475. /**
  83476. * Defines the PoseEnabledController object that contains state of a vr capable controller
  83477. */
  83478. export class PoseEnabledController extends Gamepad implements PoseControlled {
  83479. /**
  83480. * If the controller is used in a webXR session
  83481. */
  83482. isXR: boolean;
  83483. private _deviceRoomPosition;
  83484. private _deviceRoomRotationQuaternion;
  83485. /**
  83486. * The device position in babylon space
  83487. */
  83488. devicePosition: Vector3;
  83489. /**
  83490. * The device rotation in babylon space
  83491. */
  83492. deviceRotationQuaternion: Quaternion;
  83493. /**
  83494. * The scale factor of the device in babylon space
  83495. */
  83496. deviceScaleFactor: number;
  83497. /**
  83498. * (Likely devicePosition should be used instead) The device position in its room space
  83499. */
  83500. position: Vector3;
  83501. /**
  83502. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  83503. */
  83504. rotationQuaternion: Quaternion;
  83505. /**
  83506. * The type of controller (Eg. Windows mixed reality)
  83507. */
  83508. controllerType: PoseEnabledControllerType;
  83509. protected _calculatedPosition: Vector3;
  83510. private _calculatedRotation;
  83511. /**
  83512. * The raw pose from the device
  83513. */
  83514. rawPose: DevicePose;
  83515. private _trackPosition;
  83516. private _maxRotationDistFromHeadset;
  83517. private _draggedRoomRotation;
  83518. /**
  83519. * @hidden
  83520. */
  83521. _disableTrackPosition(fixedPosition: Vector3): void;
  83522. /**
  83523. * Internal, the mesh attached to the controller
  83524. * @hidden
  83525. */
  83526. _mesh: Nullable<AbstractMesh>;
  83527. private _poseControlledCamera;
  83528. private _leftHandSystemQuaternion;
  83529. /**
  83530. * Internal, matrix used to convert room space to babylon space
  83531. * @hidden
  83532. */
  83533. _deviceToWorld: Matrix;
  83534. /**
  83535. * Node to be used when casting a ray from the controller
  83536. * @hidden
  83537. */
  83538. _pointingPoseNode: Nullable<TransformNode>;
  83539. /**
  83540. * Name of the child mesh that can be used to cast a ray from the controller
  83541. */
  83542. static readonly POINTING_POSE: string;
  83543. /**
  83544. * Creates a new PoseEnabledController from a gamepad
  83545. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  83546. */
  83547. constructor(browserGamepad: any);
  83548. private _workingMatrix;
  83549. /**
  83550. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  83551. */
  83552. update(): void;
  83553. /**
  83554. * Updates only the pose device and mesh without doing any button event checking
  83555. */
  83556. protected _updatePoseAndMesh(): void;
  83557. /**
  83558. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  83559. * @param poseData raw pose fromthe device
  83560. */
  83561. updateFromDevice(poseData: DevicePose): void;
  83562. /**
  83563. * @hidden
  83564. */
  83565. _meshAttachedObservable: Observable<AbstractMesh>;
  83566. /**
  83567. * Attaches a mesh to the controller
  83568. * @param mesh the mesh to be attached
  83569. */
  83570. attachToMesh(mesh: AbstractMesh): void;
  83571. /**
  83572. * Attaches the controllers mesh to a camera
  83573. * @param camera the camera the mesh should be attached to
  83574. */
  83575. attachToPoseControlledCamera(camera: TargetCamera): void;
  83576. /**
  83577. * Disposes of the controller
  83578. */
  83579. dispose(): void;
  83580. /**
  83581. * The mesh that is attached to the controller
  83582. */
  83583. readonly mesh: Nullable<AbstractMesh>;
  83584. /**
  83585. * Gets the ray of the controller in the direction the controller is pointing
  83586. * @param length the length the resulting ray should be
  83587. * @returns a ray in the direction the controller is pointing
  83588. */
  83589. getForwardRay(length?: number): Ray;
  83590. }
  83591. }
  83592. declare module BABYLON {
  83593. /**
  83594. * Defines the WebVRController object that represents controllers tracked in 3D space
  83595. */
  83596. export abstract class WebVRController extends PoseEnabledController {
  83597. /**
  83598. * Internal, the default controller model for the controller
  83599. */
  83600. protected _defaultModel: Nullable<AbstractMesh>;
  83601. /**
  83602. * Fired when the trigger state has changed
  83603. */
  83604. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  83605. /**
  83606. * Fired when the main button state has changed
  83607. */
  83608. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83609. /**
  83610. * Fired when the secondary button state has changed
  83611. */
  83612. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83613. /**
  83614. * Fired when the pad state has changed
  83615. */
  83616. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  83617. /**
  83618. * Fired when controllers stick values have changed
  83619. */
  83620. onPadValuesChangedObservable: Observable<StickValues>;
  83621. /**
  83622. * Array of button availible on the controller
  83623. */
  83624. protected _buttons: Array<MutableGamepadButton>;
  83625. private _onButtonStateChange;
  83626. /**
  83627. * Fired when a controller button's state has changed
  83628. * @param callback the callback containing the button that was modified
  83629. */
  83630. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  83631. /**
  83632. * X and Y axis corresponding to the controllers joystick
  83633. */
  83634. pad: StickValues;
  83635. /**
  83636. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  83637. */
  83638. hand: string;
  83639. /**
  83640. * The default controller model for the controller
  83641. */
  83642. readonly defaultModel: Nullable<AbstractMesh>;
  83643. /**
  83644. * Creates a new WebVRController from a gamepad
  83645. * @param vrGamepad the gamepad that the WebVRController should be created from
  83646. */
  83647. constructor(vrGamepad: any);
  83648. /**
  83649. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  83650. */
  83651. update(): void;
  83652. /**
  83653. * Function to be called when a button is modified
  83654. */
  83655. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  83656. /**
  83657. * Loads a mesh and attaches it to the controller
  83658. * @param scene the scene the mesh should be added to
  83659. * @param meshLoaded callback for when the mesh has been loaded
  83660. */
  83661. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  83662. private _setButtonValue;
  83663. private _changes;
  83664. private _checkChanges;
  83665. /**
  83666. * Disposes of th webVRCOntroller
  83667. */
  83668. dispose(): void;
  83669. }
  83670. }
  83671. declare module BABYLON {
  83672. /**
  83673. * The HemisphericLight simulates the ambient environment light,
  83674. * so the passed direction is the light reflection direction, not the incoming direction.
  83675. */
  83676. export class HemisphericLight extends Light {
  83677. /**
  83678. * The groundColor is the light in the opposite direction to the one specified during creation.
  83679. * 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.
  83680. */
  83681. groundColor: Color3;
  83682. /**
  83683. * The light reflection direction, not the incoming direction.
  83684. */
  83685. direction: Vector3;
  83686. /**
  83687. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  83688. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  83689. * The HemisphericLight can't cast shadows.
  83690. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83691. * @param name The friendly name of the light
  83692. * @param direction The direction of the light reflection
  83693. * @param scene The scene the light belongs to
  83694. */
  83695. constructor(name: string, direction: Vector3, scene: Scene);
  83696. protected _buildUniformLayout(): void;
  83697. /**
  83698. * Returns the string "HemisphericLight".
  83699. * @return The class name
  83700. */
  83701. getClassName(): string;
  83702. /**
  83703. * Sets the HemisphericLight direction towards the passed target (Vector3).
  83704. * Returns the updated direction.
  83705. * @param target The target the direction should point to
  83706. * @return The computed direction
  83707. */
  83708. setDirectionToTarget(target: Vector3): Vector3;
  83709. /**
  83710. * Returns the shadow generator associated to the light.
  83711. * @returns Always null for hemispheric lights because it does not support shadows.
  83712. */
  83713. getShadowGenerator(): Nullable<IShadowGenerator>;
  83714. /**
  83715. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  83716. * @param effect The effect to update
  83717. * @param lightIndex The index of the light in the effect to update
  83718. * @returns The hemispheric light
  83719. */
  83720. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  83721. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  83722. /**
  83723. * Computes the world matrix of the node
  83724. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83725. * @param useWasUpdatedFlag defines a reserved property
  83726. * @returns the world matrix
  83727. */
  83728. computeWorldMatrix(): Matrix;
  83729. /**
  83730. * Returns the integer 3.
  83731. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83732. */
  83733. getTypeID(): number;
  83734. /**
  83735. * Prepares the list of defines specific to the light type.
  83736. * @param defines the list of defines
  83737. * @param lightIndex defines the index of the light for the effect
  83738. */
  83739. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83740. }
  83741. }
  83742. declare module BABYLON {
  83743. /** @hidden */
  83744. export var vrMultiviewToSingleviewPixelShader: {
  83745. name: string;
  83746. shader: string;
  83747. };
  83748. }
  83749. declare module BABYLON {
  83750. /**
  83751. * Renders to multiple views with a single draw call
  83752. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  83753. */
  83754. export class MultiviewRenderTarget extends RenderTargetTexture {
  83755. /**
  83756. * Creates a multiview render target
  83757. * @param scene scene used with the render target
  83758. * @param size the size of the render target (used for each view)
  83759. */
  83760. constructor(scene: Scene, size?: number | {
  83761. width: number;
  83762. height: number;
  83763. } | {
  83764. ratio: number;
  83765. });
  83766. /**
  83767. * @hidden
  83768. * @param faceIndex the face index, if its a cube texture
  83769. */
  83770. _bindFrameBuffer(faceIndex?: number): void;
  83771. /**
  83772. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83773. * @returns the view count
  83774. */
  83775. getViewCount(): number;
  83776. }
  83777. }
  83778. declare module BABYLON {
  83779. /**
  83780. * Represents a camera frustum
  83781. */
  83782. export class Frustum {
  83783. /**
  83784. * Gets the planes representing the frustum
  83785. * @param transform matrix to be applied to the returned planes
  83786. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  83787. */
  83788. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  83789. /**
  83790. * Gets the near frustum plane transformed by the transform matrix
  83791. * @param transform transformation matrix to be applied to the resulting frustum plane
  83792. * @param frustumPlane the resuling frustum plane
  83793. */
  83794. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83795. /**
  83796. * Gets the far frustum plane transformed by the transform matrix
  83797. * @param transform transformation matrix to be applied to the resulting frustum plane
  83798. * @param frustumPlane the resuling frustum plane
  83799. */
  83800. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83801. /**
  83802. * Gets the left frustum plane transformed by the transform matrix
  83803. * @param transform transformation matrix to be applied to the resulting frustum plane
  83804. * @param frustumPlane the resuling frustum plane
  83805. */
  83806. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83807. /**
  83808. * Gets the right frustum plane transformed by the transform matrix
  83809. * @param transform transformation matrix to be applied to the resulting frustum plane
  83810. * @param frustumPlane the resuling frustum plane
  83811. */
  83812. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83813. /**
  83814. * Gets the top frustum plane transformed by the transform matrix
  83815. * @param transform transformation matrix to be applied to the resulting frustum plane
  83816. * @param frustumPlane the resuling frustum plane
  83817. */
  83818. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83819. /**
  83820. * Gets the bottom frustum plane transformed by the transform matrix
  83821. * @param transform transformation matrix to be applied to the resulting frustum plane
  83822. * @param frustumPlane the resuling frustum plane
  83823. */
  83824. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83825. /**
  83826. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  83827. * @param transform transformation matrix to be applied to the resulting frustum planes
  83828. * @param frustumPlanes the resuling frustum planes
  83829. */
  83830. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  83831. }
  83832. }
  83833. declare module BABYLON {
  83834. interface Engine {
  83835. /**
  83836. * Creates a new multiview render target
  83837. * @param width defines the width of the texture
  83838. * @param height defines the height of the texture
  83839. * @returns the created multiview texture
  83840. */
  83841. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  83842. /**
  83843. * Binds a multiview framebuffer to be drawn to
  83844. * @param multiviewTexture texture to bind
  83845. */
  83846. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83847. }
  83848. interface Camera {
  83849. /**
  83850. * @hidden
  83851. * 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)
  83852. */
  83853. _useMultiviewToSingleView: boolean;
  83854. /**
  83855. * @hidden
  83856. * 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)
  83857. */
  83858. _multiviewTexture: Nullable<RenderTargetTexture>;
  83859. /**
  83860. * @hidden
  83861. * ensures the multiview texture of the camera exists and has the specified width/height
  83862. * @param width height to set on the multiview texture
  83863. * @param height width to set on the multiview texture
  83864. */
  83865. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83866. }
  83867. interface Scene {
  83868. /** @hidden */
  83869. _transformMatrixR: Matrix;
  83870. /** @hidden */
  83871. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83872. /** @hidden */
  83873. _createMultiviewUbo(): void;
  83874. /** @hidden */
  83875. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83876. /** @hidden */
  83877. _renderMultiviewToSingleView(camera: Camera): void;
  83878. }
  83879. }
  83880. declare module BABYLON {
  83881. /**
  83882. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83883. * This will not be used for webXR as it supports displaying texture arrays directly
  83884. */
  83885. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83886. /**
  83887. * Initializes a VRMultiviewToSingleview
  83888. * @param name name of the post process
  83889. * @param camera camera to be applied to
  83890. * @param scaleFactor scaling factor to the size of the output texture
  83891. */
  83892. constructor(name: string, camera: Camera, scaleFactor: number);
  83893. }
  83894. }
  83895. declare module BABYLON {
  83896. /**
  83897. * Interface used to define additional presentation attributes
  83898. */
  83899. export interface IVRPresentationAttributes {
  83900. /**
  83901. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83902. */
  83903. highRefreshRate: boolean;
  83904. /**
  83905. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83906. */
  83907. foveationLevel: number;
  83908. }
  83909. interface Engine {
  83910. /** @hidden */
  83911. _vrDisplay: any;
  83912. /** @hidden */
  83913. _vrSupported: boolean;
  83914. /** @hidden */
  83915. _oldSize: Size;
  83916. /** @hidden */
  83917. _oldHardwareScaleFactor: number;
  83918. /** @hidden */
  83919. _vrExclusivePointerMode: boolean;
  83920. /** @hidden */
  83921. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83922. /** @hidden */
  83923. _onVRDisplayPointerRestricted: () => void;
  83924. /** @hidden */
  83925. _onVRDisplayPointerUnrestricted: () => void;
  83926. /** @hidden */
  83927. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83928. /** @hidden */
  83929. _onVrDisplayDisconnect: Nullable<() => void>;
  83930. /** @hidden */
  83931. _onVrDisplayPresentChange: Nullable<() => void>;
  83932. /**
  83933. * Observable signaled when VR display mode changes
  83934. */
  83935. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83936. /**
  83937. * Observable signaled when VR request present is complete
  83938. */
  83939. onVRRequestPresentComplete: Observable<boolean>;
  83940. /**
  83941. * Observable signaled when VR request present starts
  83942. */
  83943. onVRRequestPresentStart: Observable<Engine>;
  83944. /**
  83945. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83946. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83947. */
  83948. isInVRExclusivePointerMode: boolean;
  83949. /**
  83950. * Gets a boolean indicating if a webVR device was detected
  83951. * @returns true if a webVR device was detected
  83952. */
  83953. isVRDevicePresent(): boolean;
  83954. /**
  83955. * Gets the current webVR device
  83956. * @returns the current webVR device (or null)
  83957. */
  83958. getVRDevice(): any;
  83959. /**
  83960. * Initializes a webVR display and starts listening to display change events
  83961. * The onVRDisplayChangedObservable will be notified upon these changes
  83962. * @returns A promise containing a VRDisplay and if vr is supported
  83963. */
  83964. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83965. /** @hidden */
  83966. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83967. /**
  83968. * Gets or sets the presentation attributes used to configure VR rendering
  83969. */
  83970. vrPresentationAttributes?: IVRPresentationAttributes;
  83971. /**
  83972. * Call this function to switch to webVR mode
  83973. * Will do nothing if webVR is not supported or if there is no webVR device
  83974. * @param options the webvr options provided to the camera. mainly used for multiview
  83975. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83976. */
  83977. enableVR(options: WebVROptions): void;
  83978. /** @hidden */
  83979. _onVRFullScreenTriggered(): void;
  83980. }
  83981. }
  83982. declare module BABYLON {
  83983. /**
  83984. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83985. * IMPORTANT!! The data is right-hand data.
  83986. * @export
  83987. * @interface DevicePose
  83988. */
  83989. export interface DevicePose {
  83990. /**
  83991. * The position of the device, values in array are [x,y,z].
  83992. */
  83993. readonly position: Nullable<Float32Array>;
  83994. /**
  83995. * The linearVelocity of the device, values in array are [x,y,z].
  83996. */
  83997. readonly linearVelocity: Nullable<Float32Array>;
  83998. /**
  83999. * The linearAcceleration of the device, values in array are [x,y,z].
  84000. */
  84001. readonly linearAcceleration: Nullable<Float32Array>;
  84002. /**
  84003. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  84004. */
  84005. readonly orientation: Nullable<Float32Array>;
  84006. /**
  84007. * The angularVelocity of the device, values in array are [x,y,z].
  84008. */
  84009. readonly angularVelocity: Nullable<Float32Array>;
  84010. /**
  84011. * The angularAcceleration of the device, values in array are [x,y,z].
  84012. */
  84013. readonly angularAcceleration: Nullable<Float32Array>;
  84014. }
  84015. /**
  84016. * Interface representing a pose controlled object in Babylon.
  84017. * A pose controlled object has both regular pose values as well as pose values
  84018. * from an external device such as a VR head mounted display
  84019. */
  84020. export interface PoseControlled {
  84021. /**
  84022. * The position of the object in babylon space.
  84023. */
  84024. position: Vector3;
  84025. /**
  84026. * The rotation quaternion of the object in babylon space.
  84027. */
  84028. rotationQuaternion: Quaternion;
  84029. /**
  84030. * The position of the device in babylon space.
  84031. */
  84032. devicePosition?: Vector3;
  84033. /**
  84034. * The rotation quaternion of the device in babylon space.
  84035. */
  84036. deviceRotationQuaternion: Quaternion;
  84037. /**
  84038. * The raw pose coming from the device.
  84039. */
  84040. rawPose: Nullable<DevicePose>;
  84041. /**
  84042. * The scale of the device to be used when translating from device space to babylon space.
  84043. */
  84044. deviceScaleFactor: number;
  84045. /**
  84046. * Updates the poseControlled values based on the input device pose.
  84047. * @param poseData the pose data to update the object with
  84048. */
  84049. updateFromDevice(poseData: DevicePose): void;
  84050. }
  84051. /**
  84052. * Set of options to customize the webVRCamera
  84053. */
  84054. export interface WebVROptions {
  84055. /**
  84056. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  84057. */
  84058. trackPosition?: boolean;
  84059. /**
  84060. * Sets the scale of the vrDevice in babylon space. (default: 1)
  84061. */
  84062. positionScale?: number;
  84063. /**
  84064. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  84065. */
  84066. displayName?: string;
  84067. /**
  84068. * Should the native controller meshes be initialized. (default: true)
  84069. */
  84070. controllerMeshes?: boolean;
  84071. /**
  84072. * Creating a default HemiLight only on controllers. (default: true)
  84073. */
  84074. defaultLightingOnControllers?: boolean;
  84075. /**
  84076. * If you don't want to use the default VR button of the helper. (default: false)
  84077. */
  84078. useCustomVRButton?: boolean;
  84079. /**
  84080. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  84081. */
  84082. customVRButton?: HTMLButtonElement;
  84083. /**
  84084. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  84085. */
  84086. rayLength?: number;
  84087. /**
  84088. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  84089. */
  84090. defaultHeight?: number;
  84091. /**
  84092. * If multiview should be used if availible (default: false)
  84093. */
  84094. useMultiview?: boolean;
  84095. }
  84096. /**
  84097. * This represents a WebVR camera.
  84098. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  84099. * @example http://doc.babylonjs.com/how_to/webvr_camera
  84100. */
  84101. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  84102. private webVROptions;
  84103. /**
  84104. * @hidden
  84105. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  84106. */
  84107. _vrDevice: any;
  84108. /**
  84109. * The rawPose of the vrDevice.
  84110. */
  84111. rawPose: Nullable<DevicePose>;
  84112. private _onVREnabled;
  84113. private _specsVersion;
  84114. private _attached;
  84115. private _frameData;
  84116. protected _descendants: Array<Node>;
  84117. private _deviceRoomPosition;
  84118. /** @hidden */
  84119. _deviceRoomRotationQuaternion: Quaternion;
  84120. private _standingMatrix;
  84121. /**
  84122. * Represents device position in babylon space.
  84123. */
  84124. devicePosition: Vector3;
  84125. /**
  84126. * Represents device rotation in babylon space.
  84127. */
  84128. deviceRotationQuaternion: Quaternion;
  84129. /**
  84130. * The scale of the device to be used when translating from device space to babylon space.
  84131. */
  84132. deviceScaleFactor: number;
  84133. private _deviceToWorld;
  84134. private _worldToDevice;
  84135. /**
  84136. * References to the webVR controllers for the vrDevice.
  84137. */
  84138. controllers: Array<WebVRController>;
  84139. /**
  84140. * Emits an event when a controller is attached.
  84141. */
  84142. onControllersAttachedObservable: Observable<WebVRController[]>;
  84143. /**
  84144. * Emits an event when a controller's mesh has been loaded;
  84145. */
  84146. onControllerMeshLoadedObservable: Observable<WebVRController>;
  84147. /**
  84148. * Emits an event when the HMD's pose has been updated.
  84149. */
  84150. onPoseUpdatedFromDeviceObservable: Observable<any>;
  84151. private _poseSet;
  84152. /**
  84153. * If the rig cameras be used as parent instead of this camera.
  84154. */
  84155. rigParenting: boolean;
  84156. private _lightOnControllers;
  84157. private _defaultHeight?;
  84158. /**
  84159. * Instantiates a WebVRFreeCamera.
  84160. * @param name The name of the WebVRFreeCamera
  84161. * @param position The starting anchor position for the camera
  84162. * @param scene The scene the camera belongs to
  84163. * @param webVROptions a set of customizable options for the webVRCamera
  84164. */
  84165. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  84166. /**
  84167. * Gets the device distance from the ground in meters.
  84168. * @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.
  84169. */
  84170. deviceDistanceToRoomGround(): number;
  84171. /**
  84172. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84173. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  84174. */
  84175. useStandingMatrix(callback?: (bool: boolean) => void): void;
  84176. /**
  84177. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84178. * @returns A promise with a boolean set to if the standing matrix is supported.
  84179. */
  84180. useStandingMatrixAsync(): Promise<boolean>;
  84181. /**
  84182. * Disposes the camera
  84183. */
  84184. dispose(): void;
  84185. /**
  84186. * Gets a vrController by name.
  84187. * @param name The name of the controller to retreive
  84188. * @returns the controller matching the name specified or null if not found
  84189. */
  84190. getControllerByName(name: string): Nullable<WebVRController>;
  84191. private _leftController;
  84192. /**
  84193. * The controller corresponding to the users left hand.
  84194. */
  84195. readonly leftController: Nullable<WebVRController>;
  84196. private _rightController;
  84197. /**
  84198. * The controller corresponding to the users right hand.
  84199. */
  84200. readonly rightController: Nullable<WebVRController>;
  84201. /**
  84202. * Casts a ray forward from the vrCamera's gaze.
  84203. * @param length Length of the ray (default: 100)
  84204. * @returns the ray corresponding to the gaze
  84205. */
  84206. getForwardRay(length?: number): Ray;
  84207. /**
  84208. * @hidden
  84209. * Updates the camera based on device's frame data
  84210. */
  84211. _checkInputs(): void;
  84212. /**
  84213. * Updates the poseControlled values based on the input device pose.
  84214. * @param poseData Pose coming from the device
  84215. */
  84216. updateFromDevice(poseData: DevicePose): void;
  84217. private _htmlElementAttached;
  84218. private _detachIfAttached;
  84219. /**
  84220. * WebVR's attach control will start broadcasting frames to the device.
  84221. * Note that in certain browsers (chrome for example) this function must be called
  84222. * within a user-interaction callback. Example:
  84223. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  84224. *
  84225. * @param element html element to attach the vrDevice to
  84226. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  84227. */
  84228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84229. /**
  84230. * Detaches the camera from the html element and disables VR
  84231. *
  84232. * @param element html element to detach from
  84233. */
  84234. detachControl(element: HTMLElement): void;
  84235. /**
  84236. * @returns the name of this class
  84237. */
  84238. getClassName(): string;
  84239. /**
  84240. * Calls resetPose on the vrDisplay
  84241. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  84242. */
  84243. resetToCurrentRotation(): void;
  84244. /**
  84245. * @hidden
  84246. * Updates the rig cameras (left and right eye)
  84247. */
  84248. _updateRigCameras(): void;
  84249. private _workingVector;
  84250. private _oneVector;
  84251. private _workingMatrix;
  84252. private updateCacheCalled;
  84253. private _correctPositionIfNotTrackPosition;
  84254. /**
  84255. * @hidden
  84256. * Updates the cached values of the camera
  84257. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  84258. */
  84259. _updateCache(ignoreParentClass?: boolean): void;
  84260. /**
  84261. * @hidden
  84262. * Get current device position in babylon world
  84263. */
  84264. _computeDevicePosition(): void;
  84265. /**
  84266. * Updates the current device position and rotation in the babylon world
  84267. */
  84268. update(): void;
  84269. /**
  84270. * @hidden
  84271. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  84272. * @returns an identity matrix
  84273. */
  84274. _getViewMatrix(): Matrix;
  84275. private _tmpMatrix;
  84276. /**
  84277. * This function is called by the two RIG cameras.
  84278. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  84279. * @hidden
  84280. */
  84281. _getWebVRViewMatrix(): Matrix;
  84282. /** @hidden */
  84283. _getWebVRProjectionMatrix(): Matrix;
  84284. private _onGamepadConnectedObserver;
  84285. private _onGamepadDisconnectedObserver;
  84286. private _updateCacheWhenTrackingDisabledObserver;
  84287. /**
  84288. * Initializes the controllers and their meshes
  84289. */
  84290. initControllers(): void;
  84291. }
  84292. }
  84293. declare module BABYLON {
  84294. /**
  84295. * Size options for a post process
  84296. */
  84297. export type PostProcessOptions = {
  84298. width: number;
  84299. height: number;
  84300. };
  84301. /**
  84302. * PostProcess can be used to apply a shader to a texture after it has been rendered
  84303. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84304. */
  84305. export class PostProcess {
  84306. /** Name of the PostProcess. */
  84307. name: string;
  84308. /**
  84309. * Gets or sets the unique id of the post process
  84310. */
  84311. uniqueId: number;
  84312. /**
  84313. * Width of the texture to apply the post process on
  84314. */
  84315. width: number;
  84316. /**
  84317. * Height of the texture to apply the post process on
  84318. */
  84319. height: number;
  84320. /**
  84321. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  84322. * @hidden
  84323. */
  84324. _outputTexture: Nullable<InternalTexture>;
  84325. /**
  84326. * Sampling mode used by the shader
  84327. * See https://doc.babylonjs.com/classes/3.1/texture
  84328. */
  84329. renderTargetSamplingMode: number;
  84330. /**
  84331. * Clear color to use when screen clearing
  84332. */
  84333. clearColor: Color4;
  84334. /**
  84335. * If the buffer needs to be cleared before applying the post process. (default: true)
  84336. * Should be set to false if shader will overwrite all previous pixels.
  84337. */
  84338. autoClear: boolean;
  84339. /**
  84340. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  84341. */
  84342. alphaMode: number;
  84343. /**
  84344. * Sets the setAlphaBlendConstants of the babylon engine
  84345. */
  84346. alphaConstants: Color4;
  84347. /**
  84348. * Animations to be used for the post processing
  84349. */
  84350. animations: Animation[];
  84351. /**
  84352. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  84353. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  84354. */
  84355. enablePixelPerfectMode: boolean;
  84356. /**
  84357. * Force the postprocess to be applied without taking in account viewport
  84358. */
  84359. forceFullscreenViewport: boolean;
  84360. /**
  84361. * List of inspectable custom properties (used by the Inspector)
  84362. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84363. */
  84364. inspectableCustomProperties: IInspectable[];
  84365. /**
  84366. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  84367. *
  84368. * | Value | Type | Description |
  84369. * | ----- | ----------------------------------- | ----------- |
  84370. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  84371. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  84372. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  84373. *
  84374. */
  84375. scaleMode: number;
  84376. /**
  84377. * Force textures to be a power of two (default: false)
  84378. */
  84379. alwaysForcePOT: boolean;
  84380. private _samples;
  84381. /**
  84382. * Number of sample textures (default: 1)
  84383. */
  84384. samples: number;
  84385. /**
  84386. * Modify the scale of the post process to be the same as the viewport (default: false)
  84387. */
  84388. adaptScaleToCurrentViewport: boolean;
  84389. private _camera;
  84390. private _scene;
  84391. private _engine;
  84392. private _options;
  84393. private _reusable;
  84394. private _textureType;
  84395. /**
  84396. * Smart array of input and output textures for the post process.
  84397. * @hidden
  84398. */
  84399. _textures: SmartArray<InternalTexture>;
  84400. /**
  84401. * The index in _textures that corresponds to the output texture.
  84402. * @hidden
  84403. */
  84404. _currentRenderTextureInd: number;
  84405. private _effect;
  84406. private _samplers;
  84407. private _fragmentUrl;
  84408. private _vertexUrl;
  84409. private _parameters;
  84410. private _scaleRatio;
  84411. protected _indexParameters: any;
  84412. private _shareOutputWithPostProcess;
  84413. private _texelSize;
  84414. private _forcedOutputTexture;
  84415. /**
  84416. * Returns the fragment url or shader name used in the post process.
  84417. * @returns the fragment url or name in the shader store.
  84418. */
  84419. getEffectName(): string;
  84420. /**
  84421. * An event triggered when the postprocess is activated.
  84422. */
  84423. onActivateObservable: Observable<Camera>;
  84424. private _onActivateObserver;
  84425. /**
  84426. * A function that is added to the onActivateObservable
  84427. */
  84428. onActivate: Nullable<(camera: Camera) => void>;
  84429. /**
  84430. * An event triggered when the postprocess changes its size.
  84431. */
  84432. onSizeChangedObservable: Observable<PostProcess>;
  84433. private _onSizeChangedObserver;
  84434. /**
  84435. * A function that is added to the onSizeChangedObservable
  84436. */
  84437. onSizeChanged: (postProcess: PostProcess) => void;
  84438. /**
  84439. * An event triggered when the postprocess applies its effect.
  84440. */
  84441. onApplyObservable: Observable<Effect>;
  84442. private _onApplyObserver;
  84443. /**
  84444. * A function that is added to the onApplyObservable
  84445. */
  84446. onApply: (effect: Effect) => void;
  84447. /**
  84448. * An event triggered before rendering the postprocess
  84449. */
  84450. onBeforeRenderObservable: Observable<Effect>;
  84451. private _onBeforeRenderObserver;
  84452. /**
  84453. * A function that is added to the onBeforeRenderObservable
  84454. */
  84455. onBeforeRender: (effect: Effect) => void;
  84456. /**
  84457. * An event triggered after rendering the postprocess
  84458. */
  84459. onAfterRenderObservable: Observable<Effect>;
  84460. private _onAfterRenderObserver;
  84461. /**
  84462. * A function that is added to the onAfterRenderObservable
  84463. */
  84464. onAfterRender: (efect: Effect) => void;
  84465. /**
  84466. * 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
  84467. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  84468. */
  84469. inputTexture: InternalTexture;
  84470. /**
  84471. * Gets the camera which post process is applied to.
  84472. * @returns The camera the post process is applied to.
  84473. */
  84474. getCamera(): Camera;
  84475. /**
  84476. * Gets the texel size of the postprocess.
  84477. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  84478. */
  84479. readonly texelSize: Vector2;
  84480. /**
  84481. * Creates a new instance PostProcess
  84482. * @param name The name of the PostProcess.
  84483. * @param fragmentUrl The url of the fragment shader to be used.
  84484. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  84485. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  84486. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84487. * @param camera The camera to apply the render pass to.
  84488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84489. * @param engine The engine which the post process will be applied. (default: current engine)
  84490. * @param reusable If the post process can be reused on the same frame. (default: false)
  84491. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  84492. * @param textureType Type of textures used when performing the post process. (default: 0)
  84493. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  84494. * @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
  84495. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  84496. */
  84497. constructor(
  84498. /** Name of the PostProcess. */
  84499. 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);
  84500. /**
  84501. * Gets a string idenfifying the name of the class
  84502. * @returns "PostProcess" string
  84503. */
  84504. getClassName(): string;
  84505. /**
  84506. * Gets the engine which this post process belongs to.
  84507. * @returns The engine the post process was enabled with.
  84508. */
  84509. getEngine(): Engine;
  84510. /**
  84511. * The effect that is created when initializing the post process.
  84512. * @returns The created effect corresponding the the postprocess.
  84513. */
  84514. getEffect(): Effect;
  84515. /**
  84516. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  84517. * @param postProcess The post process to share the output with.
  84518. * @returns This post process.
  84519. */
  84520. shareOutputWith(postProcess: PostProcess): PostProcess;
  84521. /**
  84522. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  84523. * This should be called if the post process that shares output with this post process is disabled/disposed.
  84524. */
  84525. useOwnOutput(): void;
  84526. /**
  84527. * Updates the effect with the current post process compile time values and recompiles the shader.
  84528. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84529. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84530. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84531. * @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
  84532. * @param onCompiled Called when the shader has been compiled.
  84533. * @param onError Called if there is an error when compiling a shader.
  84534. */
  84535. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84536. /**
  84537. * The post process is reusable if it can be used multiple times within one frame.
  84538. * @returns If the post process is reusable
  84539. */
  84540. isReusable(): boolean;
  84541. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  84542. markTextureDirty(): void;
  84543. /**
  84544. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  84545. * 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.
  84546. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  84547. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  84548. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  84549. * @returns The target texture that was bound to be written to.
  84550. */
  84551. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  84552. /**
  84553. * If the post process is supported.
  84554. */
  84555. readonly isSupported: boolean;
  84556. /**
  84557. * The aspect ratio of the output texture.
  84558. */
  84559. readonly aspectRatio: number;
  84560. /**
  84561. * Get a value indicating if the post-process is ready to be used
  84562. * @returns true if the post-process is ready (shader is compiled)
  84563. */
  84564. isReady(): boolean;
  84565. /**
  84566. * Binds all textures and uniforms to the shader, this will be run on every pass.
  84567. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  84568. */
  84569. apply(): Nullable<Effect>;
  84570. private _disposeTextures;
  84571. /**
  84572. * Disposes the post process.
  84573. * @param camera The camera to dispose the post process on.
  84574. */
  84575. dispose(camera?: Camera): void;
  84576. }
  84577. }
  84578. declare module BABYLON {
  84579. /** @hidden */
  84580. export var kernelBlurVaryingDeclaration: {
  84581. name: string;
  84582. shader: string;
  84583. };
  84584. }
  84585. declare module BABYLON {
  84586. /** @hidden */
  84587. export var kernelBlurFragment: {
  84588. name: string;
  84589. shader: string;
  84590. };
  84591. }
  84592. declare module BABYLON {
  84593. /** @hidden */
  84594. export var kernelBlurFragment2: {
  84595. name: string;
  84596. shader: string;
  84597. };
  84598. }
  84599. declare module BABYLON {
  84600. /** @hidden */
  84601. export var kernelBlurPixelShader: {
  84602. name: string;
  84603. shader: string;
  84604. };
  84605. }
  84606. declare module BABYLON {
  84607. /** @hidden */
  84608. export var kernelBlurVertex: {
  84609. name: string;
  84610. shader: string;
  84611. };
  84612. }
  84613. declare module BABYLON {
  84614. /** @hidden */
  84615. export var kernelBlurVertexShader: {
  84616. name: string;
  84617. shader: string;
  84618. };
  84619. }
  84620. declare module BABYLON {
  84621. /**
  84622. * The Blur Post Process which blurs an image based on a kernel and direction.
  84623. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  84624. */
  84625. export class BlurPostProcess extends PostProcess {
  84626. /** The direction in which to blur the image. */
  84627. direction: Vector2;
  84628. private blockCompilation;
  84629. protected _kernel: number;
  84630. protected _idealKernel: number;
  84631. protected _packedFloat: boolean;
  84632. private _staticDefines;
  84633. /**
  84634. * Sets the length in pixels of the blur sample region
  84635. */
  84636. /**
  84637. * Gets the length in pixels of the blur sample region
  84638. */
  84639. kernel: number;
  84640. /**
  84641. * Sets wether or not the blur needs to unpack/repack floats
  84642. */
  84643. /**
  84644. * Gets wether or not the blur is unpacking/repacking floats
  84645. */
  84646. packedFloat: boolean;
  84647. /**
  84648. * Creates a new instance BlurPostProcess
  84649. * @param name The name of the effect.
  84650. * @param direction The direction in which to blur the image.
  84651. * @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.
  84652. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84653. * @param camera The camera to apply the render pass to.
  84654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84655. * @param engine The engine which the post process will be applied. (default: current engine)
  84656. * @param reusable If the post process can be reused on the same frame. (default: false)
  84657. * @param textureType Type of textures used when performing the post process. (default: 0)
  84658. * @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)
  84659. */
  84660. constructor(name: string,
  84661. /** The direction in which to blur the image. */
  84662. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  84663. /**
  84664. * Updates the effect with the current post process compile time values and recompiles the shader.
  84665. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84666. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84667. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84668. * @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
  84669. * @param onCompiled Called when the shader has been compiled.
  84670. * @param onError Called if there is an error when compiling a shader.
  84671. */
  84672. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84673. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84674. /**
  84675. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  84676. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  84677. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  84678. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  84679. * The gaps between physical kernels are compensated for in the weighting of the samples
  84680. * @param idealKernel Ideal blur kernel.
  84681. * @return Nearest best kernel.
  84682. */
  84683. protected _nearestBestKernel(idealKernel: number): number;
  84684. /**
  84685. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  84686. * @param x The point on the Gaussian distribution to sample.
  84687. * @return the value of the Gaussian function at x.
  84688. */
  84689. protected _gaussianWeight(x: number): number;
  84690. /**
  84691. * Generates a string that can be used as a floating point number in GLSL.
  84692. * @param x Value to print.
  84693. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  84694. * @return GLSL float string.
  84695. */
  84696. protected _glslFloat(x: number, decimalFigures?: number): string;
  84697. }
  84698. }
  84699. declare module BABYLON {
  84700. /**
  84701. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84702. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84703. * You can then easily use it as a reflectionTexture on a flat surface.
  84704. * In case the surface is not a plane, please consider relying on reflection probes.
  84705. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84706. */
  84707. export class MirrorTexture extends RenderTargetTexture {
  84708. private scene;
  84709. /**
  84710. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  84711. * 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.
  84712. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84713. */
  84714. mirrorPlane: Plane;
  84715. /**
  84716. * Define the blur ratio used to blur the reflection if needed.
  84717. */
  84718. blurRatio: number;
  84719. /**
  84720. * Define the adaptive blur kernel used to blur the reflection if needed.
  84721. * This will autocompute the closest best match for the `blurKernel`
  84722. */
  84723. adaptiveBlurKernel: number;
  84724. /**
  84725. * Define the blur kernel used to blur the reflection if needed.
  84726. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84727. */
  84728. blurKernel: number;
  84729. /**
  84730. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  84731. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84732. */
  84733. blurKernelX: number;
  84734. /**
  84735. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  84736. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84737. */
  84738. blurKernelY: number;
  84739. private _autoComputeBlurKernel;
  84740. protected _onRatioRescale(): void;
  84741. private _updateGammaSpace;
  84742. private _imageProcessingConfigChangeObserver;
  84743. private _transformMatrix;
  84744. private _mirrorMatrix;
  84745. private _savedViewMatrix;
  84746. private _blurX;
  84747. private _blurY;
  84748. private _adaptiveBlurKernel;
  84749. private _blurKernelX;
  84750. private _blurKernelY;
  84751. private _blurRatio;
  84752. /**
  84753. * Instantiates a Mirror Texture.
  84754. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84755. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84756. * You can then easily use it as a reflectionTexture on a flat surface.
  84757. * In case the surface is not a plane, please consider relying on reflection probes.
  84758. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84759. * @param name
  84760. * @param size
  84761. * @param scene
  84762. * @param generateMipMaps
  84763. * @param type
  84764. * @param samplingMode
  84765. * @param generateDepthBuffer
  84766. */
  84767. constructor(name: string, size: number | {
  84768. width: number;
  84769. height: number;
  84770. } | {
  84771. ratio: number;
  84772. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  84773. private _preparePostProcesses;
  84774. /**
  84775. * Clone the mirror texture.
  84776. * @returns the cloned texture
  84777. */
  84778. clone(): MirrorTexture;
  84779. /**
  84780. * Serialize the texture to a JSON representation you could use in Parse later on
  84781. * @returns the serialized JSON representation
  84782. */
  84783. serialize(): any;
  84784. /**
  84785. * Dispose the texture and release its associated resources.
  84786. */
  84787. dispose(): void;
  84788. }
  84789. }
  84790. declare module BABYLON {
  84791. /**
  84792. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84793. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84794. */
  84795. export class Texture extends BaseTexture {
  84796. /**
  84797. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  84798. */
  84799. static SerializeBuffers: boolean;
  84800. /** @hidden */
  84801. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  84802. /** @hidden */
  84803. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  84804. /** @hidden */
  84805. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  84806. /** nearest is mag = nearest and min = nearest and mip = linear */
  84807. static readonly NEAREST_SAMPLINGMODE: number;
  84808. /** nearest is mag = nearest and min = nearest and mip = linear */
  84809. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  84810. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84811. static readonly BILINEAR_SAMPLINGMODE: number;
  84812. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84813. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  84814. /** Trilinear is mag = linear and min = linear and mip = linear */
  84815. static readonly TRILINEAR_SAMPLINGMODE: number;
  84816. /** Trilinear is mag = linear and min = linear and mip = linear */
  84817. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  84818. /** mag = nearest and min = nearest and mip = nearest */
  84819. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  84820. /** mag = nearest and min = linear and mip = nearest */
  84821. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  84822. /** mag = nearest and min = linear and mip = linear */
  84823. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  84824. /** mag = nearest and min = linear and mip = none */
  84825. static readonly NEAREST_LINEAR: number;
  84826. /** mag = nearest and min = nearest and mip = none */
  84827. static readonly NEAREST_NEAREST: number;
  84828. /** mag = linear and min = nearest and mip = nearest */
  84829. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  84830. /** mag = linear and min = nearest and mip = linear */
  84831. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  84832. /** mag = linear and min = linear and mip = none */
  84833. static readonly LINEAR_LINEAR: number;
  84834. /** mag = linear and min = nearest and mip = none */
  84835. static readonly LINEAR_NEAREST: number;
  84836. /** Explicit coordinates mode */
  84837. static readonly EXPLICIT_MODE: number;
  84838. /** Spherical coordinates mode */
  84839. static readonly SPHERICAL_MODE: number;
  84840. /** Planar coordinates mode */
  84841. static readonly PLANAR_MODE: number;
  84842. /** Cubic coordinates mode */
  84843. static readonly CUBIC_MODE: number;
  84844. /** Projection coordinates mode */
  84845. static readonly PROJECTION_MODE: number;
  84846. /** Inverse Cubic coordinates mode */
  84847. static readonly SKYBOX_MODE: number;
  84848. /** Inverse Cubic coordinates mode */
  84849. static readonly INVCUBIC_MODE: number;
  84850. /** Equirectangular coordinates mode */
  84851. static readonly EQUIRECTANGULAR_MODE: number;
  84852. /** Equirectangular Fixed coordinates mode */
  84853. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84854. /** Equirectangular Fixed Mirrored coordinates mode */
  84855. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84856. /** Texture is not repeating outside of 0..1 UVs */
  84857. static readonly CLAMP_ADDRESSMODE: number;
  84858. /** Texture is repeating outside of 0..1 UVs */
  84859. static readonly WRAP_ADDRESSMODE: number;
  84860. /** Texture is repeating and mirrored */
  84861. static readonly MIRROR_ADDRESSMODE: number;
  84862. /**
  84863. * 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
  84864. */
  84865. static UseSerializedUrlIfAny: boolean;
  84866. /**
  84867. * Define the url of the texture.
  84868. */
  84869. url: Nullable<string>;
  84870. /**
  84871. * Define an offset on the texture to offset the u coordinates of the UVs
  84872. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84873. */
  84874. uOffset: number;
  84875. /**
  84876. * Define an offset on the texture to offset the v coordinates of the UVs
  84877. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84878. */
  84879. vOffset: number;
  84880. /**
  84881. * Define an offset on the texture to scale the u coordinates of the UVs
  84882. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84883. */
  84884. uScale: number;
  84885. /**
  84886. * Define an offset on the texture to scale the v coordinates of the UVs
  84887. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84888. */
  84889. vScale: number;
  84890. /**
  84891. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84892. * @see http://doc.babylonjs.com/how_to/more_materials
  84893. */
  84894. uAng: number;
  84895. /**
  84896. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84897. * @see http://doc.babylonjs.com/how_to/more_materials
  84898. */
  84899. vAng: number;
  84900. /**
  84901. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84902. * @see http://doc.babylonjs.com/how_to/more_materials
  84903. */
  84904. wAng: number;
  84905. /**
  84906. * Defines the center of rotation (U)
  84907. */
  84908. uRotationCenter: number;
  84909. /**
  84910. * Defines the center of rotation (V)
  84911. */
  84912. vRotationCenter: number;
  84913. /**
  84914. * Defines the center of rotation (W)
  84915. */
  84916. wRotationCenter: number;
  84917. /**
  84918. * Are mip maps generated for this texture or not.
  84919. */
  84920. readonly noMipmap: boolean;
  84921. /**
  84922. * List of inspectable custom properties (used by the Inspector)
  84923. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84924. */
  84925. inspectableCustomProperties: Nullable<IInspectable[]>;
  84926. private _noMipmap;
  84927. /** @hidden */
  84928. _invertY: boolean;
  84929. private _rowGenerationMatrix;
  84930. private _cachedTextureMatrix;
  84931. private _projectionModeMatrix;
  84932. private _t0;
  84933. private _t1;
  84934. private _t2;
  84935. private _cachedUOffset;
  84936. private _cachedVOffset;
  84937. private _cachedUScale;
  84938. private _cachedVScale;
  84939. private _cachedUAng;
  84940. private _cachedVAng;
  84941. private _cachedWAng;
  84942. private _cachedProjectionMatrixId;
  84943. private _cachedCoordinatesMode;
  84944. /** @hidden */
  84945. protected _initialSamplingMode: number;
  84946. /** @hidden */
  84947. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84948. private _deleteBuffer;
  84949. protected _format: Nullable<number>;
  84950. private _delayedOnLoad;
  84951. private _delayedOnError;
  84952. private _mimeType?;
  84953. /**
  84954. * Observable triggered once the texture has been loaded.
  84955. */
  84956. onLoadObservable: Observable<Texture>;
  84957. protected _isBlocking: boolean;
  84958. /**
  84959. * Is the texture preventing material to render while loading.
  84960. * If false, a default texture will be used instead of the loading one during the preparation step.
  84961. */
  84962. isBlocking: boolean;
  84963. /**
  84964. * Get the current sampling mode associated with the texture.
  84965. */
  84966. readonly samplingMode: number;
  84967. /**
  84968. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84969. */
  84970. readonly invertY: boolean;
  84971. /**
  84972. * Instantiates a new texture.
  84973. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84974. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84975. * @param url defines the url of the picture to load as a texture
  84976. * @param scene defines the scene or engine the texture will belong to
  84977. * @param noMipmap defines if the texture will require mip maps or not
  84978. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84979. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84980. * @param onLoad defines a callback triggered when the texture has been loaded
  84981. * @param onError defines a callback triggered when an error occurred during the loading session
  84982. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84983. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84984. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84985. * @param mimeType defines an optional mime type information
  84986. */
  84987. 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);
  84988. /**
  84989. * Update the url (and optional buffer) of this texture if url was null during construction.
  84990. * @param url the url of the texture
  84991. * @param buffer the buffer of the texture (defaults to null)
  84992. * @param onLoad callback called when the texture is loaded (defaults to null)
  84993. */
  84994. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84995. /**
  84996. * Finish the loading sequence of a texture flagged as delayed load.
  84997. * @hidden
  84998. */
  84999. delayLoad(): void;
  85000. private _prepareRowForTextureGeneration;
  85001. /**
  85002. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  85003. * @returns the transform matrix of the texture.
  85004. */
  85005. getTextureMatrix(uBase?: number): Matrix;
  85006. /**
  85007. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  85008. * @returns The reflection texture transform
  85009. */
  85010. getReflectionTextureMatrix(): Matrix;
  85011. /**
  85012. * Clones the texture.
  85013. * @returns the cloned texture
  85014. */
  85015. clone(): Texture;
  85016. /**
  85017. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85018. * @returns The JSON representation of the texture
  85019. */
  85020. serialize(): any;
  85021. /**
  85022. * Get the current class name of the texture useful for serialization or dynamic coding.
  85023. * @returns "Texture"
  85024. */
  85025. getClassName(): string;
  85026. /**
  85027. * Dispose the texture and release its associated resources.
  85028. */
  85029. dispose(): void;
  85030. /**
  85031. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  85032. * @param parsedTexture Define the JSON representation of the texture
  85033. * @param scene Define the scene the parsed texture should be instantiated in
  85034. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  85035. * @returns The parsed texture if successful
  85036. */
  85037. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  85038. /**
  85039. * Creates a texture from its base 64 representation.
  85040. * @param data Define the base64 payload without the data: prefix
  85041. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85042. * @param scene Define the scene the texture should belong to
  85043. * @param noMipmap Forces the texture to not create mip map information if true
  85044. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85045. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85046. * @param onLoad define a callback triggered when the texture has been loaded
  85047. * @param onError define a callback triggered when an error occurred during the loading session
  85048. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85049. * @returns the created texture
  85050. */
  85051. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  85052. /**
  85053. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  85054. * @param data Define the base64 payload without the data: prefix
  85055. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85056. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  85057. * @param scene Define the scene the texture should belong to
  85058. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  85059. * @param noMipmap Forces the texture to not create mip map information if true
  85060. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85061. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85062. * @param onLoad define a callback triggered when the texture has been loaded
  85063. * @param onError define a callback triggered when an error occurred during the loading session
  85064. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85065. * @returns the created texture
  85066. */
  85067. 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;
  85068. }
  85069. }
  85070. declare module BABYLON {
  85071. /**
  85072. * PostProcessManager is used to manage one or more post processes or post process pipelines
  85073. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  85074. */
  85075. export class PostProcessManager {
  85076. private _scene;
  85077. private _indexBuffer;
  85078. private _vertexBuffers;
  85079. /**
  85080. * Creates a new instance PostProcess
  85081. * @param scene The scene that the post process is associated with.
  85082. */
  85083. constructor(scene: Scene);
  85084. private _prepareBuffers;
  85085. private _buildIndexBuffer;
  85086. /**
  85087. * Rebuilds the vertex buffers of the manager.
  85088. * @hidden
  85089. */
  85090. _rebuild(): void;
  85091. /**
  85092. * Prepares a frame to be run through a post process.
  85093. * @param sourceTexture The input texture to the post procesess. (default: null)
  85094. * @param postProcesses An array of post processes to be run. (default: null)
  85095. * @returns True if the post processes were able to be run.
  85096. * @hidden
  85097. */
  85098. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  85099. /**
  85100. * Manually render a set of post processes to a texture.
  85101. * @param postProcesses An array of post processes to be run.
  85102. * @param targetTexture The target texture to render to.
  85103. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  85104. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  85105. * @param lodLevel defines which lod of the texture to render to
  85106. */
  85107. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  85108. /**
  85109. * Finalize the result of the output of the postprocesses.
  85110. * @param doNotPresent If true the result will not be displayed to the screen.
  85111. * @param targetTexture The target texture to render to.
  85112. * @param faceIndex The index of the face to bind the target texture to.
  85113. * @param postProcesses The array of post processes to render.
  85114. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  85115. * @hidden
  85116. */
  85117. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  85118. /**
  85119. * Disposes of the post process manager.
  85120. */
  85121. dispose(): void;
  85122. }
  85123. }
  85124. declare module BABYLON {
  85125. /** Interface used by value gradients (color, factor, ...) */
  85126. export interface IValueGradient {
  85127. /**
  85128. * Gets or sets the gradient value (between 0 and 1)
  85129. */
  85130. gradient: number;
  85131. }
  85132. /** Class used to store color4 gradient */
  85133. export class ColorGradient implements IValueGradient {
  85134. /**
  85135. * Gets or sets the gradient value (between 0 and 1)
  85136. */
  85137. gradient: number;
  85138. /**
  85139. * Gets or sets first associated color
  85140. */
  85141. color1: Color4;
  85142. /**
  85143. * Gets or sets second associated color
  85144. */
  85145. color2?: Color4;
  85146. /**
  85147. * Will get a color picked randomly between color1 and color2.
  85148. * If color2 is undefined then color1 will be used
  85149. * @param result defines the target Color4 to store the result in
  85150. */
  85151. getColorToRef(result: Color4): void;
  85152. }
  85153. /** Class used to store color 3 gradient */
  85154. export class Color3Gradient implements IValueGradient {
  85155. /**
  85156. * Gets or sets the gradient value (between 0 and 1)
  85157. */
  85158. gradient: number;
  85159. /**
  85160. * Gets or sets the associated color
  85161. */
  85162. color: Color3;
  85163. }
  85164. /** Class used to store factor gradient */
  85165. export class FactorGradient implements IValueGradient {
  85166. /**
  85167. * Gets or sets the gradient value (between 0 and 1)
  85168. */
  85169. gradient: number;
  85170. /**
  85171. * Gets or sets first associated factor
  85172. */
  85173. factor1: number;
  85174. /**
  85175. * Gets or sets second associated factor
  85176. */
  85177. factor2?: number;
  85178. /**
  85179. * Will get a number picked randomly between factor1 and factor2.
  85180. * If factor2 is undefined then factor1 will be used
  85181. * @returns the picked number
  85182. */
  85183. getFactor(): number;
  85184. }
  85185. /**
  85186. * Helper used to simplify some generic gradient tasks
  85187. */
  85188. export class GradientHelper {
  85189. /**
  85190. * Gets the current gradient from an array of IValueGradient
  85191. * @param ratio defines the current ratio to get
  85192. * @param gradients defines the array of IValueGradient
  85193. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  85194. */
  85195. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  85196. }
  85197. }
  85198. declare module BABYLON {
  85199. interface ThinEngine {
  85200. /**
  85201. * Creates a dynamic texture
  85202. * @param width defines the width of the texture
  85203. * @param height defines the height of the texture
  85204. * @param generateMipMaps defines if the engine should generate the mip levels
  85205. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85206. * @returns the dynamic texture inside an InternalTexture
  85207. */
  85208. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85209. /**
  85210. * Update the content of a dynamic texture
  85211. * @param texture defines the texture to update
  85212. * @param canvas defines the canvas containing the source
  85213. * @param invertY defines if data must be stored with Y axis inverted
  85214. * @param premulAlpha defines if alpha is stored as premultiplied
  85215. * @param format defines the format of the data
  85216. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85217. */
  85218. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85219. }
  85220. }
  85221. declare module BABYLON {
  85222. /**
  85223. * Helper class used to generate a canvas to manipulate images
  85224. */
  85225. export class CanvasGenerator {
  85226. /**
  85227. * Create a new canvas (or offscreen canvas depending on the context)
  85228. * @param width defines the expected width
  85229. * @param height defines the expected height
  85230. * @return a new canvas or offscreen canvas
  85231. */
  85232. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  85233. }
  85234. }
  85235. declare module BABYLON {
  85236. /**
  85237. * A class extending Texture allowing drawing on a texture
  85238. * @see http://doc.babylonjs.com/how_to/dynamictexture
  85239. */
  85240. export class DynamicTexture extends Texture {
  85241. private _generateMipMaps;
  85242. private _canvas;
  85243. private _context;
  85244. private _engine;
  85245. /**
  85246. * Creates a DynamicTexture
  85247. * @param name defines the name of the texture
  85248. * @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
  85249. * @param scene defines the scene where you want the texture
  85250. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  85251. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  85252. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  85253. */
  85254. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  85255. /**
  85256. * Get the current class name of the texture useful for serialization or dynamic coding.
  85257. * @returns "DynamicTexture"
  85258. */
  85259. getClassName(): string;
  85260. /**
  85261. * Gets the current state of canRescale
  85262. */
  85263. readonly canRescale: boolean;
  85264. private _recreate;
  85265. /**
  85266. * Scales the texture
  85267. * @param ratio the scale factor to apply to both width and height
  85268. */
  85269. scale(ratio: number): void;
  85270. /**
  85271. * Resizes the texture
  85272. * @param width the new width
  85273. * @param height the new height
  85274. */
  85275. scaleTo(width: number, height: number): void;
  85276. /**
  85277. * Gets the context of the canvas used by the texture
  85278. * @returns the canvas context of the dynamic texture
  85279. */
  85280. getContext(): CanvasRenderingContext2D;
  85281. /**
  85282. * Clears the texture
  85283. */
  85284. clear(): void;
  85285. /**
  85286. * Updates the texture
  85287. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85288. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  85289. */
  85290. update(invertY?: boolean, premulAlpha?: boolean): void;
  85291. /**
  85292. * Draws text onto the texture
  85293. * @param text defines the text to be drawn
  85294. * @param x defines the placement of the text from the left
  85295. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  85296. * @param font defines the font to be used with font-style, font-size, font-name
  85297. * @param color defines the color used for the text
  85298. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  85299. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85300. * @param update defines whether texture is immediately update (default is true)
  85301. */
  85302. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  85303. /**
  85304. * Clones the texture
  85305. * @returns the clone of the texture.
  85306. */
  85307. clone(): DynamicTexture;
  85308. /**
  85309. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  85310. * @returns a serialized dynamic texture object
  85311. */
  85312. serialize(): any;
  85313. /** @hidden */
  85314. _rebuild(): void;
  85315. }
  85316. }
  85317. declare module BABYLON {
  85318. interface AbstractScene {
  85319. /**
  85320. * The list of procedural textures added to the scene
  85321. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85322. */
  85323. proceduralTextures: Array<ProceduralTexture>;
  85324. }
  85325. /**
  85326. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85327. * in a given scene.
  85328. */
  85329. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85330. /**
  85331. * The component name helpfull to identify the component in the list of scene components.
  85332. */
  85333. readonly name: string;
  85334. /**
  85335. * The scene the component belongs to.
  85336. */
  85337. scene: Scene;
  85338. /**
  85339. * Creates a new instance of the component for the given scene
  85340. * @param scene Defines the scene to register the component in
  85341. */
  85342. constructor(scene: Scene);
  85343. /**
  85344. * Registers the component in a given scene
  85345. */
  85346. register(): void;
  85347. /**
  85348. * Rebuilds the elements related to this component in case of
  85349. * context lost for instance.
  85350. */
  85351. rebuild(): void;
  85352. /**
  85353. * Disposes the component and the associated ressources.
  85354. */
  85355. dispose(): void;
  85356. private _beforeClear;
  85357. }
  85358. }
  85359. declare module BABYLON {
  85360. interface ThinEngine {
  85361. /**
  85362. * Creates a new render target cube texture
  85363. * @param size defines the size of the texture
  85364. * @param options defines the options used to create the texture
  85365. * @returns a new render target cube texture stored in an InternalTexture
  85366. */
  85367. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85368. }
  85369. }
  85370. declare module BABYLON {
  85371. /** @hidden */
  85372. export var proceduralVertexShader: {
  85373. name: string;
  85374. shader: string;
  85375. };
  85376. }
  85377. declare module BABYLON {
  85378. /**
  85379. * 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.
  85380. * This is the base class of any Procedural texture and contains most of the shareable code.
  85381. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85382. */
  85383. export class ProceduralTexture extends Texture {
  85384. isCube: boolean;
  85385. /**
  85386. * Define if the texture is enabled or not (disabled texture will not render)
  85387. */
  85388. isEnabled: boolean;
  85389. /**
  85390. * Define if the texture must be cleared before rendering (default is true)
  85391. */
  85392. autoClear: boolean;
  85393. /**
  85394. * Callback called when the texture is generated
  85395. */
  85396. onGenerated: () => void;
  85397. /**
  85398. * Event raised when the texture is generated
  85399. */
  85400. onGeneratedObservable: Observable<ProceduralTexture>;
  85401. /** @hidden */
  85402. _generateMipMaps: boolean;
  85403. /** @hidden **/
  85404. _effect: Effect;
  85405. /** @hidden */
  85406. _textures: {
  85407. [key: string]: Texture;
  85408. };
  85409. private _size;
  85410. private _currentRefreshId;
  85411. private _refreshRate;
  85412. private _vertexBuffers;
  85413. private _indexBuffer;
  85414. private _uniforms;
  85415. private _samplers;
  85416. private _fragment;
  85417. private _floats;
  85418. private _ints;
  85419. private _floatsArrays;
  85420. private _colors3;
  85421. private _colors4;
  85422. private _vectors2;
  85423. private _vectors3;
  85424. private _matrices;
  85425. private _fallbackTexture;
  85426. private _fallbackTextureUsed;
  85427. private _engine;
  85428. private _cachedDefines;
  85429. private _contentUpdateId;
  85430. private _contentData;
  85431. /**
  85432. * Instantiates a new procedural texture.
  85433. * 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.
  85434. * This is the base class of any Procedural texture and contains most of the shareable code.
  85435. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85436. * @param name Define the name of the texture
  85437. * @param size Define the size of the texture to create
  85438. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85439. * @param scene Define the scene the texture belongs to
  85440. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85441. * @param generateMipMaps Define if the texture should creates mip maps or not
  85442. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85443. */
  85444. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85445. /**
  85446. * The effect that is created when initializing the post process.
  85447. * @returns The created effect corresponding the the postprocess.
  85448. */
  85449. getEffect(): Effect;
  85450. /**
  85451. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85452. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85453. */
  85454. getContent(): Nullable<ArrayBufferView>;
  85455. private _createIndexBuffer;
  85456. /** @hidden */
  85457. _rebuild(): void;
  85458. /**
  85459. * Resets the texture in order to recreate its associated resources.
  85460. * This can be called in case of context loss
  85461. */
  85462. reset(): void;
  85463. protected _getDefines(): string;
  85464. /**
  85465. * Is the texture ready to be used ? (rendered at least once)
  85466. * @returns true if ready, otherwise, false.
  85467. */
  85468. isReady(): boolean;
  85469. /**
  85470. * Resets the refresh counter of the texture and start bak from scratch.
  85471. * Could be useful to regenerate the texture if it is setup to render only once.
  85472. */
  85473. resetRefreshCounter(): void;
  85474. /**
  85475. * Set the fragment shader to use in order to render the texture.
  85476. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85477. */
  85478. setFragment(fragment: any): void;
  85479. /**
  85480. * Define the refresh rate of the texture or the rendering frequency.
  85481. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85482. */
  85483. refreshRate: number;
  85484. /** @hidden */
  85485. _shouldRender(): boolean;
  85486. /**
  85487. * Get the size the texture is rendering at.
  85488. * @returns the size (texture is always squared)
  85489. */
  85490. getRenderSize(): number;
  85491. /**
  85492. * Resize the texture to new value.
  85493. * @param size Define the new size the texture should have
  85494. * @param generateMipMaps Define whether the new texture should create mip maps
  85495. */
  85496. resize(size: number, generateMipMaps: boolean): void;
  85497. private _checkUniform;
  85498. /**
  85499. * Set a texture in the shader program used to render.
  85500. * @param name Define the name of the uniform samplers as defined in the shader
  85501. * @param texture Define the texture to bind to this sampler
  85502. * @return the texture itself allowing "fluent" like uniform updates
  85503. */
  85504. setTexture(name: string, texture: Texture): ProceduralTexture;
  85505. /**
  85506. * Set a float in the shader.
  85507. * @param name Define the name of the uniform as defined in the shader
  85508. * @param value Define the value to give to the uniform
  85509. * @return the texture itself allowing "fluent" like uniform updates
  85510. */
  85511. setFloat(name: string, value: number): ProceduralTexture;
  85512. /**
  85513. * Set a int in the shader.
  85514. * @param name Define the name of the uniform as defined in the shader
  85515. * @param value Define the value to give to the uniform
  85516. * @return the texture itself allowing "fluent" like uniform updates
  85517. */
  85518. setInt(name: string, value: number): ProceduralTexture;
  85519. /**
  85520. * Set an array of floats in the shader.
  85521. * @param name Define the name of the uniform as defined in the shader
  85522. * @param value Define the value to give to the uniform
  85523. * @return the texture itself allowing "fluent" like uniform updates
  85524. */
  85525. setFloats(name: string, value: number[]): ProceduralTexture;
  85526. /**
  85527. * Set a vec3 in the shader from a Color3.
  85528. * @param name Define the name of the uniform as defined in the shader
  85529. * @param value Define the value to give to the uniform
  85530. * @return the texture itself allowing "fluent" like uniform updates
  85531. */
  85532. setColor3(name: string, value: Color3): ProceduralTexture;
  85533. /**
  85534. * Set a vec4 in the shader from a Color4.
  85535. * @param name Define the name of the uniform as defined in the shader
  85536. * @param value Define the value to give to the uniform
  85537. * @return the texture itself allowing "fluent" like uniform updates
  85538. */
  85539. setColor4(name: string, value: Color4): ProceduralTexture;
  85540. /**
  85541. * Set a vec2 in the shader from a Vector2.
  85542. * @param name Define the name of the uniform as defined in the shader
  85543. * @param value Define the value to give to the uniform
  85544. * @return the texture itself allowing "fluent" like uniform updates
  85545. */
  85546. setVector2(name: string, value: Vector2): ProceduralTexture;
  85547. /**
  85548. * Set a vec3 in the shader from a Vector3.
  85549. * @param name Define the name of the uniform as defined in the shader
  85550. * @param value Define the value to give to the uniform
  85551. * @return the texture itself allowing "fluent" like uniform updates
  85552. */
  85553. setVector3(name: string, value: Vector3): ProceduralTexture;
  85554. /**
  85555. * Set a mat4 in the shader from a MAtrix.
  85556. * @param name Define the name of the uniform as defined in the shader
  85557. * @param value Define the value to give to the uniform
  85558. * @return the texture itself allowing "fluent" like uniform updates
  85559. */
  85560. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85561. /**
  85562. * Render the texture to its associated render target.
  85563. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85564. */
  85565. render(useCameraPostProcess?: boolean): void;
  85566. /**
  85567. * Clone the texture.
  85568. * @returns the cloned texture
  85569. */
  85570. clone(): ProceduralTexture;
  85571. /**
  85572. * Dispose the texture and release its asoociated resources.
  85573. */
  85574. dispose(): void;
  85575. }
  85576. }
  85577. declare module BABYLON {
  85578. /**
  85579. * This represents the base class for particle system in Babylon.
  85580. * 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.
  85581. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85582. * @example https://doc.babylonjs.com/babylon101/particles
  85583. */
  85584. export class BaseParticleSystem {
  85585. /**
  85586. * Source color is added to the destination color without alpha affecting the result
  85587. */
  85588. static BLENDMODE_ONEONE: number;
  85589. /**
  85590. * Blend current color and particle color using particle’s alpha
  85591. */
  85592. static BLENDMODE_STANDARD: number;
  85593. /**
  85594. * Add current color and particle color multiplied by particle’s alpha
  85595. */
  85596. static BLENDMODE_ADD: number;
  85597. /**
  85598. * Multiply current color with particle color
  85599. */
  85600. static BLENDMODE_MULTIPLY: number;
  85601. /**
  85602. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85603. */
  85604. static BLENDMODE_MULTIPLYADD: number;
  85605. /**
  85606. * List of animations used by the particle system.
  85607. */
  85608. animations: Animation[];
  85609. /**
  85610. * The id of the Particle system.
  85611. */
  85612. id: string;
  85613. /**
  85614. * The friendly name of the Particle system.
  85615. */
  85616. name: string;
  85617. /**
  85618. * The rendering group used by the Particle system to chose when to render.
  85619. */
  85620. renderingGroupId: number;
  85621. /**
  85622. * The emitter represents the Mesh or position we are attaching the particle system to.
  85623. */
  85624. emitter: Nullable<AbstractMesh | Vector3>;
  85625. /**
  85626. * The maximum number of particles to emit per frame
  85627. */
  85628. emitRate: number;
  85629. /**
  85630. * If you want to launch only a few particles at once, that can be done, as well.
  85631. */
  85632. manualEmitCount: number;
  85633. /**
  85634. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85635. */
  85636. updateSpeed: number;
  85637. /**
  85638. * The amount of time the particle system is running (depends of the overall update speed).
  85639. */
  85640. targetStopDuration: number;
  85641. /**
  85642. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85643. */
  85644. disposeOnStop: boolean;
  85645. /**
  85646. * Minimum power of emitting particles.
  85647. */
  85648. minEmitPower: number;
  85649. /**
  85650. * Maximum power of emitting particles.
  85651. */
  85652. maxEmitPower: number;
  85653. /**
  85654. * Minimum life time of emitting particles.
  85655. */
  85656. minLifeTime: number;
  85657. /**
  85658. * Maximum life time of emitting particles.
  85659. */
  85660. maxLifeTime: number;
  85661. /**
  85662. * Minimum Size of emitting particles.
  85663. */
  85664. minSize: number;
  85665. /**
  85666. * Maximum Size of emitting particles.
  85667. */
  85668. maxSize: number;
  85669. /**
  85670. * Minimum scale of emitting particles on X axis.
  85671. */
  85672. minScaleX: number;
  85673. /**
  85674. * Maximum scale of emitting particles on X axis.
  85675. */
  85676. maxScaleX: number;
  85677. /**
  85678. * Minimum scale of emitting particles on Y axis.
  85679. */
  85680. minScaleY: number;
  85681. /**
  85682. * Maximum scale of emitting particles on Y axis.
  85683. */
  85684. maxScaleY: number;
  85685. /**
  85686. * Gets or sets the minimal initial rotation in radians.
  85687. */
  85688. minInitialRotation: number;
  85689. /**
  85690. * Gets or sets the maximal initial rotation in radians.
  85691. */
  85692. maxInitialRotation: number;
  85693. /**
  85694. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85695. */
  85696. minAngularSpeed: number;
  85697. /**
  85698. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85699. */
  85700. maxAngularSpeed: number;
  85701. /**
  85702. * The texture used to render each particle. (this can be a spritesheet)
  85703. */
  85704. particleTexture: Nullable<Texture>;
  85705. /**
  85706. * The layer mask we are rendering the particles through.
  85707. */
  85708. layerMask: number;
  85709. /**
  85710. * This can help using your own shader to render the particle system.
  85711. * The according effect will be created
  85712. */
  85713. customShader: any;
  85714. /**
  85715. * By default particle system starts as soon as they are created. This prevents the
  85716. * automatic start to happen and let you decide when to start emitting particles.
  85717. */
  85718. preventAutoStart: boolean;
  85719. private _noiseTexture;
  85720. /**
  85721. * Gets or sets a texture used to add random noise to particle positions
  85722. */
  85723. noiseTexture: Nullable<ProceduralTexture>;
  85724. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85725. noiseStrength: Vector3;
  85726. /**
  85727. * Callback triggered when the particle animation is ending.
  85728. */
  85729. onAnimationEnd: Nullable<() => void>;
  85730. /**
  85731. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85732. */
  85733. blendMode: number;
  85734. /**
  85735. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85736. * to override the particles.
  85737. */
  85738. forceDepthWrite: boolean;
  85739. /** 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 */
  85740. preWarmCycles: number;
  85741. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85742. preWarmStepOffset: number;
  85743. /**
  85744. * 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)
  85745. */
  85746. spriteCellChangeSpeed: number;
  85747. /**
  85748. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85749. */
  85750. startSpriteCellID: number;
  85751. /**
  85752. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85753. */
  85754. endSpriteCellID: number;
  85755. /**
  85756. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85757. */
  85758. spriteCellWidth: number;
  85759. /**
  85760. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85761. */
  85762. spriteCellHeight: number;
  85763. /**
  85764. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85765. */
  85766. spriteRandomStartCell: boolean;
  85767. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85768. translationPivot: Vector2;
  85769. /** @hidden */
  85770. protected _isAnimationSheetEnabled: boolean;
  85771. /**
  85772. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85773. */
  85774. beginAnimationOnStart: boolean;
  85775. /**
  85776. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85777. */
  85778. beginAnimationFrom: number;
  85779. /**
  85780. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85781. */
  85782. beginAnimationTo: number;
  85783. /**
  85784. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85785. */
  85786. beginAnimationLoop: boolean;
  85787. /**
  85788. * Gets or sets a world offset applied to all particles
  85789. */
  85790. worldOffset: Vector3;
  85791. /**
  85792. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85793. */
  85794. isAnimationSheetEnabled: boolean;
  85795. /**
  85796. * Get hosting scene
  85797. * @returns the scene
  85798. */
  85799. getScene(): Scene;
  85800. /**
  85801. * You can use gravity if you want to give an orientation to your particles.
  85802. */
  85803. gravity: Vector3;
  85804. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85805. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85806. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85807. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85808. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85809. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85810. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85811. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85812. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85813. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85814. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85815. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85816. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85817. /**
  85818. * Defines the delay in milliseconds before starting the system (0 by default)
  85819. */
  85820. startDelay: number;
  85821. /**
  85822. * Gets the current list of drag gradients.
  85823. * You must use addDragGradient and removeDragGradient to udpate this list
  85824. * @returns the list of drag gradients
  85825. */
  85826. getDragGradients(): Nullable<Array<FactorGradient>>;
  85827. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85828. limitVelocityDamping: number;
  85829. /**
  85830. * Gets the current list of limit velocity gradients.
  85831. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85832. * @returns the list of limit velocity gradients
  85833. */
  85834. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85835. /**
  85836. * Gets the current list of color gradients.
  85837. * You must use addColorGradient and removeColorGradient to udpate this list
  85838. * @returns the list of color gradients
  85839. */
  85840. getColorGradients(): Nullable<Array<ColorGradient>>;
  85841. /**
  85842. * Gets the current list of size gradients.
  85843. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85844. * @returns the list of size gradients
  85845. */
  85846. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85847. /**
  85848. * Gets the current list of color remap gradients.
  85849. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85850. * @returns the list of color remap gradients
  85851. */
  85852. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85853. /**
  85854. * Gets the current list of alpha remap gradients.
  85855. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85856. * @returns the list of alpha remap gradients
  85857. */
  85858. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85859. /**
  85860. * Gets the current list of life time gradients.
  85861. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85862. * @returns the list of life time gradients
  85863. */
  85864. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85865. /**
  85866. * Gets the current list of angular speed gradients.
  85867. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85868. * @returns the list of angular speed gradients
  85869. */
  85870. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85871. /**
  85872. * Gets the current list of velocity gradients.
  85873. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85874. * @returns the list of velocity gradients
  85875. */
  85876. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85877. /**
  85878. * Gets the current list of start size gradients.
  85879. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85880. * @returns the list of start size gradients
  85881. */
  85882. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85883. /**
  85884. * Gets the current list of emit rate gradients.
  85885. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85886. * @returns the list of emit rate gradients
  85887. */
  85888. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85889. /**
  85890. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85891. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85892. */
  85893. direction1: Vector3;
  85894. /**
  85895. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85896. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85897. */
  85898. direction2: Vector3;
  85899. /**
  85900. * 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.
  85901. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85902. */
  85903. minEmitBox: Vector3;
  85904. /**
  85905. * 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.
  85906. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85907. */
  85908. maxEmitBox: Vector3;
  85909. /**
  85910. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85911. */
  85912. color1: Color4;
  85913. /**
  85914. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85915. */
  85916. color2: Color4;
  85917. /**
  85918. * Color the particle will have at the end of its lifetime
  85919. */
  85920. colorDead: Color4;
  85921. /**
  85922. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85923. */
  85924. textureMask: Color4;
  85925. /**
  85926. * The particle emitter type defines the emitter used by the particle system.
  85927. * It can be for example box, sphere, or cone...
  85928. */
  85929. particleEmitterType: IParticleEmitterType;
  85930. /** @hidden */
  85931. _isSubEmitter: boolean;
  85932. /**
  85933. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85934. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85935. */
  85936. billboardMode: number;
  85937. protected _isBillboardBased: boolean;
  85938. /**
  85939. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85940. */
  85941. isBillboardBased: boolean;
  85942. /**
  85943. * The scene the particle system belongs to.
  85944. */
  85945. protected _scene: Scene;
  85946. /**
  85947. * Local cache of defines for image processing.
  85948. */
  85949. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85950. /**
  85951. * Default configuration related to image processing available in the standard Material.
  85952. */
  85953. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85954. /**
  85955. * Gets the image processing configuration used either in this material.
  85956. */
  85957. /**
  85958. * Sets the Default image processing configuration used either in the this material.
  85959. *
  85960. * If sets to null, the scene one is in use.
  85961. */
  85962. imageProcessingConfiguration: ImageProcessingConfiguration;
  85963. /**
  85964. * Attaches a new image processing configuration to the Standard Material.
  85965. * @param configuration
  85966. */
  85967. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85968. /** @hidden */
  85969. protected _reset(): void;
  85970. /** @hidden */
  85971. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85972. /**
  85973. * Instantiates a particle system.
  85974. * 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.
  85975. * @param name The name of the particle system
  85976. */
  85977. constructor(name: string);
  85978. /**
  85979. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85980. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85981. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85982. * @returns the emitter
  85983. */
  85984. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85985. /**
  85986. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85987. * @param radius The radius of the hemisphere to emit from
  85988. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85989. * @returns the emitter
  85990. */
  85991. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85992. /**
  85993. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85994. * @param radius The radius of the sphere to emit from
  85995. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85996. * @returns the emitter
  85997. */
  85998. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85999. /**
  86000. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86001. * @param radius The radius of the sphere to emit from
  86002. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86003. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86004. * @returns the emitter
  86005. */
  86006. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  86007. /**
  86008. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86009. * @param radius The radius of the emission cylinder
  86010. * @param height The height of the emission cylinder
  86011. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86012. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86013. * @returns the emitter
  86014. */
  86015. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  86016. /**
  86017. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86018. * @param radius The radius of the cylinder to emit from
  86019. * @param height The height of the emission cylinder
  86020. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86021. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86022. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86023. * @returns the emitter
  86024. */
  86025. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  86026. /**
  86027. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86028. * @param radius The radius of the cone to emit from
  86029. * @param angle The base angle of the cone
  86030. * @returns the emitter
  86031. */
  86032. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  86033. /**
  86034. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86035. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86036. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86037. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86038. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86039. * @returns the emitter
  86040. */
  86041. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86042. }
  86043. }
  86044. declare module BABYLON {
  86045. /**
  86046. * Type of sub emitter
  86047. */
  86048. export enum SubEmitterType {
  86049. /**
  86050. * Attached to the particle over it's lifetime
  86051. */
  86052. ATTACHED = 0,
  86053. /**
  86054. * Created when the particle dies
  86055. */
  86056. END = 1
  86057. }
  86058. /**
  86059. * Sub emitter class used to emit particles from an existing particle
  86060. */
  86061. export class SubEmitter {
  86062. /**
  86063. * the particle system to be used by the sub emitter
  86064. */
  86065. particleSystem: ParticleSystem;
  86066. /**
  86067. * Type of the submitter (Default: END)
  86068. */
  86069. type: SubEmitterType;
  86070. /**
  86071. * 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)
  86072. * Note: This only is supported when using an emitter of type Mesh
  86073. */
  86074. inheritDirection: boolean;
  86075. /**
  86076. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  86077. */
  86078. inheritedVelocityAmount: number;
  86079. /**
  86080. * Creates a sub emitter
  86081. * @param particleSystem the particle system to be used by the sub emitter
  86082. */
  86083. constructor(
  86084. /**
  86085. * the particle system to be used by the sub emitter
  86086. */
  86087. particleSystem: ParticleSystem);
  86088. /**
  86089. * Clones the sub emitter
  86090. * @returns the cloned sub emitter
  86091. */
  86092. clone(): SubEmitter;
  86093. /**
  86094. * Serialize current object to a JSON object
  86095. * @returns the serialized object
  86096. */
  86097. serialize(): any;
  86098. /** @hidden */
  86099. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  86100. /**
  86101. * Creates a new SubEmitter from a serialized JSON version
  86102. * @param serializationObject defines the JSON object to read from
  86103. * @param scene defines the hosting scene
  86104. * @param rootUrl defines the rootUrl for data loading
  86105. * @returns a new SubEmitter
  86106. */
  86107. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  86108. /** Release associated resources */
  86109. dispose(): void;
  86110. }
  86111. }
  86112. declare module BABYLON {
  86113. /** @hidden */
  86114. export var clipPlaneFragmentDeclaration: {
  86115. name: string;
  86116. shader: string;
  86117. };
  86118. }
  86119. declare module BABYLON {
  86120. /** @hidden */
  86121. export var imageProcessingDeclaration: {
  86122. name: string;
  86123. shader: string;
  86124. };
  86125. }
  86126. declare module BABYLON {
  86127. /** @hidden */
  86128. export var imageProcessingFunctions: {
  86129. name: string;
  86130. shader: string;
  86131. };
  86132. }
  86133. declare module BABYLON {
  86134. /** @hidden */
  86135. export var clipPlaneFragment: {
  86136. name: string;
  86137. shader: string;
  86138. };
  86139. }
  86140. declare module BABYLON {
  86141. /** @hidden */
  86142. export var particlesPixelShader: {
  86143. name: string;
  86144. shader: string;
  86145. };
  86146. }
  86147. declare module BABYLON {
  86148. /** @hidden */
  86149. export var clipPlaneVertexDeclaration: {
  86150. name: string;
  86151. shader: string;
  86152. };
  86153. }
  86154. declare module BABYLON {
  86155. /** @hidden */
  86156. export var clipPlaneVertex: {
  86157. name: string;
  86158. shader: string;
  86159. };
  86160. }
  86161. declare module BABYLON {
  86162. /** @hidden */
  86163. export var particlesVertexShader: {
  86164. name: string;
  86165. shader: string;
  86166. };
  86167. }
  86168. declare module BABYLON {
  86169. /**
  86170. * This represents a particle system in Babylon.
  86171. * 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.
  86172. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86173. * @example https://doc.babylonjs.com/babylon101/particles
  86174. */
  86175. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  86176. /**
  86177. * Billboard mode will only apply to Y axis
  86178. */
  86179. static readonly BILLBOARDMODE_Y: number;
  86180. /**
  86181. * Billboard mode will apply to all axes
  86182. */
  86183. static readonly BILLBOARDMODE_ALL: number;
  86184. /**
  86185. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  86186. */
  86187. static readonly BILLBOARDMODE_STRETCHED: number;
  86188. /**
  86189. * This function can be defined to provide custom update for active particles.
  86190. * This function will be called instead of regular update (age, position, color, etc.).
  86191. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  86192. */
  86193. updateFunction: (particles: Particle[]) => void;
  86194. private _emitterWorldMatrix;
  86195. /**
  86196. * This function can be defined to specify initial direction for every new particle.
  86197. * It by default use the emitterType defined function
  86198. */
  86199. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  86200. /**
  86201. * This function can be defined to specify initial position for every new particle.
  86202. * It by default use the emitterType defined function
  86203. */
  86204. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  86205. /**
  86206. * @hidden
  86207. */
  86208. _inheritedVelocityOffset: Vector3;
  86209. /**
  86210. * An event triggered when the system is disposed
  86211. */
  86212. onDisposeObservable: Observable<ParticleSystem>;
  86213. private _onDisposeObserver;
  86214. /**
  86215. * Sets a callback that will be triggered when the system is disposed
  86216. */
  86217. onDispose: () => void;
  86218. private _particles;
  86219. private _epsilon;
  86220. private _capacity;
  86221. private _stockParticles;
  86222. private _newPartsExcess;
  86223. private _vertexData;
  86224. private _vertexBuffer;
  86225. private _vertexBuffers;
  86226. private _spriteBuffer;
  86227. private _indexBuffer;
  86228. private _effect;
  86229. private _customEffect;
  86230. private _cachedDefines;
  86231. private _scaledColorStep;
  86232. private _colorDiff;
  86233. private _scaledDirection;
  86234. private _scaledGravity;
  86235. private _currentRenderId;
  86236. private _alive;
  86237. private _useInstancing;
  86238. private _started;
  86239. private _stopped;
  86240. private _actualFrame;
  86241. private _scaledUpdateSpeed;
  86242. private _vertexBufferSize;
  86243. /** @hidden */
  86244. _currentEmitRateGradient: Nullable<FactorGradient>;
  86245. /** @hidden */
  86246. _currentEmitRate1: number;
  86247. /** @hidden */
  86248. _currentEmitRate2: number;
  86249. /** @hidden */
  86250. _currentStartSizeGradient: Nullable<FactorGradient>;
  86251. /** @hidden */
  86252. _currentStartSize1: number;
  86253. /** @hidden */
  86254. _currentStartSize2: number;
  86255. private readonly _rawTextureWidth;
  86256. private _rampGradientsTexture;
  86257. private _useRampGradients;
  86258. /** Gets or sets a boolean indicating that ramp gradients must be used
  86259. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86260. */
  86261. useRampGradients: boolean;
  86262. /**
  86263. * 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.
  86264. * 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: [])
  86265. */
  86266. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  86267. private _subEmitters;
  86268. /**
  86269. * @hidden
  86270. * If the particle systems emitter should be disposed when the particle system is disposed
  86271. */
  86272. _disposeEmitterOnDispose: boolean;
  86273. /**
  86274. * The current active Sub-systems, this property is used by the root particle system only.
  86275. */
  86276. activeSubSystems: Array<ParticleSystem>;
  86277. private _rootParticleSystem;
  86278. /**
  86279. * Gets the current list of active particles
  86280. */
  86281. readonly particles: Particle[];
  86282. /**
  86283. * Returns the string "ParticleSystem"
  86284. * @returns a string containing the class name
  86285. */
  86286. getClassName(): string;
  86287. /**
  86288. * Instantiates a particle system.
  86289. * 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.
  86290. * @param name The name of the particle system
  86291. * @param capacity The max number of particles alive at the same time
  86292. * @param scene The scene the particle system belongs to
  86293. * @param customEffect a custom effect used to change the way particles are rendered by default
  86294. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86295. * @param epsilon Offset used to render the particles
  86296. */
  86297. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86298. private _addFactorGradient;
  86299. private _removeFactorGradient;
  86300. /**
  86301. * Adds a new life time gradient
  86302. * @param gradient defines the gradient to use (between 0 and 1)
  86303. * @param factor defines the life time factor to affect to the specified gradient
  86304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86305. * @returns the current particle system
  86306. */
  86307. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86308. /**
  86309. * Remove a specific life time gradient
  86310. * @param gradient defines the gradient to remove
  86311. * @returns the current particle system
  86312. */
  86313. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86314. /**
  86315. * Adds a new size gradient
  86316. * @param gradient defines the gradient to use (between 0 and 1)
  86317. * @param factor defines the size factor to affect to the specified gradient
  86318. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86319. * @returns the current particle system
  86320. */
  86321. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86322. /**
  86323. * Remove a specific size gradient
  86324. * @param gradient defines the gradient to remove
  86325. * @returns the current particle system
  86326. */
  86327. removeSizeGradient(gradient: number): IParticleSystem;
  86328. /**
  86329. * Adds a new color remap gradient
  86330. * @param gradient defines the gradient to use (between 0 and 1)
  86331. * @param min defines the color remap minimal range
  86332. * @param max defines the color remap maximal range
  86333. * @returns the current particle system
  86334. */
  86335. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86336. /**
  86337. * Remove a specific color remap gradient
  86338. * @param gradient defines the gradient to remove
  86339. * @returns the current particle system
  86340. */
  86341. removeColorRemapGradient(gradient: number): IParticleSystem;
  86342. /**
  86343. * Adds a new alpha remap gradient
  86344. * @param gradient defines the gradient to use (between 0 and 1)
  86345. * @param min defines the alpha remap minimal range
  86346. * @param max defines the alpha remap maximal range
  86347. * @returns the current particle system
  86348. */
  86349. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86350. /**
  86351. * Remove a specific alpha remap gradient
  86352. * @param gradient defines the gradient to remove
  86353. * @returns the current particle system
  86354. */
  86355. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86356. /**
  86357. * Adds a new angular speed gradient
  86358. * @param gradient defines the gradient to use (between 0 and 1)
  86359. * @param factor defines the angular speed to affect to the specified gradient
  86360. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86361. * @returns the current particle system
  86362. */
  86363. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86364. /**
  86365. * Remove a specific angular speed gradient
  86366. * @param gradient defines the gradient to remove
  86367. * @returns the current particle system
  86368. */
  86369. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86370. /**
  86371. * Adds a new velocity gradient
  86372. * @param gradient defines the gradient to use (between 0 and 1)
  86373. * @param factor defines the velocity to affect to the specified gradient
  86374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86375. * @returns the current particle system
  86376. */
  86377. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86378. /**
  86379. * Remove a specific velocity gradient
  86380. * @param gradient defines the gradient to remove
  86381. * @returns the current particle system
  86382. */
  86383. removeVelocityGradient(gradient: number): IParticleSystem;
  86384. /**
  86385. * Adds a new limit velocity gradient
  86386. * @param gradient defines the gradient to use (between 0 and 1)
  86387. * @param factor defines the limit velocity value to affect to the specified gradient
  86388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86389. * @returns the current particle system
  86390. */
  86391. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86392. /**
  86393. * Remove a specific limit velocity gradient
  86394. * @param gradient defines the gradient to remove
  86395. * @returns the current particle system
  86396. */
  86397. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86398. /**
  86399. * Adds a new drag gradient
  86400. * @param gradient defines the gradient to use (between 0 and 1)
  86401. * @param factor defines the drag value to affect to the specified gradient
  86402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86403. * @returns the current particle system
  86404. */
  86405. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86406. /**
  86407. * Remove a specific drag gradient
  86408. * @param gradient defines the gradient to remove
  86409. * @returns the current particle system
  86410. */
  86411. removeDragGradient(gradient: number): IParticleSystem;
  86412. /**
  86413. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86414. * @param gradient defines the gradient to use (between 0 and 1)
  86415. * @param factor defines the emit rate value to affect to the specified gradient
  86416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86417. * @returns the current particle system
  86418. */
  86419. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86420. /**
  86421. * Remove a specific emit rate gradient
  86422. * @param gradient defines the gradient to remove
  86423. * @returns the current particle system
  86424. */
  86425. removeEmitRateGradient(gradient: number): IParticleSystem;
  86426. /**
  86427. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86428. * @param gradient defines the gradient to use (between 0 and 1)
  86429. * @param factor defines the start size value to affect to the specified gradient
  86430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86431. * @returns the current particle system
  86432. */
  86433. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86434. /**
  86435. * Remove a specific start size gradient
  86436. * @param gradient defines the gradient to remove
  86437. * @returns the current particle system
  86438. */
  86439. removeStartSizeGradient(gradient: number): IParticleSystem;
  86440. private _createRampGradientTexture;
  86441. /**
  86442. * Gets the current list of ramp gradients.
  86443. * You must use addRampGradient and removeRampGradient to udpate this list
  86444. * @returns the list of ramp gradients
  86445. */
  86446. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86447. /**
  86448. * Adds a new ramp gradient used to remap particle colors
  86449. * @param gradient defines the gradient to use (between 0 and 1)
  86450. * @param color defines the color to affect to the specified gradient
  86451. * @returns the current particle system
  86452. */
  86453. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86454. /**
  86455. * Remove a specific ramp gradient
  86456. * @param gradient defines the gradient to remove
  86457. * @returns the current particle system
  86458. */
  86459. removeRampGradient(gradient: number): ParticleSystem;
  86460. /**
  86461. * Adds a new color gradient
  86462. * @param gradient defines the gradient to use (between 0 and 1)
  86463. * @param color1 defines the color to affect to the specified gradient
  86464. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86465. * @returns this particle system
  86466. */
  86467. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86468. /**
  86469. * Remove a specific color gradient
  86470. * @param gradient defines the gradient to remove
  86471. * @returns this particle system
  86472. */
  86473. removeColorGradient(gradient: number): IParticleSystem;
  86474. private _fetchR;
  86475. protected _reset(): void;
  86476. private _resetEffect;
  86477. private _createVertexBuffers;
  86478. private _createIndexBuffer;
  86479. /**
  86480. * Gets the maximum number of particles active at the same time.
  86481. * @returns The max number of active particles.
  86482. */
  86483. getCapacity(): number;
  86484. /**
  86485. * Gets whether there are still active particles in the system.
  86486. * @returns True if it is alive, otherwise false.
  86487. */
  86488. isAlive(): boolean;
  86489. /**
  86490. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86491. * @returns True if it has been started, otherwise false.
  86492. */
  86493. isStarted(): boolean;
  86494. private _prepareSubEmitterInternalArray;
  86495. /**
  86496. * Starts the particle system and begins to emit
  86497. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86498. */
  86499. start(delay?: number): void;
  86500. /**
  86501. * Stops the particle system.
  86502. * @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.
  86503. */
  86504. stop(stopSubEmitters?: boolean): void;
  86505. /**
  86506. * Remove all active particles
  86507. */
  86508. reset(): void;
  86509. /**
  86510. * @hidden (for internal use only)
  86511. */
  86512. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86513. /**
  86514. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86515. * Its lifetime will start back at 0.
  86516. */
  86517. recycleParticle: (particle: Particle) => void;
  86518. private _stopSubEmitters;
  86519. private _createParticle;
  86520. private _removeFromRoot;
  86521. private _emitFromParticle;
  86522. private _update;
  86523. /** @hidden */
  86524. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86525. /** @hidden */
  86526. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86527. /** @hidden */
  86528. private _getEffect;
  86529. /**
  86530. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86531. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86532. */
  86533. animate(preWarmOnly?: boolean): void;
  86534. private _appendParticleVertices;
  86535. /**
  86536. * Rebuilds the particle system.
  86537. */
  86538. rebuild(): void;
  86539. /**
  86540. * Is this system ready to be used/rendered
  86541. * @return true if the system is ready
  86542. */
  86543. isReady(): boolean;
  86544. private _render;
  86545. /**
  86546. * Renders the particle system in its current state.
  86547. * @returns the current number of particles
  86548. */
  86549. render(): number;
  86550. /**
  86551. * Disposes the particle system and free the associated resources
  86552. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86553. */
  86554. dispose(disposeTexture?: boolean): void;
  86555. /**
  86556. * Clones the particle system.
  86557. * @param name The name of the cloned object
  86558. * @param newEmitter The new emitter to use
  86559. * @returns the cloned particle system
  86560. */
  86561. clone(name: string, newEmitter: any): ParticleSystem;
  86562. /**
  86563. * Serializes the particle system to a JSON object.
  86564. * @returns the JSON object
  86565. */
  86566. serialize(): any;
  86567. /** @hidden */
  86568. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  86569. /** @hidden */
  86570. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86571. /**
  86572. * Parses a JSON object to create a particle system.
  86573. * @param parsedParticleSystem The JSON object to parse
  86574. * @param scene The scene to create the particle system in
  86575. * @param rootUrl The root url to use to load external dependencies like texture
  86576. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86577. * @returns the Parsed particle system
  86578. */
  86579. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86580. }
  86581. }
  86582. declare module BABYLON {
  86583. /**
  86584. * A particle represents one of the element emitted by a particle system.
  86585. * This is mainly define by its coordinates, direction, velocity and age.
  86586. */
  86587. export class Particle {
  86588. /**
  86589. * The particle system the particle belongs to.
  86590. */
  86591. particleSystem: ParticleSystem;
  86592. private static _Count;
  86593. /**
  86594. * Unique ID of the particle
  86595. */
  86596. id: number;
  86597. /**
  86598. * The world position of the particle in the scene.
  86599. */
  86600. position: Vector3;
  86601. /**
  86602. * The world direction of the particle in the scene.
  86603. */
  86604. direction: Vector3;
  86605. /**
  86606. * The color of the particle.
  86607. */
  86608. color: Color4;
  86609. /**
  86610. * The color change of the particle per step.
  86611. */
  86612. colorStep: Color4;
  86613. /**
  86614. * Defines how long will the life of the particle be.
  86615. */
  86616. lifeTime: number;
  86617. /**
  86618. * The current age of the particle.
  86619. */
  86620. age: number;
  86621. /**
  86622. * The current size of the particle.
  86623. */
  86624. size: number;
  86625. /**
  86626. * The current scale of the particle.
  86627. */
  86628. scale: Vector2;
  86629. /**
  86630. * The current angle of the particle.
  86631. */
  86632. angle: number;
  86633. /**
  86634. * Defines how fast is the angle changing.
  86635. */
  86636. angularSpeed: number;
  86637. /**
  86638. * Defines the cell index used by the particle to be rendered from a sprite.
  86639. */
  86640. cellIndex: number;
  86641. /**
  86642. * The information required to support color remapping
  86643. */
  86644. remapData: Vector4;
  86645. /** @hidden */
  86646. _randomCellOffset?: number;
  86647. /** @hidden */
  86648. _initialDirection: Nullable<Vector3>;
  86649. /** @hidden */
  86650. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86651. /** @hidden */
  86652. _initialStartSpriteCellID: number;
  86653. /** @hidden */
  86654. _initialEndSpriteCellID: number;
  86655. /** @hidden */
  86656. _currentColorGradient: Nullable<ColorGradient>;
  86657. /** @hidden */
  86658. _currentColor1: Color4;
  86659. /** @hidden */
  86660. _currentColor2: Color4;
  86661. /** @hidden */
  86662. _currentSizeGradient: Nullable<FactorGradient>;
  86663. /** @hidden */
  86664. _currentSize1: number;
  86665. /** @hidden */
  86666. _currentSize2: number;
  86667. /** @hidden */
  86668. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86669. /** @hidden */
  86670. _currentAngularSpeed1: number;
  86671. /** @hidden */
  86672. _currentAngularSpeed2: number;
  86673. /** @hidden */
  86674. _currentVelocityGradient: Nullable<FactorGradient>;
  86675. /** @hidden */
  86676. _currentVelocity1: number;
  86677. /** @hidden */
  86678. _currentVelocity2: number;
  86679. /** @hidden */
  86680. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86681. /** @hidden */
  86682. _currentLimitVelocity1: number;
  86683. /** @hidden */
  86684. _currentLimitVelocity2: number;
  86685. /** @hidden */
  86686. _currentDragGradient: Nullable<FactorGradient>;
  86687. /** @hidden */
  86688. _currentDrag1: number;
  86689. /** @hidden */
  86690. _currentDrag2: number;
  86691. /** @hidden */
  86692. _randomNoiseCoordinates1: Vector3;
  86693. /** @hidden */
  86694. _randomNoiseCoordinates2: Vector3;
  86695. /**
  86696. * Creates a new instance Particle
  86697. * @param particleSystem the particle system the particle belongs to
  86698. */
  86699. constructor(
  86700. /**
  86701. * The particle system the particle belongs to.
  86702. */
  86703. particleSystem: ParticleSystem);
  86704. private updateCellInfoFromSystem;
  86705. /**
  86706. * Defines how the sprite cell index is updated for the particle
  86707. */
  86708. updateCellIndex(): void;
  86709. /** @hidden */
  86710. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86711. /** @hidden */
  86712. _inheritParticleInfoToSubEmitters(): void;
  86713. /** @hidden */
  86714. _reset(): void;
  86715. /**
  86716. * Copy the properties of particle to another one.
  86717. * @param other the particle to copy the information to.
  86718. */
  86719. copyTo(other: Particle): void;
  86720. }
  86721. }
  86722. declare module BABYLON {
  86723. /**
  86724. * Particle emitter represents a volume emitting particles.
  86725. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86726. */
  86727. export interface IParticleEmitterType {
  86728. /**
  86729. * Called by the particle System when the direction is computed for the created particle.
  86730. * @param worldMatrix is the world matrix of the particle system
  86731. * @param directionToUpdate is the direction vector to update with the result
  86732. * @param particle is the particle we are computed the direction for
  86733. */
  86734. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86735. /**
  86736. * Called by the particle System when the position is computed for the created particle.
  86737. * @param worldMatrix is the world matrix of the particle system
  86738. * @param positionToUpdate is the position vector to update with the result
  86739. * @param particle is the particle we are computed the position for
  86740. */
  86741. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86742. /**
  86743. * Clones the current emitter and returns a copy of it
  86744. * @returns the new emitter
  86745. */
  86746. clone(): IParticleEmitterType;
  86747. /**
  86748. * Called by the GPUParticleSystem to setup the update shader
  86749. * @param effect defines the update shader
  86750. */
  86751. applyToShader(effect: Effect): void;
  86752. /**
  86753. * Returns a string to use to update the GPU particles update shader
  86754. * @returns the effect defines string
  86755. */
  86756. getEffectDefines(): string;
  86757. /**
  86758. * Returns a string representing the class name
  86759. * @returns a string containing the class name
  86760. */
  86761. getClassName(): string;
  86762. /**
  86763. * Serializes the particle system to a JSON object.
  86764. * @returns the JSON object
  86765. */
  86766. serialize(): any;
  86767. /**
  86768. * Parse properties from a JSON object
  86769. * @param serializationObject defines the JSON object
  86770. */
  86771. parse(serializationObject: any): void;
  86772. }
  86773. }
  86774. declare module BABYLON {
  86775. /**
  86776. * Particle emitter emitting particles from the inside of a box.
  86777. * It emits the particles randomly between 2 given directions.
  86778. */
  86779. export class BoxParticleEmitter implements IParticleEmitterType {
  86780. /**
  86781. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86782. */
  86783. direction1: Vector3;
  86784. /**
  86785. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86786. */
  86787. direction2: Vector3;
  86788. /**
  86789. * 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.
  86790. */
  86791. minEmitBox: Vector3;
  86792. /**
  86793. * 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.
  86794. */
  86795. maxEmitBox: Vector3;
  86796. /**
  86797. * Creates a new instance BoxParticleEmitter
  86798. */
  86799. constructor();
  86800. /**
  86801. * Called by the particle System when the direction is computed for the created particle.
  86802. * @param worldMatrix is the world matrix of the particle system
  86803. * @param directionToUpdate is the direction vector to update with the result
  86804. * @param particle is the particle we are computed the direction for
  86805. */
  86806. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86807. /**
  86808. * Called by the particle System when the position is computed for the created particle.
  86809. * @param worldMatrix is the world matrix of the particle system
  86810. * @param positionToUpdate is the position vector to update with the result
  86811. * @param particle is the particle we are computed the position for
  86812. */
  86813. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86814. /**
  86815. * Clones the current emitter and returns a copy of it
  86816. * @returns the new emitter
  86817. */
  86818. clone(): BoxParticleEmitter;
  86819. /**
  86820. * Called by the GPUParticleSystem to setup the update shader
  86821. * @param effect defines the update shader
  86822. */
  86823. applyToShader(effect: Effect): void;
  86824. /**
  86825. * Returns a string to use to update the GPU particles update shader
  86826. * @returns a string containng the defines string
  86827. */
  86828. getEffectDefines(): string;
  86829. /**
  86830. * Returns the string "BoxParticleEmitter"
  86831. * @returns a string containing the class name
  86832. */
  86833. getClassName(): string;
  86834. /**
  86835. * Serializes the particle system to a JSON object.
  86836. * @returns the JSON object
  86837. */
  86838. serialize(): any;
  86839. /**
  86840. * Parse properties from a JSON object
  86841. * @param serializationObject defines the JSON object
  86842. */
  86843. parse(serializationObject: any): void;
  86844. }
  86845. }
  86846. declare module BABYLON {
  86847. /**
  86848. * Particle emitter emitting particles from the inside of a cone.
  86849. * It emits the particles alongside the cone volume from the base to the particle.
  86850. * The emission direction might be randomized.
  86851. */
  86852. export class ConeParticleEmitter implements IParticleEmitterType {
  86853. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86854. directionRandomizer: number;
  86855. private _radius;
  86856. private _angle;
  86857. private _height;
  86858. /**
  86859. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86860. */
  86861. radiusRange: number;
  86862. /**
  86863. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86864. */
  86865. heightRange: number;
  86866. /**
  86867. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86868. */
  86869. emitFromSpawnPointOnly: boolean;
  86870. /**
  86871. * Gets or sets the radius of the emission cone
  86872. */
  86873. radius: number;
  86874. /**
  86875. * Gets or sets the angle of the emission cone
  86876. */
  86877. angle: number;
  86878. private _buildHeight;
  86879. /**
  86880. * Creates a new instance ConeParticleEmitter
  86881. * @param radius the radius of the emission cone (1 by default)
  86882. * @param angle the cone base angle (PI by default)
  86883. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86884. */
  86885. constructor(radius?: number, angle?: number,
  86886. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86887. directionRandomizer?: number);
  86888. /**
  86889. * Called by the particle System when the direction is computed for the created particle.
  86890. * @param worldMatrix is the world matrix of the particle system
  86891. * @param directionToUpdate is the direction vector to update with the result
  86892. * @param particle is the particle we are computed the direction for
  86893. */
  86894. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86895. /**
  86896. * Called by the particle System when the position is computed for the created particle.
  86897. * @param worldMatrix is the world matrix of the particle system
  86898. * @param positionToUpdate is the position vector to update with the result
  86899. * @param particle is the particle we are computed the position for
  86900. */
  86901. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86902. /**
  86903. * Clones the current emitter and returns a copy of it
  86904. * @returns the new emitter
  86905. */
  86906. clone(): ConeParticleEmitter;
  86907. /**
  86908. * Called by the GPUParticleSystem to setup the update shader
  86909. * @param effect defines the update shader
  86910. */
  86911. applyToShader(effect: Effect): void;
  86912. /**
  86913. * Returns a string to use to update the GPU particles update shader
  86914. * @returns a string containng the defines string
  86915. */
  86916. getEffectDefines(): string;
  86917. /**
  86918. * Returns the string "ConeParticleEmitter"
  86919. * @returns a string containing the class name
  86920. */
  86921. getClassName(): string;
  86922. /**
  86923. * Serializes the particle system to a JSON object.
  86924. * @returns the JSON object
  86925. */
  86926. serialize(): any;
  86927. /**
  86928. * Parse properties from a JSON object
  86929. * @param serializationObject defines the JSON object
  86930. */
  86931. parse(serializationObject: any): void;
  86932. }
  86933. }
  86934. declare module BABYLON {
  86935. /**
  86936. * Particle emitter emitting particles from the inside of a cylinder.
  86937. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86938. */
  86939. export class CylinderParticleEmitter implements IParticleEmitterType {
  86940. /**
  86941. * The radius of the emission cylinder.
  86942. */
  86943. radius: number;
  86944. /**
  86945. * The height of the emission cylinder.
  86946. */
  86947. height: number;
  86948. /**
  86949. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86950. */
  86951. radiusRange: number;
  86952. /**
  86953. * How much to randomize the particle direction [0-1].
  86954. */
  86955. directionRandomizer: number;
  86956. /**
  86957. * Creates a new instance CylinderParticleEmitter
  86958. * @param radius the radius of the emission cylinder (1 by default)
  86959. * @param height the height of the emission cylinder (1 by default)
  86960. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86961. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86962. */
  86963. constructor(
  86964. /**
  86965. * The radius of the emission cylinder.
  86966. */
  86967. radius?: number,
  86968. /**
  86969. * The height of the emission cylinder.
  86970. */
  86971. height?: number,
  86972. /**
  86973. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86974. */
  86975. radiusRange?: number,
  86976. /**
  86977. * How much to randomize the particle direction [0-1].
  86978. */
  86979. directionRandomizer?: number);
  86980. /**
  86981. * Called by the particle System when the direction is computed for the created particle.
  86982. * @param worldMatrix is the world matrix of the particle system
  86983. * @param directionToUpdate is the direction vector to update with the result
  86984. * @param particle is the particle we are computed the direction for
  86985. */
  86986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86987. /**
  86988. * Called by the particle System when the position is computed for the created particle.
  86989. * @param worldMatrix is the world matrix of the particle system
  86990. * @param positionToUpdate is the position vector to update with the result
  86991. * @param particle is the particle we are computed the position for
  86992. */
  86993. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86994. /**
  86995. * Clones the current emitter and returns a copy of it
  86996. * @returns the new emitter
  86997. */
  86998. clone(): CylinderParticleEmitter;
  86999. /**
  87000. * Called by the GPUParticleSystem to setup the update shader
  87001. * @param effect defines the update shader
  87002. */
  87003. applyToShader(effect: Effect): void;
  87004. /**
  87005. * Returns a string to use to update the GPU particles update shader
  87006. * @returns a string containng the defines string
  87007. */
  87008. getEffectDefines(): string;
  87009. /**
  87010. * Returns the string "CylinderParticleEmitter"
  87011. * @returns a string containing the class name
  87012. */
  87013. getClassName(): string;
  87014. /**
  87015. * Serializes the particle system to a JSON object.
  87016. * @returns the JSON object
  87017. */
  87018. serialize(): any;
  87019. /**
  87020. * Parse properties from a JSON object
  87021. * @param serializationObject defines the JSON object
  87022. */
  87023. parse(serializationObject: any): void;
  87024. }
  87025. /**
  87026. * Particle emitter emitting particles from the inside of a cylinder.
  87027. * It emits the particles randomly between two vectors.
  87028. */
  87029. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  87030. /**
  87031. * The min limit of the emission direction.
  87032. */
  87033. direction1: Vector3;
  87034. /**
  87035. * The max limit of the emission direction.
  87036. */
  87037. direction2: Vector3;
  87038. /**
  87039. * Creates a new instance CylinderDirectedParticleEmitter
  87040. * @param radius the radius of the emission cylinder (1 by default)
  87041. * @param height the height of the emission cylinder (1 by default)
  87042. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87043. * @param direction1 the min limit of the emission direction (up vector by default)
  87044. * @param direction2 the max limit of the emission direction (up vector by default)
  87045. */
  87046. constructor(radius?: number, height?: number, radiusRange?: number,
  87047. /**
  87048. * The min limit of the emission direction.
  87049. */
  87050. direction1?: Vector3,
  87051. /**
  87052. * The max limit of the emission direction.
  87053. */
  87054. direction2?: Vector3);
  87055. /**
  87056. * Called by the particle System when the direction is computed for the created particle.
  87057. * @param worldMatrix is the world matrix of the particle system
  87058. * @param directionToUpdate is the direction vector to update with the result
  87059. * @param particle is the particle we are computed the direction for
  87060. */
  87061. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87062. /**
  87063. * Clones the current emitter and returns a copy of it
  87064. * @returns the new emitter
  87065. */
  87066. clone(): CylinderDirectedParticleEmitter;
  87067. /**
  87068. * Called by the GPUParticleSystem to setup the update shader
  87069. * @param effect defines the update shader
  87070. */
  87071. applyToShader(effect: Effect): void;
  87072. /**
  87073. * Returns a string to use to update the GPU particles update shader
  87074. * @returns a string containng the defines string
  87075. */
  87076. getEffectDefines(): string;
  87077. /**
  87078. * Returns the string "CylinderDirectedParticleEmitter"
  87079. * @returns a string containing the class name
  87080. */
  87081. getClassName(): string;
  87082. /**
  87083. * Serializes the particle system to a JSON object.
  87084. * @returns the JSON object
  87085. */
  87086. serialize(): any;
  87087. /**
  87088. * Parse properties from a JSON object
  87089. * @param serializationObject defines the JSON object
  87090. */
  87091. parse(serializationObject: any): void;
  87092. }
  87093. }
  87094. declare module BABYLON {
  87095. /**
  87096. * Particle emitter emitting particles from the inside of a hemisphere.
  87097. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  87098. */
  87099. export class HemisphericParticleEmitter implements IParticleEmitterType {
  87100. /**
  87101. * The radius of the emission hemisphere.
  87102. */
  87103. radius: number;
  87104. /**
  87105. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87106. */
  87107. radiusRange: number;
  87108. /**
  87109. * How much to randomize the particle direction [0-1].
  87110. */
  87111. directionRandomizer: number;
  87112. /**
  87113. * Creates a new instance HemisphericParticleEmitter
  87114. * @param radius the radius of the emission hemisphere (1 by default)
  87115. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87116. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87117. */
  87118. constructor(
  87119. /**
  87120. * The radius of the emission hemisphere.
  87121. */
  87122. radius?: number,
  87123. /**
  87124. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87125. */
  87126. radiusRange?: number,
  87127. /**
  87128. * How much to randomize the particle direction [0-1].
  87129. */
  87130. directionRandomizer?: number);
  87131. /**
  87132. * Called by the particle System when the direction is computed for the created particle.
  87133. * @param worldMatrix is the world matrix of the particle system
  87134. * @param directionToUpdate is the direction vector to update with the result
  87135. * @param particle is the particle we are computed the direction for
  87136. */
  87137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87138. /**
  87139. * Called by the particle System when the position is computed for the created particle.
  87140. * @param worldMatrix is the world matrix of the particle system
  87141. * @param positionToUpdate is the position vector to update with the result
  87142. * @param particle is the particle we are computed the position for
  87143. */
  87144. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87145. /**
  87146. * Clones the current emitter and returns a copy of it
  87147. * @returns the new emitter
  87148. */
  87149. clone(): HemisphericParticleEmitter;
  87150. /**
  87151. * Called by the GPUParticleSystem to setup the update shader
  87152. * @param effect defines the update shader
  87153. */
  87154. applyToShader(effect: Effect): void;
  87155. /**
  87156. * Returns a string to use to update the GPU particles update shader
  87157. * @returns a string containng the defines string
  87158. */
  87159. getEffectDefines(): string;
  87160. /**
  87161. * Returns the string "HemisphericParticleEmitter"
  87162. * @returns a string containing the class name
  87163. */
  87164. getClassName(): string;
  87165. /**
  87166. * Serializes the particle system to a JSON object.
  87167. * @returns the JSON object
  87168. */
  87169. serialize(): any;
  87170. /**
  87171. * Parse properties from a JSON object
  87172. * @param serializationObject defines the JSON object
  87173. */
  87174. parse(serializationObject: any): void;
  87175. }
  87176. }
  87177. declare module BABYLON {
  87178. /**
  87179. * Particle emitter emitting particles from a point.
  87180. * It emits the particles randomly between 2 given directions.
  87181. */
  87182. export class PointParticleEmitter implements IParticleEmitterType {
  87183. /**
  87184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87185. */
  87186. direction1: Vector3;
  87187. /**
  87188. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87189. */
  87190. direction2: Vector3;
  87191. /**
  87192. * Creates a new instance PointParticleEmitter
  87193. */
  87194. constructor();
  87195. /**
  87196. * Called by the particle System when the direction is computed for the created particle.
  87197. * @param worldMatrix is the world matrix of the particle system
  87198. * @param directionToUpdate is the direction vector to update with the result
  87199. * @param particle is the particle we are computed the direction for
  87200. */
  87201. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87202. /**
  87203. * Called by the particle System when the position is computed for the created particle.
  87204. * @param worldMatrix is the world matrix of the particle system
  87205. * @param positionToUpdate is the position vector to update with the result
  87206. * @param particle is the particle we are computed the position for
  87207. */
  87208. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87209. /**
  87210. * Clones the current emitter and returns a copy of it
  87211. * @returns the new emitter
  87212. */
  87213. clone(): PointParticleEmitter;
  87214. /**
  87215. * Called by the GPUParticleSystem to setup the update shader
  87216. * @param effect defines the update shader
  87217. */
  87218. applyToShader(effect: Effect): void;
  87219. /**
  87220. * Returns a string to use to update the GPU particles update shader
  87221. * @returns a string containng the defines string
  87222. */
  87223. getEffectDefines(): string;
  87224. /**
  87225. * Returns the string "PointParticleEmitter"
  87226. * @returns a string containing the class name
  87227. */
  87228. getClassName(): string;
  87229. /**
  87230. * Serializes the particle system to a JSON object.
  87231. * @returns the JSON object
  87232. */
  87233. serialize(): any;
  87234. /**
  87235. * Parse properties from a JSON object
  87236. * @param serializationObject defines the JSON object
  87237. */
  87238. parse(serializationObject: any): void;
  87239. }
  87240. }
  87241. declare module BABYLON {
  87242. /**
  87243. * Particle emitter emitting particles from the inside of a sphere.
  87244. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  87245. */
  87246. export class SphereParticleEmitter implements IParticleEmitterType {
  87247. /**
  87248. * The radius of the emission sphere.
  87249. */
  87250. radius: number;
  87251. /**
  87252. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87253. */
  87254. radiusRange: number;
  87255. /**
  87256. * How much to randomize the particle direction [0-1].
  87257. */
  87258. directionRandomizer: number;
  87259. /**
  87260. * Creates a new instance SphereParticleEmitter
  87261. * @param radius the radius of the emission sphere (1 by default)
  87262. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87263. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87264. */
  87265. constructor(
  87266. /**
  87267. * The radius of the emission sphere.
  87268. */
  87269. radius?: number,
  87270. /**
  87271. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87272. */
  87273. radiusRange?: number,
  87274. /**
  87275. * How much to randomize the particle direction [0-1].
  87276. */
  87277. directionRandomizer?: number);
  87278. /**
  87279. * Called by the particle System when the direction is computed for the created particle.
  87280. * @param worldMatrix is the world matrix of the particle system
  87281. * @param directionToUpdate is the direction vector to update with the result
  87282. * @param particle is the particle we are computed the direction for
  87283. */
  87284. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87285. /**
  87286. * Called by the particle System when the position is computed for the created particle.
  87287. * @param worldMatrix is the world matrix of the particle system
  87288. * @param positionToUpdate is the position vector to update with the result
  87289. * @param particle is the particle we are computed the position for
  87290. */
  87291. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87292. /**
  87293. * Clones the current emitter and returns a copy of it
  87294. * @returns the new emitter
  87295. */
  87296. clone(): SphereParticleEmitter;
  87297. /**
  87298. * Called by the GPUParticleSystem to setup the update shader
  87299. * @param effect defines the update shader
  87300. */
  87301. applyToShader(effect: Effect): void;
  87302. /**
  87303. * Returns a string to use to update the GPU particles update shader
  87304. * @returns a string containng the defines string
  87305. */
  87306. getEffectDefines(): string;
  87307. /**
  87308. * Returns the string "SphereParticleEmitter"
  87309. * @returns a string containing the class name
  87310. */
  87311. getClassName(): string;
  87312. /**
  87313. * Serializes the particle system to a JSON object.
  87314. * @returns the JSON object
  87315. */
  87316. serialize(): any;
  87317. /**
  87318. * Parse properties from a JSON object
  87319. * @param serializationObject defines the JSON object
  87320. */
  87321. parse(serializationObject: any): void;
  87322. }
  87323. /**
  87324. * Particle emitter emitting particles from the inside of a sphere.
  87325. * It emits the particles randomly between two vectors.
  87326. */
  87327. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87328. /**
  87329. * The min limit of the emission direction.
  87330. */
  87331. direction1: Vector3;
  87332. /**
  87333. * The max limit of the emission direction.
  87334. */
  87335. direction2: Vector3;
  87336. /**
  87337. * Creates a new instance SphereDirectedParticleEmitter
  87338. * @param radius the radius of the emission sphere (1 by default)
  87339. * @param direction1 the min limit of the emission direction (up vector by default)
  87340. * @param direction2 the max limit of the emission direction (up vector by default)
  87341. */
  87342. constructor(radius?: number,
  87343. /**
  87344. * The min limit of the emission direction.
  87345. */
  87346. direction1?: Vector3,
  87347. /**
  87348. * The max limit of the emission direction.
  87349. */
  87350. direction2?: Vector3);
  87351. /**
  87352. * Called by the particle System when the direction is computed for the created particle.
  87353. * @param worldMatrix is the world matrix of the particle system
  87354. * @param directionToUpdate is the direction vector to update with the result
  87355. * @param particle is the particle we are computed the direction for
  87356. */
  87357. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87358. /**
  87359. * Clones the current emitter and returns a copy of it
  87360. * @returns the new emitter
  87361. */
  87362. clone(): SphereDirectedParticleEmitter;
  87363. /**
  87364. * Called by the GPUParticleSystem to setup the update shader
  87365. * @param effect defines the update shader
  87366. */
  87367. applyToShader(effect: Effect): void;
  87368. /**
  87369. * Returns a string to use to update the GPU particles update shader
  87370. * @returns a string containng the defines string
  87371. */
  87372. getEffectDefines(): string;
  87373. /**
  87374. * Returns the string "SphereDirectedParticleEmitter"
  87375. * @returns a string containing the class name
  87376. */
  87377. getClassName(): string;
  87378. /**
  87379. * Serializes the particle system to a JSON object.
  87380. * @returns the JSON object
  87381. */
  87382. serialize(): any;
  87383. /**
  87384. * Parse properties from a JSON object
  87385. * @param serializationObject defines the JSON object
  87386. */
  87387. parse(serializationObject: any): void;
  87388. }
  87389. }
  87390. declare module BABYLON {
  87391. /**
  87392. * Interface representing a particle system in Babylon.js.
  87393. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87394. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87395. */
  87396. export interface IParticleSystem {
  87397. /**
  87398. * List of animations used by the particle system.
  87399. */
  87400. animations: Animation[];
  87401. /**
  87402. * The id of the Particle system.
  87403. */
  87404. id: string;
  87405. /**
  87406. * The name of the Particle system.
  87407. */
  87408. name: string;
  87409. /**
  87410. * The emitter represents the Mesh or position we are attaching the particle system to.
  87411. */
  87412. emitter: Nullable<AbstractMesh | Vector3>;
  87413. /**
  87414. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87415. */
  87416. isBillboardBased: boolean;
  87417. /**
  87418. * The rendering group used by the Particle system to chose when to render.
  87419. */
  87420. renderingGroupId: number;
  87421. /**
  87422. * The layer mask we are rendering the particles through.
  87423. */
  87424. layerMask: number;
  87425. /**
  87426. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87427. */
  87428. updateSpeed: number;
  87429. /**
  87430. * The amount of time the particle system is running (depends of the overall update speed).
  87431. */
  87432. targetStopDuration: number;
  87433. /**
  87434. * The texture used to render each particle. (this can be a spritesheet)
  87435. */
  87436. particleTexture: Nullable<Texture>;
  87437. /**
  87438. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87439. */
  87440. blendMode: number;
  87441. /**
  87442. * Minimum life time of emitting particles.
  87443. */
  87444. minLifeTime: number;
  87445. /**
  87446. * Maximum life time of emitting particles.
  87447. */
  87448. maxLifeTime: number;
  87449. /**
  87450. * Minimum Size of emitting particles.
  87451. */
  87452. minSize: number;
  87453. /**
  87454. * Maximum Size of emitting particles.
  87455. */
  87456. maxSize: number;
  87457. /**
  87458. * Minimum scale of emitting particles on X axis.
  87459. */
  87460. minScaleX: number;
  87461. /**
  87462. * Maximum scale of emitting particles on X axis.
  87463. */
  87464. maxScaleX: number;
  87465. /**
  87466. * Minimum scale of emitting particles on Y axis.
  87467. */
  87468. minScaleY: number;
  87469. /**
  87470. * Maximum scale of emitting particles on Y axis.
  87471. */
  87472. maxScaleY: number;
  87473. /**
  87474. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87475. */
  87476. color1: Color4;
  87477. /**
  87478. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87479. */
  87480. color2: Color4;
  87481. /**
  87482. * Color the particle will have at the end of its lifetime.
  87483. */
  87484. colorDead: Color4;
  87485. /**
  87486. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87487. */
  87488. emitRate: number;
  87489. /**
  87490. * You can use gravity if you want to give an orientation to your particles.
  87491. */
  87492. gravity: Vector3;
  87493. /**
  87494. * Minimum power of emitting particles.
  87495. */
  87496. minEmitPower: number;
  87497. /**
  87498. * Maximum power of emitting particles.
  87499. */
  87500. maxEmitPower: number;
  87501. /**
  87502. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87503. */
  87504. minAngularSpeed: number;
  87505. /**
  87506. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87507. */
  87508. maxAngularSpeed: number;
  87509. /**
  87510. * Gets or sets the minimal initial rotation in radians.
  87511. */
  87512. minInitialRotation: number;
  87513. /**
  87514. * Gets or sets the maximal initial rotation in radians.
  87515. */
  87516. maxInitialRotation: number;
  87517. /**
  87518. * The particle emitter type defines the emitter used by the particle system.
  87519. * It can be for example box, sphere, or cone...
  87520. */
  87521. particleEmitterType: Nullable<IParticleEmitterType>;
  87522. /**
  87523. * Defines the delay in milliseconds before starting the system (0 by default)
  87524. */
  87525. startDelay: number;
  87526. /**
  87527. * 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
  87528. */
  87529. preWarmCycles: number;
  87530. /**
  87531. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87532. */
  87533. preWarmStepOffset: number;
  87534. /**
  87535. * 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)
  87536. */
  87537. spriteCellChangeSpeed: number;
  87538. /**
  87539. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87540. */
  87541. startSpriteCellID: number;
  87542. /**
  87543. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87544. */
  87545. endSpriteCellID: number;
  87546. /**
  87547. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87548. */
  87549. spriteCellWidth: number;
  87550. /**
  87551. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87552. */
  87553. spriteCellHeight: number;
  87554. /**
  87555. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87556. */
  87557. spriteRandomStartCell: boolean;
  87558. /**
  87559. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87560. */
  87561. isAnimationSheetEnabled: boolean;
  87562. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87563. translationPivot: Vector2;
  87564. /**
  87565. * Gets or sets a texture used to add random noise to particle positions
  87566. */
  87567. noiseTexture: Nullable<BaseTexture>;
  87568. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87569. noiseStrength: Vector3;
  87570. /**
  87571. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87572. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87573. */
  87574. billboardMode: number;
  87575. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87576. limitVelocityDamping: number;
  87577. /**
  87578. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87579. */
  87580. beginAnimationOnStart: boolean;
  87581. /**
  87582. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87583. */
  87584. beginAnimationFrom: number;
  87585. /**
  87586. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87587. */
  87588. beginAnimationTo: number;
  87589. /**
  87590. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87591. */
  87592. beginAnimationLoop: boolean;
  87593. /**
  87594. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87595. */
  87596. disposeOnStop: boolean;
  87597. /**
  87598. * Gets the maximum number of particles active at the same time.
  87599. * @returns The max number of active particles.
  87600. */
  87601. getCapacity(): number;
  87602. /**
  87603. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87604. * @returns True if it has been started, otherwise false.
  87605. */
  87606. isStarted(): boolean;
  87607. /**
  87608. * Animates the particle system for this frame.
  87609. */
  87610. animate(): void;
  87611. /**
  87612. * Renders the particle system in its current state.
  87613. * @returns the current number of particles
  87614. */
  87615. render(): number;
  87616. /**
  87617. * Dispose the particle system and frees its associated resources.
  87618. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87619. */
  87620. dispose(disposeTexture?: boolean): void;
  87621. /**
  87622. * Clones the particle system.
  87623. * @param name The name of the cloned object
  87624. * @param newEmitter The new emitter to use
  87625. * @returns the cloned particle system
  87626. */
  87627. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87628. /**
  87629. * Serializes the particle system to a JSON object.
  87630. * @returns the JSON object
  87631. */
  87632. serialize(): any;
  87633. /**
  87634. * Rebuild the particle system
  87635. */
  87636. rebuild(): void;
  87637. /**
  87638. * Starts the particle system and begins to emit
  87639. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87640. */
  87641. start(delay?: number): void;
  87642. /**
  87643. * Stops the particle system.
  87644. */
  87645. stop(): void;
  87646. /**
  87647. * Remove all active particles
  87648. */
  87649. reset(): void;
  87650. /**
  87651. * Is this system ready to be used/rendered
  87652. * @return true if the system is ready
  87653. */
  87654. isReady(): boolean;
  87655. /**
  87656. * Adds a new color gradient
  87657. * @param gradient defines the gradient to use (between 0 and 1)
  87658. * @param color1 defines the color to affect to the specified gradient
  87659. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87660. * @returns the current particle system
  87661. */
  87662. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87663. /**
  87664. * Remove a specific color gradient
  87665. * @param gradient defines the gradient to remove
  87666. * @returns the current particle system
  87667. */
  87668. removeColorGradient(gradient: number): IParticleSystem;
  87669. /**
  87670. * Adds a new size gradient
  87671. * @param gradient defines the gradient to use (between 0 and 1)
  87672. * @param factor defines the size factor to affect to the specified gradient
  87673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87674. * @returns the current particle system
  87675. */
  87676. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87677. /**
  87678. * Remove a specific size gradient
  87679. * @param gradient defines the gradient to remove
  87680. * @returns the current particle system
  87681. */
  87682. removeSizeGradient(gradient: number): IParticleSystem;
  87683. /**
  87684. * Gets the current list of color gradients.
  87685. * You must use addColorGradient and removeColorGradient to udpate this list
  87686. * @returns the list of color gradients
  87687. */
  87688. getColorGradients(): Nullable<Array<ColorGradient>>;
  87689. /**
  87690. * Gets the current list of size gradients.
  87691. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87692. * @returns the list of size gradients
  87693. */
  87694. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87695. /**
  87696. * Gets the current list of angular speed gradients.
  87697. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87698. * @returns the list of angular speed gradients
  87699. */
  87700. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87701. /**
  87702. * Adds a new angular speed gradient
  87703. * @param gradient defines the gradient to use (between 0 and 1)
  87704. * @param factor defines the angular speed to affect to the specified gradient
  87705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87706. * @returns the current particle system
  87707. */
  87708. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87709. /**
  87710. * Remove a specific angular speed gradient
  87711. * @param gradient defines the gradient to remove
  87712. * @returns the current particle system
  87713. */
  87714. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87715. /**
  87716. * Gets the current list of velocity gradients.
  87717. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87718. * @returns the list of velocity gradients
  87719. */
  87720. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87721. /**
  87722. * Adds a new velocity gradient
  87723. * @param gradient defines the gradient to use (between 0 and 1)
  87724. * @param factor defines the velocity to affect to the specified gradient
  87725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87726. * @returns the current particle system
  87727. */
  87728. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87729. /**
  87730. * Remove a specific velocity gradient
  87731. * @param gradient defines the gradient to remove
  87732. * @returns the current particle system
  87733. */
  87734. removeVelocityGradient(gradient: number): IParticleSystem;
  87735. /**
  87736. * Gets the current list of limit velocity gradients.
  87737. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87738. * @returns the list of limit velocity gradients
  87739. */
  87740. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87741. /**
  87742. * Adds a new limit velocity gradient
  87743. * @param gradient defines the gradient to use (between 0 and 1)
  87744. * @param factor defines the limit velocity to affect to the specified gradient
  87745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87746. * @returns the current particle system
  87747. */
  87748. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87749. /**
  87750. * Remove a specific limit velocity gradient
  87751. * @param gradient defines the gradient to remove
  87752. * @returns the current particle system
  87753. */
  87754. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87755. /**
  87756. * Adds a new drag gradient
  87757. * @param gradient defines the gradient to use (between 0 and 1)
  87758. * @param factor defines the drag to affect to the specified gradient
  87759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87760. * @returns the current particle system
  87761. */
  87762. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87763. /**
  87764. * Remove a specific drag gradient
  87765. * @param gradient defines the gradient to remove
  87766. * @returns the current particle system
  87767. */
  87768. removeDragGradient(gradient: number): IParticleSystem;
  87769. /**
  87770. * Gets the current list of drag gradients.
  87771. * You must use addDragGradient and removeDragGradient to udpate this list
  87772. * @returns the list of drag gradients
  87773. */
  87774. getDragGradients(): Nullable<Array<FactorGradient>>;
  87775. /**
  87776. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87777. * @param gradient defines the gradient to use (between 0 and 1)
  87778. * @param factor defines the emit rate to affect to the specified gradient
  87779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87780. * @returns the current particle system
  87781. */
  87782. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87783. /**
  87784. * Remove a specific emit rate gradient
  87785. * @param gradient defines the gradient to remove
  87786. * @returns the current particle system
  87787. */
  87788. removeEmitRateGradient(gradient: number): IParticleSystem;
  87789. /**
  87790. * Gets the current list of emit rate gradients.
  87791. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87792. * @returns the list of emit rate gradients
  87793. */
  87794. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87795. /**
  87796. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87797. * @param gradient defines the gradient to use (between 0 and 1)
  87798. * @param factor defines the start size to affect to the specified gradient
  87799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87800. * @returns the current particle system
  87801. */
  87802. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87803. /**
  87804. * Remove a specific start size gradient
  87805. * @param gradient defines the gradient to remove
  87806. * @returns the current particle system
  87807. */
  87808. removeStartSizeGradient(gradient: number): IParticleSystem;
  87809. /**
  87810. * Gets the current list of start size gradients.
  87811. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87812. * @returns the list of start size gradients
  87813. */
  87814. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87815. /**
  87816. * Adds a new life time gradient
  87817. * @param gradient defines the gradient to use (between 0 and 1)
  87818. * @param factor defines the life time factor to affect to the specified gradient
  87819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87820. * @returns the current particle system
  87821. */
  87822. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87823. /**
  87824. * Remove a specific life time gradient
  87825. * @param gradient defines the gradient to remove
  87826. * @returns the current particle system
  87827. */
  87828. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87829. /**
  87830. * Gets the current list of life time gradients.
  87831. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87832. * @returns the list of life time gradients
  87833. */
  87834. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87835. /**
  87836. * Gets the current list of color gradients.
  87837. * You must use addColorGradient and removeColorGradient to udpate this list
  87838. * @returns the list of color gradients
  87839. */
  87840. getColorGradients(): Nullable<Array<ColorGradient>>;
  87841. /**
  87842. * Adds a new ramp gradient used to remap particle colors
  87843. * @param gradient defines the gradient to use (between 0 and 1)
  87844. * @param color defines the color to affect to the specified gradient
  87845. * @returns the current particle system
  87846. */
  87847. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87848. /**
  87849. * Gets the current list of ramp gradients.
  87850. * You must use addRampGradient and removeRampGradient to udpate this list
  87851. * @returns the list of ramp gradients
  87852. */
  87853. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87854. /** Gets or sets a boolean indicating that ramp gradients must be used
  87855. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87856. */
  87857. useRampGradients: boolean;
  87858. /**
  87859. * Adds a new color remap gradient
  87860. * @param gradient defines the gradient to use (between 0 and 1)
  87861. * @param min defines the color remap minimal range
  87862. * @param max defines the color remap maximal range
  87863. * @returns the current particle system
  87864. */
  87865. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87866. /**
  87867. * Gets the current list of color remap gradients.
  87868. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87869. * @returns the list of color remap gradients
  87870. */
  87871. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87872. /**
  87873. * Adds a new alpha remap gradient
  87874. * @param gradient defines the gradient to use (between 0 and 1)
  87875. * @param min defines the alpha remap minimal range
  87876. * @param max defines the alpha remap maximal range
  87877. * @returns the current particle system
  87878. */
  87879. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87880. /**
  87881. * Gets the current list of alpha remap gradients.
  87882. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87883. * @returns the list of alpha remap gradients
  87884. */
  87885. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87886. /**
  87887. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87888. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87889. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87890. * @returns the emitter
  87891. */
  87892. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87893. /**
  87894. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87895. * @param radius The radius of the hemisphere to emit from
  87896. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87897. * @returns the emitter
  87898. */
  87899. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87900. /**
  87901. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87902. * @param radius The radius of the sphere to emit from
  87903. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87904. * @returns the emitter
  87905. */
  87906. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87907. /**
  87908. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87909. * @param radius The radius of the sphere to emit from
  87910. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87911. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87912. * @returns the emitter
  87913. */
  87914. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87915. /**
  87916. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87917. * @param radius The radius of the emission cylinder
  87918. * @param height The height of the emission cylinder
  87919. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87920. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87921. * @returns the emitter
  87922. */
  87923. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87924. /**
  87925. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87926. * @param radius The radius of the cylinder to emit from
  87927. * @param height The height of the emission cylinder
  87928. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87929. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87930. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87931. * @returns the emitter
  87932. */
  87933. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87934. /**
  87935. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87936. * @param radius The radius of the cone to emit from
  87937. * @param angle The base angle of the cone
  87938. * @returns the emitter
  87939. */
  87940. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87941. /**
  87942. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87943. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87944. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87945. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87946. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87947. * @returns the emitter
  87948. */
  87949. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87950. /**
  87951. * Get hosting scene
  87952. * @returns the scene
  87953. */
  87954. getScene(): Scene;
  87955. }
  87956. }
  87957. declare module BABYLON {
  87958. /**
  87959. * Creates an instance based on a source mesh.
  87960. */
  87961. export class InstancedMesh extends AbstractMesh {
  87962. private _sourceMesh;
  87963. private _currentLOD;
  87964. /** @hidden */
  87965. _indexInSourceMeshInstanceArray: number;
  87966. constructor(name: string, source: Mesh);
  87967. /**
  87968. * Returns the string "InstancedMesh".
  87969. */
  87970. getClassName(): string;
  87971. /** Gets the list of lights affecting that mesh */
  87972. readonly lightSources: Light[];
  87973. _resyncLightSources(): void;
  87974. _resyncLightSource(light: Light): void;
  87975. _removeLightSource(light: Light, dispose: boolean): void;
  87976. /**
  87977. * If the source mesh receives shadows
  87978. */
  87979. readonly receiveShadows: boolean;
  87980. /**
  87981. * The material of the source mesh
  87982. */
  87983. readonly material: Nullable<Material>;
  87984. /**
  87985. * Visibility of the source mesh
  87986. */
  87987. readonly visibility: number;
  87988. /**
  87989. * Skeleton of the source mesh
  87990. */
  87991. readonly skeleton: Nullable<Skeleton>;
  87992. /**
  87993. * Rendering ground id of the source mesh
  87994. */
  87995. renderingGroupId: number;
  87996. /**
  87997. * Returns the total number of vertices (integer).
  87998. */
  87999. getTotalVertices(): number;
  88000. /**
  88001. * Returns a positive integer : the total number of indices in this mesh geometry.
  88002. * @returns the numner of indices or zero if the mesh has no geometry.
  88003. */
  88004. getTotalIndices(): number;
  88005. /**
  88006. * The source mesh of the instance
  88007. */
  88008. readonly sourceMesh: Mesh;
  88009. /**
  88010. * Is this node ready to be used/rendered
  88011. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88012. * @return {boolean} is it ready
  88013. */
  88014. isReady(completeCheck?: boolean): boolean;
  88015. /**
  88016. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88017. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88018. * @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.
  88019. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88020. */
  88021. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88022. /**
  88023. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88024. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88025. * The `data` are either a numeric array either a Float32Array.
  88026. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88027. * 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).
  88028. * Note that a new underlying VertexBuffer object is created each call.
  88029. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88030. *
  88031. * Possible `kind` values :
  88032. * - VertexBuffer.PositionKind
  88033. * - VertexBuffer.UVKind
  88034. * - VertexBuffer.UV2Kind
  88035. * - VertexBuffer.UV3Kind
  88036. * - VertexBuffer.UV4Kind
  88037. * - VertexBuffer.UV5Kind
  88038. * - VertexBuffer.UV6Kind
  88039. * - VertexBuffer.ColorKind
  88040. * - VertexBuffer.MatricesIndicesKind
  88041. * - VertexBuffer.MatricesIndicesExtraKind
  88042. * - VertexBuffer.MatricesWeightsKind
  88043. * - VertexBuffer.MatricesWeightsExtraKind
  88044. *
  88045. * Returns the Mesh.
  88046. */
  88047. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88048. /**
  88049. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88050. * If the mesh has no geometry, it is simply returned as it is.
  88051. * The `data` are either a numeric array either a Float32Array.
  88052. * No new underlying VertexBuffer object is created.
  88053. * 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.
  88054. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88055. *
  88056. * Possible `kind` values :
  88057. * - VertexBuffer.PositionKind
  88058. * - VertexBuffer.UVKind
  88059. * - VertexBuffer.UV2Kind
  88060. * - VertexBuffer.UV3Kind
  88061. * - VertexBuffer.UV4Kind
  88062. * - VertexBuffer.UV5Kind
  88063. * - VertexBuffer.UV6Kind
  88064. * - VertexBuffer.ColorKind
  88065. * - VertexBuffer.MatricesIndicesKind
  88066. * - VertexBuffer.MatricesIndicesExtraKind
  88067. * - VertexBuffer.MatricesWeightsKind
  88068. * - VertexBuffer.MatricesWeightsExtraKind
  88069. *
  88070. * Returns the Mesh.
  88071. */
  88072. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88073. /**
  88074. * Sets the mesh indices.
  88075. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88076. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88077. * This method creates a new index buffer each call.
  88078. * Returns the Mesh.
  88079. */
  88080. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88081. /**
  88082. * Boolean : True if the mesh owns the requested kind of data.
  88083. */
  88084. isVerticesDataPresent(kind: string): boolean;
  88085. /**
  88086. * Returns an array of indices (IndicesArray).
  88087. */
  88088. getIndices(): Nullable<IndicesArray>;
  88089. readonly _positions: Nullable<Vector3[]>;
  88090. /**
  88091. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88092. * This means the mesh underlying bounding box and sphere are recomputed.
  88093. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88094. * @returns the current mesh
  88095. */
  88096. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88097. /** @hidden */
  88098. _preActivate(): InstancedMesh;
  88099. /** @hidden */
  88100. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88101. /** @hidden */
  88102. _postActivate(): void;
  88103. getWorldMatrix(): Matrix;
  88104. readonly isAnInstance: boolean;
  88105. /**
  88106. * Returns the current associated LOD AbstractMesh.
  88107. */
  88108. getLOD(camera: Camera): AbstractMesh;
  88109. /** @hidden */
  88110. _syncSubMeshes(): InstancedMesh;
  88111. /** @hidden */
  88112. _generatePointsArray(): boolean;
  88113. /**
  88114. * Creates a new InstancedMesh from the current mesh.
  88115. * - name (string) : the cloned mesh name
  88116. * - newParent (optional Node) : the optional Node to parent the clone to.
  88117. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88118. *
  88119. * Returns the clone.
  88120. */
  88121. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88122. /**
  88123. * Disposes the InstancedMesh.
  88124. * Returns nothing.
  88125. */
  88126. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88127. }
  88128. interface Mesh {
  88129. /**
  88130. * Register a custom buffer that will be instanced
  88131. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88132. * @param kind defines the buffer kind
  88133. * @param stride defines the stride in floats
  88134. */
  88135. registerInstancedBuffer(kind: string, stride: number): void;
  88136. /** @hidden */
  88137. _userInstancedBuffersStorage: {
  88138. data: {
  88139. [key: string]: Float32Array;
  88140. };
  88141. sizes: {
  88142. [key: string]: number;
  88143. };
  88144. vertexBuffers: {
  88145. [key: string]: Nullable<VertexBuffer>;
  88146. };
  88147. strides: {
  88148. [key: string]: number;
  88149. };
  88150. };
  88151. }
  88152. interface AbstractMesh {
  88153. /**
  88154. * Object used to store instanced buffers defined by user
  88155. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88156. */
  88157. instancedBuffers: {
  88158. [key: string]: any;
  88159. };
  88160. }
  88161. }
  88162. declare module BABYLON {
  88163. /**
  88164. * Defines the options associated with the creation of a shader material.
  88165. */
  88166. export interface IShaderMaterialOptions {
  88167. /**
  88168. * Does the material work in alpha blend mode
  88169. */
  88170. needAlphaBlending: boolean;
  88171. /**
  88172. * Does the material work in alpha test mode
  88173. */
  88174. needAlphaTesting: boolean;
  88175. /**
  88176. * The list of attribute names used in the shader
  88177. */
  88178. attributes: string[];
  88179. /**
  88180. * The list of unifrom names used in the shader
  88181. */
  88182. uniforms: string[];
  88183. /**
  88184. * The list of UBO names used in the shader
  88185. */
  88186. uniformBuffers: string[];
  88187. /**
  88188. * The list of sampler names used in the shader
  88189. */
  88190. samplers: string[];
  88191. /**
  88192. * The list of defines used in the shader
  88193. */
  88194. defines: string[];
  88195. }
  88196. /**
  88197. * 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.
  88198. *
  88199. * This returned material effects how the mesh will look based on the code in the shaders.
  88200. *
  88201. * @see http://doc.babylonjs.com/how_to/shader_material
  88202. */
  88203. export class ShaderMaterial extends Material {
  88204. private _shaderPath;
  88205. private _options;
  88206. private _textures;
  88207. private _textureArrays;
  88208. private _floats;
  88209. private _ints;
  88210. private _floatsArrays;
  88211. private _colors3;
  88212. private _colors3Arrays;
  88213. private _colors4;
  88214. private _colors4Arrays;
  88215. private _vectors2;
  88216. private _vectors3;
  88217. private _vectors4;
  88218. private _matrices;
  88219. private _matrixArrays;
  88220. private _matrices3x3;
  88221. private _matrices2x2;
  88222. private _vectors2Arrays;
  88223. private _vectors3Arrays;
  88224. private _vectors4Arrays;
  88225. private _cachedWorldViewMatrix;
  88226. private _cachedWorldViewProjectionMatrix;
  88227. private _renderId;
  88228. private _multiview;
  88229. /**
  88230. * Instantiate a new shader material.
  88231. * 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.
  88232. * This returned material effects how the mesh will look based on the code in the shaders.
  88233. * @see http://doc.babylonjs.com/how_to/shader_material
  88234. * @param name Define the name of the material in the scene
  88235. * @param scene Define the scene the material belongs to
  88236. * @param shaderPath Defines the route to the shader code in one of three ways:
  88237. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88238. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88239. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88240. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88241. * @param options Define the options used to create the shader
  88242. */
  88243. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88244. /**
  88245. * Gets the shader path used to define the shader code
  88246. * It can be modified to trigger a new compilation
  88247. */
  88248. /**
  88249. * Sets the shader path used to define the shader code
  88250. * It can be modified to trigger a new compilation
  88251. */
  88252. shaderPath: any;
  88253. /**
  88254. * Gets the options used to compile the shader.
  88255. * They can be modified to trigger a new compilation
  88256. */
  88257. readonly options: IShaderMaterialOptions;
  88258. /**
  88259. * Gets the current class name of the material e.g. "ShaderMaterial"
  88260. * Mainly use in serialization.
  88261. * @returns the class name
  88262. */
  88263. getClassName(): string;
  88264. /**
  88265. * Specifies if the material will require alpha blending
  88266. * @returns a boolean specifying if alpha blending is needed
  88267. */
  88268. needAlphaBlending(): boolean;
  88269. /**
  88270. * Specifies if this material should be rendered in alpha test mode
  88271. * @returns a boolean specifying if an alpha test is needed.
  88272. */
  88273. needAlphaTesting(): boolean;
  88274. private _checkUniform;
  88275. /**
  88276. * Set a texture in the shader.
  88277. * @param name Define the name of the uniform samplers as defined in the shader
  88278. * @param texture Define the texture to bind to this sampler
  88279. * @return the material itself allowing "fluent" like uniform updates
  88280. */
  88281. setTexture(name: string, texture: Texture): ShaderMaterial;
  88282. /**
  88283. * Set a texture array in the shader.
  88284. * @param name Define the name of the uniform sampler array as defined in the shader
  88285. * @param textures Define the list of textures to bind to this sampler
  88286. * @return the material itself allowing "fluent" like uniform updates
  88287. */
  88288. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88289. /**
  88290. * Set a float in the shader.
  88291. * @param name Define the name of the uniform as defined in the shader
  88292. * @param value Define the value to give to the uniform
  88293. * @return the material itself allowing "fluent" like uniform updates
  88294. */
  88295. setFloat(name: string, value: number): ShaderMaterial;
  88296. /**
  88297. * Set a int in the shader.
  88298. * @param name Define the name of the uniform as defined in the shader
  88299. * @param value Define the value to give to the uniform
  88300. * @return the material itself allowing "fluent" like uniform updates
  88301. */
  88302. setInt(name: string, value: number): ShaderMaterial;
  88303. /**
  88304. * Set an array of floats in the shader.
  88305. * @param name Define the name of the uniform as defined in the shader
  88306. * @param value Define the value to give to the uniform
  88307. * @return the material itself allowing "fluent" like uniform updates
  88308. */
  88309. setFloats(name: string, value: number[]): ShaderMaterial;
  88310. /**
  88311. * Set a vec3 in the shader from a Color3.
  88312. * @param name Define the name of the uniform as defined in the shader
  88313. * @param value Define the value to give to the uniform
  88314. * @return the material itself allowing "fluent" like uniform updates
  88315. */
  88316. setColor3(name: string, value: Color3): ShaderMaterial;
  88317. /**
  88318. * Set a vec3 array in the shader from a Color3 array.
  88319. * @param name Define the name of the uniform as defined in the shader
  88320. * @param value Define the value to give to the uniform
  88321. * @return the material itself allowing "fluent" like uniform updates
  88322. */
  88323. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88324. /**
  88325. * Set a vec4 in the shader from a Color4.
  88326. * @param name Define the name of the uniform as defined in the shader
  88327. * @param value Define the value to give to the uniform
  88328. * @return the material itself allowing "fluent" like uniform updates
  88329. */
  88330. setColor4(name: string, value: Color4): ShaderMaterial;
  88331. /**
  88332. * Set a vec4 array in the shader from a Color4 array.
  88333. * @param name Define the name of the uniform as defined in the shader
  88334. * @param value Define the value to give to the uniform
  88335. * @return the material itself allowing "fluent" like uniform updates
  88336. */
  88337. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88338. /**
  88339. * Set a vec2 in the shader from a Vector2.
  88340. * @param name Define the name of the uniform as defined in the shader
  88341. * @param value Define the value to give to the uniform
  88342. * @return the material itself allowing "fluent" like uniform updates
  88343. */
  88344. setVector2(name: string, value: Vector2): ShaderMaterial;
  88345. /**
  88346. * Set a vec3 in the shader from a Vector3.
  88347. * @param name Define the name of the uniform as defined in the shader
  88348. * @param value Define the value to give to the uniform
  88349. * @return the material itself allowing "fluent" like uniform updates
  88350. */
  88351. setVector3(name: string, value: Vector3): ShaderMaterial;
  88352. /**
  88353. * Set a vec4 in the shader from a Vector4.
  88354. * @param name Define the name of the uniform as defined in the shader
  88355. * @param value Define the value to give to the uniform
  88356. * @return the material itself allowing "fluent" like uniform updates
  88357. */
  88358. setVector4(name: string, value: Vector4): ShaderMaterial;
  88359. /**
  88360. * Set a mat4 in the shader from a Matrix.
  88361. * @param name Define the name of the uniform as defined in the shader
  88362. * @param value Define the value to give to the uniform
  88363. * @return the material itself allowing "fluent" like uniform updates
  88364. */
  88365. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88366. /**
  88367. * Set a float32Array in the shader from a matrix array.
  88368. * @param name Define the name of the uniform as defined in the shader
  88369. * @param value Define the value to give to the uniform
  88370. * @return the material itself allowing "fluent" like uniform updates
  88371. */
  88372. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88373. /**
  88374. * Set a mat3 in the shader from a Float32Array.
  88375. * @param name Define the name of the uniform as defined in the shader
  88376. * @param value Define the value to give to the uniform
  88377. * @return the material itself allowing "fluent" like uniform updates
  88378. */
  88379. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88380. /**
  88381. * Set a mat2 in the shader from a Float32Array.
  88382. * @param name Define the name of the uniform as defined in the shader
  88383. * @param value Define the value to give to the uniform
  88384. * @return the material itself allowing "fluent" like uniform updates
  88385. */
  88386. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88387. /**
  88388. * Set a vec2 array in the shader from a number array.
  88389. * @param name Define the name of the uniform as defined in the shader
  88390. * @param value Define the value to give to the uniform
  88391. * @return the material itself allowing "fluent" like uniform updates
  88392. */
  88393. setArray2(name: string, value: number[]): ShaderMaterial;
  88394. /**
  88395. * Set a vec3 array in the shader from a number array.
  88396. * @param name Define the name of the uniform as defined in the shader
  88397. * @param value Define the value to give to the uniform
  88398. * @return the material itself allowing "fluent" like uniform updates
  88399. */
  88400. setArray3(name: string, value: number[]): ShaderMaterial;
  88401. /**
  88402. * Set a vec4 array in the shader from a number array.
  88403. * @param name Define the name of the uniform as defined in the shader
  88404. * @param value Define the value to give to the uniform
  88405. * @return the material itself allowing "fluent" like uniform updates
  88406. */
  88407. setArray4(name: string, value: number[]): ShaderMaterial;
  88408. private _checkCache;
  88409. /**
  88410. * Specifies that the submesh is ready to be used
  88411. * @param mesh defines the mesh to check
  88412. * @param subMesh defines which submesh to check
  88413. * @param useInstances specifies that instances should be used
  88414. * @returns a boolean indicating that the submesh is ready or not
  88415. */
  88416. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88417. /**
  88418. * Checks if the material is ready to render the requested mesh
  88419. * @param mesh Define the mesh to render
  88420. * @param useInstances Define whether or not the material is used with instances
  88421. * @returns true if ready, otherwise false
  88422. */
  88423. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88424. /**
  88425. * Binds the world matrix to the material
  88426. * @param world defines the world transformation matrix
  88427. */
  88428. bindOnlyWorldMatrix(world: Matrix): void;
  88429. /**
  88430. * Binds the material to the mesh
  88431. * @param world defines the world transformation matrix
  88432. * @param mesh defines the mesh to bind the material to
  88433. */
  88434. bind(world: Matrix, mesh?: Mesh): void;
  88435. /**
  88436. * Gets the active textures from the material
  88437. * @returns an array of textures
  88438. */
  88439. getActiveTextures(): BaseTexture[];
  88440. /**
  88441. * Specifies if the material uses a texture
  88442. * @param texture defines the texture to check against the material
  88443. * @returns a boolean specifying if the material uses the texture
  88444. */
  88445. hasTexture(texture: BaseTexture): boolean;
  88446. /**
  88447. * Makes a duplicate of the material, and gives it a new name
  88448. * @param name defines the new name for the duplicated material
  88449. * @returns the cloned material
  88450. */
  88451. clone(name: string): ShaderMaterial;
  88452. /**
  88453. * Disposes the material
  88454. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88455. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88456. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88457. */
  88458. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88459. /**
  88460. * Serializes this material in a JSON representation
  88461. * @returns the serialized material object
  88462. */
  88463. serialize(): any;
  88464. /**
  88465. * Creates a shader material from parsed shader material data
  88466. * @param source defines the JSON represnetation of the material
  88467. * @param scene defines the hosting scene
  88468. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88469. * @returns a new material
  88470. */
  88471. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88472. }
  88473. }
  88474. declare module BABYLON {
  88475. /** @hidden */
  88476. export var colorPixelShader: {
  88477. name: string;
  88478. shader: string;
  88479. };
  88480. }
  88481. declare module BABYLON {
  88482. /** @hidden */
  88483. export var colorVertexShader: {
  88484. name: string;
  88485. shader: string;
  88486. };
  88487. }
  88488. declare module BABYLON {
  88489. /**
  88490. * Line mesh
  88491. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88492. */
  88493. export class LinesMesh extends Mesh {
  88494. /**
  88495. * If vertex color should be applied to the mesh
  88496. */
  88497. readonly useVertexColor?: boolean | undefined;
  88498. /**
  88499. * If vertex alpha should be applied to the mesh
  88500. */
  88501. readonly useVertexAlpha?: boolean | undefined;
  88502. /**
  88503. * Color of the line (Default: White)
  88504. */
  88505. color: Color3;
  88506. /**
  88507. * Alpha of the line (Default: 1)
  88508. */
  88509. alpha: number;
  88510. /**
  88511. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88512. * This margin is expressed in world space coordinates, so its value may vary.
  88513. * Default value is 0.1
  88514. */
  88515. intersectionThreshold: number;
  88516. private _colorShader;
  88517. private color4;
  88518. /**
  88519. * Creates a new LinesMesh
  88520. * @param name defines the name
  88521. * @param scene defines the hosting scene
  88522. * @param parent defines the parent mesh if any
  88523. * @param source defines the optional source LinesMesh used to clone data from
  88524. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88525. * When false, achieved by calling a clone(), also passing False.
  88526. * This will make creation of children, recursive.
  88527. * @param useVertexColor defines if this LinesMesh supports vertex color
  88528. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88529. */
  88530. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88531. /**
  88532. * If vertex color should be applied to the mesh
  88533. */
  88534. useVertexColor?: boolean | undefined,
  88535. /**
  88536. * If vertex alpha should be applied to the mesh
  88537. */
  88538. useVertexAlpha?: boolean | undefined);
  88539. private _addClipPlaneDefine;
  88540. private _removeClipPlaneDefine;
  88541. isReady(): boolean;
  88542. /**
  88543. * Returns the string "LineMesh"
  88544. */
  88545. getClassName(): string;
  88546. /**
  88547. * @hidden
  88548. */
  88549. /**
  88550. * @hidden
  88551. */
  88552. material: Material;
  88553. /**
  88554. * @hidden
  88555. */
  88556. readonly checkCollisions: boolean;
  88557. /** @hidden */
  88558. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88559. /** @hidden */
  88560. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88561. /**
  88562. * Disposes of the line mesh
  88563. * @param doNotRecurse If children should be disposed
  88564. */
  88565. dispose(doNotRecurse?: boolean): void;
  88566. /**
  88567. * Returns a new LineMesh object cloned from the current one.
  88568. */
  88569. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88570. /**
  88571. * Creates a new InstancedLinesMesh object from the mesh model.
  88572. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88573. * @param name defines the name of the new instance
  88574. * @returns a new InstancedLinesMesh
  88575. */
  88576. createInstance(name: string): InstancedLinesMesh;
  88577. }
  88578. /**
  88579. * Creates an instance based on a source LinesMesh
  88580. */
  88581. export class InstancedLinesMesh extends InstancedMesh {
  88582. /**
  88583. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88584. * This margin is expressed in world space coordinates, so its value may vary.
  88585. * Initilized with the intersectionThreshold value of the source LinesMesh
  88586. */
  88587. intersectionThreshold: number;
  88588. constructor(name: string, source: LinesMesh);
  88589. /**
  88590. * Returns the string "InstancedLinesMesh".
  88591. */
  88592. getClassName(): string;
  88593. }
  88594. }
  88595. declare module BABYLON {
  88596. /** @hidden */
  88597. export var linePixelShader: {
  88598. name: string;
  88599. shader: string;
  88600. };
  88601. }
  88602. declare module BABYLON {
  88603. /** @hidden */
  88604. export var lineVertexShader: {
  88605. name: string;
  88606. shader: string;
  88607. };
  88608. }
  88609. declare module BABYLON {
  88610. interface AbstractMesh {
  88611. /**
  88612. * Gets the edgesRenderer associated with the mesh
  88613. */
  88614. edgesRenderer: Nullable<EdgesRenderer>;
  88615. }
  88616. interface LinesMesh {
  88617. /**
  88618. * Enables the edge rendering mode on the mesh.
  88619. * This mode makes the mesh edges visible
  88620. * @param epsilon defines the maximal distance between two angles to detect a face
  88621. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88622. * @returns the currentAbstractMesh
  88623. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88624. */
  88625. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88626. }
  88627. interface InstancedLinesMesh {
  88628. /**
  88629. * Enables the edge rendering mode on the mesh.
  88630. * This mode makes the mesh edges visible
  88631. * @param epsilon defines the maximal distance between two angles to detect a face
  88632. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88633. * @returns the current InstancedLinesMesh
  88634. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88635. */
  88636. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88637. }
  88638. /**
  88639. * Defines the minimum contract an Edges renderer should follow.
  88640. */
  88641. export interface IEdgesRenderer extends IDisposable {
  88642. /**
  88643. * Gets or sets a boolean indicating if the edgesRenderer is active
  88644. */
  88645. isEnabled: boolean;
  88646. /**
  88647. * Renders the edges of the attached mesh,
  88648. */
  88649. render(): void;
  88650. /**
  88651. * Checks wether or not the edges renderer is ready to render.
  88652. * @return true if ready, otherwise false.
  88653. */
  88654. isReady(): boolean;
  88655. }
  88656. /**
  88657. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88658. */
  88659. export class EdgesRenderer implements IEdgesRenderer {
  88660. /**
  88661. * Define the size of the edges with an orthographic camera
  88662. */
  88663. edgesWidthScalerForOrthographic: number;
  88664. /**
  88665. * Define the size of the edges with a perspective camera
  88666. */
  88667. edgesWidthScalerForPerspective: number;
  88668. protected _source: AbstractMesh;
  88669. protected _linesPositions: number[];
  88670. protected _linesNormals: number[];
  88671. protected _linesIndices: number[];
  88672. protected _epsilon: number;
  88673. protected _indicesCount: number;
  88674. protected _lineShader: ShaderMaterial;
  88675. protected _ib: DataBuffer;
  88676. protected _buffers: {
  88677. [key: string]: Nullable<VertexBuffer>;
  88678. };
  88679. protected _checkVerticesInsteadOfIndices: boolean;
  88680. private _meshRebuildObserver;
  88681. private _meshDisposeObserver;
  88682. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88683. isEnabled: boolean;
  88684. /**
  88685. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88686. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88687. * @param source Mesh used to create edges
  88688. * @param epsilon sum of angles in adjacency to check for edge
  88689. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88690. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88691. */
  88692. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88693. protected _prepareRessources(): void;
  88694. /** @hidden */
  88695. _rebuild(): void;
  88696. /**
  88697. * Releases the required resources for the edges renderer
  88698. */
  88699. dispose(): void;
  88700. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88701. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88702. /**
  88703. * Checks if the pair of p0 and p1 is en edge
  88704. * @param faceIndex
  88705. * @param edge
  88706. * @param faceNormals
  88707. * @param p0
  88708. * @param p1
  88709. * @private
  88710. */
  88711. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88712. /**
  88713. * push line into the position, normal and index buffer
  88714. * @protected
  88715. */
  88716. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  88717. /**
  88718. * Generates lines edges from adjacencjes
  88719. * @private
  88720. */
  88721. _generateEdgesLines(): void;
  88722. /**
  88723. * Checks wether or not the edges renderer is ready to render.
  88724. * @return true if ready, otherwise false.
  88725. */
  88726. isReady(): boolean;
  88727. /**
  88728. * Renders the edges of the attached mesh,
  88729. */
  88730. render(): void;
  88731. }
  88732. /**
  88733. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  88734. */
  88735. export class LineEdgesRenderer extends EdgesRenderer {
  88736. /**
  88737. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  88738. * @param source LineMesh used to generate edges
  88739. * @param epsilon not important (specified angle for edge detection)
  88740. * @param checkVerticesInsteadOfIndices not important for LineMesh
  88741. */
  88742. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  88743. /**
  88744. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  88745. */
  88746. _generateEdgesLines(): void;
  88747. }
  88748. }
  88749. declare module BABYLON {
  88750. /**
  88751. * This represents the object necessary to create a rendering group.
  88752. * This is exclusively used and created by the rendering manager.
  88753. * To modify the behavior, you use the available helpers in your scene or meshes.
  88754. * @hidden
  88755. */
  88756. export class RenderingGroup {
  88757. index: number;
  88758. private static _zeroVector;
  88759. private _scene;
  88760. private _opaqueSubMeshes;
  88761. private _transparentSubMeshes;
  88762. private _alphaTestSubMeshes;
  88763. private _depthOnlySubMeshes;
  88764. private _particleSystems;
  88765. private _spriteManagers;
  88766. private _opaqueSortCompareFn;
  88767. private _alphaTestSortCompareFn;
  88768. private _transparentSortCompareFn;
  88769. private _renderOpaque;
  88770. private _renderAlphaTest;
  88771. private _renderTransparent;
  88772. /** @hidden */
  88773. _edgesRenderers: SmartArray<IEdgesRenderer>;
  88774. onBeforeTransparentRendering: () => void;
  88775. /**
  88776. * Set the opaque sort comparison function.
  88777. * If null the sub meshes will be render in the order they were created
  88778. */
  88779. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88780. /**
  88781. * Set the alpha test sort comparison function.
  88782. * If null the sub meshes will be render in the order they were created
  88783. */
  88784. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88785. /**
  88786. * Set the transparent sort comparison function.
  88787. * If null the sub meshes will be render in the order they were created
  88788. */
  88789. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88790. /**
  88791. * Creates a new rendering group.
  88792. * @param index The rendering group index
  88793. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  88794. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  88795. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  88796. */
  88797. 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>);
  88798. /**
  88799. * Render all the sub meshes contained in the group.
  88800. * @param customRenderFunction Used to override the default render behaviour of the group.
  88801. * @returns true if rendered some submeshes.
  88802. */
  88803. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  88804. /**
  88805. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  88806. * @param subMeshes The submeshes to render
  88807. */
  88808. private renderOpaqueSorted;
  88809. /**
  88810. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  88811. * @param subMeshes The submeshes to render
  88812. */
  88813. private renderAlphaTestSorted;
  88814. /**
  88815. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  88816. * @param subMeshes The submeshes to render
  88817. */
  88818. private renderTransparentSorted;
  88819. /**
  88820. * Renders the submeshes in a specified order.
  88821. * @param subMeshes The submeshes to sort before render
  88822. * @param sortCompareFn The comparison function use to sort
  88823. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  88824. * @param transparent Specifies to activate blending if true
  88825. */
  88826. private static renderSorted;
  88827. /**
  88828. * Renders the submeshes in the order they were dispatched (no sort applied).
  88829. * @param subMeshes The submeshes to render
  88830. */
  88831. private static renderUnsorted;
  88832. /**
  88833. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88834. * are rendered back to front if in the same alpha index.
  88835. *
  88836. * @param a The first submesh
  88837. * @param b The second submesh
  88838. * @returns The result of the comparison
  88839. */
  88840. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  88841. /**
  88842. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88843. * are rendered back to front.
  88844. *
  88845. * @param a The first submesh
  88846. * @param b The second submesh
  88847. * @returns The result of the comparison
  88848. */
  88849. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88850. /**
  88851. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88852. * are rendered front to back (prevent overdraw).
  88853. *
  88854. * @param a The first submesh
  88855. * @param b The second submesh
  88856. * @returns The result of the comparison
  88857. */
  88858. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88859. /**
  88860. * Resets the different lists of submeshes to prepare a new frame.
  88861. */
  88862. prepare(): void;
  88863. dispose(): void;
  88864. /**
  88865. * Inserts the submesh in its correct queue depending on its material.
  88866. * @param subMesh The submesh to dispatch
  88867. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88868. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88869. */
  88870. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88871. dispatchSprites(spriteManager: ISpriteManager): void;
  88872. dispatchParticles(particleSystem: IParticleSystem): void;
  88873. private _renderParticles;
  88874. private _renderSprites;
  88875. }
  88876. }
  88877. declare module BABYLON {
  88878. /**
  88879. * Interface describing the different options available in the rendering manager
  88880. * regarding Auto Clear between groups.
  88881. */
  88882. export interface IRenderingManagerAutoClearSetup {
  88883. /**
  88884. * Defines whether or not autoclear is enable.
  88885. */
  88886. autoClear: boolean;
  88887. /**
  88888. * Defines whether or not to autoclear the depth buffer.
  88889. */
  88890. depth: boolean;
  88891. /**
  88892. * Defines whether or not to autoclear the stencil buffer.
  88893. */
  88894. stencil: boolean;
  88895. }
  88896. /**
  88897. * This class is used by the onRenderingGroupObservable
  88898. */
  88899. export class RenderingGroupInfo {
  88900. /**
  88901. * The Scene that being rendered
  88902. */
  88903. scene: Scene;
  88904. /**
  88905. * The camera currently used for the rendering pass
  88906. */
  88907. camera: Nullable<Camera>;
  88908. /**
  88909. * The ID of the renderingGroup being processed
  88910. */
  88911. renderingGroupId: number;
  88912. }
  88913. /**
  88914. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88915. * It is enable to manage the different groups as well as the different necessary sort functions.
  88916. * This should not be used directly aside of the few static configurations
  88917. */
  88918. export class RenderingManager {
  88919. /**
  88920. * The max id used for rendering groups (not included)
  88921. */
  88922. static MAX_RENDERINGGROUPS: number;
  88923. /**
  88924. * The min id used for rendering groups (included)
  88925. */
  88926. static MIN_RENDERINGGROUPS: number;
  88927. /**
  88928. * Used to globally prevent autoclearing scenes.
  88929. */
  88930. static AUTOCLEAR: boolean;
  88931. /**
  88932. * @hidden
  88933. */
  88934. _useSceneAutoClearSetup: boolean;
  88935. private _scene;
  88936. private _renderingGroups;
  88937. private _depthStencilBufferAlreadyCleaned;
  88938. private _autoClearDepthStencil;
  88939. private _customOpaqueSortCompareFn;
  88940. private _customAlphaTestSortCompareFn;
  88941. private _customTransparentSortCompareFn;
  88942. private _renderingGroupInfo;
  88943. /**
  88944. * Instantiates a new rendering group for a particular scene
  88945. * @param scene Defines the scene the groups belongs to
  88946. */
  88947. constructor(scene: Scene);
  88948. private _clearDepthStencilBuffer;
  88949. /**
  88950. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88951. * @hidden
  88952. */
  88953. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88954. /**
  88955. * Resets the different information of the group to prepare a new frame
  88956. * @hidden
  88957. */
  88958. reset(): void;
  88959. /**
  88960. * Dispose and release the group and its associated resources.
  88961. * @hidden
  88962. */
  88963. dispose(): void;
  88964. /**
  88965. * Clear the info related to rendering groups preventing retention points during dispose.
  88966. */
  88967. freeRenderingGroups(): void;
  88968. private _prepareRenderingGroup;
  88969. /**
  88970. * Add a sprite manager to the rendering manager in order to render it this frame.
  88971. * @param spriteManager Define the sprite manager to render
  88972. */
  88973. dispatchSprites(spriteManager: ISpriteManager): void;
  88974. /**
  88975. * Add a particle system to the rendering manager in order to render it this frame.
  88976. * @param particleSystem Define the particle system to render
  88977. */
  88978. dispatchParticles(particleSystem: IParticleSystem): void;
  88979. /**
  88980. * Add a submesh to the manager in order to render it this frame
  88981. * @param subMesh The submesh to dispatch
  88982. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88983. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88984. */
  88985. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88986. /**
  88987. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88988. * This allowed control for front to back rendering or reversly depending of the special needs.
  88989. *
  88990. * @param renderingGroupId The rendering group id corresponding to its index
  88991. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88992. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88993. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88994. */
  88995. 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;
  88996. /**
  88997. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88998. *
  88999. * @param renderingGroupId The rendering group id corresponding to its index
  89000. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89001. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89002. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89003. */
  89004. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89005. /**
  89006. * Gets the current auto clear configuration for one rendering group of the rendering
  89007. * manager.
  89008. * @param index the rendering group index to get the information for
  89009. * @returns The auto clear setup for the requested rendering group
  89010. */
  89011. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89012. }
  89013. }
  89014. declare module BABYLON {
  89015. /**
  89016. * This Helps creating a texture that will be created from a camera in your scene.
  89017. * It is basically a dynamic texture that could be used to create special effects for instance.
  89018. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  89019. */
  89020. export class RenderTargetTexture extends Texture {
  89021. isCube: boolean;
  89022. /**
  89023. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  89024. */
  89025. static readonly REFRESHRATE_RENDER_ONCE: number;
  89026. /**
  89027. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  89028. */
  89029. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  89030. /**
  89031. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  89032. * the central point of your effect and can save a lot of performances.
  89033. */
  89034. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  89035. /**
  89036. * Use this predicate to dynamically define the list of mesh you want to render.
  89037. * If set, the renderList property will be overwritten.
  89038. */
  89039. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  89040. private _renderList;
  89041. /**
  89042. * Use this list to define the list of mesh you want to render.
  89043. */
  89044. renderList: Nullable<Array<AbstractMesh>>;
  89045. private _hookArray;
  89046. /**
  89047. * Define if particles should be rendered in your texture.
  89048. */
  89049. renderParticles: boolean;
  89050. /**
  89051. * Define if sprites should be rendered in your texture.
  89052. */
  89053. renderSprites: boolean;
  89054. /**
  89055. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  89056. */
  89057. coordinatesMode: number;
  89058. /**
  89059. * Define the camera used to render the texture.
  89060. */
  89061. activeCamera: Nullable<Camera>;
  89062. /**
  89063. * Override the render function of the texture with your own one.
  89064. */
  89065. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  89066. /**
  89067. * Define if camera post processes should be use while rendering the texture.
  89068. */
  89069. useCameraPostProcesses: boolean;
  89070. /**
  89071. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  89072. */
  89073. ignoreCameraViewport: boolean;
  89074. private _postProcessManager;
  89075. private _postProcesses;
  89076. private _resizeObserver;
  89077. /**
  89078. * An event triggered when the texture is unbind.
  89079. */
  89080. onBeforeBindObservable: Observable<RenderTargetTexture>;
  89081. /**
  89082. * An event triggered when the texture is unbind.
  89083. */
  89084. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  89085. private _onAfterUnbindObserver;
  89086. /**
  89087. * Set a after unbind callback in the texture.
  89088. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  89089. */
  89090. onAfterUnbind: () => void;
  89091. /**
  89092. * An event triggered before rendering the texture
  89093. */
  89094. onBeforeRenderObservable: Observable<number>;
  89095. private _onBeforeRenderObserver;
  89096. /**
  89097. * Set a before render callback in the texture.
  89098. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  89099. */
  89100. onBeforeRender: (faceIndex: number) => void;
  89101. /**
  89102. * An event triggered after rendering the texture
  89103. */
  89104. onAfterRenderObservable: Observable<number>;
  89105. private _onAfterRenderObserver;
  89106. /**
  89107. * Set a after render callback in the texture.
  89108. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  89109. */
  89110. onAfterRender: (faceIndex: number) => void;
  89111. /**
  89112. * An event triggered after the texture clear
  89113. */
  89114. onClearObservable: Observable<Engine>;
  89115. private _onClearObserver;
  89116. /**
  89117. * Set a clear callback in the texture.
  89118. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  89119. */
  89120. onClear: (Engine: Engine) => void;
  89121. /**
  89122. * An event triggered when the texture is resized.
  89123. */
  89124. onResizeObservable: Observable<RenderTargetTexture>;
  89125. /**
  89126. * Define the clear color of the Render Target if it should be different from the scene.
  89127. */
  89128. clearColor: Color4;
  89129. protected _size: number | {
  89130. width: number;
  89131. height: number;
  89132. };
  89133. protected _initialSizeParameter: number | {
  89134. width: number;
  89135. height: number;
  89136. } | {
  89137. ratio: number;
  89138. };
  89139. protected _sizeRatio: Nullable<number>;
  89140. /** @hidden */
  89141. _generateMipMaps: boolean;
  89142. protected _renderingManager: RenderingManager;
  89143. /** @hidden */
  89144. _waitingRenderList: string[];
  89145. protected _doNotChangeAspectRatio: boolean;
  89146. protected _currentRefreshId: number;
  89147. protected _refreshRate: number;
  89148. protected _textureMatrix: Matrix;
  89149. protected _samples: number;
  89150. protected _renderTargetOptions: RenderTargetCreationOptions;
  89151. /**
  89152. * Gets render target creation options that were used.
  89153. */
  89154. readonly renderTargetOptions: RenderTargetCreationOptions;
  89155. protected _engine: Engine;
  89156. protected _onRatioRescale(): void;
  89157. /**
  89158. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  89159. * It must define where the camera used to render the texture is set
  89160. */
  89161. boundingBoxPosition: Vector3;
  89162. private _boundingBoxSize;
  89163. /**
  89164. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  89165. * When defined, the cubemap will switch to local mode
  89166. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89167. * @example https://www.babylonjs-playground.com/#RNASML
  89168. */
  89169. boundingBoxSize: Vector3;
  89170. /**
  89171. * In case the RTT has been created with a depth texture, get the associated
  89172. * depth texture.
  89173. * Otherwise, return null.
  89174. */
  89175. depthStencilTexture: Nullable<InternalTexture>;
  89176. /**
  89177. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  89178. * or used a shadow, depth texture...
  89179. * @param name The friendly name of the texture
  89180. * @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)
  89181. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  89182. * @param generateMipMaps True if mip maps need to be generated after render.
  89183. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  89184. * @param type The type of the buffer in the RTT (int, half float, float...)
  89185. * @param isCube True if a cube texture needs to be created
  89186. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  89187. * @param generateDepthBuffer True to generate a depth buffer
  89188. * @param generateStencilBuffer True to generate a stencil buffer
  89189. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  89190. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  89191. * @param delayAllocation if the texture allocation should be delayed (default: false)
  89192. */
  89193. constructor(name: string, size: number | {
  89194. width: number;
  89195. height: number;
  89196. } | {
  89197. ratio: number;
  89198. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  89199. /**
  89200. * Creates a depth stencil texture.
  89201. * This is only available in WebGL 2 or with the depth texture extension available.
  89202. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  89203. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  89204. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  89205. */
  89206. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  89207. private _processSizeParameter;
  89208. /**
  89209. * Define the number of samples to use in case of MSAA.
  89210. * It defaults to one meaning no MSAA has been enabled.
  89211. */
  89212. samples: number;
  89213. /**
  89214. * Resets the refresh counter of the texture and start bak from scratch.
  89215. * Could be useful to regenerate the texture if it is setup to render only once.
  89216. */
  89217. resetRefreshCounter(): void;
  89218. /**
  89219. * Define the refresh rate of the texture or the rendering frequency.
  89220. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89221. */
  89222. refreshRate: number;
  89223. /**
  89224. * Adds a post process to the render target rendering passes.
  89225. * @param postProcess define the post process to add
  89226. */
  89227. addPostProcess(postProcess: PostProcess): void;
  89228. /**
  89229. * Clear all the post processes attached to the render target
  89230. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  89231. */
  89232. clearPostProcesses(dispose?: boolean): void;
  89233. /**
  89234. * Remove one of the post process from the list of attached post processes to the texture
  89235. * @param postProcess define the post process to remove from the list
  89236. */
  89237. removePostProcess(postProcess: PostProcess): void;
  89238. /** @hidden */
  89239. _shouldRender(): boolean;
  89240. /**
  89241. * Gets the actual render size of the texture.
  89242. * @returns the width of the render size
  89243. */
  89244. getRenderSize(): number;
  89245. /**
  89246. * Gets the actual render width of the texture.
  89247. * @returns the width of the render size
  89248. */
  89249. getRenderWidth(): number;
  89250. /**
  89251. * Gets the actual render height of the texture.
  89252. * @returns the height of the render size
  89253. */
  89254. getRenderHeight(): number;
  89255. /**
  89256. * Get if the texture can be rescaled or not.
  89257. */
  89258. readonly canRescale: boolean;
  89259. /**
  89260. * Resize the texture using a ratio.
  89261. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  89262. */
  89263. scale(ratio: number): void;
  89264. /**
  89265. * Get the texture reflection matrix used to rotate/transform the reflection.
  89266. * @returns the reflection matrix
  89267. */
  89268. getReflectionTextureMatrix(): Matrix;
  89269. /**
  89270. * Resize the texture to a new desired size.
  89271. * Be carrefull as it will recreate all the data in the new texture.
  89272. * @param size Define the new size. It can be:
  89273. * - a number for squared texture,
  89274. * - an object containing { width: number, height: number }
  89275. * - or an object containing a ratio { ratio: number }
  89276. */
  89277. resize(size: number | {
  89278. width: number;
  89279. height: number;
  89280. } | {
  89281. ratio: number;
  89282. }): void;
  89283. /**
  89284. * Renders all the objects from the render list into the texture.
  89285. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  89286. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  89287. */
  89288. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  89289. private _bestReflectionRenderTargetDimension;
  89290. /**
  89291. * @hidden
  89292. * @param faceIndex face index to bind to if this is a cubetexture
  89293. */
  89294. _bindFrameBuffer(faceIndex?: number): void;
  89295. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  89296. private renderToTarget;
  89297. /**
  89298. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89299. * This allowed control for front to back rendering or reversly depending of the special needs.
  89300. *
  89301. * @param renderingGroupId The rendering group id corresponding to its index
  89302. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89303. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89304. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89305. */
  89306. 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;
  89307. /**
  89308. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89309. *
  89310. * @param renderingGroupId The rendering group id corresponding to its index
  89311. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89312. */
  89313. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  89314. /**
  89315. * Clones the texture.
  89316. * @returns the cloned texture
  89317. */
  89318. clone(): RenderTargetTexture;
  89319. /**
  89320. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89321. * @returns The JSON representation of the texture
  89322. */
  89323. serialize(): any;
  89324. /**
  89325. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  89326. */
  89327. disposeFramebufferObjects(): void;
  89328. /**
  89329. * Dispose the texture and release its associated resources.
  89330. */
  89331. dispose(): void;
  89332. /** @hidden */
  89333. _rebuild(): void;
  89334. /**
  89335. * Clear the info related to rendering groups preventing retention point in material dispose.
  89336. */
  89337. freeRenderingGroups(): void;
  89338. /**
  89339. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  89340. * @returns the view count
  89341. */
  89342. getViewCount(): number;
  89343. }
  89344. }
  89345. declare module BABYLON {
  89346. /**
  89347. * Options for compiling materials.
  89348. */
  89349. export interface IMaterialCompilationOptions {
  89350. /**
  89351. * Defines whether clip planes are enabled.
  89352. */
  89353. clipPlane: boolean;
  89354. /**
  89355. * Defines whether instances are enabled.
  89356. */
  89357. useInstances: boolean;
  89358. }
  89359. /**
  89360. * Base class for the main features of a material in Babylon.js
  89361. */
  89362. export class Material implements IAnimatable {
  89363. /**
  89364. * Returns the triangle fill mode
  89365. */
  89366. static readonly TriangleFillMode: number;
  89367. /**
  89368. * Returns the wireframe mode
  89369. */
  89370. static readonly WireFrameFillMode: number;
  89371. /**
  89372. * Returns the point fill mode
  89373. */
  89374. static readonly PointFillMode: number;
  89375. /**
  89376. * Returns the point list draw mode
  89377. */
  89378. static readonly PointListDrawMode: number;
  89379. /**
  89380. * Returns the line list draw mode
  89381. */
  89382. static readonly LineListDrawMode: number;
  89383. /**
  89384. * Returns the line loop draw mode
  89385. */
  89386. static readonly LineLoopDrawMode: number;
  89387. /**
  89388. * Returns the line strip draw mode
  89389. */
  89390. static readonly LineStripDrawMode: number;
  89391. /**
  89392. * Returns the triangle strip draw mode
  89393. */
  89394. static readonly TriangleStripDrawMode: number;
  89395. /**
  89396. * Returns the triangle fan draw mode
  89397. */
  89398. static readonly TriangleFanDrawMode: number;
  89399. /**
  89400. * Stores the clock-wise side orientation
  89401. */
  89402. static readonly ClockWiseSideOrientation: number;
  89403. /**
  89404. * Stores the counter clock-wise side orientation
  89405. */
  89406. static readonly CounterClockWiseSideOrientation: number;
  89407. /**
  89408. * The dirty texture flag value
  89409. */
  89410. static readonly TextureDirtyFlag: number;
  89411. /**
  89412. * The dirty light flag value
  89413. */
  89414. static readonly LightDirtyFlag: number;
  89415. /**
  89416. * The dirty fresnel flag value
  89417. */
  89418. static readonly FresnelDirtyFlag: number;
  89419. /**
  89420. * The dirty attribute flag value
  89421. */
  89422. static readonly AttributesDirtyFlag: number;
  89423. /**
  89424. * The dirty misc flag value
  89425. */
  89426. static readonly MiscDirtyFlag: number;
  89427. /**
  89428. * The all dirty flag value
  89429. */
  89430. static readonly AllDirtyFlag: number;
  89431. /**
  89432. * The ID of the material
  89433. */
  89434. id: string;
  89435. /**
  89436. * Gets or sets the unique id of the material
  89437. */
  89438. uniqueId: number;
  89439. /**
  89440. * The name of the material
  89441. */
  89442. name: string;
  89443. /**
  89444. * Gets or sets user defined metadata
  89445. */
  89446. metadata: any;
  89447. /**
  89448. * For internal use only. Please do not use.
  89449. */
  89450. reservedDataStore: any;
  89451. /**
  89452. * Specifies if the ready state should be checked on each call
  89453. */
  89454. checkReadyOnEveryCall: boolean;
  89455. /**
  89456. * Specifies if the ready state should be checked once
  89457. */
  89458. checkReadyOnlyOnce: boolean;
  89459. /**
  89460. * The state of the material
  89461. */
  89462. state: string;
  89463. /**
  89464. * The alpha value of the material
  89465. */
  89466. protected _alpha: number;
  89467. /**
  89468. * List of inspectable custom properties (used by the Inspector)
  89469. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89470. */
  89471. inspectableCustomProperties: IInspectable[];
  89472. /**
  89473. * Sets the alpha value of the material
  89474. */
  89475. /**
  89476. * Gets the alpha value of the material
  89477. */
  89478. alpha: number;
  89479. /**
  89480. * Specifies if back face culling is enabled
  89481. */
  89482. protected _backFaceCulling: boolean;
  89483. /**
  89484. * Sets the back-face culling state
  89485. */
  89486. /**
  89487. * Gets the back-face culling state
  89488. */
  89489. backFaceCulling: boolean;
  89490. /**
  89491. * Stores the value for side orientation
  89492. */
  89493. sideOrientation: number;
  89494. /**
  89495. * Callback triggered when the material is compiled
  89496. */
  89497. onCompiled: Nullable<(effect: Effect) => void>;
  89498. /**
  89499. * Callback triggered when an error occurs
  89500. */
  89501. onError: Nullable<(effect: Effect, errors: string) => void>;
  89502. /**
  89503. * Callback triggered to get the render target textures
  89504. */
  89505. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  89506. /**
  89507. * Gets a boolean indicating that current material needs to register RTT
  89508. */
  89509. readonly hasRenderTargetTextures: boolean;
  89510. /**
  89511. * Specifies if the material should be serialized
  89512. */
  89513. doNotSerialize: boolean;
  89514. /**
  89515. * @hidden
  89516. */
  89517. _storeEffectOnSubMeshes: boolean;
  89518. /**
  89519. * Stores the animations for the material
  89520. */
  89521. animations: Nullable<Array<Animation>>;
  89522. /**
  89523. * An event triggered when the material is disposed
  89524. */
  89525. onDisposeObservable: Observable<Material>;
  89526. /**
  89527. * An observer which watches for dispose events
  89528. */
  89529. private _onDisposeObserver;
  89530. private _onUnBindObservable;
  89531. /**
  89532. * Called during a dispose event
  89533. */
  89534. onDispose: () => void;
  89535. private _onBindObservable;
  89536. /**
  89537. * An event triggered when the material is bound
  89538. */
  89539. readonly onBindObservable: Observable<AbstractMesh>;
  89540. /**
  89541. * An observer which watches for bind events
  89542. */
  89543. private _onBindObserver;
  89544. /**
  89545. * Called during a bind event
  89546. */
  89547. onBind: (Mesh: AbstractMesh) => void;
  89548. /**
  89549. * An event triggered when the material is unbound
  89550. */
  89551. readonly onUnBindObservable: Observable<Material>;
  89552. /**
  89553. * Stores the value of the alpha mode
  89554. */
  89555. private _alphaMode;
  89556. /**
  89557. * Sets the value of the alpha mode.
  89558. *
  89559. * | Value | Type | Description |
  89560. * | --- | --- | --- |
  89561. * | 0 | ALPHA_DISABLE | |
  89562. * | 1 | ALPHA_ADD | |
  89563. * | 2 | ALPHA_COMBINE | |
  89564. * | 3 | ALPHA_SUBTRACT | |
  89565. * | 4 | ALPHA_MULTIPLY | |
  89566. * | 5 | ALPHA_MAXIMIZED | |
  89567. * | 6 | ALPHA_ONEONE | |
  89568. * | 7 | ALPHA_PREMULTIPLIED | |
  89569. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  89570. * | 9 | ALPHA_INTERPOLATE | |
  89571. * | 10 | ALPHA_SCREENMODE | |
  89572. *
  89573. */
  89574. /**
  89575. * Gets the value of the alpha mode
  89576. */
  89577. alphaMode: number;
  89578. /**
  89579. * Stores the state of the need depth pre-pass value
  89580. */
  89581. private _needDepthPrePass;
  89582. /**
  89583. * Sets the need depth pre-pass value
  89584. */
  89585. /**
  89586. * Gets the depth pre-pass value
  89587. */
  89588. needDepthPrePass: boolean;
  89589. /**
  89590. * Specifies if depth writing should be disabled
  89591. */
  89592. disableDepthWrite: boolean;
  89593. /**
  89594. * Specifies if depth writing should be forced
  89595. */
  89596. forceDepthWrite: boolean;
  89597. /**
  89598. * Specifies the depth function that should be used. 0 means the default engine function
  89599. */
  89600. depthFunction: number;
  89601. /**
  89602. * Specifies if there should be a separate pass for culling
  89603. */
  89604. separateCullingPass: boolean;
  89605. /**
  89606. * Stores the state specifing if fog should be enabled
  89607. */
  89608. private _fogEnabled;
  89609. /**
  89610. * Sets the state for enabling fog
  89611. */
  89612. /**
  89613. * Gets the value of the fog enabled state
  89614. */
  89615. fogEnabled: boolean;
  89616. /**
  89617. * Stores the size of points
  89618. */
  89619. pointSize: number;
  89620. /**
  89621. * Stores the z offset value
  89622. */
  89623. zOffset: number;
  89624. /**
  89625. * Gets a value specifying if wireframe mode is enabled
  89626. */
  89627. /**
  89628. * Sets the state of wireframe mode
  89629. */
  89630. wireframe: boolean;
  89631. /**
  89632. * Gets the value specifying if point clouds are enabled
  89633. */
  89634. /**
  89635. * Sets the state of point cloud mode
  89636. */
  89637. pointsCloud: boolean;
  89638. /**
  89639. * Gets the material fill mode
  89640. */
  89641. /**
  89642. * Sets the material fill mode
  89643. */
  89644. fillMode: number;
  89645. /**
  89646. * @hidden
  89647. * Stores the effects for the material
  89648. */
  89649. _effect: Nullable<Effect>;
  89650. /**
  89651. * @hidden
  89652. * Specifies if the material was previously ready
  89653. */
  89654. _wasPreviouslyReady: boolean;
  89655. /**
  89656. * Specifies if uniform buffers should be used
  89657. */
  89658. private _useUBO;
  89659. /**
  89660. * Stores a reference to the scene
  89661. */
  89662. private _scene;
  89663. /**
  89664. * Stores the fill mode state
  89665. */
  89666. private _fillMode;
  89667. /**
  89668. * Specifies if the depth write state should be cached
  89669. */
  89670. private _cachedDepthWriteState;
  89671. /**
  89672. * Specifies if the depth function state should be cached
  89673. */
  89674. private _cachedDepthFunctionState;
  89675. /**
  89676. * Stores the uniform buffer
  89677. */
  89678. protected _uniformBuffer: UniformBuffer;
  89679. /** @hidden */
  89680. _indexInSceneMaterialArray: number;
  89681. /** @hidden */
  89682. meshMap: Nullable<{
  89683. [id: string]: AbstractMesh | undefined;
  89684. }>;
  89685. /**
  89686. * Creates a material instance
  89687. * @param name defines the name of the material
  89688. * @param scene defines the scene to reference
  89689. * @param doNotAdd specifies if the material should be added to the scene
  89690. */
  89691. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  89692. /**
  89693. * Returns a string representation of the current material
  89694. * @param fullDetails defines a boolean indicating which levels of logging is desired
  89695. * @returns a string with material information
  89696. */
  89697. toString(fullDetails?: boolean): string;
  89698. /**
  89699. * Gets the class name of the material
  89700. * @returns a string with the class name of the material
  89701. */
  89702. getClassName(): string;
  89703. /**
  89704. * Specifies if updates for the material been locked
  89705. */
  89706. readonly isFrozen: boolean;
  89707. /**
  89708. * Locks updates for the material
  89709. */
  89710. freeze(): void;
  89711. /**
  89712. * Unlocks updates for the material
  89713. */
  89714. unfreeze(): void;
  89715. /**
  89716. * Specifies if the material is ready to be used
  89717. * @param mesh defines the mesh to check
  89718. * @param useInstances specifies if instances should be used
  89719. * @returns a boolean indicating if the material is ready to be used
  89720. */
  89721. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89722. /**
  89723. * Specifies that the submesh is ready to be used
  89724. * @param mesh defines the mesh to check
  89725. * @param subMesh defines which submesh to check
  89726. * @param useInstances specifies that instances should be used
  89727. * @returns a boolean indicating that the submesh is ready or not
  89728. */
  89729. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89730. /**
  89731. * Returns the material effect
  89732. * @returns the effect associated with the material
  89733. */
  89734. getEffect(): Nullable<Effect>;
  89735. /**
  89736. * Returns the current scene
  89737. * @returns a Scene
  89738. */
  89739. getScene(): Scene;
  89740. /**
  89741. * Specifies if the material will require alpha blending
  89742. * @returns a boolean specifying if alpha blending is needed
  89743. */
  89744. needAlphaBlending(): boolean;
  89745. /**
  89746. * Specifies if the mesh will require alpha blending
  89747. * @param mesh defines the mesh to check
  89748. * @returns a boolean specifying if alpha blending is needed for the mesh
  89749. */
  89750. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  89751. /**
  89752. * Specifies if this material should be rendered in alpha test mode
  89753. * @returns a boolean specifying if an alpha test is needed.
  89754. */
  89755. needAlphaTesting(): boolean;
  89756. /**
  89757. * Gets the texture used for the alpha test
  89758. * @returns the texture to use for alpha testing
  89759. */
  89760. getAlphaTestTexture(): Nullable<BaseTexture>;
  89761. /**
  89762. * Marks the material to indicate that it needs to be re-calculated
  89763. */
  89764. markDirty(): void;
  89765. /** @hidden */
  89766. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  89767. /**
  89768. * Binds the material to the mesh
  89769. * @param world defines the world transformation matrix
  89770. * @param mesh defines the mesh to bind the material to
  89771. */
  89772. bind(world: Matrix, mesh?: Mesh): void;
  89773. /**
  89774. * Binds the submesh to the material
  89775. * @param world defines the world transformation matrix
  89776. * @param mesh defines the mesh containing the submesh
  89777. * @param subMesh defines the submesh to bind the material to
  89778. */
  89779. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  89780. /**
  89781. * Binds the world matrix to the material
  89782. * @param world defines the world transformation matrix
  89783. */
  89784. bindOnlyWorldMatrix(world: Matrix): void;
  89785. /**
  89786. * Binds the scene's uniform buffer to the effect.
  89787. * @param effect defines the effect to bind to the scene uniform buffer
  89788. * @param sceneUbo defines the uniform buffer storing scene data
  89789. */
  89790. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  89791. /**
  89792. * Binds the view matrix to the effect
  89793. * @param effect defines the effect to bind the view matrix to
  89794. */
  89795. bindView(effect: Effect): void;
  89796. /**
  89797. * Binds the view projection matrix to the effect
  89798. * @param effect defines the effect to bind the view projection matrix to
  89799. */
  89800. bindViewProjection(effect: Effect): void;
  89801. /**
  89802. * Specifies if material alpha testing should be turned on for the mesh
  89803. * @param mesh defines the mesh to check
  89804. */
  89805. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  89806. /**
  89807. * Processes to execute after binding the material to a mesh
  89808. * @param mesh defines the rendered mesh
  89809. */
  89810. protected _afterBind(mesh?: Mesh): void;
  89811. /**
  89812. * Unbinds the material from the mesh
  89813. */
  89814. unbind(): void;
  89815. /**
  89816. * Gets the active textures from the material
  89817. * @returns an array of textures
  89818. */
  89819. getActiveTextures(): BaseTexture[];
  89820. /**
  89821. * Specifies if the material uses a texture
  89822. * @param texture defines the texture to check against the material
  89823. * @returns a boolean specifying if the material uses the texture
  89824. */
  89825. hasTexture(texture: BaseTexture): boolean;
  89826. /**
  89827. * Makes a duplicate of the material, and gives it a new name
  89828. * @param name defines the new name for the duplicated material
  89829. * @returns the cloned material
  89830. */
  89831. clone(name: string): Nullable<Material>;
  89832. /**
  89833. * Gets the meshes bound to the material
  89834. * @returns an array of meshes bound to the material
  89835. */
  89836. getBindedMeshes(): AbstractMesh[];
  89837. /**
  89838. * Force shader compilation
  89839. * @param mesh defines the mesh associated with this material
  89840. * @param onCompiled defines a function to execute once the material is compiled
  89841. * @param options defines the options to configure the compilation
  89842. * @param onError defines a function to execute if the material fails compiling
  89843. */
  89844. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  89845. /**
  89846. * Force shader compilation
  89847. * @param mesh defines the mesh that will use this material
  89848. * @param options defines additional options for compiling the shaders
  89849. * @returns a promise that resolves when the compilation completes
  89850. */
  89851. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89852. private static readonly _AllDirtyCallBack;
  89853. private static readonly _ImageProcessingDirtyCallBack;
  89854. private static readonly _TextureDirtyCallBack;
  89855. private static readonly _FresnelDirtyCallBack;
  89856. private static readonly _MiscDirtyCallBack;
  89857. private static readonly _LightsDirtyCallBack;
  89858. private static readonly _AttributeDirtyCallBack;
  89859. private static _FresnelAndMiscDirtyCallBack;
  89860. private static _TextureAndMiscDirtyCallBack;
  89861. private static readonly _DirtyCallbackArray;
  89862. private static readonly _RunDirtyCallBacks;
  89863. /**
  89864. * Marks a define in the material to indicate that it needs to be re-computed
  89865. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89866. */
  89867. markAsDirty(flag: number): void;
  89868. /**
  89869. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89870. * @param func defines a function which checks material defines against the submeshes
  89871. */
  89872. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89873. /**
  89874. * Indicates that we need to re-calculated for all submeshes
  89875. */
  89876. protected _markAllSubMeshesAsAllDirty(): void;
  89877. /**
  89878. * Indicates that image processing needs to be re-calculated for all submeshes
  89879. */
  89880. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89881. /**
  89882. * Indicates that textures need to be re-calculated for all submeshes
  89883. */
  89884. protected _markAllSubMeshesAsTexturesDirty(): void;
  89885. /**
  89886. * Indicates that fresnel needs to be re-calculated for all submeshes
  89887. */
  89888. protected _markAllSubMeshesAsFresnelDirty(): void;
  89889. /**
  89890. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89891. */
  89892. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89893. /**
  89894. * Indicates that lights need to be re-calculated for all submeshes
  89895. */
  89896. protected _markAllSubMeshesAsLightsDirty(): void;
  89897. /**
  89898. * Indicates that attributes need to be re-calculated for all submeshes
  89899. */
  89900. protected _markAllSubMeshesAsAttributesDirty(): void;
  89901. /**
  89902. * Indicates that misc needs to be re-calculated for all submeshes
  89903. */
  89904. protected _markAllSubMeshesAsMiscDirty(): void;
  89905. /**
  89906. * Indicates that textures and misc need to be re-calculated for all submeshes
  89907. */
  89908. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89909. /**
  89910. * Disposes the material
  89911. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89912. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89913. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89914. */
  89915. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89916. /** @hidden */
  89917. private releaseVertexArrayObject;
  89918. /**
  89919. * Serializes this material
  89920. * @returns the serialized material object
  89921. */
  89922. serialize(): any;
  89923. /**
  89924. * Creates a material from parsed material data
  89925. * @param parsedMaterial defines parsed material data
  89926. * @param scene defines the hosting scene
  89927. * @param rootUrl defines the root URL to use to load textures
  89928. * @returns a new material
  89929. */
  89930. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89931. }
  89932. }
  89933. declare module BABYLON {
  89934. /**
  89935. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89936. * separate meshes. This can be use to improve performances.
  89937. * @see http://doc.babylonjs.com/how_to/multi_materials
  89938. */
  89939. export class MultiMaterial extends Material {
  89940. private _subMaterials;
  89941. /**
  89942. * Gets or Sets the list of Materials used within the multi material.
  89943. * They need to be ordered according to the submeshes order in the associated mesh
  89944. */
  89945. subMaterials: Nullable<Material>[];
  89946. /**
  89947. * Function used to align with Node.getChildren()
  89948. * @returns the list of Materials used within the multi material
  89949. */
  89950. getChildren(): Nullable<Material>[];
  89951. /**
  89952. * Instantiates a new Multi Material
  89953. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89954. * separate meshes. This can be use to improve performances.
  89955. * @see http://doc.babylonjs.com/how_to/multi_materials
  89956. * @param name Define the name in the scene
  89957. * @param scene Define the scene the material belongs to
  89958. */
  89959. constructor(name: string, scene: Scene);
  89960. private _hookArray;
  89961. /**
  89962. * Get one of the submaterial by its index in the submaterials array
  89963. * @param index The index to look the sub material at
  89964. * @returns The Material if the index has been defined
  89965. */
  89966. getSubMaterial(index: number): Nullable<Material>;
  89967. /**
  89968. * Get the list of active textures for the whole sub materials list.
  89969. * @returns All the textures that will be used during the rendering
  89970. */
  89971. getActiveTextures(): BaseTexture[];
  89972. /**
  89973. * Gets the current class name of the material e.g. "MultiMaterial"
  89974. * Mainly use in serialization.
  89975. * @returns the class name
  89976. */
  89977. getClassName(): string;
  89978. /**
  89979. * Checks if the material is ready to render the requested sub mesh
  89980. * @param mesh Define the mesh the submesh belongs to
  89981. * @param subMesh Define the sub mesh to look readyness for
  89982. * @param useInstances Define whether or not the material is used with instances
  89983. * @returns true if ready, otherwise false
  89984. */
  89985. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89986. /**
  89987. * Clones the current material and its related sub materials
  89988. * @param name Define the name of the newly cloned material
  89989. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89990. * @returns the cloned material
  89991. */
  89992. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89993. /**
  89994. * Serializes the materials into a JSON representation.
  89995. * @returns the JSON representation
  89996. */
  89997. serialize(): any;
  89998. /**
  89999. * Dispose the material and release its associated resources
  90000. * @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)
  90001. * @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)
  90002. * @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)
  90003. */
  90004. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  90005. /**
  90006. * Creates a MultiMaterial from parsed MultiMaterial data.
  90007. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  90008. * @param scene defines the hosting scene
  90009. * @returns a new MultiMaterial
  90010. */
  90011. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  90012. }
  90013. }
  90014. declare module BABYLON {
  90015. /**
  90016. * Base class for submeshes
  90017. */
  90018. export class BaseSubMesh {
  90019. /** @hidden */
  90020. _materialDefines: Nullable<MaterialDefines>;
  90021. /** @hidden */
  90022. _materialEffect: Nullable<Effect>;
  90023. /**
  90024. * Gets material defines used by the effect associated to the sub mesh
  90025. */
  90026. /**
  90027. * Sets material defines used by the effect associated to the sub mesh
  90028. */
  90029. materialDefines: Nullable<MaterialDefines>;
  90030. /**
  90031. * Gets associated effect
  90032. */
  90033. readonly effect: Nullable<Effect>;
  90034. /**
  90035. * Sets associated effect (effect used to render this submesh)
  90036. * @param effect defines the effect to associate with
  90037. * @param defines defines the set of defines used to compile this effect
  90038. */
  90039. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  90040. }
  90041. /**
  90042. * Defines a subdivision inside a mesh
  90043. */
  90044. export class SubMesh extends BaseSubMesh implements ICullable {
  90045. /** the material index to use */
  90046. materialIndex: number;
  90047. /** vertex index start */
  90048. verticesStart: number;
  90049. /** vertices count */
  90050. verticesCount: number;
  90051. /** index start */
  90052. indexStart: number;
  90053. /** indices count */
  90054. indexCount: number;
  90055. /** @hidden */
  90056. _linesIndexCount: number;
  90057. private _mesh;
  90058. private _renderingMesh;
  90059. private _boundingInfo;
  90060. private _linesIndexBuffer;
  90061. /** @hidden */
  90062. _lastColliderWorldVertices: Nullable<Vector3[]>;
  90063. /** @hidden */
  90064. _trianglePlanes: Plane[];
  90065. /** @hidden */
  90066. _lastColliderTransformMatrix: Nullable<Matrix>;
  90067. /** @hidden */
  90068. _renderId: number;
  90069. /** @hidden */
  90070. _alphaIndex: number;
  90071. /** @hidden */
  90072. _distanceToCamera: number;
  90073. /** @hidden */
  90074. _id: number;
  90075. private _currentMaterial;
  90076. /**
  90077. * Add a new submesh to a mesh
  90078. * @param materialIndex defines the material index to use
  90079. * @param verticesStart defines vertex index start
  90080. * @param verticesCount defines vertices count
  90081. * @param indexStart defines index start
  90082. * @param indexCount defines indices count
  90083. * @param mesh defines the parent mesh
  90084. * @param renderingMesh defines an optional rendering mesh
  90085. * @param createBoundingBox defines if bounding box should be created for this submesh
  90086. * @returns the new submesh
  90087. */
  90088. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  90089. /**
  90090. * Creates a new submesh
  90091. * @param materialIndex defines the material index to use
  90092. * @param verticesStart defines vertex index start
  90093. * @param verticesCount defines vertices count
  90094. * @param indexStart defines index start
  90095. * @param indexCount defines indices count
  90096. * @param mesh defines the parent mesh
  90097. * @param renderingMesh defines an optional rendering mesh
  90098. * @param createBoundingBox defines if bounding box should be created for this submesh
  90099. */
  90100. constructor(
  90101. /** the material index to use */
  90102. materialIndex: number,
  90103. /** vertex index start */
  90104. verticesStart: number,
  90105. /** vertices count */
  90106. verticesCount: number,
  90107. /** index start */
  90108. indexStart: number,
  90109. /** indices count */
  90110. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  90111. /**
  90112. * Returns true if this submesh covers the entire parent mesh
  90113. * @ignorenaming
  90114. */
  90115. readonly IsGlobal: boolean;
  90116. /**
  90117. * Returns the submesh BoudingInfo object
  90118. * @returns current bounding info (or mesh's one if the submesh is global)
  90119. */
  90120. getBoundingInfo(): BoundingInfo;
  90121. /**
  90122. * Sets the submesh BoundingInfo
  90123. * @param boundingInfo defines the new bounding info to use
  90124. * @returns the SubMesh
  90125. */
  90126. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  90127. /**
  90128. * Returns the mesh of the current submesh
  90129. * @return the parent mesh
  90130. */
  90131. getMesh(): AbstractMesh;
  90132. /**
  90133. * Returns the rendering mesh of the submesh
  90134. * @returns the rendering mesh (could be different from parent mesh)
  90135. */
  90136. getRenderingMesh(): Mesh;
  90137. /**
  90138. * Returns the submesh material
  90139. * @returns null or the current material
  90140. */
  90141. getMaterial(): Nullable<Material>;
  90142. /**
  90143. * Sets a new updated BoundingInfo object to the submesh
  90144. * @param data defines an optional position array to use to determine the bounding info
  90145. * @returns the SubMesh
  90146. */
  90147. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  90148. /** @hidden */
  90149. _checkCollision(collider: Collider): boolean;
  90150. /**
  90151. * Updates the submesh BoundingInfo
  90152. * @param world defines the world matrix to use to update the bounding info
  90153. * @returns the submesh
  90154. */
  90155. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  90156. /**
  90157. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  90158. * @param frustumPlanes defines the frustum planes
  90159. * @returns true if the submesh is intersecting with the frustum
  90160. */
  90161. isInFrustum(frustumPlanes: Plane[]): boolean;
  90162. /**
  90163. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  90164. * @param frustumPlanes defines the frustum planes
  90165. * @returns true if the submesh is inside the frustum
  90166. */
  90167. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90168. /**
  90169. * Renders the submesh
  90170. * @param enableAlphaMode defines if alpha needs to be used
  90171. * @returns the submesh
  90172. */
  90173. render(enableAlphaMode: boolean): SubMesh;
  90174. /**
  90175. * @hidden
  90176. */
  90177. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  90178. /**
  90179. * Checks if the submesh intersects with a ray
  90180. * @param ray defines the ray to test
  90181. * @returns true is the passed ray intersects the submesh bounding box
  90182. */
  90183. canIntersects(ray: Ray): boolean;
  90184. /**
  90185. * Intersects current submesh with a ray
  90186. * @param ray defines the ray to test
  90187. * @param positions defines mesh's positions array
  90188. * @param indices defines mesh's indices array
  90189. * @param fastCheck defines if only bounding info should be used
  90190. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90191. * @returns intersection info or null if no intersection
  90192. */
  90193. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  90194. /** @hidden */
  90195. private _intersectLines;
  90196. /** @hidden */
  90197. private _intersectUnIndexedLines;
  90198. /** @hidden */
  90199. private _intersectTriangles;
  90200. /** @hidden */
  90201. private _intersectUnIndexedTriangles;
  90202. /** @hidden */
  90203. _rebuild(): void;
  90204. /**
  90205. * Creates a new submesh from the passed mesh
  90206. * @param newMesh defines the new hosting mesh
  90207. * @param newRenderingMesh defines an optional rendering mesh
  90208. * @returns the new submesh
  90209. */
  90210. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  90211. /**
  90212. * Release associated resources
  90213. */
  90214. dispose(): void;
  90215. /**
  90216. * Gets the class name
  90217. * @returns the string "SubMesh".
  90218. */
  90219. getClassName(): string;
  90220. /**
  90221. * Creates a new submesh from indices data
  90222. * @param materialIndex the index of the main mesh material
  90223. * @param startIndex the index where to start the copy in the mesh indices array
  90224. * @param indexCount the number of indices to copy then from the startIndex
  90225. * @param mesh the main mesh to create the submesh from
  90226. * @param renderingMesh the optional rendering mesh
  90227. * @returns a new submesh
  90228. */
  90229. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  90230. }
  90231. }
  90232. declare module BABYLON {
  90233. /**
  90234. * Class used to represent data loading progression
  90235. */
  90236. export class SceneLoaderFlags {
  90237. private static _ForceFullSceneLoadingForIncremental;
  90238. private static _ShowLoadingScreen;
  90239. private static _CleanBoneMatrixWeights;
  90240. private static _loggingLevel;
  90241. /**
  90242. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  90243. */
  90244. static ForceFullSceneLoadingForIncremental: boolean;
  90245. /**
  90246. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  90247. */
  90248. static ShowLoadingScreen: boolean;
  90249. /**
  90250. * Defines the current logging level (while loading the scene)
  90251. * @ignorenaming
  90252. */
  90253. static loggingLevel: number;
  90254. /**
  90255. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  90256. */
  90257. static CleanBoneMatrixWeights: boolean;
  90258. }
  90259. }
  90260. declare module BABYLON {
  90261. /**
  90262. * Class used to store geometry data (vertex buffers + index buffer)
  90263. */
  90264. export class Geometry implements IGetSetVerticesData {
  90265. /**
  90266. * Gets or sets the ID of the geometry
  90267. */
  90268. id: string;
  90269. /**
  90270. * Gets or sets the unique ID of the geometry
  90271. */
  90272. uniqueId: number;
  90273. /**
  90274. * Gets the delay loading state of the geometry (none by default which means not delayed)
  90275. */
  90276. delayLoadState: number;
  90277. /**
  90278. * Gets the file containing the data to load when running in delay load state
  90279. */
  90280. delayLoadingFile: Nullable<string>;
  90281. /**
  90282. * Callback called when the geometry is updated
  90283. */
  90284. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  90285. private _scene;
  90286. private _engine;
  90287. private _meshes;
  90288. private _totalVertices;
  90289. /** @hidden */
  90290. _indices: IndicesArray;
  90291. /** @hidden */
  90292. _vertexBuffers: {
  90293. [key: string]: VertexBuffer;
  90294. };
  90295. private _isDisposed;
  90296. private _extend;
  90297. private _boundingBias;
  90298. /** @hidden */
  90299. _delayInfo: Array<string>;
  90300. private _indexBuffer;
  90301. private _indexBufferIsUpdatable;
  90302. /** @hidden */
  90303. _boundingInfo: Nullable<BoundingInfo>;
  90304. /** @hidden */
  90305. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  90306. /** @hidden */
  90307. _softwareSkinningFrameId: number;
  90308. private _vertexArrayObjects;
  90309. private _updatable;
  90310. /** @hidden */
  90311. _positions: Nullable<Vector3[]>;
  90312. /**
  90313. * 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
  90314. */
  90315. /**
  90316. * 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
  90317. */
  90318. boundingBias: Vector2;
  90319. /**
  90320. * Static function used to attach a new empty geometry to a mesh
  90321. * @param mesh defines the mesh to attach the geometry to
  90322. * @returns the new Geometry
  90323. */
  90324. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  90325. /**
  90326. * Creates a new geometry
  90327. * @param id defines the unique ID
  90328. * @param scene defines the hosting scene
  90329. * @param vertexData defines the VertexData used to get geometry data
  90330. * @param updatable defines if geometry must be updatable (false by default)
  90331. * @param mesh defines the mesh that will be associated with the geometry
  90332. */
  90333. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  90334. /**
  90335. * Gets the current extend of the geometry
  90336. */
  90337. readonly extend: {
  90338. minimum: Vector3;
  90339. maximum: Vector3;
  90340. };
  90341. /**
  90342. * Gets the hosting scene
  90343. * @returns the hosting Scene
  90344. */
  90345. getScene(): Scene;
  90346. /**
  90347. * Gets the hosting engine
  90348. * @returns the hosting Engine
  90349. */
  90350. getEngine(): Engine;
  90351. /**
  90352. * Defines if the geometry is ready to use
  90353. * @returns true if the geometry is ready to be used
  90354. */
  90355. isReady(): boolean;
  90356. /**
  90357. * Gets a value indicating that the geometry should not be serialized
  90358. */
  90359. readonly doNotSerialize: boolean;
  90360. /** @hidden */
  90361. _rebuild(): void;
  90362. /**
  90363. * Affects all geometry data in one call
  90364. * @param vertexData defines the geometry data
  90365. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  90366. */
  90367. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  90368. /**
  90369. * Set specific vertex data
  90370. * @param kind defines the data kind (Position, normal, etc...)
  90371. * @param data defines the vertex data to use
  90372. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90373. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90374. */
  90375. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  90376. /**
  90377. * Removes a specific vertex data
  90378. * @param kind defines the data kind (Position, normal, etc...)
  90379. */
  90380. removeVerticesData(kind: string): void;
  90381. /**
  90382. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  90383. * @param buffer defines the vertex buffer to use
  90384. * @param totalVertices defines the total number of vertices for position kind (could be null)
  90385. */
  90386. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  90387. /**
  90388. * Update a specific vertex buffer
  90389. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  90390. * It will do nothing if the buffer is not updatable
  90391. * @param kind defines the data kind (Position, normal, etc...)
  90392. * @param data defines the data to use
  90393. * @param offset defines the offset in the target buffer where to store the data
  90394. * @param useBytes set to true if the offset is in bytes
  90395. */
  90396. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  90397. /**
  90398. * Update a specific vertex buffer
  90399. * This function will create a new buffer if the current one is not updatable
  90400. * @param kind defines the data kind (Position, normal, etc...)
  90401. * @param data defines the data to use
  90402. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  90403. */
  90404. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  90405. private _updateBoundingInfo;
  90406. /** @hidden */
  90407. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  90408. /**
  90409. * Gets total number of vertices
  90410. * @returns the total number of vertices
  90411. */
  90412. getTotalVertices(): number;
  90413. /**
  90414. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90415. * @param kind defines the data kind (Position, normal, etc...)
  90416. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90417. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90418. * @returns a float array containing vertex data
  90419. */
  90420. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90421. /**
  90422. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  90423. * @param kind defines the data kind (Position, normal, etc...)
  90424. * @returns true if the vertex buffer with the specified kind is updatable
  90425. */
  90426. isVertexBufferUpdatable(kind: string): boolean;
  90427. /**
  90428. * Gets a specific vertex buffer
  90429. * @param kind defines the data kind (Position, normal, etc...)
  90430. * @returns a VertexBuffer
  90431. */
  90432. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90433. /**
  90434. * Returns all vertex buffers
  90435. * @return an object holding all vertex buffers indexed by kind
  90436. */
  90437. getVertexBuffers(): Nullable<{
  90438. [key: string]: VertexBuffer;
  90439. }>;
  90440. /**
  90441. * Gets a boolean indicating if specific vertex buffer is present
  90442. * @param kind defines the data kind (Position, normal, etc...)
  90443. * @returns true if data is present
  90444. */
  90445. isVerticesDataPresent(kind: string): boolean;
  90446. /**
  90447. * Gets a list of all attached data kinds (Position, normal, etc...)
  90448. * @returns a list of string containing all kinds
  90449. */
  90450. getVerticesDataKinds(): string[];
  90451. /**
  90452. * Update index buffer
  90453. * @param indices defines the indices to store in the index buffer
  90454. * @param offset defines the offset in the target buffer where to store the data
  90455. * @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)
  90456. */
  90457. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  90458. /**
  90459. * Creates a new index buffer
  90460. * @param indices defines the indices to store in the index buffer
  90461. * @param totalVertices defines the total number of vertices (could be null)
  90462. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90463. */
  90464. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  90465. /**
  90466. * Return the total number of indices
  90467. * @returns the total number of indices
  90468. */
  90469. getTotalIndices(): number;
  90470. /**
  90471. * Gets the index buffer array
  90472. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90473. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90474. * @returns the index buffer array
  90475. */
  90476. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90477. /**
  90478. * Gets the index buffer
  90479. * @return the index buffer
  90480. */
  90481. getIndexBuffer(): Nullable<DataBuffer>;
  90482. /** @hidden */
  90483. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  90484. /**
  90485. * Release the associated resources for a specific mesh
  90486. * @param mesh defines the source mesh
  90487. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  90488. */
  90489. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  90490. /**
  90491. * Apply current geometry to a given mesh
  90492. * @param mesh defines the mesh to apply geometry to
  90493. */
  90494. applyToMesh(mesh: Mesh): void;
  90495. private _updateExtend;
  90496. private _applyToMesh;
  90497. private notifyUpdate;
  90498. /**
  90499. * Load the geometry if it was flagged as delay loaded
  90500. * @param scene defines the hosting scene
  90501. * @param onLoaded defines a callback called when the geometry is loaded
  90502. */
  90503. load(scene: Scene, onLoaded?: () => void): void;
  90504. private _queueLoad;
  90505. /**
  90506. * Invert the geometry to move from a right handed system to a left handed one.
  90507. */
  90508. toLeftHanded(): void;
  90509. /** @hidden */
  90510. _resetPointsArrayCache(): void;
  90511. /** @hidden */
  90512. _generatePointsArray(): boolean;
  90513. /**
  90514. * Gets a value indicating if the geometry is disposed
  90515. * @returns true if the geometry was disposed
  90516. */
  90517. isDisposed(): boolean;
  90518. private _disposeVertexArrayObjects;
  90519. /**
  90520. * Free all associated resources
  90521. */
  90522. dispose(): void;
  90523. /**
  90524. * Clone the current geometry into a new geometry
  90525. * @param id defines the unique ID of the new geometry
  90526. * @returns a new geometry object
  90527. */
  90528. copy(id: string): Geometry;
  90529. /**
  90530. * Serialize the current geometry info (and not the vertices data) into a JSON object
  90531. * @return a JSON representation of the current geometry data (without the vertices data)
  90532. */
  90533. serialize(): any;
  90534. private toNumberArray;
  90535. /**
  90536. * Serialize all vertices data into a JSON oject
  90537. * @returns a JSON representation of the current geometry data
  90538. */
  90539. serializeVerticeData(): any;
  90540. /**
  90541. * Extracts a clone of a mesh geometry
  90542. * @param mesh defines the source mesh
  90543. * @param id defines the unique ID of the new geometry object
  90544. * @returns the new geometry object
  90545. */
  90546. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  90547. /**
  90548. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  90549. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90550. * Be aware Math.random() could cause collisions, but:
  90551. * "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"
  90552. * @returns a string containing a new GUID
  90553. */
  90554. static RandomId(): string;
  90555. /** @hidden */
  90556. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  90557. private static _CleanMatricesWeights;
  90558. /**
  90559. * Create a new geometry from persisted data (Using .babylon file format)
  90560. * @param parsedVertexData defines the persisted data
  90561. * @param scene defines the hosting scene
  90562. * @param rootUrl defines the root url to use to load assets (like delayed data)
  90563. * @returns the new geometry object
  90564. */
  90565. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  90566. }
  90567. }
  90568. declare module BABYLON {
  90569. /**
  90570. * Define an interface for all classes that will get and set the data on vertices
  90571. */
  90572. export interface IGetSetVerticesData {
  90573. /**
  90574. * Gets a boolean indicating if specific vertex data is present
  90575. * @param kind defines the vertex data kind to use
  90576. * @returns true is data kind is present
  90577. */
  90578. isVerticesDataPresent(kind: string): boolean;
  90579. /**
  90580. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90581. * @param kind defines the data kind (Position, normal, etc...)
  90582. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90583. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90584. * @returns a float array containing vertex data
  90585. */
  90586. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90587. /**
  90588. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90589. * @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.
  90590. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90591. * @returns the indices array or an empty array if the mesh has no geometry
  90592. */
  90593. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90594. /**
  90595. * Set specific vertex data
  90596. * @param kind defines the data kind (Position, normal, etc...)
  90597. * @param data defines the vertex data to use
  90598. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90599. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90600. */
  90601. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  90602. /**
  90603. * Update a specific associated vertex buffer
  90604. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90605. * - VertexBuffer.PositionKind
  90606. * - VertexBuffer.UVKind
  90607. * - VertexBuffer.UV2Kind
  90608. * - VertexBuffer.UV3Kind
  90609. * - VertexBuffer.UV4Kind
  90610. * - VertexBuffer.UV5Kind
  90611. * - VertexBuffer.UV6Kind
  90612. * - VertexBuffer.ColorKind
  90613. * - VertexBuffer.MatricesIndicesKind
  90614. * - VertexBuffer.MatricesIndicesExtraKind
  90615. * - VertexBuffer.MatricesWeightsKind
  90616. * - VertexBuffer.MatricesWeightsExtraKind
  90617. * @param data defines the data source
  90618. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90619. * @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)
  90620. */
  90621. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  90622. /**
  90623. * Creates a new index buffer
  90624. * @param indices defines the indices to store in the index buffer
  90625. * @param totalVertices defines the total number of vertices (could be null)
  90626. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90627. */
  90628. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  90629. }
  90630. /**
  90631. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90632. */
  90633. export class VertexData {
  90634. /**
  90635. * Mesh side orientation : usually the external or front surface
  90636. */
  90637. static readonly FRONTSIDE: number;
  90638. /**
  90639. * Mesh side orientation : usually the internal or back surface
  90640. */
  90641. static readonly BACKSIDE: number;
  90642. /**
  90643. * Mesh side orientation : both internal and external or front and back surfaces
  90644. */
  90645. static readonly DOUBLESIDE: number;
  90646. /**
  90647. * Mesh side orientation : by default, `FRONTSIDE`
  90648. */
  90649. static readonly DEFAULTSIDE: number;
  90650. /**
  90651. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  90652. */
  90653. positions: Nullable<FloatArray>;
  90654. /**
  90655. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  90656. */
  90657. normals: Nullable<FloatArray>;
  90658. /**
  90659. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  90660. */
  90661. tangents: Nullable<FloatArray>;
  90662. /**
  90663. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90664. */
  90665. uvs: Nullable<FloatArray>;
  90666. /**
  90667. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90668. */
  90669. uvs2: Nullable<FloatArray>;
  90670. /**
  90671. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90672. */
  90673. uvs3: Nullable<FloatArray>;
  90674. /**
  90675. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90676. */
  90677. uvs4: Nullable<FloatArray>;
  90678. /**
  90679. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90680. */
  90681. uvs5: Nullable<FloatArray>;
  90682. /**
  90683. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90684. */
  90685. uvs6: Nullable<FloatArray>;
  90686. /**
  90687. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  90688. */
  90689. colors: Nullable<FloatArray>;
  90690. /**
  90691. * 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).
  90692. */
  90693. matricesIndices: Nullable<FloatArray>;
  90694. /**
  90695. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  90696. */
  90697. matricesWeights: Nullable<FloatArray>;
  90698. /**
  90699. * An array extending the number of possible indices
  90700. */
  90701. matricesIndicesExtra: Nullable<FloatArray>;
  90702. /**
  90703. * An array extending the number of possible weights when the number of indices is extended
  90704. */
  90705. matricesWeightsExtra: Nullable<FloatArray>;
  90706. /**
  90707. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  90708. */
  90709. indices: Nullable<IndicesArray>;
  90710. /**
  90711. * Uses the passed data array to set the set the values for the specified kind of data
  90712. * @param data a linear array of floating numbers
  90713. * @param kind the type of data that is being set, eg positions, colors etc
  90714. */
  90715. set(data: FloatArray, kind: string): void;
  90716. /**
  90717. * Associates the vertexData to the passed Mesh.
  90718. * Sets it as updatable or not (default `false`)
  90719. * @param mesh the mesh the vertexData is applied to
  90720. * @param updatable when used and having the value true allows new data to update the vertexData
  90721. * @returns the VertexData
  90722. */
  90723. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  90724. /**
  90725. * Associates the vertexData to the passed Geometry.
  90726. * Sets it as updatable or not (default `false`)
  90727. * @param geometry the geometry the vertexData is applied to
  90728. * @param updatable when used and having the value true allows new data to update the vertexData
  90729. * @returns VertexData
  90730. */
  90731. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  90732. /**
  90733. * Updates the associated mesh
  90734. * @param mesh the mesh to be updated
  90735. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90736. * @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
  90737. * @returns VertexData
  90738. */
  90739. updateMesh(mesh: Mesh): VertexData;
  90740. /**
  90741. * Updates the associated geometry
  90742. * @param geometry the geometry to be updated
  90743. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90744. * @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
  90745. * @returns VertexData.
  90746. */
  90747. updateGeometry(geometry: Geometry): VertexData;
  90748. private _applyTo;
  90749. private _update;
  90750. /**
  90751. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90752. * @param matrix the transforming matrix
  90753. * @returns the VertexData
  90754. */
  90755. transform(matrix: Matrix): VertexData;
  90756. /**
  90757. * Merges the passed VertexData into the current one
  90758. * @param other the VertexData to be merged into the current one
  90759. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90760. * @returns the modified VertexData
  90761. */
  90762. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  90763. private _mergeElement;
  90764. private _validate;
  90765. /**
  90766. * Serializes the VertexData
  90767. * @returns a serialized object
  90768. */
  90769. serialize(): any;
  90770. /**
  90771. * Extracts the vertexData from a mesh
  90772. * @param mesh the mesh from which to extract the VertexData
  90773. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90774. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90775. * @returns the object VertexData associated to the passed mesh
  90776. */
  90777. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90778. /**
  90779. * Extracts the vertexData from the geometry
  90780. * @param geometry the geometry from which to extract the VertexData
  90781. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90782. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90783. * @returns the object VertexData associated to the passed mesh
  90784. */
  90785. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90786. private static _ExtractFrom;
  90787. /**
  90788. * Creates the VertexData for a Ribbon
  90789. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90790. * * pathArray array of paths, each of which an array of successive Vector3
  90791. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90792. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90793. * * 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
  90794. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90795. * * 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)
  90796. * * 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)
  90797. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90798. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90799. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90800. * @returns the VertexData of the ribbon
  90801. */
  90802. static CreateRibbon(options: {
  90803. pathArray: Vector3[][];
  90804. closeArray?: boolean;
  90805. closePath?: boolean;
  90806. offset?: number;
  90807. sideOrientation?: number;
  90808. frontUVs?: Vector4;
  90809. backUVs?: Vector4;
  90810. invertUV?: boolean;
  90811. uvs?: Vector2[];
  90812. colors?: Color4[];
  90813. }): VertexData;
  90814. /**
  90815. * Creates the VertexData for a box
  90816. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90817. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90818. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90819. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90820. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90821. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90822. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90823. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90824. * * 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)
  90825. * * 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)
  90826. * @returns the VertexData of the box
  90827. */
  90828. static CreateBox(options: {
  90829. size?: number;
  90830. width?: number;
  90831. height?: number;
  90832. depth?: number;
  90833. faceUV?: Vector4[];
  90834. faceColors?: Color4[];
  90835. sideOrientation?: number;
  90836. frontUVs?: Vector4;
  90837. backUVs?: Vector4;
  90838. }): VertexData;
  90839. /**
  90840. * Creates the VertexData for a tiled box
  90841. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90842. * * faceTiles sets the pattern, tile size and number of tiles for a face
  90843. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90844. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90845. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90846. * @returns the VertexData of the box
  90847. */
  90848. static CreateTiledBox(options: {
  90849. pattern?: number;
  90850. width?: number;
  90851. height?: number;
  90852. depth?: number;
  90853. tileSize?: number;
  90854. tileWidth?: number;
  90855. tileHeight?: number;
  90856. alignHorizontal?: number;
  90857. alignVertical?: number;
  90858. faceUV?: Vector4[];
  90859. faceColors?: Color4[];
  90860. sideOrientation?: number;
  90861. }): VertexData;
  90862. /**
  90863. * Creates the VertexData for a tiled plane
  90864. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90865. * * pattern a limited pattern arrangement depending on the number
  90866. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90867. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90868. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90869. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90870. * * 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)
  90871. * * 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)
  90872. * @returns the VertexData of the tiled plane
  90873. */
  90874. static CreateTiledPlane(options: {
  90875. pattern?: number;
  90876. tileSize?: number;
  90877. tileWidth?: number;
  90878. tileHeight?: number;
  90879. size?: number;
  90880. width?: number;
  90881. height?: number;
  90882. alignHorizontal?: number;
  90883. alignVertical?: number;
  90884. sideOrientation?: number;
  90885. frontUVs?: Vector4;
  90886. backUVs?: Vector4;
  90887. }): VertexData;
  90888. /**
  90889. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90890. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90891. * * segments sets the number of horizontal strips optional, default 32
  90892. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90893. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90894. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90895. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90896. * * 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
  90897. * * 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
  90898. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90899. * * 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)
  90900. * * 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)
  90901. * @returns the VertexData of the ellipsoid
  90902. */
  90903. static CreateSphere(options: {
  90904. segments?: number;
  90905. diameter?: number;
  90906. diameterX?: number;
  90907. diameterY?: number;
  90908. diameterZ?: number;
  90909. arc?: number;
  90910. slice?: number;
  90911. sideOrientation?: number;
  90912. frontUVs?: Vector4;
  90913. backUVs?: Vector4;
  90914. }): VertexData;
  90915. /**
  90916. * Creates the VertexData for a cylinder, cone or prism
  90917. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90918. * * height sets the height (y direction) of the cylinder, optional, default 2
  90919. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90920. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90921. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90922. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90923. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90924. * * 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
  90925. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90926. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90927. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90928. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90929. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90930. * * 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)
  90931. * * 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)
  90932. * @returns the VertexData of the cylinder, cone or prism
  90933. */
  90934. static CreateCylinder(options: {
  90935. height?: number;
  90936. diameterTop?: number;
  90937. diameterBottom?: number;
  90938. diameter?: number;
  90939. tessellation?: number;
  90940. subdivisions?: number;
  90941. arc?: number;
  90942. faceColors?: Color4[];
  90943. faceUV?: Vector4[];
  90944. hasRings?: boolean;
  90945. enclose?: boolean;
  90946. sideOrientation?: number;
  90947. frontUVs?: Vector4;
  90948. backUVs?: Vector4;
  90949. }): VertexData;
  90950. /**
  90951. * Creates the VertexData for a torus
  90952. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90953. * * diameter the diameter of the torus, optional default 1
  90954. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90955. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90957. * * 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)
  90958. * * 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)
  90959. * @returns the VertexData of the torus
  90960. */
  90961. static CreateTorus(options: {
  90962. diameter?: number;
  90963. thickness?: number;
  90964. tessellation?: number;
  90965. sideOrientation?: number;
  90966. frontUVs?: Vector4;
  90967. backUVs?: Vector4;
  90968. }): VertexData;
  90969. /**
  90970. * Creates the VertexData of the LineSystem
  90971. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90972. * - lines an array of lines, each line being an array of successive Vector3
  90973. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90974. * @returns the VertexData of the LineSystem
  90975. */
  90976. static CreateLineSystem(options: {
  90977. lines: Vector3[][];
  90978. colors?: Nullable<Color4[][]>;
  90979. }): VertexData;
  90980. /**
  90981. * Create the VertexData for a DashedLines
  90982. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90983. * - points an array successive Vector3
  90984. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90985. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90986. * - dashNb the intended total number of dashes, optional, default 200
  90987. * @returns the VertexData for the DashedLines
  90988. */
  90989. static CreateDashedLines(options: {
  90990. points: Vector3[];
  90991. dashSize?: number;
  90992. gapSize?: number;
  90993. dashNb?: number;
  90994. }): VertexData;
  90995. /**
  90996. * Creates the VertexData for a Ground
  90997. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90998. * - width the width (x direction) of the ground, optional, default 1
  90999. * - height the height (z direction) of the ground, optional, default 1
  91000. * - subdivisions the number of subdivisions per side, optional, default 1
  91001. * @returns the VertexData of the Ground
  91002. */
  91003. static CreateGround(options: {
  91004. width?: number;
  91005. height?: number;
  91006. subdivisions?: number;
  91007. subdivisionsX?: number;
  91008. subdivisionsY?: number;
  91009. }): VertexData;
  91010. /**
  91011. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  91012. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91013. * * xmin the ground minimum X coordinate, optional, default -1
  91014. * * zmin the ground minimum Z coordinate, optional, default -1
  91015. * * xmax the ground maximum X coordinate, optional, default 1
  91016. * * zmax the ground maximum Z coordinate, optional, default 1
  91017. * * 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}
  91018. * * 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}
  91019. * @returns the VertexData of the TiledGround
  91020. */
  91021. static CreateTiledGround(options: {
  91022. xmin: number;
  91023. zmin: number;
  91024. xmax: number;
  91025. zmax: number;
  91026. subdivisions?: {
  91027. w: number;
  91028. h: number;
  91029. };
  91030. precision?: {
  91031. w: number;
  91032. h: number;
  91033. };
  91034. }): VertexData;
  91035. /**
  91036. * Creates the VertexData of the Ground designed from a heightmap
  91037. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  91038. * * width the width (x direction) of the ground
  91039. * * height the height (z direction) of the ground
  91040. * * subdivisions the number of subdivisions per side
  91041. * * minHeight the minimum altitude on the ground, optional, default 0
  91042. * * maxHeight the maximum altitude on the ground, optional default 1
  91043. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  91044. * * buffer the array holding the image color data
  91045. * * bufferWidth the width of image
  91046. * * bufferHeight the height of image
  91047. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  91048. * @returns the VertexData of the Ground designed from a heightmap
  91049. */
  91050. static CreateGroundFromHeightMap(options: {
  91051. width: number;
  91052. height: number;
  91053. subdivisions: number;
  91054. minHeight: number;
  91055. maxHeight: number;
  91056. colorFilter: Color3;
  91057. buffer: Uint8Array;
  91058. bufferWidth: number;
  91059. bufferHeight: number;
  91060. alphaFilter: number;
  91061. }): VertexData;
  91062. /**
  91063. * Creates the VertexData for a Plane
  91064. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  91065. * * size sets the width and height of the plane to the value of size, optional default 1
  91066. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  91067. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  91068. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91069. * * 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)
  91070. * * 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)
  91071. * @returns the VertexData of the box
  91072. */
  91073. static CreatePlane(options: {
  91074. size?: number;
  91075. width?: number;
  91076. height?: number;
  91077. sideOrientation?: number;
  91078. frontUVs?: Vector4;
  91079. backUVs?: Vector4;
  91080. }): VertexData;
  91081. /**
  91082. * Creates the VertexData of the Disc or regular Polygon
  91083. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  91084. * * radius the radius of the disc, optional default 0.5
  91085. * * tessellation the number of polygon sides, optional, default 64
  91086. * * 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
  91087. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91088. * * 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)
  91089. * * 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)
  91090. * @returns the VertexData of the box
  91091. */
  91092. static CreateDisc(options: {
  91093. radius?: number;
  91094. tessellation?: number;
  91095. arc?: number;
  91096. sideOrientation?: number;
  91097. frontUVs?: Vector4;
  91098. backUVs?: Vector4;
  91099. }): VertexData;
  91100. /**
  91101. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  91102. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  91103. * @param polygon a mesh built from polygonTriangulation.build()
  91104. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91105. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91106. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91107. * @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)
  91108. * @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)
  91109. * @returns the VertexData of the Polygon
  91110. */
  91111. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  91112. /**
  91113. * Creates the VertexData of the IcoSphere
  91114. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  91115. * * radius the radius of the IcoSphere, optional default 1
  91116. * * radiusX allows stretching in the x direction, optional, default radius
  91117. * * radiusY allows stretching in the y direction, optional, default radius
  91118. * * radiusZ allows stretching in the z direction, optional, default radius
  91119. * * flat when true creates a flat shaded mesh, optional, default true
  91120. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91122. * * 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)
  91123. * * 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)
  91124. * @returns the VertexData of the IcoSphere
  91125. */
  91126. static CreateIcoSphere(options: {
  91127. radius?: number;
  91128. radiusX?: number;
  91129. radiusY?: number;
  91130. radiusZ?: number;
  91131. flat?: boolean;
  91132. subdivisions?: number;
  91133. sideOrientation?: number;
  91134. frontUVs?: Vector4;
  91135. backUVs?: Vector4;
  91136. }): VertexData;
  91137. /**
  91138. * Creates the VertexData for a Polyhedron
  91139. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  91140. * * type provided types are:
  91141. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  91142. * * 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)
  91143. * * size the size of the IcoSphere, optional default 1
  91144. * * sizeX allows stretching in the x direction, optional, default size
  91145. * * sizeY allows stretching in the y direction, optional, default size
  91146. * * sizeZ allows stretching in the z direction, optional, default size
  91147. * * 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
  91148. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91149. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91150. * * flat when true creates a flat shaded mesh, optional, default true
  91151. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91152. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91153. * * 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)
  91154. * * 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)
  91155. * @returns the VertexData of the Polyhedron
  91156. */
  91157. static CreatePolyhedron(options: {
  91158. type?: number;
  91159. size?: number;
  91160. sizeX?: number;
  91161. sizeY?: number;
  91162. sizeZ?: number;
  91163. custom?: any;
  91164. faceUV?: Vector4[];
  91165. faceColors?: Color4[];
  91166. flat?: boolean;
  91167. sideOrientation?: number;
  91168. frontUVs?: Vector4;
  91169. backUVs?: Vector4;
  91170. }): VertexData;
  91171. /**
  91172. * Creates the VertexData for a TorusKnot
  91173. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  91174. * * radius the radius of the torus knot, optional, default 2
  91175. * * tube the thickness of the tube, optional, default 0.5
  91176. * * radialSegments the number of sides on each tube segments, optional, default 32
  91177. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  91178. * * p the number of windings around the z axis, optional, default 2
  91179. * * q the number of windings around the x axis, optional, default 3
  91180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91181. * * 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)
  91182. * * 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)
  91183. * @returns the VertexData of the Torus Knot
  91184. */
  91185. static CreateTorusKnot(options: {
  91186. radius?: number;
  91187. tube?: number;
  91188. radialSegments?: number;
  91189. tubularSegments?: number;
  91190. p?: number;
  91191. q?: number;
  91192. sideOrientation?: number;
  91193. frontUVs?: Vector4;
  91194. backUVs?: Vector4;
  91195. }): VertexData;
  91196. /**
  91197. * Compute normals for given positions and indices
  91198. * @param positions an array of vertex positions, [...., x, y, z, ......]
  91199. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  91200. * @param normals an array of vertex normals, [...., x, y, z, ......]
  91201. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  91202. * * facetNormals : optional array of facet normals (vector3)
  91203. * * facetPositions : optional array of facet positions (vector3)
  91204. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  91205. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  91206. * * bInfo : optional bounding info, required for facetPartitioning computation
  91207. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  91208. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  91209. * * useRightHandedSystem: optional boolean to for right handed system computation
  91210. * * depthSort : optional boolean to enable the facet depth sort computation
  91211. * * distanceTo : optional Vector3 to compute the facet depth from this location
  91212. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  91213. */
  91214. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  91215. facetNormals?: any;
  91216. facetPositions?: any;
  91217. facetPartitioning?: any;
  91218. ratio?: number;
  91219. bInfo?: any;
  91220. bbSize?: Vector3;
  91221. subDiv?: any;
  91222. useRightHandedSystem?: boolean;
  91223. depthSort?: boolean;
  91224. distanceTo?: Vector3;
  91225. depthSortedFacets?: any;
  91226. }): void;
  91227. /** @hidden */
  91228. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  91229. /**
  91230. * Applies VertexData created from the imported parameters to the geometry
  91231. * @param parsedVertexData the parsed data from an imported file
  91232. * @param geometry the geometry to apply the VertexData to
  91233. */
  91234. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  91235. }
  91236. }
  91237. declare module BABYLON {
  91238. /**
  91239. * Defines a target to use with MorphTargetManager
  91240. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91241. */
  91242. export class MorphTarget implements IAnimatable {
  91243. /** defines the name of the target */
  91244. name: string;
  91245. /**
  91246. * Gets or sets the list of animations
  91247. */
  91248. animations: Animation[];
  91249. private _scene;
  91250. private _positions;
  91251. private _normals;
  91252. private _tangents;
  91253. private _uvs;
  91254. private _influence;
  91255. private _uniqueId;
  91256. /**
  91257. * Observable raised when the influence changes
  91258. */
  91259. onInfluenceChanged: Observable<boolean>;
  91260. /** @hidden */
  91261. _onDataLayoutChanged: Observable<void>;
  91262. /**
  91263. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  91264. */
  91265. influence: number;
  91266. /**
  91267. * Gets or sets the id of the morph Target
  91268. */
  91269. id: string;
  91270. private _animationPropertiesOverride;
  91271. /**
  91272. * Gets or sets the animation properties override
  91273. */
  91274. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91275. /**
  91276. * Creates a new MorphTarget
  91277. * @param name defines the name of the target
  91278. * @param influence defines the influence to use
  91279. * @param scene defines the scene the morphtarget belongs to
  91280. */
  91281. constructor(
  91282. /** defines the name of the target */
  91283. name: string, influence?: number, scene?: Nullable<Scene>);
  91284. /**
  91285. * Gets the unique ID of this manager
  91286. */
  91287. readonly uniqueId: number;
  91288. /**
  91289. * Gets a boolean defining if the target contains position data
  91290. */
  91291. readonly hasPositions: boolean;
  91292. /**
  91293. * Gets a boolean defining if the target contains normal data
  91294. */
  91295. readonly hasNormals: boolean;
  91296. /**
  91297. * Gets a boolean defining if the target contains tangent data
  91298. */
  91299. readonly hasTangents: boolean;
  91300. /**
  91301. * Gets a boolean defining if the target contains texture coordinates data
  91302. */
  91303. readonly hasUVs: boolean;
  91304. /**
  91305. * Affects position data to this target
  91306. * @param data defines the position data to use
  91307. */
  91308. setPositions(data: Nullable<FloatArray>): void;
  91309. /**
  91310. * Gets the position data stored in this target
  91311. * @returns a FloatArray containing the position data (or null if not present)
  91312. */
  91313. getPositions(): Nullable<FloatArray>;
  91314. /**
  91315. * Affects normal data to this target
  91316. * @param data defines the normal data to use
  91317. */
  91318. setNormals(data: Nullable<FloatArray>): void;
  91319. /**
  91320. * Gets the normal data stored in this target
  91321. * @returns a FloatArray containing the normal data (or null if not present)
  91322. */
  91323. getNormals(): Nullable<FloatArray>;
  91324. /**
  91325. * Affects tangent data to this target
  91326. * @param data defines the tangent data to use
  91327. */
  91328. setTangents(data: Nullable<FloatArray>): void;
  91329. /**
  91330. * Gets the tangent data stored in this target
  91331. * @returns a FloatArray containing the tangent data (or null if not present)
  91332. */
  91333. getTangents(): Nullable<FloatArray>;
  91334. /**
  91335. * Affects texture coordinates data to this target
  91336. * @param data defines the texture coordinates data to use
  91337. */
  91338. setUVs(data: Nullable<FloatArray>): void;
  91339. /**
  91340. * Gets the texture coordinates data stored in this target
  91341. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  91342. */
  91343. getUVs(): Nullable<FloatArray>;
  91344. /**
  91345. * Clone the current target
  91346. * @returns a new MorphTarget
  91347. */
  91348. clone(): MorphTarget;
  91349. /**
  91350. * Serializes the current target into a Serialization object
  91351. * @returns the serialized object
  91352. */
  91353. serialize(): any;
  91354. /**
  91355. * Returns the string "MorphTarget"
  91356. * @returns "MorphTarget"
  91357. */
  91358. getClassName(): string;
  91359. /**
  91360. * Creates a new target from serialized data
  91361. * @param serializationObject defines the serialized data to use
  91362. * @returns a new MorphTarget
  91363. */
  91364. static Parse(serializationObject: any): MorphTarget;
  91365. /**
  91366. * Creates a MorphTarget from mesh data
  91367. * @param mesh defines the source mesh
  91368. * @param name defines the name to use for the new target
  91369. * @param influence defines the influence to attach to the target
  91370. * @returns a new MorphTarget
  91371. */
  91372. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  91373. }
  91374. }
  91375. declare module BABYLON {
  91376. /**
  91377. * This class is used to deform meshes using morphing between different targets
  91378. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91379. */
  91380. export class MorphTargetManager {
  91381. private _targets;
  91382. private _targetInfluenceChangedObservers;
  91383. private _targetDataLayoutChangedObservers;
  91384. private _activeTargets;
  91385. private _scene;
  91386. private _influences;
  91387. private _supportsNormals;
  91388. private _supportsTangents;
  91389. private _supportsUVs;
  91390. private _vertexCount;
  91391. private _uniqueId;
  91392. private _tempInfluences;
  91393. /**
  91394. * Gets or sets a boolean indicating if normals must be morphed
  91395. */
  91396. enableNormalMorphing: boolean;
  91397. /**
  91398. * Gets or sets a boolean indicating if tangents must be morphed
  91399. */
  91400. enableTangentMorphing: boolean;
  91401. /**
  91402. * Gets or sets a boolean indicating if UV must be morphed
  91403. */
  91404. enableUVMorphing: boolean;
  91405. /**
  91406. * Creates a new MorphTargetManager
  91407. * @param scene defines the current scene
  91408. */
  91409. constructor(scene?: Nullable<Scene>);
  91410. /**
  91411. * Gets the unique ID of this manager
  91412. */
  91413. readonly uniqueId: number;
  91414. /**
  91415. * Gets the number of vertices handled by this manager
  91416. */
  91417. readonly vertexCount: number;
  91418. /**
  91419. * Gets a boolean indicating if this manager supports morphing of normals
  91420. */
  91421. readonly supportsNormals: boolean;
  91422. /**
  91423. * Gets a boolean indicating if this manager supports morphing of tangents
  91424. */
  91425. readonly supportsTangents: boolean;
  91426. /**
  91427. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  91428. */
  91429. readonly supportsUVs: boolean;
  91430. /**
  91431. * Gets the number of targets stored in this manager
  91432. */
  91433. readonly numTargets: number;
  91434. /**
  91435. * Gets the number of influencers (ie. the number of targets with influences > 0)
  91436. */
  91437. readonly numInfluencers: number;
  91438. /**
  91439. * Gets the list of influences (one per target)
  91440. */
  91441. readonly influences: Float32Array;
  91442. /**
  91443. * Gets the active target at specified index. An active target is a target with an influence > 0
  91444. * @param index defines the index to check
  91445. * @returns the requested target
  91446. */
  91447. getActiveTarget(index: number): MorphTarget;
  91448. /**
  91449. * Gets the target at specified index
  91450. * @param index defines the index to check
  91451. * @returns the requested target
  91452. */
  91453. getTarget(index: number): MorphTarget;
  91454. /**
  91455. * Add a new target to this manager
  91456. * @param target defines the target to add
  91457. */
  91458. addTarget(target: MorphTarget): void;
  91459. /**
  91460. * Removes a target from the manager
  91461. * @param target defines the target to remove
  91462. */
  91463. removeTarget(target: MorphTarget): void;
  91464. /**
  91465. * Clone the current manager
  91466. * @returns a new MorphTargetManager
  91467. */
  91468. clone(): MorphTargetManager;
  91469. /**
  91470. * Serializes the current manager into a Serialization object
  91471. * @returns the serialized object
  91472. */
  91473. serialize(): any;
  91474. private _syncActiveTargets;
  91475. /**
  91476. * Syncrhonize the targets with all the meshes using this morph target manager
  91477. */
  91478. synchronize(): void;
  91479. /**
  91480. * Creates a new MorphTargetManager from serialized data
  91481. * @param serializationObject defines the serialized data
  91482. * @param scene defines the hosting scene
  91483. * @returns the new MorphTargetManager
  91484. */
  91485. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  91486. }
  91487. }
  91488. declare module BABYLON {
  91489. /**
  91490. * Class used to represent a specific level of detail of a mesh
  91491. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91492. */
  91493. export class MeshLODLevel {
  91494. /** Defines the distance where this level should start being displayed */
  91495. distance: number;
  91496. /** Defines the mesh to use to render this level */
  91497. mesh: Nullable<Mesh>;
  91498. /**
  91499. * Creates a new LOD level
  91500. * @param distance defines the distance where this level should star being displayed
  91501. * @param mesh defines the mesh to use to render this level
  91502. */
  91503. constructor(
  91504. /** Defines the distance where this level should start being displayed */
  91505. distance: number,
  91506. /** Defines the mesh to use to render this level */
  91507. mesh: Nullable<Mesh>);
  91508. }
  91509. }
  91510. declare module BABYLON {
  91511. /**
  91512. * Mesh representing the gorund
  91513. */
  91514. export class GroundMesh extends Mesh {
  91515. /** If octree should be generated */
  91516. generateOctree: boolean;
  91517. private _heightQuads;
  91518. /** @hidden */
  91519. _subdivisionsX: number;
  91520. /** @hidden */
  91521. _subdivisionsY: number;
  91522. /** @hidden */
  91523. _width: number;
  91524. /** @hidden */
  91525. _height: number;
  91526. /** @hidden */
  91527. _minX: number;
  91528. /** @hidden */
  91529. _maxX: number;
  91530. /** @hidden */
  91531. _minZ: number;
  91532. /** @hidden */
  91533. _maxZ: number;
  91534. constructor(name: string, scene: Scene);
  91535. /**
  91536. * "GroundMesh"
  91537. * @returns "GroundMesh"
  91538. */
  91539. getClassName(): string;
  91540. /**
  91541. * The minimum of x and y subdivisions
  91542. */
  91543. readonly subdivisions: number;
  91544. /**
  91545. * X subdivisions
  91546. */
  91547. readonly subdivisionsX: number;
  91548. /**
  91549. * Y subdivisions
  91550. */
  91551. readonly subdivisionsY: number;
  91552. /**
  91553. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  91554. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  91555. * @param chunksCount the number of subdivisions for x and y
  91556. * @param octreeBlocksSize (Default: 32)
  91557. */
  91558. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  91559. /**
  91560. * Returns a height (y) value in the Worl system :
  91561. * the ground altitude at the coordinates (x, z) expressed in the World system.
  91562. * @param x x coordinate
  91563. * @param z z coordinate
  91564. * @returns the ground y position if (x, z) are outside the ground surface.
  91565. */
  91566. getHeightAtCoordinates(x: number, z: number): number;
  91567. /**
  91568. * Returns a normalized vector (Vector3) orthogonal to the ground
  91569. * at the ground coordinates (x, z) expressed in the World system.
  91570. * @param x x coordinate
  91571. * @param z z coordinate
  91572. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  91573. */
  91574. getNormalAtCoordinates(x: number, z: number): Vector3;
  91575. /**
  91576. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  91577. * at the ground coordinates (x, z) expressed in the World system.
  91578. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  91579. * @param x x coordinate
  91580. * @param z z coordinate
  91581. * @param ref vector to store the result
  91582. * @returns the GroundMesh.
  91583. */
  91584. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  91585. /**
  91586. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  91587. * if the ground has been updated.
  91588. * This can be used in the render loop.
  91589. * @returns the GroundMesh.
  91590. */
  91591. updateCoordinateHeights(): GroundMesh;
  91592. private _getFacetAt;
  91593. private _initHeightQuads;
  91594. private _computeHeightQuads;
  91595. /**
  91596. * Serializes this ground mesh
  91597. * @param serializationObject object to write serialization to
  91598. */
  91599. serialize(serializationObject: any): void;
  91600. /**
  91601. * Parses a serialized ground mesh
  91602. * @param parsedMesh the serialized mesh
  91603. * @param scene the scene to create the ground mesh in
  91604. * @returns the created ground mesh
  91605. */
  91606. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  91607. }
  91608. }
  91609. declare module BABYLON {
  91610. /**
  91611. * Interface for Physics-Joint data
  91612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91613. */
  91614. export interface PhysicsJointData {
  91615. /**
  91616. * The main pivot of the joint
  91617. */
  91618. mainPivot?: Vector3;
  91619. /**
  91620. * The connected pivot of the joint
  91621. */
  91622. connectedPivot?: Vector3;
  91623. /**
  91624. * The main axis of the joint
  91625. */
  91626. mainAxis?: Vector3;
  91627. /**
  91628. * The connected axis of the joint
  91629. */
  91630. connectedAxis?: Vector3;
  91631. /**
  91632. * The collision of the joint
  91633. */
  91634. collision?: boolean;
  91635. /**
  91636. * Native Oimo/Cannon/Energy data
  91637. */
  91638. nativeParams?: any;
  91639. }
  91640. /**
  91641. * This is a holder class for the physics joint created by the physics plugin
  91642. * It holds a set of functions to control the underlying joint
  91643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91644. */
  91645. export class PhysicsJoint {
  91646. /**
  91647. * The type of the physics joint
  91648. */
  91649. type: number;
  91650. /**
  91651. * The data for the physics joint
  91652. */
  91653. jointData: PhysicsJointData;
  91654. private _physicsJoint;
  91655. protected _physicsPlugin: IPhysicsEnginePlugin;
  91656. /**
  91657. * Initializes the physics joint
  91658. * @param type The type of the physics joint
  91659. * @param jointData The data for the physics joint
  91660. */
  91661. constructor(
  91662. /**
  91663. * The type of the physics joint
  91664. */
  91665. type: number,
  91666. /**
  91667. * The data for the physics joint
  91668. */
  91669. jointData: PhysicsJointData);
  91670. /**
  91671. * Gets the physics joint
  91672. */
  91673. /**
  91674. * Sets the physics joint
  91675. */
  91676. physicsJoint: any;
  91677. /**
  91678. * Sets the physics plugin
  91679. */
  91680. physicsPlugin: IPhysicsEnginePlugin;
  91681. /**
  91682. * Execute a function that is physics-plugin specific.
  91683. * @param {Function} func the function that will be executed.
  91684. * It accepts two parameters: the physics world and the physics joint
  91685. */
  91686. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  91687. /**
  91688. * Distance-Joint type
  91689. */
  91690. static DistanceJoint: number;
  91691. /**
  91692. * Hinge-Joint type
  91693. */
  91694. static HingeJoint: number;
  91695. /**
  91696. * Ball-and-Socket joint type
  91697. */
  91698. static BallAndSocketJoint: number;
  91699. /**
  91700. * Wheel-Joint type
  91701. */
  91702. static WheelJoint: number;
  91703. /**
  91704. * Slider-Joint type
  91705. */
  91706. static SliderJoint: number;
  91707. /**
  91708. * Prismatic-Joint type
  91709. */
  91710. static PrismaticJoint: number;
  91711. /**
  91712. * Universal-Joint type
  91713. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  91714. */
  91715. static UniversalJoint: number;
  91716. /**
  91717. * Hinge-Joint 2 type
  91718. */
  91719. static Hinge2Joint: number;
  91720. /**
  91721. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  91722. */
  91723. static PointToPointJoint: number;
  91724. /**
  91725. * Spring-Joint type
  91726. */
  91727. static SpringJoint: number;
  91728. /**
  91729. * Lock-Joint type
  91730. */
  91731. static LockJoint: number;
  91732. }
  91733. /**
  91734. * A class representing a physics distance joint
  91735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91736. */
  91737. export class DistanceJoint extends PhysicsJoint {
  91738. /**
  91739. *
  91740. * @param jointData The data for the Distance-Joint
  91741. */
  91742. constructor(jointData: DistanceJointData);
  91743. /**
  91744. * Update the predefined distance.
  91745. * @param maxDistance The maximum preferred distance
  91746. * @param minDistance The minimum preferred distance
  91747. */
  91748. updateDistance(maxDistance: number, minDistance?: number): void;
  91749. }
  91750. /**
  91751. * Represents a Motor-Enabled Joint
  91752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91753. */
  91754. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  91755. /**
  91756. * Initializes the Motor-Enabled Joint
  91757. * @param type The type of the joint
  91758. * @param jointData The physica joint data for the joint
  91759. */
  91760. constructor(type: number, jointData: PhysicsJointData);
  91761. /**
  91762. * Set the motor values.
  91763. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91764. * @param force the force to apply
  91765. * @param maxForce max force for this motor.
  91766. */
  91767. setMotor(force?: number, maxForce?: number): void;
  91768. /**
  91769. * Set the motor's limits.
  91770. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91771. * @param upperLimit The upper limit of the motor
  91772. * @param lowerLimit The lower limit of the motor
  91773. */
  91774. setLimit(upperLimit: number, lowerLimit?: number): void;
  91775. }
  91776. /**
  91777. * This class represents a single physics Hinge-Joint
  91778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91779. */
  91780. export class HingeJoint extends MotorEnabledJoint {
  91781. /**
  91782. * Initializes the Hinge-Joint
  91783. * @param jointData The joint data for the Hinge-Joint
  91784. */
  91785. constructor(jointData: PhysicsJointData);
  91786. /**
  91787. * Set the motor values.
  91788. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91789. * @param {number} force the force to apply
  91790. * @param {number} maxForce max force for this motor.
  91791. */
  91792. setMotor(force?: number, maxForce?: number): void;
  91793. /**
  91794. * Set the motor's limits.
  91795. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91796. * @param upperLimit The upper limit of the motor
  91797. * @param lowerLimit The lower limit of the motor
  91798. */
  91799. setLimit(upperLimit: number, lowerLimit?: number): void;
  91800. }
  91801. /**
  91802. * This class represents a dual hinge physics joint (same as wheel joint)
  91803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91804. */
  91805. export class Hinge2Joint extends MotorEnabledJoint {
  91806. /**
  91807. * Initializes the Hinge2-Joint
  91808. * @param jointData The joint data for the Hinge2-Joint
  91809. */
  91810. constructor(jointData: PhysicsJointData);
  91811. /**
  91812. * Set the motor values.
  91813. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91814. * @param {number} targetSpeed the speed the motor is to reach
  91815. * @param {number} maxForce max force for this motor.
  91816. * @param {motorIndex} the motor's index, 0 or 1.
  91817. */
  91818. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  91819. /**
  91820. * Set the motor limits.
  91821. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91822. * @param {number} upperLimit the upper limit
  91823. * @param {number} lowerLimit lower limit
  91824. * @param {motorIndex} the motor's index, 0 or 1.
  91825. */
  91826. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91827. }
  91828. /**
  91829. * Interface for a motor enabled joint
  91830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91831. */
  91832. export interface IMotorEnabledJoint {
  91833. /**
  91834. * Physics joint
  91835. */
  91836. physicsJoint: any;
  91837. /**
  91838. * Sets the motor of the motor-enabled joint
  91839. * @param force The force of the motor
  91840. * @param maxForce The maximum force of the motor
  91841. * @param motorIndex The index of the motor
  91842. */
  91843. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  91844. /**
  91845. * Sets the limit of the motor
  91846. * @param upperLimit The upper limit of the motor
  91847. * @param lowerLimit The lower limit of the motor
  91848. * @param motorIndex The index of the motor
  91849. */
  91850. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91851. }
  91852. /**
  91853. * Joint data for a Distance-Joint
  91854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91855. */
  91856. export interface DistanceJointData extends PhysicsJointData {
  91857. /**
  91858. * Max distance the 2 joint objects can be apart
  91859. */
  91860. maxDistance: number;
  91861. }
  91862. /**
  91863. * Joint data from a spring joint
  91864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91865. */
  91866. export interface SpringJointData extends PhysicsJointData {
  91867. /**
  91868. * Length of the spring
  91869. */
  91870. length: number;
  91871. /**
  91872. * Stiffness of the spring
  91873. */
  91874. stiffness: number;
  91875. /**
  91876. * Damping of the spring
  91877. */
  91878. damping: number;
  91879. /** this callback will be called when applying the force to the impostors. */
  91880. forceApplicationCallback: () => void;
  91881. }
  91882. }
  91883. declare module BABYLON {
  91884. /**
  91885. * Holds the data for the raycast result
  91886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91887. */
  91888. export class PhysicsRaycastResult {
  91889. private _hasHit;
  91890. private _hitDistance;
  91891. private _hitNormalWorld;
  91892. private _hitPointWorld;
  91893. private _rayFromWorld;
  91894. private _rayToWorld;
  91895. /**
  91896. * Gets if there was a hit
  91897. */
  91898. readonly hasHit: boolean;
  91899. /**
  91900. * Gets the distance from the hit
  91901. */
  91902. readonly hitDistance: number;
  91903. /**
  91904. * Gets the hit normal/direction in the world
  91905. */
  91906. readonly hitNormalWorld: Vector3;
  91907. /**
  91908. * Gets the hit point in the world
  91909. */
  91910. readonly hitPointWorld: Vector3;
  91911. /**
  91912. * Gets the ray "start point" of the ray in the world
  91913. */
  91914. readonly rayFromWorld: Vector3;
  91915. /**
  91916. * Gets the ray "end point" of the ray in the world
  91917. */
  91918. readonly rayToWorld: Vector3;
  91919. /**
  91920. * Sets the hit data (normal & point in world space)
  91921. * @param hitNormalWorld defines the normal in world space
  91922. * @param hitPointWorld defines the point in world space
  91923. */
  91924. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91925. /**
  91926. * Sets the distance from the start point to the hit point
  91927. * @param distance
  91928. */
  91929. setHitDistance(distance: number): void;
  91930. /**
  91931. * Calculates the distance manually
  91932. */
  91933. calculateHitDistance(): void;
  91934. /**
  91935. * Resets all the values to default
  91936. * @param from The from point on world space
  91937. * @param to The to point on world space
  91938. */
  91939. reset(from?: Vector3, to?: Vector3): void;
  91940. }
  91941. /**
  91942. * Interface for the size containing width and height
  91943. */
  91944. interface IXYZ {
  91945. /**
  91946. * X
  91947. */
  91948. x: number;
  91949. /**
  91950. * Y
  91951. */
  91952. y: number;
  91953. /**
  91954. * Z
  91955. */
  91956. z: number;
  91957. }
  91958. }
  91959. declare module BABYLON {
  91960. /**
  91961. * Interface used to describe a physics joint
  91962. */
  91963. export interface PhysicsImpostorJoint {
  91964. /** Defines the main impostor to which the joint is linked */
  91965. mainImpostor: PhysicsImpostor;
  91966. /** Defines the impostor that is connected to the main impostor using this joint */
  91967. connectedImpostor: PhysicsImpostor;
  91968. /** Defines the joint itself */
  91969. joint: PhysicsJoint;
  91970. }
  91971. /** @hidden */
  91972. export interface IPhysicsEnginePlugin {
  91973. world: any;
  91974. name: string;
  91975. setGravity(gravity: Vector3): void;
  91976. setTimeStep(timeStep: number): void;
  91977. getTimeStep(): number;
  91978. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91979. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91980. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91981. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91982. removePhysicsBody(impostor: PhysicsImpostor): void;
  91983. generateJoint(joint: PhysicsImpostorJoint): void;
  91984. removeJoint(joint: PhysicsImpostorJoint): void;
  91985. isSupported(): boolean;
  91986. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91987. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91988. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91989. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91990. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91991. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91992. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91993. getBodyMass(impostor: PhysicsImpostor): number;
  91994. getBodyFriction(impostor: PhysicsImpostor): number;
  91995. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91996. getBodyRestitution(impostor: PhysicsImpostor): number;
  91997. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91998. getBodyPressure?(impostor: PhysicsImpostor): number;
  91999. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  92000. getBodyStiffness?(impostor: PhysicsImpostor): number;
  92001. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  92002. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  92003. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  92004. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  92005. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  92006. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  92007. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  92008. sleepBody(impostor: PhysicsImpostor): void;
  92009. wakeUpBody(impostor: PhysicsImpostor): void;
  92010. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92011. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  92012. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  92013. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92014. getRadius(impostor: PhysicsImpostor): number;
  92015. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  92016. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  92017. dispose(): void;
  92018. }
  92019. /**
  92020. * Interface used to define a physics engine
  92021. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  92022. */
  92023. export interface IPhysicsEngine {
  92024. /**
  92025. * Gets the gravity vector used by the simulation
  92026. */
  92027. gravity: Vector3;
  92028. /**
  92029. * Sets the gravity vector used by the simulation
  92030. * @param gravity defines the gravity vector to use
  92031. */
  92032. setGravity(gravity: Vector3): void;
  92033. /**
  92034. * Set the time step of the physics engine.
  92035. * Default is 1/60.
  92036. * To slow it down, enter 1/600 for example.
  92037. * To speed it up, 1/30
  92038. * @param newTimeStep the new timestep to apply to this world.
  92039. */
  92040. setTimeStep(newTimeStep: number): void;
  92041. /**
  92042. * Get the time step of the physics engine.
  92043. * @returns the current time step
  92044. */
  92045. getTimeStep(): number;
  92046. /**
  92047. * Set the sub time step of the physics engine.
  92048. * Default is 0 meaning there is no sub steps
  92049. * To increase physics resolution precision, set a small value (like 1 ms)
  92050. * @param subTimeStep defines the new sub timestep used for physics resolution.
  92051. */
  92052. setSubTimeStep(subTimeStep: number): void;
  92053. /**
  92054. * Get the sub time step of the physics engine.
  92055. * @returns the current sub time step
  92056. */
  92057. getSubTimeStep(): number;
  92058. /**
  92059. * Release all resources
  92060. */
  92061. dispose(): void;
  92062. /**
  92063. * Gets the name of the current physics plugin
  92064. * @returns the name of the plugin
  92065. */
  92066. getPhysicsPluginName(): string;
  92067. /**
  92068. * Adding a new impostor for the impostor tracking.
  92069. * This will be done by the impostor itself.
  92070. * @param impostor the impostor to add
  92071. */
  92072. addImpostor(impostor: PhysicsImpostor): void;
  92073. /**
  92074. * Remove an impostor from the engine.
  92075. * This impostor and its mesh will not longer be updated by the physics engine.
  92076. * @param impostor the impostor to remove
  92077. */
  92078. removeImpostor(impostor: PhysicsImpostor): void;
  92079. /**
  92080. * Add a joint to the physics engine
  92081. * @param mainImpostor defines the main impostor to which the joint is added.
  92082. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  92083. * @param joint defines the joint that will connect both impostors.
  92084. */
  92085. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92086. /**
  92087. * Removes a joint from the simulation
  92088. * @param mainImpostor defines the impostor used with the joint
  92089. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  92090. * @param joint defines the joint to remove
  92091. */
  92092. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92093. /**
  92094. * Gets the current plugin used to run the simulation
  92095. * @returns current plugin
  92096. */
  92097. getPhysicsPlugin(): IPhysicsEnginePlugin;
  92098. /**
  92099. * Gets the list of physic impostors
  92100. * @returns an array of PhysicsImpostor
  92101. */
  92102. getImpostors(): Array<PhysicsImpostor>;
  92103. /**
  92104. * Gets the impostor for a physics enabled object
  92105. * @param object defines the object impersonated by the impostor
  92106. * @returns the PhysicsImpostor or null if not found
  92107. */
  92108. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92109. /**
  92110. * Gets the impostor for a physics body object
  92111. * @param body defines physics body used by the impostor
  92112. * @returns the PhysicsImpostor or null if not found
  92113. */
  92114. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  92115. /**
  92116. * Does a raycast in the physics world
  92117. * @param from when should the ray start?
  92118. * @param to when should the ray end?
  92119. * @returns PhysicsRaycastResult
  92120. */
  92121. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92122. /**
  92123. * Called by the scene. No need to call it.
  92124. * @param delta defines the timespam between frames
  92125. */
  92126. _step(delta: number): void;
  92127. }
  92128. }
  92129. declare module BABYLON {
  92130. /**
  92131. * The interface for the physics imposter parameters
  92132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92133. */
  92134. export interface PhysicsImpostorParameters {
  92135. /**
  92136. * The mass of the physics imposter
  92137. */
  92138. mass: number;
  92139. /**
  92140. * The friction of the physics imposter
  92141. */
  92142. friction?: number;
  92143. /**
  92144. * The coefficient of restitution of the physics imposter
  92145. */
  92146. restitution?: number;
  92147. /**
  92148. * The native options of the physics imposter
  92149. */
  92150. nativeOptions?: any;
  92151. /**
  92152. * Specifies if the parent should be ignored
  92153. */
  92154. ignoreParent?: boolean;
  92155. /**
  92156. * Specifies if bi-directional transformations should be disabled
  92157. */
  92158. disableBidirectionalTransformation?: boolean;
  92159. /**
  92160. * The pressure inside the physics imposter, soft object only
  92161. */
  92162. pressure?: number;
  92163. /**
  92164. * The stiffness the physics imposter, soft object only
  92165. */
  92166. stiffness?: number;
  92167. /**
  92168. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  92169. */
  92170. velocityIterations?: number;
  92171. /**
  92172. * The number of iterations used in maintaining consistent vertex positions, soft object only
  92173. */
  92174. positionIterations?: number;
  92175. /**
  92176. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  92177. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  92178. * Add to fix multiple points
  92179. */
  92180. fixedPoints?: number;
  92181. /**
  92182. * The collision margin around a soft object
  92183. */
  92184. margin?: number;
  92185. /**
  92186. * The collision margin around a soft object
  92187. */
  92188. damping?: number;
  92189. /**
  92190. * The path for a rope based on an extrusion
  92191. */
  92192. path?: any;
  92193. /**
  92194. * The shape of an extrusion used for a rope based on an extrusion
  92195. */
  92196. shape?: any;
  92197. }
  92198. /**
  92199. * Interface for a physics-enabled object
  92200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92201. */
  92202. export interface IPhysicsEnabledObject {
  92203. /**
  92204. * The position of the physics-enabled object
  92205. */
  92206. position: Vector3;
  92207. /**
  92208. * The rotation of the physics-enabled object
  92209. */
  92210. rotationQuaternion: Nullable<Quaternion>;
  92211. /**
  92212. * The scale of the physics-enabled object
  92213. */
  92214. scaling: Vector3;
  92215. /**
  92216. * The rotation of the physics-enabled object
  92217. */
  92218. rotation?: Vector3;
  92219. /**
  92220. * The parent of the physics-enabled object
  92221. */
  92222. parent?: any;
  92223. /**
  92224. * The bounding info of the physics-enabled object
  92225. * @returns The bounding info of the physics-enabled object
  92226. */
  92227. getBoundingInfo(): BoundingInfo;
  92228. /**
  92229. * Computes the world matrix
  92230. * @param force Specifies if the world matrix should be computed by force
  92231. * @returns A world matrix
  92232. */
  92233. computeWorldMatrix(force: boolean): Matrix;
  92234. /**
  92235. * Gets the world matrix
  92236. * @returns A world matrix
  92237. */
  92238. getWorldMatrix?(): Matrix;
  92239. /**
  92240. * Gets the child meshes
  92241. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  92242. * @returns An array of abstract meshes
  92243. */
  92244. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  92245. /**
  92246. * Gets the vertex data
  92247. * @param kind The type of vertex data
  92248. * @returns A nullable array of numbers, or a float32 array
  92249. */
  92250. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  92251. /**
  92252. * Gets the indices from the mesh
  92253. * @returns A nullable array of index arrays
  92254. */
  92255. getIndices?(): Nullable<IndicesArray>;
  92256. /**
  92257. * Gets the scene from the mesh
  92258. * @returns the indices array or null
  92259. */
  92260. getScene?(): Scene;
  92261. /**
  92262. * Gets the absolute position from the mesh
  92263. * @returns the absolute position
  92264. */
  92265. getAbsolutePosition(): Vector3;
  92266. /**
  92267. * Gets the absolute pivot point from the mesh
  92268. * @returns the absolute pivot point
  92269. */
  92270. getAbsolutePivotPoint(): Vector3;
  92271. /**
  92272. * Rotates the mesh
  92273. * @param axis The axis of rotation
  92274. * @param amount The amount of rotation
  92275. * @param space The space of the rotation
  92276. * @returns The rotation transform node
  92277. */
  92278. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92279. /**
  92280. * Translates the mesh
  92281. * @param axis The axis of translation
  92282. * @param distance The distance of translation
  92283. * @param space The space of the translation
  92284. * @returns The transform node
  92285. */
  92286. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92287. /**
  92288. * Sets the absolute position of the mesh
  92289. * @param absolutePosition The absolute position of the mesh
  92290. * @returns The transform node
  92291. */
  92292. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92293. /**
  92294. * Gets the class name of the mesh
  92295. * @returns The class name
  92296. */
  92297. getClassName(): string;
  92298. }
  92299. /**
  92300. * Represents a physics imposter
  92301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92302. */
  92303. export class PhysicsImpostor {
  92304. /**
  92305. * The physics-enabled object used as the physics imposter
  92306. */
  92307. object: IPhysicsEnabledObject;
  92308. /**
  92309. * The type of the physics imposter
  92310. */
  92311. type: number;
  92312. private _options;
  92313. private _scene?;
  92314. /**
  92315. * The default object size of the imposter
  92316. */
  92317. static DEFAULT_OBJECT_SIZE: Vector3;
  92318. /**
  92319. * The identity quaternion of the imposter
  92320. */
  92321. static IDENTITY_QUATERNION: Quaternion;
  92322. /** @hidden */
  92323. _pluginData: any;
  92324. private _physicsEngine;
  92325. private _physicsBody;
  92326. private _bodyUpdateRequired;
  92327. private _onBeforePhysicsStepCallbacks;
  92328. private _onAfterPhysicsStepCallbacks;
  92329. /** @hidden */
  92330. _onPhysicsCollideCallbacks: Array<{
  92331. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  92332. otherImpostors: Array<PhysicsImpostor>;
  92333. }>;
  92334. private _deltaPosition;
  92335. private _deltaRotation;
  92336. private _deltaRotationConjugated;
  92337. /** @hidden */
  92338. _isFromLine: boolean;
  92339. private _parent;
  92340. private _isDisposed;
  92341. private static _tmpVecs;
  92342. private static _tmpQuat;
  92343. /**
  92344. * Specifies if the physics imposter is disposed
  92345. */
  92346. readonly isDisposed: boolean;
  92347. /**
  92348. * Gets the mass of the physics imposter
  92349. */
  92350. mass: number;
  92351. /**
  92352. * Gets the coefficient of friction
  92353. */
  92354. /**
  92355. * Sets the coefficient of friction
  92356. */
  92357. friction: number;
  92358. /**
  92359. * Gets the coefficient of restitution
  92360. */
  92361. /**
  92362. * Sets the coefficient of restitution
  92363. */
  92364. restitution: number;
  92365. /**
  92366. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  92367. */
  92368. /**
  92369. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  92370. */
  92371. pressure: number;
  92372. /**
  92373. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92374. */
  92375. /**
  92376. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92377. */
  92378. stiffness: number;
  92379. /**
  92380. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92381. */
  92382. /**
  92383. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92384. */
  92385. velocityIterations: number;
  92386. /**
  92387. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92388. */
  92389. /**
  92390. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92391. */
  92392. positionIterations: number;
  92393. /**
  92394. * The unique id of the physics imposter
  92395. * set by the physics engine when adding this impostor to the array
  92396. */
  92397. uniqueId: number;
  92398. /**
  92399. * @hidden
  92400. */
  92401. soft: boolean;
  92402. /**
  92403. * @hidden
  92404. */
  92405. segments: number;
  92406. private _joints;
  92407. /**
  92408. * Initializes the physics imposter
  92409. * @param object The physics-enabled object used as the physics imposter
  92410. * @param type The type of the physics imposter
  92411. * @param _options The options for the physics imposter
  92412. * @param _scene The Babylon scene
  92413. */
  92414. constructor(
  92415. /**
  92416. * The physics-enabled object used as the physics imposter
  92417. */
  92418. object: IPhysicsEnabledObject,
  92419. /**
  92420. * The type of the physics imposter
  92421. */
  92422. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  92423. /**
  92424. * This function will completly initialize this impostor.
  92425. * It will create a new body - but only if this mesh has no parent.
  92426. * If it has, this impostor will not be used other than to define the impostor
  92427. * of the child mesh.
  92428. * @hidden
  92429. */
  92430. _init(): void;
  92431. private _getPhysicsParent;
  92432. /**
  92433. * Should a new body be generated.
  92434. * @returns boolean specifying if body initialization is required
  92435. */
  92436. isBodyInitRequired(): boolean;
  92437. /**
  92438. * Sets the updated scaling
  92439. * @param updated Specifies if the scaling is updated
  92440. */
  92441. setScalingUpdated(): void;
  92442. /**
  92443. * Force a regeneration of this or the parent's impostor's body.
  92444. * Use under cautious - This will remove all joints already implemented.
  92445. */
  92446. forceUpdate(): void;
  92447. /**
  92448. * Gets the body that holds this impostor. Either its own, or its parent.
  92449. */
  92450. /**
  92451. * Set the physics body. Used mainly by the physics engine/plugin
  92452. */
  92453. physicsBody: any;
  92454. /**
  92455. * Get the parent of the physics imposter
  92456. * @returns Physics imposter or null
  92457. */
  92458. /**
  92459. * Sets the parent of the physics imposter
  92460. */
  92461. parent: Nullable<PhysicsImpostor>;
  92462. /**
  92463. * Resets the update flags
  92464. */
  92465. resetUpdateFlags(): void;
  92466. /**
  92467. * Gets the object extend size
  92468. * @returns the object extend size
  92469. */
  92470. getObjectExtendSize(): Vector3;
  92471. /**
  92472. * Gets the object center
  92473. * @returns The object center
  92474. */
  92475. getObjectCenter(): Vector3;
  92476. /**
  92477. * Get a specific parametes from the options parameter
  92478. * @param paramName The object parameter name
  92479. * @returns The object parameter
  92480. */
  92481. getParam(paramName: string): any;
  92482. /**
  92483. * Sets a specific parameter in the options given to the physics plugin
  92484. * @param paramName The parameter name
  92485. * @param value The value of the parameter
  92486. */
  92487. setParam(paramName: string, value: number): void;
  92488. /**
  92489. * Specifically change the body's mass option. Won't recreate the physics body object
  92490. * @param mass The mass of the physics imposter
  92491. */
  92492. setMass(mass: number): void;
  92493. /**
  92494. * Gets the linear velocity
  92495. * @returns linear velocity or null
  92496. */
  92497. getLinearVelocity(): Nullable<Vector3>;
  92498. /**
  92499. * Sets the linear velocity
  92500. * @param velocity linear velocity or null
  92501. */
  92502. setLinearVelocity(velocity: Nullable<Vector3>): void;
  92503. /**
  92504. * Gets the angular velocity
  92505. * @returns angular velocity or null
  92506. */
  92507. getAngularVelocity(): Nullable<Vector3>;
  92508. /**
  92509. * Sets the angular velocity
  92510. * @param velocity The velocity or null
  92511. */
  92512. setAngularVelocity(velocity: Nullable<Vector3>): void;
  92513. /**
  92514. * Execute a function with the physics plugin native code
  92515. * Provide a function the will have two variables - the world object and the physics body object
  92516. * @param func The function to execute with the physics plugin native code
  92517. */
  92518. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  92519. /**
  92520. * Register a function that will be executed before the physics world is stepping forward
  92521. * @param func The function to execute before the physics world is stepped forward
  92522. */
  92523. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92524. /**
  92525. * Unregister a function that will be executed before the physics world is stepping forward
  92526. * @param func The function to execute before the physics world is stepped forward
  92527. */
  92528. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92529. /**
  92530. * Register a function that will be executed after the physics step
  92531. * @param func The function to execute after physics step
  92532. */
  92533. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92534. /**
  92535. * Unregisters a function that will be executed after the physics step
  92536. * @param func The function to execute after physics step
  92537. */
  92538. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92539. /**
  92540. * register a function that will be executed when this impostor collides against a different body
  92541. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  92542. * @param func Callback that is executed on collision
  92543. */
  92544. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  92545. /**
  92546. * Unregisters the physics imposter on contact
  92547. * @param collideAgainst The physics object to collide against
  92548. * @param func Callback to execute on collision
  92549. */
  92550. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  92551. private _tmpQuat;
  92552. private _tmpQuat2;
  92553. /**
  92554. * Get the parent rotation
  92555. * @returns The parent rotation
  92556. */
  92557. getParentsRotation(): Quaternion;
  92558. /**
  92559. * this function is executed by the physics engine.
  92560. */
  92561. beforeStep: () => void;
  92562. /**
  92563. * this function is executed by the physics engine
  92564. */
  92565. afterStep: () => void;
  92566. /**
  92567. * Legacy collision detection event support
  92568. */
  92569. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  92570. /**
  92571. * event and body object due to cannon's event-based architecture.
  92572. */
  92573. onCollide: (e: {
  92574. body: any;
  92575. }) => void;
  92576. /**
  92577. * Apply a force
  92578. * @param force The force to apply
  92579. * @param contactPoint The contact point for the force
  92580. * @returns The physics imposter
  92581. */
  92582. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92583. /**
  92584. * Apply an impulse
  92585. * @param force The impulse force
  92586. * @param contactPoint The contact point for the impulse force
  92587. * @returns The physics imposter
  92588. */
  92589. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92590. /**
  92591. * A help function to create a joint
  92592. * @param otherImpostor A physics imposter used to create a joint
  92593. * @param jointType The type of joint
  92594. * @param jointData The data for the joint
  92595. * @returns The physics imposter
  92596. */
  92597. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  92598. /**
  92599. * Add a joint to this impostor with a different impostor
  92600. * @param otherImpostor A physics imposter used to add a joint
  92601. * @param joint The joint to add
  92602. * @returns The physics imposter
  92603. */
  92604. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  92605. /**
  92606. * Add an anchor to a cloth impostor
  92607. * @param otherImpostor rigid impostor to anchor to
  92608. * @param width ratio across width from 0 to 1
  92609. * @param height ratio up height from 0 to 1
  92610. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  92611. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  92612. * @returns impostor the soft imposter
  92613. */
  92614. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92615. /**
  92616. * Add a hook to a rope impostor
  92617. * @param otherImpostor rigid impostor to anchor to
  92618. * @param length ratio across rope from 0 to 1
  92619. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  92620. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  92621. * @returns impostor the rope imposter
  92622. */
  92623. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92624. /**
  92625. * Will keep this body still, in a sleep mode.
  92626. * @returns the physics imposter
  92627. */
  92628. sleep(): PhysicsImpostor;
  92629. /**
  92630. * Wake the body up.
  92631. * @returns The physics imposter
  92632. */
  92633. wakeUp(): PhysicsImpostor;
  92634. /**
  92635. * Clones the physics imposter
  92636. * @param newObject The physics imposter clones to this physics-enabled object
  92637. * @returns A nullable physics imposter
  92638. */
  92639. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92640. /**
  92641. * Disposes the physics imposter
  92642. */
  92643. dispose(): void;
  92644. /**
  92645. * Sets the delta position
  92646. * @param position The delta position amount
  92647. */
  92648. setDeltaPosition(position: Vector3): void;
  92649. /**
  92650. * Sets the delta rotation
  92651. * @param rotation The delta rotation amount
  92652. */
  92653. setDeltaRotation(rotation: Quaternion): void;
  92654. /**
  92655. * Gets the box size of the physics imposter and stores the result in the input parameter
  92656. * @param result Stores the box size
  92657. * @returns The physics imposter
  92658. */
  92659. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  92660. /**
  92661. * Gets the radius of the physics imposter
  92662. * @returns Radius of the physics imposter
  92663. */
  92664. getRadius(): number;
  92665. /**
  92666. * Sync a bone with this impostor
  92667. * @param bone The bone to sync to the impostor.
  92668. * @param boneMesh The mesh that the bone is influencing.
  92669. * @param jointPivot The pivot of the joint / bone in local space.
  92670. * @param distToJoint Optional distance from the impostor to the joint.
  92671. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92672. */
  92673. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  92674. /**
  92675. * Sync impostor to a bone
  92676. * @param bone The bone that the impostor will be synced to.
  92677. * @param boneMesh The mesh that the bone is influencing.
  92678. * @param jointPivot The pivot of the joint / bone in local space.
  92679. * @param distToJoint Optional distance from the impostor to the joint.
  92680. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92681. * @param boneAxis Optional vector3 axis the bone is aligned with
  92682. */
  92683. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  92684. /**
  92685. * No-Imposter type
  92686. */
  92687. static NoImpostor: number;
  92688. /**
  92689. * Sphere-Imposter type
  92690. */
  92691. static SphereImpostor: number;
  92692. /**
  92693. * Box-Imposter type
  92694. */
  92695. static BoxImpostor: number;
  92696. /**
  92697. * Plane-Imposter type
  92698. */
  92699. static PlaneImpostor: number;
  92700. /**
  92701. * Mesh-imposter type
  92702. */
  92703. static MeshImpostor: number;
  92704. /**
  92705. * Capsule-Impostor type (Ammo.js plugin only)
  92706. */
  92707. static CapsuleImpostor: number;
  92708. /**
  92709. * Cylinder-Imposter type
  92710. */
  92711. static CylinderImpostor: number;
  92712. /**
  92713. * Particle-Imposter type
  92714. */
  92715. static ParticleImpostor: number;
  92716. /**
  92717. * Heightmap-Imposter type
  92718. */
  92719. static HeightmapImpostor: number;
  92720. /**
  92721. * ConvexHull-Impostor type (Ammo.js plugin only)
  92722. */
  92723. static ConvexHullImpostor: number;
  92724. /**
  92725. * Custom-Imposter type (Ammo.js plugin only)
  92726. */
  92727. static CustomImpostor: number;
  92728. /**
  92729. * Rope-Imposter type
  92730. */
  92731. static RopeImpostor: number;
  92732. /**
  92733. * Cloth-Imposter type
  92734. */
  92735. static ClothImpostor: number;
  92736. /**
  92737. * Softbody-Imposter type
  92738. */
  92739. static SoftbodyImpostor: number;
  92740. }
  92741. }
  92742. declare module BABYLON {
  92743. /**
  92744. * @hidden
  92745. **/
  92746. export class _CreationDataStorage {
  92747. closePath?: boolean;
  92748. closeArray?: boolean;
  92749. idx: number[];
  92750. dashSize: number;
  92751. gapSize: number;
  92752. path3D: Path3D;
  92753. pathArray: Vector3[][];
  92754. arc: number;
  92755. radius: number;
  92756. cap: number;
  92757. tessellation: number;
  92758. }
  92759. /**
  92760. * @hidden
  92761. **/
  92762. class _InstanceDataStorage {
  92763. visibleInstances: any;
  92764. batchCache: _InstancesBatch;
  92765. instancesBufferSize: number;
  92766. instancesBuffer: Nullable<Buffer>;
  92767. instancesData: Float32Array;
  92768. overridenInstanceCount: number;
  92769. isFrozen: boolean;
  92770. previousBatch: Nullable<_InstancesBatch>;
  92771. hardwareInstancedRendering: boolean;
  92772. sideOrientation: number;
  92773. manualUpdate: boolean;
  92774. }
  92775. /**
  92776. * @hidden
  92777. **/
  92778. export class _InstancesBatch {
  92779. mustReturn: boolean;
  92780. visibleInstances: Nullable<InstancedMesh[]>[];
  92781. renderSelf: boolean[];
  92782. hardwareInstancedRendering: boolean[];
  92783. }
  92784. /**
  92785. * Class used to represent renderable models
  92786. */
  92787. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  92788. /**
  92789. * Mesh side orientation : usually the external or front surface
  92790. */
  92791. static readonly FRONTSIDE: number;
  92792. /**
  92793. * Mesh side orientation : usually the internal or back surface
  92794. */
  92795. static readonly BACKSIDE: number;
  92796. /**
  92797. * Mesh side orientation : both internal and external or front and back surfaces
  92798. */
  92799. static readonly DOUBLESIDE: number;
  92800. /**
  92801. * Mesh side orientation : by default, `FRONTSIDE`
  92802. */
  92803. static readonly DEFAULTSIDE: number;
  92804. /**
  92805. * Mesh cap setting : no cap
  92806. */
  92807. static readonly NO_CAP: number;
  92808. /**
  92809. * Mesh cap setting : one cap at the beginning of the mesh
  92810. */
  92811. static readonly CAP_START: number;
  92812. /**
  92813. * Mesh cap setting : one cap at the end of the mesh
  92814. */
  92815. static readonly CAP_END: number;
  92816. /**
  92817. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  92818. */
  92819. static readonly CAP_ALL: number;
  92820. /**
  92821. * Mesh pattern setting : no flip or rotate
  92822. */
  92823. static readonly NO_FLIP: number;
  92824. /**
  92825. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  92826. */
  92827. static readonly FLIP_TILE: number;
  92828. /**
  92829. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  92830. */
  92831. static readonly ROTATE_TILE: number;
  92832. /**
  92833. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  92834. */
  92835. static readonly FLIP_ROW: number;
  92836. /**
  92837. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  92838. */
  92839. static readonly ROTATE_ROW: number;
  92840. /**
  92841. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  92842. */
  92843. static readonly FLIP_N_ROTATE_TILE: number;
  92844. /**
  92845. * Mesh pattern setting : rotate pattern and rotate
  92846. */
  92847. static readonly FLIP_N_ROTATE_ROW: number;
  92848. /**
  92849. * Mesh tile positioning : part tiles same on left/right or top/bottom
  92850. */
  92851. static readonly CENTER: number;
  92852. /**
  92853. * Mesh tile positioning : part tiles on left
  92854. */
  92855. static readonly LEFT: number;
  92856. /**
  92857. * Mesh tile positioning : part tiles on right
  92858. */
  92859. static readonly RIGHT: number;
  92860. /**
  92861. * Mesh tile positioning : part tiles on top
  92862. */
  92863. static readonly TOP: number;
  92864. /**
  92865. * Mesh tile positioning : part tiles on bottom
  92866. */
  92867. static readonly BOTTOM: number;
  92868. /**
  92869. * Gets the default side orientation.
  92870. * @param orientation the orientation to value to attempt to get
  92871. * @returns the default orientation
  92872. * @hidden
  92873. */
  92874. static _GetDefaultSideOrientation(orientation?: number): number;
  92875. private _internalMeshDataInfo;
  92876. /**
  92877. * An event triggered before rendering the mesh
  92878. */
  92879. readonly onBeforeRenderObservable: Observable<Mesh>;
  92880. /**
  92881. * An event triggered before binding the mesh
  92882. */
  92883. readonly onBeforeBindObservable: Observable<Mesh>;
  92884. /**
  92885. * An event triggered after rendering the mesh
  92886. */
  92887. readonly onAfterRenderObservable: Observable<Mesh>;
  92888. /**
  92889. * An event triggered before drawing the mesh
  92890. */
  92891. readonly onBeforeDrawObservable: Observable<Mesh>;
  92892. private _onBeforeDrawObserver;
  92893. /**
  92894. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92895. */
  92896. onBeforeDraw: () => void;
  92897. readonly hasInstances: boolean;
  92898. /**
  92899. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92900. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92901. */
  92902. delayLoadState: number;
  92903. /**
  92904. * Gets the list of instances created from this mesh
  92905. * it is not supposed to be modified manually.
  92906. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92907. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92908. */
  92909. instances: InstancedMesh[];
  92910. /**
  92911. * Gets the file containing delay loading data for this mesh
  92912. */
  92913. delayLoadingFile: string;
  92914. /** @hidden */
  92915. _binaryInfo: any;
  92916. /**
  92917. * User defined function used to change how LOD level selection is done
  92918. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92919. */
  92920. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92921. /**
  92922. * Gets or sets the morph target manager
  92923. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92924. */
  92925. morphTargetManager: Nullable<MorphTargetManager>;
  92926. /** @hidden */
  92927. _creationDataStorage: Nullable<_CreationDataStorage>;
  92928. /** @hidden */
  92929. _geometry: Nullable<Geometry>;
  92930. /** @hidden */
  92931. _delayInfo: Array<string>;
  92932. /** @hidden */
  92933. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92934. /** @hidden */
  92935. _instanceDataStorage: _InstanceDataStorage;
  92936. private _effectiveMaterial;
  92937. /** @hidden */
  92938. _shouldGenerateFlatShading: boolean;
  92939. /** @hidden */
  92940. _originalBuilderSideOrientation: number;
  92941. /**
  92942. * Use this property to change the original side orientation defined at construction time
  92943. */
  92944. overrideMaterialSideOrientation: Nullable<number>;
  92945. /**
  92946. * Gets the source mesh (the one used to clone this one from)
  92947. */
  92948. readonly source: Nullable<Mesh>;
  92949. /**
  92950. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92951. */
  92952. isUnIndexed: boolean;
  92953. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92954. readonly worldMatrixInstancedBuffer: Float32Array;
  92955. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92956. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92957. /**
  92958. * @constructor
  92959. * @param name The value used by scene.getMeshByName() to do a lookup.
  92960. * @param scene The scene to add this mesh to.
  92961. * @param parent The parent of this mesh, if it has one
  92962. * @param source An optional Mesh from which geometry is shared, cloned.
  92963. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92964. * When false, achieved by calling a clone(), also passing False.
  92965. * This will make creation of children, recursive.
  92966. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92967. */
  92968. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92969. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92970. doNotInstantiate: boolean;
  92971. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92972. /**
  92973. * Gets the class name
  92974. * @returns the string "Mesh".
  92975. */
  92976. getClassName(): string;
  92977. /** @hidden */
  92978. readonly _isMesh: boolean;
  92979. /**
  92980. * Returns a description of this mesh
  92981. * @param fullDetails define if full details about this mesh must be used
  92982. * @returns a descriptive string representing this mesh
  92983. */
  92984. toString(fullDetails?: boolean): string;
  92985. /** @hidden */
  92986. _unBindEffect(): void;
  92987. /**
  92988. * Gets a boolean indicating if this mesh has LOD
  92989. */
  92990. readonly hasLODLevels: boolean;
  92991. /**
  92992. * Gets the list of MeshLODLevel associated with the current mesh
  92993. * @returns an array of MeshLODLevel
  92994. */
  92995. getLODLevels(): MeshLODLevel[];
  92996. private _sortLODLevels;
  92997. /**
  92998. * Add a mesh as LOD level triggered at the given distance.
  92999. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93000. * @param distance The distance from the center of the object to show this level
  93001. * @param mesh The mesh to be added as LOD level (can be null)
  93002. * @return This mesh (for chaining)
  93003. */
  93004. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  93005. /**
  93006. * Returns the LOD level mesh at the passed distance or null if not found.
  93007. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93008. * @param distance The distance from the center of the object to show this level
  93009. * @returns a Mesh or `null`
  93010. */
  93011. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  93012. /**
  93013. * Remove a mesh from the LOD array
  93014. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93015. * @param mesh defines the mesh to be removed
  93016. * @return This mesh (for chaining)
  93017. */
  93018. removeLODLevel(mesh: Mesh): Mesh;
  93019. /**
  93020. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  93021. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93022. * @param camera defines the camera to use to compute distance
  93023. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  93024. * @return This mesh (for chaining)
  93025. */
  93026. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  93027. /**
  93028. * Gets the mesh internal Geometry object
  93029. */
  93030. readonly geometry: Nullable<Geometry>;
  93031. /**
  93032. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  93033. * @returns the total number of vertices
  93034. */
  93035. getTotalVertices(): number;
  93036. /**
  93037. * Returns the content of an associated vertex buffer
  93038. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93039. * - VertexBuffer.PositionKind
  93040. * - VertexBuffer.UVKind
  93041. * - VertexBuffer.UV2Kind
  93042. * - VertexBuffer.UV3Kind
  93043. * - VertexBuffer.UV4Kind
  93044. * - VertexBuffer.UV5Kind
  93045. * - VertexBuffer.UV6Kind
  93046. * - VertexBuffer.ColorKind
  93047. * - VertexBuffer.MatricesIndicesKind
  93048. * - VertexBuffer.MatricesIndicesExtraKind
  93049. * - VertexBuffer.MatricesWeightsKind
  93050. * - VertexBuffer.MatricesWeightsExtraKind
  93051. * @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
  93052. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  93053. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  93054. */
  93055. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93056. /**
  93057. * Returns the mesh VertexBuffer object from the requested `kind`
  93058. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93059. * - VertexBuffer.PositionKind
  93060. * - VertexBuffer.NormalKind
  93061. * - VertexBuffer.UVKind
  93062. * - VertexBuffer.UV2Kind
  93063. * - VertexBuffer.UV3Kind
  93064. * - VertexBuffer.UV4Kind
  93065. * - VertexBuffer.UV5Kind
  93066. * - VertexBuffer.UV6Kind
  93067. * - VertexBuffer.ColorKind
  93068. * - VertexBuffer.MatricesIndicesKind
  93069. * - VertexBuffer.MatricesIndicesExtraKind
  93070. * - VertexBuffer.MatricesWeightsKind
  93071. * - VertexBuffer.MatricesWeightsExtraKind
  93072. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  93073. */
  93074. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  93075. /**
  93076. * Tests if a specific vertex buffer is associated with this mesh
  93077. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93078. * - VertexBuffer.PositionKind
  93079. * - VertexBuffer.NormalKind
  93080. * - VertexBuffer.UVKind
  93081. * - VertexBuffer.UV2Kind
  93082. * - VertexBuffer.UV3Kind
  93083. * - VertexBuffer.UV4Kind
  93084. * - VertexBuffer.UV5Kind
  93085. * - VertexBuffer.UV6Kind
  93086. * - VertexBuffer.ColorKind
  93087. * - VertexBuffer.MatricesIndicesKind
  93088. * - VertexBuffer.MatricesIndicesExtraKind
  93089. * - VertexBuffer.MatricesWeightsKind
  93090. * - VertexBuffer.MatricesWeightsExtraKind
  93091. * @returns a boolean
  93092. */
  93093. isVerticesDataPresent(kind: string): boolean;
  93094. /**
  93095. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  93096. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93097. * - VertexBuffer.PositionKind
  93098. * - VertexBuffer.UVKind
  93099. * - VertexBuffer.UV2Kind
  93100. * - VertexBuffer.UV3Kind
  93101. * - VertexBuffer.UV4Kind
  93102. * - VertexBuffer.UV5Kind
  93103. * - VertexBuffer.UV6Kind
  93104. * - VertexBuffer.ColorKind
  93105. * - VertexBuffer.MatricesIndicesKind
  93106. * - VertexBuffer.MatricesIndicesExtraKind
  93107. * - VertexBuffer.MatricesWeightsKind
  93108. * - VertexBuffer.MatricesWeightsExtraKind
  93109. * @returns a boolean
  93110. */
  93111. isVertexBufferUpdatable(kind: string): boolean;
  93112. /**
  93113. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  93114. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93115. * - VertexBuffer.PositionKind
  93116. * - VertexBuffer.NormalKind
  93117. * - VertexBuffer.UVKind
  93118. * - VertexBuffer.UV2Kind
  93119. * - VertexBuffer.UV3Kind
  93120. * - VertexBuffer.UV4Kind
  93121. * - VertexBuffer.UV5Kind
  93122. * - VertexBuffer.UV6Kind
  93123. * - VertexBuffer.ColorKind
  93124. * - VertexBuffer.MatricesIndicesKind
  93125. * - VertexBuffer.MatricesIndicesExtraKind
  93126. * - VertexBuffer.MatricesWeightsKind
  93127. * - VertexBuffer.MatricesWeightsExtraKind
  93128. * @returns an array of strings
  93129. */
  93130. getVerticesDataKinds(): string[];
  93131. /**
  93132. * Returns a positive integer : the total number of indices in this mesh geometry.
  93133. * @returns the numner of indices or zero if the mesh has no geometry.
  93134. */
  93135. getTotalIndices(): number;
  93136. /**
  93137. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93138. * @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.
  93139. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93140. * @returns the indices array or an empty array if the mesh has no geometry
  93141. */
  93142. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93143. readonly isBlocked: boolean;
  93144. /**
  93145. * Determine if the current mesh is ready to be rendered
  93146. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93147. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  93148. * @returns true if all associated assets are ready (material, textures, shaders)
  93149. */
  93150. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  93151. /**
  93152. * 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.
  93153. */
  93154. readonly areNormalsFrozen: boolean;
  93155. /**
  93156. * 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.
  93157. * @returns the current mesh
  93158. */
  93159. freezeNormals(): Mesh;
  93160. /**
  93161. * 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
  93162. * @returns the current mesh
  93163. */
  93164. unfreezeNormals(): Mesh;
  93165. /**
  93166. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  93167. */
  93168. overridenInstanceCount: number;
  93169. /** @hidden */
  93170. _preActivate(): Mesh;
  93171. /** @hidden */
  93172. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93173. /** @hidden */
  93174. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  93175. /**
  93176. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93177. * This means the mesh underlying bounding box and sphere are recomputed.
  93178. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93179. * @returns the current mesh
  93180. */
  93181. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  93182. /** @hidden */
  93183. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  93184. /**
  93185. * This function will subdivide the mesh into multiple submeshes
  93186. * @param count defines the expected number of submeshes
  93187. */
  93188. subdivide(count: number): void;
  93189. /**
  93190. * Copy a FloatArray into a specific associated vertex buffer
  93191. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93192. * - VertexBuffer.PositionKind
  93193. * - VertexBuffer.UVKind
  93194. * - VertexBuffer.UV2Kind
  93195. * - VertexBuffer.UV3Kind
  93196. * - VertexBuffer.UV4Kind
  93197. * - VertexBuffer.UV5Kind
  93198. * - VertexBuffer.UV6Kind
  93199. * - VertexBuffer.ColorKind
  93200. * - VertexBuffer.MatricesIndicesKind
  93201. * - VertexBuffer.MatricesIndicesExtraKind
  93202. * - VertexBuffer.MatricesWeightsKind
  93203. * - VertexBuffer.MatricesWeightsExtraKind
  93204. * @param data defines the data source
  93205. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93206. * @param stride defines the data stride size (can be null)
  93207. * @returns the current mesh
  93208. */
  93209. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93210. /**
  93211. * Delete a vertex buffer associated with this mesh
  93212. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  93213. * - VertexBuffer.PositionKind
  93214. * - VertexBuffer.UVKind
  93215. * - VertexBuffer.UV2Kind
  93216. * - VertexBuffer.UV3Kind
  93217. * - VertexBuffer.UV4Kind
  93218. * - VertexBuffer.UV5Kind
  93219. * - VertexBuffer.UV6Kind
  93220. * - VertexBuffer.ColorKind
  93221. * - VertexBuffer.MatricesIndicesKind
  93222. * - VertexBuffer.MatricesIndicesExtraKind
  93223. * - VertexBuffer.MatricesWeightsKind
  93224. * - VertexBuffer.MatricesWeightsExtraKind
  93225. */
  93226. removeVerticesData(kind: string): void;
  93227. /**
  93228. * Flags an associated vertex buffer as updatable
  93229. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  93230. * - VertexBuffer.PositionKind
  93231. * - VertexBuffer.UVKind
  93232. * - VertexBuffer.UV2Kind
  93233. * - VertexBuffer.UV3Kind
  93234. * - VertexBuffer.UV4Kind
  93235. * - VertexBuffer.UV5Kind
  93236. * - VertexBuffer.UV6Kind
  93237. * - VertexBuffer.ColorKind
  93238. * - VertexBuffer.MatricesIndicesKind
  93239. * - VertexBuffer.MatricesIndicesExtraKind
  93240. * - VertexBuffer.MatricesWeightsKind
  93241. * - VertexBuffer.MatricesWeightsExtraKind
  93242. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93243. */
  93244. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  93245. /**
  93246. * Sets the mesh global Vertex Buffer
  93247. * @param buffer defines the buffer to use
  93248. * @returns the current mesh
  93249. */
  93250. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  93251. /**
  93252. * Update a specific associated vertex buffer
  93253. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93254. * - VertexBuffer.PositionKind
  93255. * - VertexBuffer.UVKind
  93256. * - VertexBuffer.UV2Kind
  93257. * - VertexBuffer.UV3Kind
  93258. * - VertexBuffer.UV4Kind
  93259. * - VertexBuffer.UV5Kind
  93260. * - VertexBuffer.UV6Kind
  93261. * - VertexBuffer.ColorKind
  93262. * - VertexBuffer.MatricesIndicesKind
  93263. * - VertexBuffer.MatricesIndicesExtraKind
  93264. * - VertexBuffer.MatricesWeightsKind
  93265. * - VertexBuffer.MatricesWeightsExtraKind
  93266. * @param data defines the data source
  93267. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  93268. * @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)
  93269. * @returns the current mesh
  93270. */
  93271. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93272. /**
  93273. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  93274. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  93275. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  93276. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  93277. * @returns the current mesh
  93278. */
  93279. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  93280. /**
  93281. * Creates a un-shared specific occurence of the geometry for the mesh.
  93282. * @returns the current mesh
  93283. */
  93284. makeGeometryUnique(): Mesh;
  93285. /**
  93286. * Set the index buffer of this mesh
  93287. * @param indices defines the source data
  93288. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  93289. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  93290. * @returns the current mesh
  93291. */
  93292. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  93293. /**
  93294. * Update the current index buffer
  93295. * @param indices defines the source data
  93296. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93297. * @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)
  93298. * @returns the current mesh
  93299. */
  93300. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93301. /**
  93302. * Invert the geometry to move from a right handed system to a left handed one.
  93303. * @returns the current mesh
  93304. */
  93305. toLeftHanded(): Mesh;
  93306. /** @hidden */
  93307. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93308. /** @hidden */
  93309. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93310. /**
  93311. * Registers for this mesh a javascript function called just before the rendering process
  93312. * @param func defines the function to call before rendering this mesh
  93313. * @returns the current mesh
  93314. */
  93315. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93316. /**
  93317. * Disposes a previously registered javascript function called before the rendering
  93318. * @param func defines the function to remove
  93319. * @returns the current mesh
  93320. */
  93321. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93322. /**
  93323. * Registers for this mesh a javascript function called just after the rendering is complete
  93324. * @param func defines the function to call after rendering this mesh
  93325. * @returns the current mesh
  93326. */
  93327. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93328. /**
  93329. * Disposes a previously registered javascript function called after the rendering.
  93330. * @param func defines the function to remove
  93331. * @returns the current mesh
  93332. */
  93333. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93334. /** @hidden */
  93335. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  93336. /** @hidden */
  93337. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  93338. /** @hidden */
  93339. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  93340. /** @hidden */
  93341. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  93342. /** @hidden */
  93343. _rebuild(): void;
  93344. /** @hidden */
  93345. _freeze(): void;
  93346. /** @hidden */
  93347. _unFreeze(): void;
  93348. /**
  93349. * 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
  93350. * @param subMesh defines the subMesh to render
  93351. * @param enableAlphaMode defines if alpha mode can be changed
  93352. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  93353. * @returns the current mesh
  93354. */
  93355. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  93356. private _onBeforeDraw;
  93357. /**
  93358. * Renormalize the mesh and patch it up if there are no weights
  93359. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  93360. * However in the case of zero weights then we set just a single influence to 1.
  93361. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  93362. */
  93363. cleanMatrixWeights(): void;
  93364. private normalizeSkinFourWeights;
  93365. private normalizeSkinWeightsAndExtra;
  93366. /**
  93367. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  93368. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  93369. * the user know there was an issue with importing the mesh
  93370. * @returns a validation object with skinned, valid and report string
  93371. */
  93372. validateSkinning(): {
  93373. skinned: boolean;
  93374. valid: boolean;
  93375. report: string;
  93376. };
  93377. /** @hidden */
  93378. _checkDelayState(): Mesh;
  93379. private _queueLoad;
  93380. /**
  93381. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93382. * A mesh is in the frustum if its bounding box intersects the frustum
  93383. * @param frustumPlanes defines the frustum to test
  93384. * @returns true if the mesh is in the frustum planes
  93385. */
  93386. isInFrustum(frustumPlanes: Plane[]): boolean;
  93387. /**
  93388. * Sets the mesh material by the material or multiMaterial `id` property
  93389. * @param id is a string identifying the material or the multiMaterial
  93390. * @returns the current mesh
  93391. */
  93392. setMaterialByID(id: string): Mesh;
  93393. /**
  93394. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  93395. * @returns an array of IAnimatable
  93396. */
  93397. getAnimatables(): IAnimatable[];
  93398. /**
  93399. * Modifies the mesh geometry according to the passed transformation matrix.
  93400. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  93401. * The mesh normals are modified using the same transformation.
  93402. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93403. * @param transform defines the transform matrix to use
  93404. * @see http://doc.babylonjs.com/resources/baking_transformations
  93405. * @returns the current mesh
  93406. */
  93407. bakeTransformIntoVertices(transform: Matrix): Mesh;
  93408. /**
  93409. * Modifies the mesh geometry according to its own current World Matrix.
  93410. * The mesh World Matrix is then reset.
  93411. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  93412. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93413. * @see http://doc.babylonjs.com/resources/baking_transformations
  93414. * @returns the current mesh
  93415. */
  93416. bakeCurrentTransformIntoVertices(): Mesh;
  93417. /** @hidden */
  93418. readonly _positions: Nullable<Vector3[]>;
  93419. /** @hidden */
  93420. _resetPointsArrayCache(): Mesh;
  93421. /** @hidden */
  93422. _generatePointsArray(): boolean;
  93423. /**
  93424. * Returns a new Mesh object generated from the current mesh properties.
  93425. * This method must not get confused with createInstance()
  93426. * @param name is a string, the name given to the new mesh
  93427. * @param newParent can be any Node object (default `null`)
  93428. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  93429. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  93430. * @returns a new mesh
  93431. */
  93432. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  93433. /**
  93434. * Releases resources associated with this mesh.
  93435. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93436. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93437. */
  93438. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93439. /** @hidden */
  93440. _disposeInstanceSpecificData(): void;
  93441. /**
  93442. * Modifies the mesh geometry according to a displacement map.
  93443. * 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.
  93444. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93445. * @param url is a string, the URL from the image file is to be downloaded.
  93446. * @param minHeight is the lower limit of the displacement.
  93447. * @param maxHeight is the upper limit of the displacement.
  93448. * @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.
  93449. * @param uvOffset is an optional vector2 used to offset UV.
  93450. * @param uvScale is an optional vector2 used to scale UV.
  93451. * @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.
  93452. * @returns the Mesh.
  93453. */
  93454. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93455. /**
  93456. * Modifies the mesh geometry according to a displacementMap buffer.
  93457. * 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.
  93458. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93459. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  93460. * @param heightMapWidth is the width of the buffer image.
  93461. * @param heightMapHeight is the height of the buffer image.
  93462. * @param minHeight is the lower limit of the displacement.
  93463. * @param maxHeight is the upper limit of the displacement.
  93464. * @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.
  93465. * @param uvOffset is an optional vector2 used to offset UV.
  93466. * @param uvScale is an optional vector2 used to scale UV.
  93467. * @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.
  93468. * @returns the Mesh.
  93469. */
  93470. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93471. /**
  93472. * Modify the mesh to get a flat shading rendering.
  93473. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  93474. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  93475. * @returns current mesh
  93476. */
  93477. convertToFlatShadedMesh(): Mesh;
  93478. /**
  93479. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  93480. * In other words, more vertices, no more indices and a single bigger VBO.
  93481. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  93482. * @returns current mesh
  93483. */
  93484. convertToUnIndexedMesh(): Mesh;
  93485. /**
  93486. * Inverses facet orientations.
  93487. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93488. * @param flipNormals will also inverts the normals
  93489. * @returns current mesh
  93490. */
  93491. flipFaces(flipNormals?: boolean): Mesh;
  93492. /**
  93493. * Increase the number of facets and hence vertices in a mesh
  93494. * Vertex normals are interpolated from existing vertex normals
  93495. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93496. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  93497. */
  93498. increaseVertices(numberPerEdge: number): void;
  93499. /**
  93500. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  93501. * This will undo any application of covertToFlatShadedMesh
  93502. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93503. */
  93504. forceSharedVertices(): void;
  93505. /** @hidden */
  93506. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  93507. /** @hidden */
  93508. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  93509. /**
  93510. * Creates a new InstancedMesh object from the mesh model.
  93511. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93512. * @param name defines the name of the new instance
  93513. * @returns a new InstancedMesh
  93514. */
  93515. createInstance(name: string): InstancedMesh;
  93516. /**
  93517. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  93518. * After this call, all the mesh instances have the same submeshes than the current mesh.
  93519. * @returns the current mesh
  93520. */
  93521. synchronizeInstances(): Mesh;
  93522. /**
  93523. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  93524. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  93525. * This should be used together with the simplification to avoid disappearing triangles.
  93526. * @param successCallback an optional success callback to be called after the optimization finished.
  93527. * @returns the current mesh
  93528. */
  93529. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  93530. /**
  93531. * Serialize current mesh
  93532. * @param serializationObject defines the object which will receive the serialization data
  93533. */
  93534. serialize(serializationObject: any): void;
  93535. /** @hidden */
  93536. _syncGeometryWithMorphTargetManager(): void;
  93537. /** @hidden */
  93538. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  93539. /**
  93540. * Returns a new Mesh object parsed from the source provided.
  93541. * @param parsedMesh is the source
  93542. * @param scene defines the hosting scene
  93543. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  93544. * @returns a new Mesh
  93545. */
  93546. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  93547. /**
  93548. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  93549. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93550. * @param name defines the name of the mesh to create
  93551. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  93552. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  93553. * @param closePath creates a seam between the first and the last points of each path of the path array
  93554. * @param offset is taken in account only if the `pathArray` is containing a single path
  93555. * @param scene defines the hosting scene
  93556. * @param updatable defines if the mesh must be flagged as updatable
  93557. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93558. * @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)
  93559. * @returns a new Mesh
  93560. */
  93561. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93562. /**
  93563. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  93564. * @param name defines the name of the mesh to create
  93565. * @param radius sets the radius size (float) of the polygon (default 0.5)
  93566. * @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
  93567. * @param scene defines the hosting scene
  93568. * @param updatable defines if the mesh must be flagged as updatable
  93569. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93570. * @returns a new Mesh
  93571. */
  93572. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93573. /**
  93574. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  93575. * @param name defines the name of the mesh to create
  93576. * @param size sets the size (float) of each box side (default 1)
  93577. * @param scene defines the hosting scene
  93578. * @param updatable defines if the mesh must be flagged as updatable
  93579. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93580. * @returns a new Mesh
  93581. */
  93582. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93583. /**
  93584. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  93585. * @param name defines the name of the mesh to create
  93586. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93587. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93588. * @param scene defines the hosting scene
  93589. * @param updatable defines if the mesh must be flagged as updatable
  93590. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93591. * @returns a new Mesh
  93592. */
  93593. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93594. /**
  93595. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  93596. * @param name defines the name of the mesh to create
  93597. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93598. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93599. * @param scene defines the hosting scene
  93600. * @returns a new Mesh
  93601. */
  93602. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  93603. /**
  93604. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  93607. * @param diameterTop set the top cap diameter (floats, default 1)
  93608. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  93609. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  93610. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  93611. * @param scene defines the hosting scene
  93612. * @param updatable defines if the mesh must be flagged as updatable
  93613. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93614. * @returns a new Mesh
  93615. */
  93616. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  93617. /**
  93618. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  93619. * @param name defines the name of the mesh to create
  93620. * @param diameter sets the diameter size (float) of the torus (default 1)
  93621. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  93622. * @param tessellation sets the number of torus sides (postive integer, default 16)
  93623. * @param scene defines the hosting scene
  93624. * @param updatable defines if the mesh must be flagged as updatable
  93625. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93626. * @returns a new Mesh
  93627. */
  93628. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93629. /**
  93630. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  93631. * @param name defines the name of the mesh to create
  93632. * @param radius sets the global radius size (float) of the torus knot (default 2)
  93633. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  93634. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  93635. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  93636. * @param p the number of windings on X axis (positive integers, default 2)
  93637. * @param q the number of windings on Y axis (positive integers, default 3)
  93638. * @param scene defines the hosting scene
  93639. * @param updatable defines if the mesh must be flagged as updatable
  93640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93641. * @returns a new Mesh
  93642. */
  93643. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93644. /**
  93645. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  93646. * @param name defines the name of the mesh to create
  93647. * @param points is an array successive Vector3
  93648. * @param scene defines the hosting scene
  93649. * @param updatable defines if the mesh must be flagged as updatable
  93650. * @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).
  93651. * @returns a new Mesh
  93652. */
  93653. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  93654. /**
  93655. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  93656. * @param name defines the name of the mesh to create
  93657. * @param points is an array successive Vector3
  93658. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  93659. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  93660. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  93661. * @param scene defines the hosting scene
  93662. * @param updatable defines if the mesh must be flagged as updatable
  93663. * @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)
  93664. * @returns a new Mesh
  93665. */
  93666. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  93667. /**
  93668. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  93669. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  93670. * 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.
  93671. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93672. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  93673. * Remember you can only change the shape positions, not their number when updating a polygon.
  93674. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93675. * @param name defines the name of the mesh to create
  93676. * @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
  93677. * @param scene defines the hosting scene
  93678. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93679. * @param updatable defines if the mesh must be flagged as updatable
  93680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93681. * @param earcutInjection can be used to inject your own earcut reference
  93682. * @returns a new Mesh
  93683. */
  93684. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93685. /**
  93686. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  93687. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  93688. * @param name defines the name of the mesh to create
  93689. * @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
  93690. * @param depth defines the height of extrusion
  93691. * @param scene defines the hosting scene
  93692. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93693. * @param updatable defines if the mesh must be flagged as updatable
  93694. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93695. * @param earcutInjection can be used to inject your own earcut reference
  93696. * @returns a new Mesh
  93697. */
  93698. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93699. /**
  93700. * Creates an extruded shape mesh.
  93701. * 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
  93702. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93703. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93704. * @param name defines the name of the mesh to create
  93705. * @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
  93706. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93707. * @param scale is the value to scale the shape
  93708. * @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
  93709. * @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
  93710. * @param scene defines the hosting scene
  93711. * @param updatable defines if the mesh must be flagged as updatable
  93712. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93713. * @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)
  93714. * @returns a new Mesh
  93715. */
  93716. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93717. /**
  93718. * Creates an custom extruded shape mesh.
  93719. * The custom extrusion is a parametric shape.
  93720. * It has no predefined shape. Its final shape will depend on the input parameters.
  93721. * Please consider using the same method from the MeshBuilder class instead
  93722. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93723. * @param name defines the name of the mesh to create
  93724. * @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
  93725. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93726. * @param scaleFunction is a custom Javascript function called on each path point
  93727. * @param rotationFunction is a custom Javascript function called on each path point
  93728. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  93729. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  93730. * @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
  93731. * @param scene defines the hosting scene
  93732. * @param updatable defines if the mesh must be flagged as updatable
  93733. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93734. * @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)
  93735. * @returns a new Mesh
  93736. */
  93737. 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;
  93738. /**
  93739. * Creates lathe mesh.
  93740. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  93741. * Please consider using the same method from the MeshBuilder class instead
  93742. * @param name defines the name of the mesh to create
  93743. * @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
  93744. * @param radius is the radius value of the lathe
  93745. * @param tessellation is the side number of the lathe.
  93746. * @param scene defines the hosting scene
  93747. * @param updatable defines if the mesh must be flagged as updatable
  93748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93749. * @returns a new Mesh
  93750. */
  93751. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93752. /**
  93753. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  93754. * @param name defines the name of the mesh to create
  93755. * @param size sets the size (float) of both sides of the plane at once (default 1)
  93756. * @param scene defines the hosting scene
  93757. * @param updatable defines if the mesh must be flagged as updatable
  93758. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93759. * @returns a new Mesh
  93760. */
  93761. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93762. /**
  93763. * Creates a ground mesh.
  93764. * Please consider using the same method from the MeshBuilder class instead
  93765. * @param name defines the name of the mesh to create
  93766. * @param width set the width of the ground
  93767. * @param height set the height of the ground
  93768. * @param subdivisions sets the number of subdivisions per side
  93769. * @param scene defines the hosting scene
  93770. * @param updatable defines if the mesh must be flagged as updatable
  93771. * @returns a new Mesh
  93772. */
  93773. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  93774. /**
  93775. * Creates a tiled ground mesh.
  93776. * Please consider using the same method from the MeshBuilder class instead
  93777. * @param name defines the name of the mesh to create
  93778. * @param xmin set the ground minimum X coordinate
  93779. * @param zmin set the ground minimum Y coordinate
  93780. * @param xmax set the ground maximum X coordinate
  93781. * @param zmax set the ground maximum Z coordinate
  93782. * @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
  93783. * @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
  93784. * @param scene defines the hosting scene
  93785. * @param updatable defines if the mesh must be flagged as updatable
  93786. * @returns a new Mesh
  93787. */
  93788. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  93789. w: number;
  93790. h: number;
  93791. }, precision: {
  93792. w: number;
  93793. h: number;
  93794. }, scene: Scene, updatable?: boolean): Mesh;
  93795. /**
  93796. * Creates a ground mesh from a height map.
  93797. * Please consider using the same method from the MeshBuilder class instead
  93798. * @see http://doc.babylonjs.com/babylon101/height_map
  93799. * @param name defines the name of the mesh to create
  93800. * @param url sets the URL of the height map image resource
  93801. * @param width set the ground width size
  93802. * @param height set the ground height size
  93803. * @param subdivisions sets the number of subdivision per side
  93804. * @param minHeight is the minimum altitude on the ground
  93805. * @param maxHeight is the maximum altitude on the ground
  93806. * @param scene defines the hosting scene
  93807. * @param updatable defines if the mesh must be flagged as updatable
  93808. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  93809. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  93810. * @returns a new Mesh
  93811. */
  93812. 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;
  93813. /**
  93814. * Creates a tube mesh.
  93815. * The tube is a parametric shape.
  93816. * It has no predefined shape. Its final shape will depend on the input parameters.
  93817. * Please consider using the same method from the MeshBuilder class instead
  93818. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93819. * @param name defines the name of the mesh to create
  93820. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  93821. * @param radius sets the tube radius size
  93822. * @param tessellation is the number of sides on the tubular surface
  93823. * @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
  93824. * @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
  93825. * @param scene defines the hosting scene
  93826. * @param updatable defines if the mesh must be flagged as updatable
  93827. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93828. * @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)
  93829. * @returns a new Mesh
  93830. */
  93831. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  93832. (i: number, distance: number): number;
  93833. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93834. /**
  93835. * Creates a polyhedron mesh.
  93836. * Please consider using the same method from the MeshBuilder class instead.
  93837. * * 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
  93838. * * The parameter `size` (positive float, default 1) sets the polygon size
  93839. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  93840. * * 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`
  93841. * * 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
  93842. * * 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)`)
  93843. * * 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
  93844. * * 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
  93845. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93846. * * If you create a double-sided mesh, you can choose what parts of 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
  93847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93848. * @param name defines the name of the mesh to create
  93849. * @param options defines the options used to create the mesh
  93850. * @param scene defines the hosting scene
  93851. * @returns a new Mesh
  93852. */
  93853. static CreatePolyhedron(name: string, options: {
  93854. type?: number;
  93855. size?: number;
  93856. sizeX?: number;
  93857. sizeY?: number;
  93858. sizeZ?: number;
  93859. custom?: any;
  93860. faceUV?: Vector4[];
  93861. faceColors?: Color4[];
  93862. updatable?: boolean;
  93863. sideOrientation?: number;
  93864. }, scene: Scene): Mesh;
  93865. /**
  93866. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  93867. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  93868. * * 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`)
  93869. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  93870. * * 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
  93871. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93872. * * If you create a double-sided mesh, you can choose what parts of 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
  93873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93874. * @param name defines the name of the mesh
  93875. * @param options defines the options used to create the mesh
  93876. * @param scene defines the hosting scene
  93877. * @returns a new Mesh
  93878. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93879. */
  93880. static CreateIcoSphere(name: string, options: {
  93881. radius?: number;
  93882. flat?: boolean;
  93883. subdivisions?: number;
  93884. sideOrientation?: number;
  93885. updatable?: boolean;
  93886. }, scene: Scene): Mesh;
  93887. /**
  93888. * Creates a decal mesh.
  93889. * Please consider using the same method from the MeshBuilder class instead.
  93890. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93891. * @param name defines the name of the mesh
  93892. * @param sourceMesh defines the mesh receiving the decal
  93893. * @param position sets the position of the decal in world coordinates
  93894. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93895. * @param size sets the decal scaling
  93896. * @param angle sets the angle to rotate the decal
  93897. * @returns a new Mesh
  93898. */
  93899. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93900. /**
  93901. * Prepare internal position array for software CPU skinning
  93902. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93903. */
  93904. setPositionsForCPUSkinning(): Float32Array;
  93905. /**
  93906. * Prepare internal normal array for software CPU skinning
  93907. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93908. */
  93909. setNormalsForCPUSkinning(): Float32Array;
  93910. /**
  93911. * Updates the vertex buffer by applying transformation from the bones
  93912. * @param skeleton defines the skeleton to apply to current mesh
  93913. * @returns the current mesh
  93914. */
  93915. applySkeleton(skeleton: Skeleton): Mesh;
  93916. /**
  93917. * 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
  93918. * @param meshes defines the list of meshes to scan
  93919. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93920. */
  93921. static MinMax(meshes: AbstractMesh[]): {
  93922. min: Vector3;
  93923. max: Vector3;
  93924. };
  93925. /**
  93926. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93927. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93928. * @returns a vector3
  93929. */
  93930. static Center(meshesOrMinMaxVector: {
  93931. min: Vector3;
  93932. max: Vector3;
  93933. } | AbstractMesh[]): Vector3;
  93934. /**
  93935. * Merge the array of meshes into a single mesh for performance reasons.
  93936. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93937. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93938. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93939. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93940. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93941. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93942. * @returns a new mesh
  93943. */
  93944. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93945. /** @hidden */
  93946. addInstance(instance: InstancedMesh): void;
  93947. /** @hidden */
  93948. removeInstance(instance: InstancedMesh): void;
  93949. }
  93950. }
  93951. declare module BABYLON {
  93952. /**
  93953. * This is the base class of all the camera used in the application.
  93954. * @see http://doc.babylonjs.com/features/cameras
  93955. */
  93956. export class Camera extends Node {
  93957. /** @hidden */
  93958. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93959. /**
  93960. * This is the default projection mode used by the cameras.
  93961. * It helps recreating a feeling of perspective and better appreciate depth.
  93962. * This is the best way to simulate real life cameras.
  93963. */
  93964. static readonly PERSPECTIVE_CAMERA: number;
  93965. /**
  93966. * This helps creating camera with an orthographic mode.
  93967. * 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.
  93968. */
  93969. static readonly ORTHOGRAPHIC_CAMERA: number;
  93970. /**
  93971. * This is the default FOV mode for perspective cameras.
  93972. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93973. */
  93974. static readonly FOVMODE_VERTICAL_FIXED: number;
  93975. /**
  93976. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93977. */
  93978. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93979. /**
  93980. * This specifies ther is no need for a camera rig.
  93981. * Basically only one eye is rendered corresponding to the camera.
  93982. */
  93983. static readonly RIG_MODE_NONE: number;
  93984. /**
  93985. * Simulates a camera Rig with one blue eye and one red eye.
  93986. * This can be use with 3d blue and red glasses.
  93987. */
  93988. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93989. /**
  93990. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93991. */
  93992. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93993. /**
  93994. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93995. */
  93996. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93997. /**
  93998. * Defines that both eyes of the camera will be rendered over under each other.
  93999. */
  94000. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  94001. /**
  94002. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  94003. */
  94004. static readonly RIG_MODE_VR: number;
  94005. /**
  94006. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  94007. */
  94008. static readonly RIG_MODE_WEBVR: number;
  94009. /**
  94010. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  94011. */
  94012. static readonly RIG_MODE_CUSTOM: number;
  94013. /**
  94014. * Defines if by default attaching controls should prevent the default javascript event to continue.
  94015. */
  94016. static ForceAttachControlToAlwaysPreventDefault: boolean;
  94017. /**
  94018. * Define the input manager associated with the camera.
  94019. */
  94020. inputs: CameraInputsManager<Camera>;
  94021. /** @hidden */
  94022. _position: Vector3;
  94023. /**
  94024. * Define the current local position of the camera in the scene
  94025. */
  94026. position: Vector3;
  94027. /**
  94028. * The vector the camera should consider as up.
  94029. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  94030. */
  94031. upVector: Vector3;
  94032. /**
  94033. * Define the current limit on the left side for an orthographic camera
  94034. * In scene unit
  94035. */
  94036. orthoLeft: Nullable<number>;
  94037. /**
  94038. * Define the current limit on the right side for an orthographic camera
  94039. * In scene unit
  94040. */
  94041. orthoRight: Nullable<number>;
  94042. /**
  94043. * Define the current limit on the bottom side for an orthographic camera
  94044. * In scene unit
  94045. */
  94046. orthoBottom: Nullable<number>;
  94047. /**
  94048. * Define the current limit on the top side for an orthographic camera
  94049. * In scene unit
  94050. */
  94051. orthoTop: Nullable<number>;
  94052. /**
  94053. * Field Of View is set in Radians. (default is 0.8)
  94054. */
  94055. fov: number;
  94056. /**
  94057. * Define the minimum distance the camera can see from.
  94058. * This is important to note that the depth buffer are not infinite and the closer it starts
  94059. * the more your scene might encounter depth fighting issue.
  94060. */
  94061. minZ: number;
  94062. /**
  94063. * Define the maximum distance the camera can see to.
  94064. * This is important to note that the depth buffer are not infinite and the further it end
  94065. * the more your scene might encounter depth fighting issue.
  94066. */
  94067. maxZ: number;
  94068. /**
  94069. * Define the default inertia of the camera.
  94070. * This helps giving a smooth feeling to the camera movement.
  94071. */
  94072. inertia: number;
  94073. /**
  94074. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  94075. */
  94076. mode: number;
  94077. /**
  94078. * Define wether the camera is intermediate.
  94079. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  94080. */
  94081. isIntermediate: boolean;
  94082. /**
  94083. * Define the viewport of the camera.
  94084. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  94085. */
  94086. viewport: Viewport;
  94087. /**
  94088. * Restricts the camera to viewing objects with the same layerMask.
  94089. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  94090. */
  94091. layerMask: number;
  94092. /**
  94093. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  94094. */
  94095. fovMode: number;
  94096. /**
  94097. * Rig mode of the camera.
  94098. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  94099. * This is normally controlled byt the camera themselves as internal use.
  94100. */
  94101. cameraRigMode: number;
  94102. /**
  94103. * Defines the distance between both "eyes" in case of a RIG
  94104. */
  94105. interaxialDistance: number;
  94106. /**
  94107. * Defines if stereoscopic rendering is done side by side or over under.
  94108. */
  94109. isStereoscopicSideBySide: boolean;
  94110. /**
  94111. * 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
  94112. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  94113. * else in the scene. (Eg. security camera)
  94114. *
  94115. * 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)
  94116. */
  94117. customRenderTargets: RenderTargetTexture[];
  94118. /**
  94119. * When set, the camera will render to this render target instead of the default canvas
  94120. *
  94121. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  94122. */
  94123. outputRenderTarget: Nullable<RenderTargetTexture>;
  94124. /**
  94125. * Observable triggered when the camera view matrix has changed.
  94126. */
  94127. onViewMatrixChangedObservable: Observable<Camera>;
  94128. /**
  94129. * Observable triggered when the camera Projection matrix has changed.
  94130. */
  94131. onProjectionMatrixChangedObservable: Observable<Camera>;
  94132. /**
  94133. * Observable triggered when the inputs have been processed.
  94134. */
  94135. onAfterCheckInputsObservable: Observable<Camera>;
  94136. /**
  94137. * Observable triggered when reset has been called and applied to the camera.
  94138. */
  94139. onRestoreStateObservable: Observable<Camera>;
  94140. /** @hidden */
  94141. _cameraRigParams: any;
  94142. /** @hidden */
  94143. _rigCameras: Camera[];
  94144. /** @hidden */
  94145. _rigPostProcess: Nullable<PostProcess>;
  94146. protected _webvrViewMatrix: Matrix;
  94147. /** @hidden */
  94148. _skipRendering: boolean;
  94149. /** @hidden */
  94150. _projectionMatrix: Matrix;
  94151. /** @hidden */
  94152. _postProcesses: Nullable<PostProcess>[];
  94153. /** @hidden */
  94154. _activeMeshes: SmartArray<AbstractMesh>;
  94155. protected _globalPosition: Vector3;
  94156. /** @hidden */
  94157. _computedViewMatrix: Matrix;
  94158. private _doNotComputeProjectionMatrix;
  94159. private _transformMatrix;
  94160. private _frustumPlanes;
  94161. private _refreshFrustumPlanes;
  94162. private _storedFov;
  94163. private _stateStored;
  94164. /**
  94165. * Instantiates a new camera object.
  94166. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  94167. * @see http://doc.babylonjs.com/features/cameras
  94168. * @param name Defines the name of the camera in the scene
  94169. * @param position Defines the position of the camera
  94170. * @param scene Defines the scene the camera belongs too
  94171. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  94172. */
  94173. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94174. /**
  94175. * Store current camera state (fov, position, etc..)
  94176. * @returns the camera
  94177. */
  94178. storeState(): Camera;
  94179. /**
  94180. * Restores the camera state values if it has been stored. You must call storeState() first
  94181. */
  94182. protected _restoreStateValues(): boolean;
  94183. /**
  94184. * Restored camera state. You must call storeState() first.
  94185. * @returns true if restored and false otherwise
  94186. */
  94187. restoreState(): boolean;
  94188. /**
  94189. * Gets the class name of the camera.
  94190. * @returns the class name
  94191. */
  94192. getClassName(): string;
  94193. /** @hidden */
  94194. readonly _isCamera: boolean;
  94195. /**
  94196. * Gets a string representation of the camera useful for debug purpose.
  94197. * @param fullDetails Defines that a more verboe level of logging is required
  94198. * @returns the string representation
  94199. */
  94200. toString(fullDetails?: boolean): string;
  94201. /**
  94202. * Gets the current world space position of the camera.
  94203. */
  94204. readonly globalPosition: Vector3;
  94205. /**
  94206. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  94207. * @returns the active meshe list
  94208. */
  94209. getActiveMeshes(): SmartArray<AbstractMesh>;
  94210. /**
  94211. * Check wether a mesh is part of the current active mesh list of the camera
  94212. * @param mesh Defines the mesh to check
  94213. * @returns true if active, false otherwise
  94214. */
  94215. isActiveMesh(mesh: Mesh): boolean;
  94216. /**
  94217. * Is this camera ready to be used/rendered
  94218. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  94219. * @return true if the camera is ready
  94220. */
  94221. isReady(completeCheck?: boolean): boolean;
  94222. /** @hidden */
  94223. _initCache(): void;
  94224. /** @hidden */
  94225. _updateCache(ignoreParentClass?: boolean): void;
  94226. /** @hidden */
  94227. _isSynchronized(): boolean;
  94228. /** @hidden */
  94229. _isSynchronizedViewMatrix(): boolean;
  94230. /** @hidden */
  94231. _isSynchronizedProjectionMatrix(): boolean;
  94232. /**
  94233. * Attach the input controls to a specific dom element to get the input from.
  94234. * @param element Defines the element the controls should be listened from
  94235. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94236. */
  94237. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94238. /**
  94239. * Detach the current controls from the specified dom element.
  94240. * @param element Defines the element to stop listening the inputs from
  94241. */
  94242. detachControl(element: HTMLElement): void;
  94243. /**
  94244. * Update the camera state according to the different inputs gathered during the frame.
  94245. */
  94246. update(): void;
  94247. /** @hidden */
  94248. _checkInputs(): void;
  94249. /** @hidden */
  94250. readonly rigCameras: Camera[];
  94251. /**
  94252. * Gets the post process used by the rig cameras
  94253. */
  94254. readonly rigPostProcess: Nullable<PostProcess>;
  94255. /**
  94256. * Internal, gets the first post proces.
  94257. * @returns the first post process to be run on this camera.
  94258. */
  94259. _getFirstPostProcess(): Nullable<PostProcess>;
  94260. private _cascadePostProcessesToRigCams;
  94261. /**
  94262. * Attach a post process to the camera.
  94263. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94264. * @param postProcess The post process to attach to the camera
  94265. * @param insertAt The position of the post process in case several of them are in use in the scene
  94266. * @returns the position the post process has been inserted at
  94267. */
  94268. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  94269. /**
  94270. * Detach a post process to the camera.
  94271. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94272. * @param postProcess The post process to detach from the camera
  94273. */
  94274. detachPostProcess(postProcess: PostProcess): void;
  94275. /**
  94276. * Gets the current world matrix of the camera
  94277. */
  94278. getWorldMatrix(): Matrix;
  94279. /** @hidden */
  94280. _getViewMatrix(): Matrix;
  94281. /**
  94282. * Gets the current view matrix of the camera.
  94283. * @param force forces the camera to recompute the matrix without looking at the cached state
  94284. * @returns the view matrix
  94285. */
  94286. getViewMatrix(force?: boolean): Matrix;
  94287. /**
  94288. * Freeze the projection matrix.
  94289. * It will prevent the cache check of the camera projection compute and can speed up perf
  94290. * if no parameter of the camera are meant to change
  94291. * @param projection Defines manually a projection if necessary
  94292. */
  94293. freezeProjectionMatrix(projection?: Matrix): void;
  94294. /**
  94295. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  94296. */
  94297. unfreezeProjectionMatrix(): void;
  94298. /**
  94299. * Gets the current projection matrix of the camera.
  94300. * @param force forces the camera to recompute the matrix without looking at the cached state
  94301. * @returns the projection matrix
  94302. */
  94303. getProjectionMatrix(force?: boolean): Matrix;
  94304. /**
  94305. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  94306. * @returns a Matrix
  94307. */
  94308. getTransformationMatrix(): Matrix;
  94309. private _updateFrustumPlanes;
  94310. /**
  94311. * Checks if a cullable object (mesh...) is in the camera frustum
  94312. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  94313. * @param target The object to check
  94314. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  94315. * @returns true if the object is in frustum otherwise false
  94316. */
  94317. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  94318. /**
  94319. * Checks if a cullable object (mesh...) is in the camera frustum
  94320. * Unlike isInFrustum this cheks the full bounding box
  94321. * @param target The object to check
  94322. * @returns true if the object is in frustum otherwise false
  94323. */
  94324. isCompletelyInFrustum(target: ICullable): boolean;
  94325. /**
  94326. * Gets a ray in the forward direction from the camera.
  94327. * @param length Defines the length of the ray to create
  94328. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  94329. * @param origin Defines the start point of the ray which defaults to the camera position
  94330. * @returns the forward ray
  94331. */
  94332. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  94333. /**
  94334. * Releases resources associated with this node.
  94335. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94336. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94337. */
  94338. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94339. /** @hidden */
  94340. _isLeftCamera: boolean;
  94341. /**
  94342. * Gets the left camera of a rig setup in case of Rigged Camera
  94343. */
  94344. readonly isLeftCamera: boolean;
  94345. /** @hidden */
  94346. _isRightCamera: boolean;
  94347. /**
  94348. * Gets the right camera of a rig setup in case of Rigged Camera
  94349. */
  94350. readonly isRightCamera: boolean;
  94351. /**
  94352. * Gets the left camera of a rig setup in case of Rigged Camera
  94353. */
  94354. readonly leftCamera: Nullable<FreeCamera>;
  94355. /**
  94356. * Gets the right camera of a rig setup in case of Rigged Camera
  94357. */
  94358. readonly rightCamera: Nullable<FreeCamera>;
  94359. /**
  94360. * Gets the left camera target of a rig setup in case of Rigged Camera
  94361. * @returns the target position
  94362. */
  94363. getLeftTarget(): Nullable<Vector3>;
  94364. /**
  94365. * Gets the right camera target of a rig setup in case of Rigged Camera
  94366. * @returns the target position
  94367. */
  94368. getRightTarget(): Nullable<Vector3>;
  94369. /**
  94370. * @hidden
  94371. */
  94372. setCameraRigMode(mode: number, rigParams: any): void;
  94373. /** @hidden */
  94374. static _setStereoscopicRigMode(camera: Camera): void;
  94375. /** @hidden */
  94376. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  94377. /** @hidden */
  94378. static _setVRRigMode(camera: Camera, rigParams: any): void;
  94379. /** @hidden */
  94380. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  94381. /** @hidden */
  94382. _getVRProjectionMatrix(): Matrix;
  94383. protected _updateCameraRotationMatrix(): void;
  94384. protected _updateWebVRCameraRotationMatrix(): void;
  94385. /**
  94386. * This function MUST be overwritten by the different WebVR cameras available.
  94387. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94388. * @hidden
  94389. */
  94390. _getWebVRProjectionMatrix(): Matrix;
  94391. /**
  94392. * This function MUST be overwritten by the different WebVR cameras available.
  94393. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94394. * @hidden
  94395. */
  94396. _getWebVRViewMatrix(): Matrix;
  94397. /** @hidden */
  94398. setCameraRigParameter(name: string, value: any): void;
  94399. /**
  94400. * needs to be overridden by children so sub has required properties to be copied
  94401. * @hidden
  94402. */
  94403. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94404. /**
  94405. * May need to be overridden by children
  94406. * @hidden
  94407. */
  94408. _updateRigCameras(): void;
  94409. /** @hidden */
  94410. _setupInputs(): void;
  94411. /**
  94412. * Serialiaze the camera setup to a json represention
  94413. * @returns the JSON representation
  94414. */
  94415. serialize(): any;
  94416. /**
  94417. * Clones the current camera.
  94418. * @param name The cloned camera name
  94419. * @returns the cloned camera
  94420. */
  94421. clone(name: string): Camera;
  94422. /**
  94423. * Gets the direction of the camera relative to a given local axis.
  94424. * @param localAxis Defines the reference axis to provide a relative direction.
  94425. * @return the direction
  94426. */
  94427. getDirection(localAxis: Vector3): Vector3;
  94428. /**
  94429. * Returns the current camera absolute rotation
  94430. */
  94431. readonly absoluteRotation: Quaternion;
  94432. /**
  94433. * Gets the direction of the camera relative to a given local axis into a passed vector.
  94434. * @param localAxis Defines the reference axis to provide a relative direction.
  94435. * @param result Defines the vector to store the result in
  94436. */
  94437. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  94438. /**
  94439. * Gets a camera constructor for a given camera type
  94440. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  94441. * @param name The name of the camera the result will be able to instantiate
  94442. * @param scene The scene the result will construct the camera in
  94443. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  94444. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  94445. * @returns a factory method to construc the camera
  94446. */
  94447. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  94448. /**
  94449. * Compute the world matrix of the camera.
  94450. * @returns the camera world matrix
  94451. */
  94452. computeWorldMatrix(): Matrix;
  94453. /**
  94454. * Parse a JSON and creates the camera from the parsed information
  94455. * @param parsedCamera The JSON to parse
  94456. * @param scene The scene to instantiate the camera in
  94457. * @returns the newly constructed camera
  94458. */
  94459. static Parse(parsedCamera: any, scene: Scene): Camera;
  94460. }
  94461. }
  94462. declare module BABYLON {
  94463. /**
  94464. * Class containing static functions to help procedurally build meshes
  94465. */
  94466. export class DiscBuilder {
  94467. /**
  94468. * Creates a plane polygonal mesh. By default, this is a disc
  94469. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  94470. * * 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
  94471. * * 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
  94472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94475. * @param name defines the name of the mesh
  94476. * @param options defines the options used to create the mesh
  94477. * @param scene defines the hosting scene
  94478. * @returns the plane polygonal mesh
  94479. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  94480. */
  94481. static CreateDisc(name: string, options: {
  94482. radius?: number;
  94483. tessellation?: number;
  94484. arc?: number;
  94485. updatable?: boolean;
  94486. sideOrientation?: number;
  94487. frontUVs?: Vector4;
  94488. backUVs?: Vector4;
  94489. }, scene?: Nullable<Scene>): Mesh;
  94490. }
  94491. }
  94492. declare module BABYLON {
  94493. /**
  94494. * This represents all the required information to add a fresnel effect on a material:
  94495. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94496. */
  94497. export class FresnelParameters {
  94498. private _isEnabled;
  94499. /**
  94500. * Define if the fresnel effect is enable or not.
  94501. */
  94502. isEnabled: boolean;
  94503. /**
  94504. * Define the color used on edges (grazing angle)
  94505. */
  94506. leftColor: Color3;
  94507. /**
  94508. * Define the color used on center
  94509. */
  94510. rightColor: Color3;
  94511. /**
  94512. * Define bias applied to computed fresnel term
  94513. */
  94514. bias: number;
  94515. /**
  94516. * Defined the power exponent applied to fresnel term
  94517. */
  94518. power: number;
  94519. /**
  94520. * Clones the current fresnel and its valuues
  94521. * @returns a clone fresnel configuration
  94522. */
  94523. clone(): FresnelParameters;
  94524. /**
  94525. * Serializes the current fresnel parameters to a JSON representation.
  94526. * @return the JSON serialization
  94527. */
  94528. serialize(): any;
  94529. /**
  94530. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94531. * @param parsedFresnelParameters Define the JSON representation
  94532. * @returns the parsed parameters
  94533. */
  94534. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94535. }
  94536. }
  94537. declare module BABYLON {
  94538. /**
  94539. * Base class of materials working in push mode in babylon JS
  94540. * @hidden
  94541. */
  94542. export class PushMaterial extends Material {
  94543. protected _activeEffect: Effect;
  94544. protected _normalMatrix: Matrix;
  94545. /**
  94546. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94547. * This means that the material can keep using a previous shader while a new one is being compiled.
  94548. * This is mostly used when shader parallel compilation is supported (true by default)
  94549. */
  94550. allowShaderHotSwapping: boolean;
  94551. constructor(name: string, scene: Scene);
  94552. getEffect(): Effect;
  94553. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94554. /**
  94555. * Binds the given world matrix to the active effect
  94556. *
  94557. * @param world the matrix to bind
  94558. */
  94559. bindOnlyWorldMatrix(world: Matrix): void;
  94560. /**
  94561. * Binds the given normal matrix to the active effect
  94562. *
  94563. * @param normalMatrix the matrix to bind
  94564. */
  94565. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94566. bind(world: Matrix, mesh?: Mesh): void;
  94567. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94568. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94569. }
  94570. }
  94571. declare module BABYLON {
  94572. /**
  94573. * This groups all the flags used to control the materials channel.
  94574. */
  94575. export class MaterialFlags {
  94576. private static _DiffuseTextureEnabled;
  94577. /**
  94578. * Are diffuse textures enabled in the application.
  94579. */
  94580. static DiffuseTextureEnabled: boolean;
  94581. private static _AmbientTextureEnabled;
  94582. /**
  94583. * Are ambient textures enabled in the application.
  94584. */
  94585. static AmbientTextureEnabled: boolean;
  94586. private static _OpacityTextureEnabled;
  94587. /**
  94588. * Are opacity textures enabled in the application.
  94589. */
  94590. static OpacityTextureEnabled: boolean;
  94591. private static _ReflectionTextureEnabled;
  94592. /**
  94593. * Are reflection textures enabled in the application.
  94594. */
  94595. static ReflectionTextureEnabled: boolean;
  94596. private static _EmissiveTextureEnabled;
  94597. /**
  94598. * Are emissive textures enabled in the application.
  94599. */
  94600. static EmissiveTextureEnabled: boolean;
  94601. private static _SpecularTextureEnabled;
  94602. /**
  94603. * Are specular textures enabled in the application.
  94604. */
  94605. static SpecularTextureEnabled: boolean;
  94606. private static _BumpTextureEnabled;
  94607. /**
  94608. * Are bump textures enabled in the application.
  94609. */
  94610. static BumpTextureEnabled: boolean;
  94611. private static _LightmapTextureEnabled;
  94612. /**
  94613. * Are lightmap textures enabled in the application.
  94614. */
  94615. static LightmapTextureEnabled: boolean;
  94616. private static _RefractionTextureEnabled;
  94617. /**
  94618. * Are refraction textures enabled in the application.
  94619. */
  94620. static RefractionTextureEnabled: boolean;
  94621. private static _ColorGradingTextureEnabled;
  94622. /**
  94623. * Are color grading textures enabled in the application.
  94624. */
  94625. static ColorGradingTextureEnabled: boolean;
  94626. private static _FresnelEnabled;
  94627. /**
  94628. * Are fresnels enabled in the application.
  94629. */
  94630. static FresnelEnabled: boolean;
  94631. private static _ClearCoatTextureEnabled;
  94632. /**
  94633. * Are clear coat textures enabled in the application.
  94634. */
  94635. static ClearCoatTextureEnabled: boolean;
  94636. private static _ClearCoatBumpTextureEnabled;
  94637. /**
  94638. * Are clear coat bump textures enabled in the application.
  94639. */
  94640. static ClearCoatBumpTextureEnabled: boolean;
  94641. private static _ClearCoatTintTextureEnabled;
  94642. /**
  94643. * Are clear coat tint textures enabled in the application.
  94644. */
  94645. static ClearCoatTintTextureEnabled: boolean;
  94646. private static _SheenTextureEnabled;
  94647. /**
  94648. * Are sheen textures enabled in the application.
  94649. */
  94650. static SheenTextureEnabled: boolean;
  94651. private static _AnisotropicTextureEnabled;
  94652. /**
  94653. * Are anisotropic textures enabled in the application.
  94654. */
  94655. static AnisotropicTextureEnabled: boolean;
  94656. private static _ThicknessTextureEnabled;
  94657. /**
  94658. * Are thickness textures enabled in the application.
  94659. */
  94660. static ThicknessTextureEnabled: boolean;
  94661. }
  94662. }
  94663. declare module BABYLON {
  94664. /** @hidden */
  94665. export var defaultFragmentDeclaration: {
  94666. name: string;
  94667. shader: string;
  94668. };
  94669. }
  94670. declare module BABYLON {
  94671. /** @hidden */
  94672. export var defaultUboDeclaration: {
  94673. name: string;
  94674. shader: string;
  94675. };
  94676. }
  94677. declare module BABYLON {
  94678. /** @hidden */
  94679. export var lightFragmentDeclaration: {
  94680. name: string;
  94681. shader: string;
  94682. };
  94683. }
  94684. declare module BABYLON {
  94685. /** @hidden */
  94686. export var lightUboDeclaration: {
  94687. name: string;
  94688. shader: string;
  94689. };
  94690. }
  94691. declare module BABYLON {
  94692. /** @hidden */
  94693. export var lightsFragmentFunctions: {
  94694. name: string;
  94695. shader: string;
  94696. };
  94697. }
  94698. declare module BABYLON {
  94699. /** @hidden */
  94700. export var shadowsFragmentFunctions: {
  94701. name: string;
  94702. shader: string;
  94703. };
  94704. }
  94705. declare module BABYLON {
  94706. /** @hidden */
  94707. export var fresnelFunction: {
  94708. name: string;
  94709. shader: string;
  94710. };
  94711. }
  94712. declare module BABYLON {
  94713. /** @hidden */
  94714. export var reflectionFunction: {
  94715. name: string;
  94716. shader: string;
  94717. };
  94718. }
  94719. declare module BABYLON {
  94720. /** @hidden */
  94721. export var bumpFragmentFunctions: {
  94722. name: string;
  94723. shader: string;
  94724. };
  94725. }
  94726. declare module BABYLON {
  94727. /** @hidden */
  94728. export var logDepthDeclaration: {
  94729. name: string;
  94730. shader: string;
  94731. };
  94732. }
  94733. declare module BABYLON {
  94734. /** @hidden */
  94735. export var bumpFragment: {
  94736. name: string;
  94737. shader: string;
  94738. };
  94739. }
  94740. declare module BABYLON {
  94741. /** @hidden */
  94742. export var depthPrePass: {
  94743. name: string;
  94744. shader: string;
  94745. };
  94746. }
  94747. declare module BABYLON {
  94748. /** @hidden */
  94749. export var lightFragment: {
  94750. name: string;
  94751. shader: string;
  94752. };
  94753. }
  94754. declare module BABYLON {
  94755. /** @hidden */
  94756. export var logDepthFragment: {
  94757. name: string;
  94758. shader: string;
  94759. };
  94760. }
  94761. declare module BABYLON {
  94762. /** @hidden */
  94763. export var defaultPixelShader: {
  94764. name: string;
  94765. shader: string;
  94766. };
  94767. }
  94768. declare module BABYLON {
  94769. /** @hidden */
  94770. export var defaultVertexDeclaration: {
  94771. name: string;
  94772. shader: string;
  94773. };
  94774. }
  94775. declare module BABYLON {
  94776. /** @hidden */
  94777. export var bumpVertexDeclaration: {
  94778. name: string;
  94779. shader: string;
  94780. };
  94781. }
  94782. declare module BABYLON {
  94783. /** @hidden */
  94784. export var bumpVertex: {
  94785. name: string;
  94786. shader: string;
  94787. };
  94788. }
  94789. declare module BABYLON {
  94790. /** @hidden */
  94791. export var fogVertex: {
  94792. name: string;
  94793. shader: string;
  94794. };
  94795. }
  94796. declare module BABYLON {
  94797. /** @hidden */
  94798. export var shadowsVertex: {
  94799. name: string;
  94800. shader: string;
  94801. };
  94802. }
  94803. declare module BABYLON {
  94804. /** @hidden */
  94805. export var pointCloudVertex: {
  94806. name: string;
  94807. shader: string;
  94808. };
  94809. }
  94810. declare module BABYLON {
  94811. /** @hidden */
  94812. export var logDepthVertex: {
  94813. name: string;
  94814. shader: string;
  94815. };
  94816. }
  94817. declare module BABYLON {
  94818. /** @hidden */
  94819. export var defaultVertexShader: {
  94820. name: string;
  94821. shader: string;
  94822. };
  94823. }
  94824. declare module BABYLON {
  94825. /** @hidden */
  94826. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94827. MAINUV1: boolean;
  94828. MAINUV2: boolean;
  94829. DIFFUSE: boolean;
  94830. DIFFUSEDIRECTUV: number;
  94831. AMBIENT: boolean;
  94832. AMBIENTDIRECTUV: number;
  94833. OPACITY: boolean;
  94834. OPACITYDIRECTUV: number;
  94835. OPACITYRGB: boolean;
  94836. REFLECTION: boolean;
  94837. EMISSIVE: boolean;
  94838. EMISSIVEDIRECTUV: number;
  94839. SPECULAR: boolean;
  94840. SPECULARDIRECTUV: number;
  94841. BUMP: boolean;
  94842. BUMPDIRECTUV: number;
  94843. PARALLAX: boolean;
  94844. PARALLAXOCCLUSION: boolean;
  94845. SPECULAROVERALPHA: boolean;
  94846. CLIPPLANE: boolean;
  94847. CLIPPLANE2: boolean;
  94848. CLIPPLANE3: boolean;
  94849. CLIPPLANE4: boolean;
  94850. ALPHATEST: boolean;
  94851. DEPTHPREPASS: boolean;
  94852. ALPHAFROMDIFFUSE: boolean;
  94853. POINTSIZE: boolean;
  94854. FOG: boolean;
  94855. SPECULARTERM: boolean;
  94856. DIFFUSEFRESNEL: boolean;
  94857. OPACITYFRESNEL: boolean;
  94858. REFLECTIONFRESNEL: boolean;
  94859. REFRACTIONFRESNEL: boolean;
  94860. EMISSIVEFRESNEL: boolean;
  94861. FRESNEL: boolean;
  94862. NORMAL: boolean;
  94863. UV1: boolean;
  94864. UV2: boolean;
  94865. VERTEXCOLOR: boolean;
  94866. VERTEXALPHA: boolean;
  94867. NUM_BONE_INFLUENCERS: number;
  94868. BonesPerMesh: number;
  94869. BONETEXTURE: boolean;
  94870. INSTANCES: boolean;
  94871. GLOSSINESS: boolean;
  94872. ROUGHNESS: boolean;
  94873. EMISSIVEASILLUMINATION: boolean;
  94874. LINKEMISSIVEWITHDIFFUSE: boolean;
  94875. REFLECTIONFRESNELFROMSPECULAR: boolean;
  94876. LIGHTMAP: boolean;
  94877. LIGHTMAPDIRECTUV: number;
  94878. OBJECTSPACE_NORMALMAP: boolean;
  94879. USELIGHTMAPASSHADOWMAP: boolean;
  94880. REFLECTIONMAP_3D: boolean;
  94881. REFLECTIONMAP_SPHERICAL: boolean;
  94882. REFLECTIONMAP_PLANAR: boolean;
  94883. REFLECTIONMAP_CUBIC: boolean;
  94884. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  94885. REFLECTIONMAP_PROJECTION: boolean;
  94886. REFLECTIONMAP_SKYBOX: boolean;
  94887. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  94888. REFLECTIONMAP_EXPLICIT: boolean;
  94889. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  94890. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  94891. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  94892. INVERTCUBICMAP: boolean;
  94893. LOGARITHMICDEPTH: boolean;
  94894. REFRACTION: boolean;
  94895. REFRACTIONMAP_3D: boolean;
  94896. REFLECTIONOVERALPHA: boolean;
  94897. TWOSIDEDLIGHTING: boolean;
  94898. SHADOWFLOAT: boolean;
  94899. MORPHTARGETS: boolean;
  94900. MORPHTARGETS_NORMAL: boolean;
  94901. MORPHTARGETS_TANGENT: boolean;
  94902. MORPHTARGETS_UV: boolean;
  94903. NUM_MORPH_INFLUENCERS: number;
  94904. NONUNIFORMSCALING: boolean;
  94905. PREMULTIPLYALPHA: boolean;
  94906. IMAGEPROCESSING: boolean;
  94907. VIGNETTE: boolean;
  94908. VIGNETTEBLENDMODEMULTIPLY: boolean;
  94909. VIGNETTEBLENDMODEOPAQUE: boolean;
  94910. TONEMAPPING: boolean;
  94911. TONEMAPPING_ACES: boolean;
  94912. CONTRAST: boolean;
  94913. COLORCURVES: boolean;
  94914. COLORGRADING: boolean;
  94915. COLORGRADING3D: boolean;
  94916. SAMPLER3DGREENDEPTH: boolean;
  94917. SAMPLER3DBGRMAP: boolean;
  94918. IMAGEPROCESSINGPOSTPROCESS: boolean;
  94919. MULTIVIEW: boolean;
  94920. /**
  94921. * If the reflection texture on this material is in linear color space
  94922. * @hidden
  94923. */
  94924. IS_REFLECTION_LINEAR: boolean;
  94925. /**
  94926. * If the refraction texture on this material is in linear color space
  94927. * @hidden
  94928. */
  94929. IS_REFRACTION_LINEAR: boolean;
  94930. EXPOSURE: boolean;
  94931. constructor();
  94932. setReflectionMode(modeToEnable: string): void;
  94933. }
  94934. /**
  94935. * This is the default material used in Babylon. It is the best trade off between quality
  94936. * and performances.
  94937. * @see http://doc.babylonjs.com/babylon101/materials
  94938. */
  94939. export class StandardMaterial extends PushMaterial {
  94940. private _diffuseTexture;
  94941. /**
  94942. * The basic texture of the material as viewed under a light.
  94943. */
  94944. diffuseTexture: Nullable<BaseTexture>;
  94945. private _ambientTexture;
  94946. /**
  94947. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  94948. */
  94949. ambientTexture: Nullable<BaseTexture>;
  94950. private _opacityTexture;
  94951. /**
  94952. * Define the transparency of the material from a texture.
  94953. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  94954. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  94955. */
  94956. opacityTexture: Nullable<BaseTexture>;
  94957. private _reflectionTexture;
  94958. /**
  94959. * Define the texture used to display the reflection.
  94960. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94961. */
  94962. reflectionTexture: Nullable<BaseTexture>;
  94963. private _emissiveTexture;
  94964. /**
  94965. * Define texture of the material as if self lit.
  94966. * This will be mixed in the final result even in the absence of light.
  94967. */
  94968. emissiveTexture: Nullable<BaseTexture>;
  94969. private _specularTexture;
  94970. /**
  94971. * Define how the color and intensity of the highlight given by the light in the material.
  94972. */
  94973. specularTexture: Nullable<BaseTexture>;
  94974. private _bumpTexture;
  94975. /**
  94976. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  94977. * 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.
  94978. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  94979. */
  94980. bumpTexture: Nullable<BaseTexture>;
  94981. private _lightmapTexture;
  94982. /**
  94983. * Complex lighting can be computationally expensive to compute at runtime.
  94984. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  94985. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  94986. */
  94987. lightmapTexture: Nullable<BaseTexture>;
  94988. private _refractionTexture;
  94989. /**
  94990. * Define the texture used to display the refraction.
  94991. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94992. */
  94993. refractionTexture: Nullable<BaseTexture>;
  94994. /**
  94995. * The color of the material lit by the environmental background lighting.
  94996. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  94997. */
  94998. ambientColor: Color3;
  94999. /**
  95000. * The basic color of the material as viewed under a light.
  95001. */
  95002. diffuseColor: Color3;
  95003. /**
  95004. * Define how the color and intensity of the highlight given by the light in the material.
  95005. */
  95006. specularColor: Color3;
  95007. /**
  95008. * Define the color of the material as if self lit.
  95009. * This will be mixed in the final result even in the absence of light.
  95010. */
  95011. emissiveColor: Color3;
  95012. /**
  95013. * Defines how sharp are the highlights in the material.
  95014. * The bigger the value the sharper giving a more glossy feeling to the result.
  95015. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95016. */
  95017. specularPower: number;
  95018. private _useAlphaFromDiffuseTexture;
  95019. /**
  95020. * Does the transparency come from the diffuse texture alpha channel.
  95021. */
  95022. useAlphaFromDiffuseTexture: boolean;
  95023. private _useEmissiveAsIllumination;
  95024. /**
  95025. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95026. */
  95027. useEmissiveAsIllumination: boolean;
  95028. private _linkEmissiveWithDiffuse;
  95029. /**
  95030. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95031. * the emissive level when the final color is close to one.
  95032. */
  95033. linkEmissiveWithDiffuse: boolean;
  95034. private _useSpecularOverAlpha;
  95035. /**
  95036. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95037. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95038. */
  95039. useSpecularOverAlpha: boolean;
  95040. private _useReflectionOverAlpha;
  95041. /**
  95042. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95043. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95044. */
  95045. useReflectionOverAlpha: boolean;
  95046. private _disableLighting;
  95047. /**
  95048. * Does lights from the scene impacts this material.
  95049. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95050. */
  95051. disableLighting: boolean;
  95052. private _useObjectSpaceNormalMap;
  95053. /**
  95054. * Allows using an object space normal map (instead of tangent space).
  95055. */
  95056. useObjectSpaceNormalMap: boolean;
  95057. private _useParallax;
  95058. /**
  95059. * Is parallax enabled or not.
  95060. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95061. */
  95062. useParallax: boolean;
  95063. private _useParallaxOcclusion;
  95064. /**
  95065. * Is parallax occlusion enabled or not.
  95066. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95067. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95068. */
  95069. useParallaxOcclusion: boolean;
  95070. /**
  95071. * 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.
  95072. */
  95073. parallaxScaleBias: number;
  95074. private _roughness;
  95075. /**
  95076. * Helps to define how blurry the reflections should appears in the material.
  95077. */
  95078. roughness: number;
  95079. /**
  95080. * In case of refraction, define the value of the index of refraction.
  95081. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95082. */
  95083. indexOfRefraction: number;
  95084. /**
  95085. * Invert the refraction texture alongside the y axis.
  95086. * It can be useful with procedural textures or probe for instance.
  95087. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95088. */
  95089. invertRefractionY: boolean;
  95090. /**
  95091. * Defines the alpha limits in alpha test mode.
  95092. */
  95093. alphaCutOff: number;
  95094. private _useLightmapAsShadowmap;
  95095. /**
  95096. * In case of light mapping, define whether the map contains light or shadow informations.
  95097. */
  95098. useLightmapAsShadowmap: boolean;
  95099. private _diffuseFresnelParameters;
  95100. /**
  95101. * Define the diffuse fresnel parameters of the material.
  95102. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95103. */
  95104. diffuseFresnelParameters: FresnelParameters;
  95105. private _opacityFresnelParameters;
  95106. /**
  95107. * Define the opacity fresnel parameters of the material.
  95108. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95109. */
  95110. opacityFresnelParameters: FresnelParameters;
  95111. private _reflectionFresnelParameters;
  95112. /**
  95113. * Define the reflection fresnel parameters of the material.
  95114. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95115. */
  95116. reflectionFresnelParameters: FresnelParameters;
  95117. private _refractionFresnelParameters;
  95118. /**
  95119. * Define the refraction fresnel parameters of the material.
  95120. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95121. */
  95122. refractionFresnelParameters: FresnelParameters;
  95123. private _emissiveFresnelParameters;
  95124. /**
  95125. * Define the emissive fresnel parameters of the material.
  95126. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95127. */
  95128. emissiveFresnelParameters: FresnelParameters;
  95129. private _useReflectionFresnelFromSpecular;
  95130. /**
  95131. * If true automatically deducts the fresnels values from the material specularity.
  95132. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95133. */
  95134. useReflectionFresnelFromSpecular: boolean;
  95135. private _useGlossinessFromSpecularMapAlpha;
  95136. /**
  95137. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95138. */
  95139. useGlossinessFromSpecularMapAlpha: boolean;
  95140. private _maxSimultaneousLights;
  95141. /**
  95142. * Defines the maximum number of lights that can be used in the material
  95143. */
  95144. maxSimultaneousLights: number;
  95145. private _invertNormalMapX;
  95146. /**
  95147. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95148. */
  95149. invertNormalMapX: boolean;
  95150. private _invertNormalMapY;
  95151. /**
  95152. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95153. */
  95154. invertNormalMapY: boolean;
  95155. private _twoSidedLighting;
  95156. /**
  95157. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95158. */
  95159. twoSidedLighting: boolean;
  95160. /**
  95161. * Default configuration related to image processing available in the standard Material.
  95162. */
  95163. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95164. /**
  95165. * Gets the image processing configuration used either in this material.
  95166. */
  95167. /**
  95168. * Sets the Default image processing configuration used either in the this material.
  95169. *
  95170. * If sets to null, the scene one is in use.
  95171. */
  95172. imageProcessingConfiguration: ImageProcessingConfiguration;
  95173. /**
  95174. * Keep track of the image processing observer to allow dispose and replace.
  95175. */
  95176. private _imageProcessingObserver;
  95177. /**
  95178. * Attaches a new image processing configuration to the Standard Material.
  95179. * @param configuration
  95180. */
  95181. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95182. /**
  95183. * Gets wether the color curves effect is enabled.
  95184. */
  95185. /**
  95186. * Sets wether the color curves effect is enabled.
  95187. */
  95188. cameraColorCurvesEnabled: boolean;
  95189. /**
  95190. * Gets wether the color grading effect is enabled.
  95191. */
  95192. /**
  95193. * Gets wether the color grading effect is enabled.
  95194. */
  95195. cameraColorGradingEnabled: boolean;
  95196. /**
  95197. * Gets wether tonemapping is enabled or not.
  95198. */
  95199. /**
  95200. * Sets wether tonemapping is enabled or not
  95201. */
  95202. cameraToneMappingEnabled: boolean;
  95203. /**
  95204. * The camera exposure used on this material.
  95205. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95206. * This corresponds to a photographic exposure.
  95207. */
  95208. /**
  95209. * The camera exposure used on this material.
  95210. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95211. * This corresponds to a photographic exposure.
  95212. */
  95213. cameraExposure: number;
  95214. /**
  95215. * Gets The camera contrast used on this material.
  95216. */
  95217. /**
  95218. * Sets The camera contrast used on this material.
  95219. */
  95220. cameraContrast: number;
  95221. /**
  95222. * Gets the Color Grading 2D Lookup Texture.
  95223. */
  95224. /**
  95225. * Sets the Color Grading 2D Lookup Texture.
  95226. */
  95227. cameraColorGradingTexture: Nullable<BaseTexture>;
  95228. /**
  95229. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95230. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95231. * 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;
  95232. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95233. */
  95234. /**
  95235. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95236. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95237. * 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;
  95238. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95239. */
  95240. cameraColorCurves: Nullable<ColorCurves>;
  95241. /**
  95242. * Custom callback helping to override the default shader used in the material.
  95243. */
  95244. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95245. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95246. protected _worldViewProjectionMatrix: Matrix;
  95247. protected _globalAmbientColor: Color3;
  95248. protected _useLogarithmicDepth: boolean;
  95249. protected _rebuildInParallel: boolean;
  95250. /**
  95251. * Instantiates a new standard material.
  95252. * This is the default material used in Babylon. It is the best trade off between quality
  95253. * and performances.
  95254. * @see http://doc.babylonjs.com/babylon101/materials
  95255. * @param name Define the name of the material in the scene
  95256. * @param scene Define the scene the material belong to
  95257. */
  95258. constructor(name: string, scene: Scene);
  95259. /**
  95260. * Gets a boolean indicating that current material needs to register RTT
  95261. */
  95262. readonly hasRenderTargetTextures: boolean;
  95263. /**
  95264. * Gets the current class name of the material e.g. "StandardMaterial"
  95265. * Mainly use in serialization.
  95266. * @returns the class name
  95267. */
  95268. getClassName(): string;
  95269. /**
  95270. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95271. * You can try switching to logarithmic depth.
  95272. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95273. */
  95274. useLogarithmicDepth: boolean;
  95275. /**
  95276. * Specifies if the material will require alpha blending
  95277. * @returns a boolean specifying if alpha blending is needed
  95278. */
  95279. needAlphaBlending(): boolean;
  95280. /**
  95281. * Specifies if this material should be rendered in alpha test mode
  95282. * @returns a boolean specifying if an alpha test is needed.
  95283. */
  95284. needAlphaTesting(): boolean;
  95285. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95286. /**
  95287. * Get the texture used for alpha test purpose.
  95288. * @returns the diffuse texture in case of the standard material.
  95289. */
  95290. getAlphaTestTexture(): Nullable<BaseTexture>;
  95291. /**
  95292. * Get if the submesh is ready to be used and all its information available.
  95293. * Child classes can use it to update shaders
  95294. * @param mesh defines the mesh to check
  95295. * @param subMesh defines which submesh to check
  95296. * @param useInstances specifies that instances should be used
  95297. * @returns a boolean indicating that the submesh is ready or not
  95298. */
  95299. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95300. /**
  95301. * Builds the material UBO layouts.
  95302. * Used internally during the effect preparation.
  95303. */
  95304. buildUniformLayout(): void;
  95305. /**
  95306. * Unbinds the material from the mesh
  95307. */
  95308. unbind(): void;
  95309. /**
  95310. * Binds the submesh to this material by preparing the effect and shader to draw
  95311. * @param world defines the world transformation matrix
  95312. * @param mesh defines the mesh containing the submesh
  95313. * @param subMesh defines the submesh to bind the material to
  95314. */
  95315. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95316. /**
  95317. * Get the list of animatables in the material.
  95318. * @returns the list of animatables object used in the material
  95319. */
  95320. getAnimatables(): IAnimatable[];
  95321. /**
  95322. * Gets the active textures from the material
  95323. * @returns an array of textures
  95324. */
  95325. getActiveTextures(): BaseTexture[];
  95326. /**
  95327. * Specifies if the material uses a texture
  95328. * @param texture defines the texture to check against the material
  95329. * @returns a boolean specifying if the material uses the texture
  95330. */
  95331. hasTexture(texture: BaseTexture): boolean;
  95332. /**
  95333. * Disposes the material
  95334. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95335. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95336. */
  95337. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95338. /**
  95339. * Makes a duplicate of the material, and gives it a new name
  95340. * @param name defines the new name for the duplicated material
  95341. * @returns the cloned material
  95342. */
  95343. clone(name: string): StandardMaterial;
  95344. /**
  95345. * Serializes this material in a JSON representation
  95346. * @returns the serialized material object
  95347. */
  95348. serialize(): any;
  95349. /**
  95350. * Creates a standard material from parsed material data
  95351. * @param source defines the JSON representation of the material
  95352. * @param scene defines the hosting scene
  95353. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95354. * @returns a new standard material
  95355. */
  95356. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95357. /**
  95358. * Are diffuse textures enabled in the application.
  95359. */
  95360. static DiffuseTextureEnabled: boolean;
  95361. /**
  95362. * Are ambient textures enabled in the application.
  95363. */
  95364. static AmbientTextureEnabled: boolean;
  95365. /**
  95366. * Are opacity textures enabled in the application.
  95367. */
  95368. static OpacityTextureEnabled: boolean;
  95369. /**
  95370. * Are reflection textures enabled in the application.
  95371. */
  95372. static ReflectionTextureEnabled: boolean;
  95373. /**
  95374. * Are emissive textures enabled in the application.
  95375. */
  95376. static EmissiveTextureEnabled: boolean;
  95377. /**
  95378. * Are specular textures enabled in the application.
  95379. */
  95380. static SpecularTextureEnabled: boolean;
  95381. /**
  95382. * Are bump textures enabled in the application.
  95383. */
  95384. static BumpTextureEnabled: boolean;
  95385. /**
  95386. * Are lightmap textures enabled in the application.
  95387. */
  95388. static LightmapTextureEnabled: boolean;
  95389. /**
  95390. * Are refraction textures enabled in the application.
  95391. */
  95392. static RefractionTextureEnabled: boolean;
  95393. /**
  95394. * Are color grading textures enabled in the application.
  95395. */
  95396. static ColorGradingTextureEnabled: boolean;
  95397. /**
  95398. * Are fresnels enabled in the application.
  95399. */
  95400. static FresnelEnabled: boolean;
  95401. }
  95402. }
  95403. declare module BABYLON {
  95404. /**
  95405. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  95406. *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.
  95407. * The SPS is also a particle system. It provides some methods to manage the particles.
  95408. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  95409. *
  95410. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  95411. */
  95412. export class SolidParticleSystem implements IDisposable {
  95413. /**
  95414. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  95415. * Example : var p = SPS.particles[i];
  95416. */
  95417. particles: SolidParticle[];
  95418. /**
  95419. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  95420. */
  95421. nbParticles: number;
  95422. /**
  95423. * If the particles must ever face the camera (default false). Useful for planar particles.
  95424. */
  95425. billboard: boolean;
  95426. /**
  95427. * Recompute normals when adding a shape
  95428. */
  95429. recomputeNormals: boolean;
  95430. /**
  95431. * This a counter ofr your own usage. It's not set by any SPS functions.
  95432. */
  95433. counter: number;
  95434. /**
  95435. * The SPS name. This name is also given to the underlying mesh.
  95436. */
  95437. name: string;
  95438. /**
  95439. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  95440. */
  95441. mesh: Mesh;
  95442. /**
  95443. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  95444. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  95445. */
  95446. vars: any;
  95447. /**
  95448. * This array is populated when the SPS is set as 'pickable'.
  95449. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  95450. * Each element of this array is an object `{idx: int, faceId: int}`.
  95451. * `idx` is the picked particle index in the `SPS.particles` array
  95452. * `faceId` is the picked face index counted within this particle.
  95453. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  95454. */
  95455. pickedParticles: {
  95456. idx: number;
  95457. faceId: number;
  95458. }[];
  95459. /**
  95460. * This array is populated when `enableDepthSort` is set to true.
  95461. * Each element of this array is an instance of the class DepthSortedParticle.
  95462. */
  95463. depthSortedParticles: DepthSortedParticle[];
  95464. /**
  95465. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  95466. * @hidden
  95467. */
  95468. _bSphereOnly: boolean;
  95469. /**
  95470. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  95471. * @hidden
  95472. */
  95473. _bSphereRadiusFactor: number;
  95474. private _scene;
  95475. private _positions;
  95476. private _indices;
  95477. private _normals;
  95478. private _colors;
  95479. private _uvs;
  95480. private _indices32;
  95481. private _positions32;
  95482. private _normals32;
  95483. private _fixedNormal32;
  95484. private _colors32;
  95485. private _uvs32;
  95486. private _index;
  95487. private _updatable;
  95488. private _pickable;
  95489. private _isVisibilityBoxLocked;
  95490. private _alwaysVisible;
  95491. private _depthSort;
  95492. private _expandable;
  95493. private _shapeCounter;
  95494. private _copy;
  95495. private _color;
  95496. private _computeParticleColor;
  95497. private _computeParticleTexture;
  95498. private _computeParticleRotation;
  95499. private _computeParticleVertex;
  95500. private _computeBoundingBox;
  95501. private _depthSortParticles;
  95502. private _camera;
  95503. private _mustUnrotateFixedNormals;
  95504. private _particlesIntersect;
  95505. private _needs32Bits;
  95506. private _isNotBuilt;
  95507. private _lastParticleId;
  95508. private _idxOfId;
  95509. private _multimaterialEnabled;
  95510. private _useModelMaterial;
  95511. private _indicesByMaterial;
  95512. private _materialIndexes;
  95513. private _depthSortFunction;
  95514. private _materialSortFunction;
  95515. private _materials;
  95516. private _multimaterial;
  95517. private _materialIndexesById;
  95518. private _defaultMaterial;
  95519. private _autoUpdateSubMeshes;
  95520. /**
  95521. * Creates a SPS (Solid Particle System) object.
  95522. * @param name (String) is the SPS name, this will be the underlying mesh name.
  95523. * @param scene (Scene) is the scene in which the SPS is added.
  95524. * @param options defines the options of the sps e.g.
  95525. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  95526. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  95527. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  95528. * * 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.
  95529. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  95530. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  95531. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  95532. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  95533. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  95534. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  95535. */
  95536. constructor(name: string, scene: Scene, options?: {
  95537. updatable?: boolean;
  95538. isPickable?: boolean;
  95539. enableDepthSort?: boolean;
  95540. particleIntersection?: boolean;
  95541. boundingSphereOnly?: boolean;
  95542. bSphereRadiusFactor?: number;
  95543. expandable?: boolean;
  95544. useModelMaterial?: boolean;
  95545. enableMultiMaterial?: boolean;
  95546. });
  95547. /**
  95548. * Builds the SPS underlying mesh. Returns a standard Mesh.
  95549. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  95550. * @returns the created mesh
  95551. */
  95552. buildMesh(): Mesh;
  95553. /**
  95554. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  95555. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  95556. * Thus the particles generated from `digest()` have their property `position` set yet.
  95557. * @param mesh ( Mesh ) is the mesh to be digested
  95558. * @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
  95559. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  95560. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  95561. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95562. * @returns the current SPS
  95563. */
  95564. digest(mesh: Mesh, options?: {
  95565. facetNb?: number;
  95566. number?: number;
  95567. delta?: number;
  95568. storage?: [];
  95569. }): SolidParticleSystem;
  95570. /**
  95571. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  95572. * @hidden
  95573. */
  95574. private _unrotateFixedNormals;
  95575. /**
  95576. * Resets the temporary working copy particle
  95577. * @hidden
  95578. */
  95579. private _resetCopy;
  95580. /**
  95581. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  95582. * @param p the current index in the positions array to be updated
  95583. * @param ind the current index in the indices array
  95584. * @param shape a Vector3 array, the shape geometry
  95585. * @param positions the positions array to be updated
  95586. * @param meshInd the shape indices array
  95587. * @param indices the indices array to be updated
  95588. * @param meshUV the shape uv array
  95589. * @param uvs the uv array to be updated
  95590. * @param meshCol the shape color array
  95591. * @param colors the color array to be updated
  95592. * @param meshNor the shape normals array
  95593. * @param normals the normals array to be updated
  95594. * @param idx the particle index
  95595. * @param idxInShape the particle index in its shape
  95596. * @param options the addShape() method passed options
  95597. * @model the particle model
  95598. * @hidden
  95599. */
  95600. private _meshBuilder;
  95601. /**
  95602. * Returns a shape Vector3 array from positions float array
  95603. * @param positions float array
  95604. * @returns a vector3 array
  95605. * @hidden
  95606. */
  95607. private _posToShape;
  95608. /**
  95609. * Returns a shapeUV array from a float uvs (array deep copy)
  95610. * @param uvs as a float array
  95611. * @returns a shapeUV array
  95612. * @hidden
  95613. */
  95614. private _uvsToShapeUV;
  95615. /**
  95616. * Adds a new particle object in the particles array
  95617. * @param idx particle index in particles array
  95618. * @param id particle id
  95619. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  95620. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  95621. * @param model particle ModelShape object
  95622. * @param shapeId model shape identifier
  95623. * @param idxInShape index of the particle in the current model
  95624. * @param bInfo model bounding info object
  95625. * @param storage target storage array, if any
  95626. * @hidden
  95627. */
  95628. private _addParticle;
  95629. /**
  95630. * Adds some particles to the SPS from the model shape. Returns the shape id.
  95631. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  95632. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  95633. * @param nb (positive integer) the number of particles to be created from this model
  95634. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  95635. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  95636. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95637. * @returns the number of shapes in the system
  95638. */
  95639. addShape(mesh: Mesh, nb: number, options?: {
  95640. positionFunction?: any;
  95641. vertexFunction?: any;
  95642. storage?: [];
  95643. }): number;
  95644. /**
  95645. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  95646. * @hidden
  95647. */
  95648. private _rebuildParticle;
  95649. /**
  95650. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  95651. * @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.
  95652. * @returns the SPS.
  95653. */
  95654. rebuildMesh(reset?: boolean): SolidParticleSystem;
  95655. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  95656. * Returns an array with the removed particles.
  95657. * 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.
  95658. * The SPS can't be empty so at least one particle needs to remain in place.
  95659. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  95660. * @param start index of the first particle to remove
  95661. * @param end index of the last particle to remove (included)
  95662. * @returns an array populated with the removed particles
  95663. */
  95664. removeParticles(start: number, end: number): SolidParticle[];
  95665. /**
  95666. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  95667. * @param solidParticleArray an array populated with Solid Particles objects
  95668. * @returns the SPS
  95669. */
  95670. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  95671. /**
  95672. * Creates a new particle and modifies the SPS mesh geometry :
  95673. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  95674. * - calls _addParticle() to populate the particle array
  95675. * factorized code from addShape() and insertParticlesFromArray()
  95676. * @param idx particle index in the particles array
  95677. * @param i particle index in its shape
  95678. * @param modelShape particle ModelShape object
  95679. * @param shape shape vertex array
  95680. * @param meshInd shape indices array
  95681. * @param meshUV shape uv array
  95682. * @param meshCol shape color array
  95683. * @param meshNor shape normals array
  95684. * @param bbInfo shape bounding info
  95685. * @param storage target particle storage
  95686. * @options addShape() passed options
  95687. * @hidden
  95688. */
  95689. private _insertNewParticle;
  95690. /**
  95691. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  95692. * This method calls `updateParticle()` for each particle of the SPS.
  95693. * For an animated SPS, it is usually called within the render loop.
  95694. * 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.
  95695. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  95696. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  95697. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  95698. * @returns the SPS.
  95699. */
  95700. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  95701. /**
  95702. * Disposes the SPS.
  95703. */
  95704. dispose(): void;
  95705. /**
  95706. * Returns a SolidParticle object from its identifier : particle.id
  95707. * @param id (integer) the particle Id
  95708. * @returns the searched particle or null if not found in the SPS.
  95709. */
  95710. getParticleById(id: number): Nullable<SolidParticle>;
  95711. /**
  95712. * Returns a new array populated with the particles having the passed shapeId.
  95713. * @param shapeId (integer) the shape identifier
  95714. * @returns a new solid particle array
  95715. */
  95716. getParticlesByShapeId(shapeId: number): SolidParticle[];
  95717. /**
  95718. * Populates the passed array "ref" with the particles having the passed shapeId.
  95719. * @param shapeId the shape identifier
  95720. * @returns the SPS
  95721. * @param ref
  95722. */
  95723. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  95724. /**
  95725. * Computes the required SubMeshes according the materials assigned to the particles.
  95726. * @returns the solid particle system.
  95727. * Does nothing if called before the SPS mesh is built.
  95728. */
  95729. computeSubMeshes(): SolidParticleSystem;
  95730. /**
  95731. * Sorts the solid particles by material when MultiMaterial is enabled.
  95732. * Updates the indices32 array.
  95733. * Updates the indicesByMaterial array.
  95734. * Updates the mesh indices array.
  95735. * @returns the SPS
  95736. * @hidden
  95737. */
  95738. private _sortParticlesByMaterial;
  95739. /**
  95740. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  95741. * @hidden
  95742. */
  95743. private _setMaterialIndexesById;
  95744. /**
  95745. * Returns an array with unique values of Materials from the passed array
  95746. * @param array the material array to be checked and filtered
  95747. * @hidden
  95748. */
  95749. private _filterUniqueMaterialId;
  95750. /**
  95751. * Sets a new Standard Material as _defaultMaterial if not already set.
  95752. * @hidden
  95753. */
  95754. private _setDefaultMaterial;
  95755. /**
  95756. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  95757. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95758. * @returns the SPS.
  95759. */
  95760. refreshVisibleSize(): SolidParticleSystem;
  95761. /**
  95762. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  95763. * @param size the size (float) of the visibility box
  95764. * note : this doesn't lock the SPS mesh bounding box.
  95765. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95766. */
  95767. setVisibilityBox(size: number): void;
  95768. /**
  95769. * Gets whether the SPS as always visible or not
  95770. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95771. */
  95772. /**
  95773. * Sets the SPS as always visible or not
  95774. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95775. */
  95776. isAlwaysVisible: boolean;
  95777. /**
  95778. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  95779. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95780. */
  95781. /**
  95782. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  95783. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95784. */
  95785. isVisibilityBoxLocked: boolean;
  95786. /**
  95787. * Tells to `setParticles()` to compute the particle rotations or not.
  95788. * Default value : true. The SPS is faster when it's set to false.
  95789. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  95790. */
  95791. /**
  95792. * Gets if `setParticles()` computes the particle rotations or not.
  95793. * Default value : true. The SPS is faster when it's set to false.
  95794. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  95795. */
  95796. computeParticleRotation: boolean;
  95797. /**
  95798. * Tells to `setParticles()` to compute the particle colors or not.
  95799. * Default value : true. The SPS is faster when it's set to false.
  95800. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  95801. */
  95802. /**
  95803. * Gets if `setParticles()` computes the particle colors or not.
  95804. * Default value : true. The SPS is faster when it's set to false.
  95805. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  95806. */
  95807. computeParticleColor: boolean;
  95808. /**
  95809. * Gets if `setParticles()` computes the particle textures or not.
  95810. * Default value : true. The SPS is faster when it's set to false.
  95811. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  95812. */
  95813. computeParticleTexture: boolean;
  95814. /**
  95815. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  95816. * Default value : false. The SPS is faster when it's set to false.
  95817. * Note : the particle custom vertex positions aren't stored values.
  95818. */
  95819. /**
  95820. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  95821. * Default value : false. The SPS is faster when it's set to false.
  95822. * Note : the particle custom vertex positions aren't stored values.
  95823. */
  95824. computeParticleVertex: boolean;
  95825. /**
  95826. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  95827. */
  95828. /**
  95829. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  95830. */
  95831. computeBoundingBox: boolean;
  95832. /**
  95833. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  95834. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  95835. * Default : `true`
  95836. */
  95837. /**
  95838. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  95839. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  95840. * Default : `true`
  95841. */
  95842. depthSortParticles: boolean;
  95843. /**
  95844. * Gets if the SPS is created as expandable at construction time.
  95845. * Default : `false`
  95846. */
  95847. readonly expandable: boolean;
  95848. /**
  95849. * Gets if the SPS supports the Multi Materials
  95850. */
  95851. readonly multimaterialEnabled: boolean;
  95852. /**
  95853. * Gets if the SPS uses the model materials for its own multimaterial.
  95854. */
  95855. readonly useModelMaterial: boolean;
  95856. /**
  95857. * The SPS used material array.
  95858. */
  95859. readonly materials: Material[];
  95860. /**
  95861. * Sets the SPS MultiMaterial from the passed materials.
  95862. * Note : the passed array is internally copied and not used then by reference.
  95863. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  95864. */
  95865. setMultiMaterial(materials: Material[]): void;
  95866. /**
  95867. * The SPS computed multimaterial object
  95868. */
  95869. multimaterial: MultiMaterial;
  95870. /**
  95871. * If the subMeshes must be updated on the next call to setParticles()
  95872. */
  95873. autoUpdateSubMeshes: boolean;
  95874. /**
  95875. * This function does nothing. It may be overwritten to set all the particle first values.
  95876. * The SPS doesn't call this function, you may have to call it by your own.
  95877. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95878. */
  95879. initParticles(): void;
  95880. /**
  95881. * This function does nothing. It may be overwritten to recycle a particle.
  95882. * The SPS doesn't call this function, you may have to call it by your own.
  95883. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95884. * @param particle The particle to recycle
  95885. * @returns the recycled particle
  95886. */
  95887. recycleParticle(particle: SolidParticle): SolidParticle;
  95888. /**
  95889. * Updates a particle : this function should be overwritten by the user.
  95890. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  95891. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95892. * @example : just set a particle position or velocity and recycle conditions
  95893. * @param particle The particle to update
  95894. * @returns the updated particle
  95895. */
  95896. updateParticle(particle: SolidParticle): SolidParticle;
  95897. /**
  95898. * Updates a vertex of a particle : it can be overwritten by the user.
  95899. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  95900. * @param particle the current particle
  95901. * @param vertex the current index of the current particle
  95902. * @param pt the index of the current vertex in the particle shape
  95903. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  95904. * @example : just set a vertex particle position
  95905. * @returns the updated vertex
  95906. */
  95907. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  95908. /**
  95909. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  95910. * This does nothing and may be overwritten by the user.
  95911. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95912. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95913. * @param update the boolean update value actually passed to setParticles()
  95914. */
  95915. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  95916. /**
  95917. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  95918. * This will be passed three parameters.
  95919. * This does nothing and may be overwritten by the user.
  95920. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95921. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95922. * @param update the boolean update value actually passed to setParticles()
  95923. */
  95924. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  95925. }
  95926. }
  95927. declare module BABYLON {
  95928. /**
  95929. * Represents one particle of a solid particle system.
  95930. */
  95931. export class SolidParticle {
  95932. /**
  95933. * particle global index
  95934. */
  95935. idx: number;
  95936. /**
  95937. * particle identifier
  95938. */
  95939. id: number;
  95940. /**
  95941. * The color of the particle
  95942. */
  95943. color: Nullable<Color4>;
  95944. /**
  95945. * The world space position of the particle.
  95946. */
  95947. position: Vector3;
  95948. /**
  95949. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  95950. */
  95951. rotation: Vector3;
  95952. /**
  95953. * The world space rotation quaternion of the particle.
  95954. */
  95955. rotationQuaternion: Nullable<Quaternion>;
  95956. /**
  95957. * The scaling of the particle.
  95958. */
  95959. scaling: Vector3;
  95960. /**
  95961. * The uvs of the particle.
  95962. */
  95963. uvs: Vector4;
  95964. /**
  95965. * The current speed of the particle.
  95966. */
  95967. velocity: Vector3;
  95968. /**
  95969. * The pivot point in the particle local space.
  95970. */
  95971. pivot: Vector3;
  95972. /**
  95973. * Must the particle be translated from its pivot point in its local space ?
  95974. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  95975. * Default : false
  95976. */
  95977. translateFromPivot: boolean;
  95978. /**
  95979. * Is the particle active or not ?
  95980. */
  95981. alive: boolean;
  95982. /**
  95983. * Is the particle visible or not ?
  95984. */
  95985. isVisible: boolean;
  95986. /**
  95987. * Index of this particle in the global "positions" array (Internal use)
  95988. * @hidden
  95989. */
  95990. _pos: number;
  95991. /**
  95992. * @hidden Index of this particle in the global "indices" array (Internal use)
  95993. */
  95994. _ind: number;
  95995. /**
  95996. * @hidden ModelShape of this particle (Internal use)
  95997. */
  95998. _model: ModelShape;
  95999. /**
  96000. * ModelShape id of this particle
  96001. */
  96002. shapeId: number;
  96003. /**
  96004. * Index of the particle in its shape id
  96005. */
  96006. idxInShape: number;
  96007. /**
  96008. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  96009. */
  96010. _modelBoundingInfo: BoundingInfo;
  96011. /**
  96012. * @hidden Particle BoundingInfo object (Internal use)
  96013. */
  96014. _boundingInfo: BoundingInfo;
  96015. /**
  96016. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  96017. */
  96018. _sps: SolidParticleSystem;
  96019. /**
  96020. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  96021. */
  96022. _stillInvisible: boolean;
  96023. /**
  96024. * @hidden Last computed particle rotation matrix
  96025. */
  96026. _rotationMatrix: number[];
  96027. /**
  96028. * Parent particle Id, if any.
  96029. * Default null.
  96030. */
  96031. parentId: Nullable<number>;
  96032. /**
  96033. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  96034. */
  96035. materialIndex: Nullable<number>;
  96036. /**
  96037. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  96038. * The possible values are :
  96039. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96040. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96041. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96042. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96043. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96044. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  96045. * */
  96046. cullingStrategy: number;
  96047. /**
  96048. * @hidden Internal global position in the SPS.
  96049. */
  96050. _globalPosition: Vector3;
  96051. /**
  96052. * Creates a Solid Particle object.
  96053. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  96054. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  96055. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  96056. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  96057. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  96058. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  96059. * @param shapeId (integer) is the model shape identifier in the SPS.
  96060. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  96061. * @param sps defines the sps it is associated to
  96062. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  96063. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  96064. */
  96065. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  96066. /**
  96067. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  96068. * @param target the particle target
  96069. * @returns the current particle
  96070. */
  96071. copyToRef(target: SolidParticle): SolidParticle;
  96072. /**
  96073. * Legacy support, changed scale to scaling
  96074. */
  96075. /**
  96076. * Legacy support, changed scale to scaling
  96077. */
  96078. scale: Vector3;
  96079. /**
  96080. * Legacy support, changed quaternion to rotationQuaternion
  96081. */
  96082. /**
  96083. * Legacy support, changed quaternion to rotationQuaternion
  96084. */
  96085. quaternion: Nullable<Quaternion>;
  96086. /**
  96087. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  96088. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  96089. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  96090. * @returns true if it intersects
  96091. */
  96092. intersectsMesh(target: Mesh | SolidParticle): boolean;
  96093. /**
  96094. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  96095. * A particle is in the frustum if its bounding box intersects the frustum
  96096. * @param frustumPlanes defines the frustum to test
  96097. * @returns true if the particle is in the frustum planes
  96098. */
  96099. isInFrustum(frustumPlanes: Plane[]): boolean;
  96100. /**
  96101. * get the rotation matrix of the particle
  96102. * @hidden
  96103. */
  96104. getRotationMatrix(m: Matrix): void;
  96105. }
  96106. /**
  96107. * Represents the shape of the model used by one particle of a solid particle system.
  96108. * SPS internal tool, don't use it manually.
  96109. */
  96110. export class ModelShape {
  96111. /**
  96112. * The shape id
  96113. * @hidden
  96114. */
  96115. shapeID: number;
  96116. /**
  96117. * flat array of model positions (internal use)
  96118. * @hidden
  96119. */
  96120. _shape: Vector3[];
  96121. /**
  96122. * flat array of model UVs (internal use)
  96123. * @hidden
  96124. */
  96125. _shapeUV: number[];
  96126. /**
  96127. * color array of the model
  96128. * @hidden
  96129. */
  96130. _shapeColors: number[];
  96131. /**
  96132. * indices array of the model
  96133. * @hidden
  96134. */
  96135. _indices: number[];
  96136. /**
  96137. * normals array of the model
  96138. * @hidden
  96139. */
  96140. _normals: number[];
  96141. /**
  96142. * length of the shape in the model indices array (internal use)
  96143. * @hidden
  96144. */
  96145. _indicesLength: number;
  96146. /**
  96147. * Custom position function (internal use)
  96148. * @hidden
  96149. */
  96150. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  96151. /**
  96152. * Custom vertex function (internal use)
  96153. * @hidden
  96154. */
  96155. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  96156. /**
  96157. * Model material (internal use)
  96158. * @hidden
  96159. */
  96160. _material: Nullable<Material>;
  96161. /**
  96162. * 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.
  96163. * SPS internal tool, don't use it manually.
  96164. * @hidden
  96165. */
  96166. 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>);
  96167. }
  96168. /**
  96169. * Represents a Depth Sorted Particle in the solid particle system.
  96170. * @hidden
  96171. */
  96172. export class DepthSortedParticle {
  96173. /**
  96174. * Index of the particle in the "indices" array
  96175. */
  96176. ind: number;
  96177. /**
  96178. * Length of the particle shape in the "indices" array
  96179. */
  96180. indicesLength: number;
  96181. /**
  96182. * Squared distance from the particle to the camera
  96183. */
  96184. sqDistance: number;
  96185. /**
  96186. * Material index when used with MultiMaterials
  96187. */
  96188. materialIndex: number;
  96189. /**
  96190. * Creates a new sorted particle
  96191. * @param materialIndex
  96192. */
  96193. constructor(ind: number, indLength: number, materialIndex: number);
  96194. }
  96195. }
  96196. declare module BABYLON {
  96197. /**
  96198. * @hidden
  96199. */
  96200. export class _MeshCollisionData {
  96201. _checkCollisions: boolean;
  96202. _collisionMask: number;
  96203. _collisionGroup: number;
  96204. _collider: Nullable<Collider>;
  96205. _oldPositionForCollisions: Vector3;
  96206. _diffPositionForCollisions: Vector3;
  96207. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  96208. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  96209. }
  96210. }
  96211. declare module BABYLON {
  96212. /** @hidden */
  96213. class _FacetDataStorage {
  96214. facetPositions: Vector3[];
  96215. facetNormals: Vector3[];
  96216. facetPartitioning: number[][];
  96217. facetNb: number;
  96218. partitioningSubdivisions: number;
  96219. partitioningBBoxRatio: number;
  96220. facetDataEnabled: boolean;
  96221. facetParameters: any;
  96222. bbSize: Vector3;
  96223. subDiv: {
  96224. max: number;
  96225. X: number;
  96226. Y: number;
  96227. Z: number;
  96228. };
  96229. facetDepthSort: boolean;
  96230. facetDepthSortEnabled: boolean;
  96231. depthSortedIndices: IndicesArray;
  96232. depthSortedFacets: {
  96233. ind: number;
  96234. sqDistance: number;
  96235. }[];
  96236. facetDepthSortFunction: (f1: {
  96237. ind: number;
  96238. sqDistance: number;
  96239. }, f2: {
  96240. ind: number;
  96241. sqDistance: number;
  96242. }) => number;
  96243. facetDepthSortFrom: Vector3;
  96244. facetDepthSortOrigin: Vector3;
  96245. invertedMatrix: Matrix;
  96246. }
  96247. /**
  96248. * @hidden
  96249. **/
  96250. class _InternalAbstractMeshDataInfo {
  96251. _hasVertexAlpha: boolean;
  96252. _useVertexColors: boolean;
  96253. _numBoneInfluencers: number;
  96254. _applyFog: boolean;
  96255. _receiveShadows: boolean;
  96256. _facetData: _FacetDataStorage;
  96257. _visibility: number;
  96258. _skeleton: Nullable<Skeleton>;
  96259. _layerMask: number;
  96260. _computeBonesUsingShaders: boolean;
  96261. _isActive: boolean;
  96262. _onlyForInstances: boolean;
  96263. _isActiveIntermediate: boolean;
  96264. _onlyForInstancesIntermediate: boolean;
  96265. _actAsRegularMesh: boolean;
  96266. }
  96267. /**
  96268. * Class used to store all common mesh properties
  96269. */
  96270. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  96271. /** No occlusion */
  96272. static OCCLUSION_TYPE_NONE: number;
  96273. /** Occlusion set to optimisitic */
  96274. static OCCLUSION_TYPE_OPTIMISTIC: number;
  96275. /** Occlusion set to strict */
  96276. static OCCLUSION_TYPE_STRICT: number;
  96277. /** Use an accurante occlusion algorithm */
  96278. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  96279. /** Use a conservative occlusion algorithm */
  96280. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  96281. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  96282. * Test order :
  96283. * Is the bounding sphere outside the frustum ?
  96284. * If not, are the bounding box vertices outside the frustum ?
  96285. * It not, then the cullable object is in the frustum.
  96286. */
  96287. static readonly CULLINGSTRATEGY_STANDARD: number;
  96288. /** Culling strategy : Bounding Sphere Only.
  96289. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  96290. * It's also less accurate than the standard because some not visible objects can still be selected.
  96291. * Test : is the bounding sphere outside the frustum ?
  96292. * If not, then the cullable object is in the frustum.
  96293. */
  96294. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  96295. /** Culling strategy : Optimistic Inclusion.
  96296. * This in an inclusion test first, then the standard exclusion test.
  96297. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  96298. * 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.
  96299. * Anyway, it's as accurate as the standard strategy.
  96300. * Test :
  96301. * Is the cullable object bounding sphere center in the frustum ?
  96302. * If not, apply the default culling strategy.
  96303. */
  96304. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  96305. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  96306. * This in an inclusion test first, then the bounding sphere only exclusion test.
  96307. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  96308. * 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.
  96309. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  96310. * Test :
  96311. * Is the cullable object bounding sphere center in the frustum ?
  96312. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  96313. */
  96314. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  96315. /**
  96316. * No billboard
  96317. */
  96318. static readonly BILLBOARDMODE_NONE: number;
  96319. /** Billboard on X axis */
  96320. static readonly BILLBOARDMODE_X: number;
  96321. /** Billboard on Y axis */
  96322. static readonly BILLBOARDMODE_Y: number;
  96323. /** Billboard on Z axis */
  96324. static readonly BILLBOARDMODE_Z: number;
  96325. /** Billboard on all axes */
  96326. static readonly BILLBOARDMODE_ALL: number;
  96327. /** Billboard on using position instead of orientation */
  96328. static readonly BILLBOARDMODE_USE_POSITION: number;
  96329. /** @hidden */
  96330. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  96331. /**
  96332. * The culling strategy to use to check whether the mesh must be rendered or not.
  96333. * This value can be changed at any time and will be used on the next render mesh selection.
  96334. * The possible values are :
  96335. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96336. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96337. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96338. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96339. * Please read each static variable documentation to get details about the culling process.
  96340. * */
  96341. cullingStrategy: number;
  96342. /**
  96343. * Gets the number of facets in the mesh
  96344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96345. */
  96346. readonly facetNb: number;
  96347. /**
  96348. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  96349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96350. */
  96351. partitioningSubdivisions: number;
  96352. /**
  96353. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  96354. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  96355. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96356. */
  96357. partitioningBBoxRatio: number;
  96358. /**
  96359. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  96360. * Works only for updatable meshes.
  96361. * Doesn't work with multi-materials
  96362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96363. */
  96364. mustDepthSortFacets: boolean;
  96365. /**
  96366. * The location (Vector3) where the facet depth sort must be computed from.
  96367. * By default, the active camera position.
  96368. * Used only when facet depth sort is enabled
  96369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96370. */
  96371. facetDepthSortFrom: Vector3;
  96372. /**
  96373. * gets a boolean indicating if facetData is enabled
  96374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96375. */
  96376. readonly isFacetDataEnabled: boolean;
  96377. /** @hidden */
  96378. _updateNonUniformScalingState(value: boolean): boolean;
  96379. /**
  96380. * An event triggered when this mesh collides with another one
  96381. */
  96382. onCollideObservable: Observable<AbstractMesh>;
  96383. /** Set a function to call when this mesh collides with another one */
  96384. onCollide: () => void;
  96385. /**
  96386. * An event triggered when the collision's position changes
  96387. */
  96388. onCollisionPositionChangeObservable: Observable<Vector3>;
  96389. /** Set a function to call when the collision's position changes */
  96390. onCollisionPositionChange: () => void;
  96391. /**
  96392. * An event triggered when material is changed
  96393. */
  96394. onMaterialChangedObservable: Observable<AbstractMesh>;
  96395. /**
  96396. * Gets or sets the orientation for POV movement & rotation
  96397. */
  96398. definedFacingForward: boolean;
  96399. /** @hidden */
  96400. _occlusionQuery: Nullable<WebGLQuery>;
  96401. /** @hidden */
  96402. _renderingGroup: Nullable<RenderingGroup>;
  96403. /**
  96404. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96405. */
  96406. /**
  96407. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96408. */
  96409. visibility: number;
  96410. /** Gets or sets the alpha index used to sort transparent meshes
  96411. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  96412. */
  96413. alphaIndex: number;
  96414. /**
  96415. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  96416. */
  96417. isVisible: boolean;
  96418. /**
  96419. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  96420. */
  96421. isPickable: boolean;
  96422. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  96423. showSubMeshesBoundingBox: boolean;
  96424. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  96425. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  96426. */
  96427. isBlocker: boolean;
  96428. /**
  96429. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  96430. */
  96431. enablePointerMoveEvents: boolean;
  96432. /**
  96433. * Specifies the rendering group id for this mesh (0 by default)
  96434. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  96435. */
  96436. renderingGroupId: number;
  96437. private _material;
  96438. /** Gets or sets current material */
  96439. material: Nullable<Material>;
  96440. /**
  96441. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  96442. * @see http://doc.babylonjs.com/babylon101/shadows
  96443. */
  96444. receiveShadows: boolean;
  96445. /** Defines color to use when rendering outline */
  96446. outlineColor: Color3;
  96447. /** Define width to use when rendering outline */
  96448. outlineWidth: number;
  96449. /** Defines color to use when rendering overlay */
  96450. overlayColor: Color3;
  96451. /** Defines alpha to use when rendering overlay */
  96452. overlayAlpha: number;
  96453. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  96454. hasVertexAlpha: boolean;
  96455. /** 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) */
  96456. useVertexColors: boolean;
  96457. /**
  96458. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  96459. */
  96460. computeBonesUsingShaders: boolean;
  96461. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  96462. numBoneInfluencers: number;
  96463. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  96464. applyFog: boolean;
  96465. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  96466. useOctreeForRenderingSelection: boolean;
  96467. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  96468. useOctreeForPicking: boolean;
  96469. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  96470. useOctreeForCollisions: boolean;
  96471. /**
  96472. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  96473. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  96474. */
  96475. layerMask: number;
  96476. /**
  96477. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  96478. */
  96479. alwaysSelectAsActiveMesh: boolean;
  96480. /**
  96481. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  96482. */
  96483. doNotSyncBoundingInfo: boolean;
  96484. /**
  96485. * Gets or sets the current action manager
  96486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96487. */
  96488. actionManager: Nullable<AbstractActionManager>;
  96489. private _meshCollisionData;
  96490. /**
  96491. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  96492. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96493. */
  96494. ellipsoid: Vector3;
  96495. /**
  96496. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  96497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96498. */
  96499. ellipsoidOffset: Vector3;
  96500. /**
  96501. * Gets or sets a collision mask used to mask collisions (default is -1).
  96502. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96503. */
  96504. collisionMask: number;
  96505. /**
  96506. * Gets or sets the current collision group mask (-1 by default).
  96507. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96508. */
  96509. collisionGroup: number;
  96510. /**
  96511. * Defines edge width used when edgesRenderer is enabled
  96512. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96513. */
  96514. edgesWidth: number;
  96515. /**
  96516. * Defines edge color used when edgesRenderer is enabled
  96517. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96518. */
  96519. edgesColor: Color4;
  96520. /** @hidden */
  96521. _edgesRenderer: Nullable<IEdgesRenderer>;
  96522. /** @hidden */
  96523. _masterMesh: Nullable<AbstractMesh>;
  96524. /** @hidden */
  96525. _boundingInfo: Nullable<BoundingInfo>;
  96526. /** @hidden */
  96527. _renderId: number;
  96528. /**
  96529. * Gets or sets the list of subMeshes
  96530. * @see http://doc.babylonjs.com/how_to/multi_materials
  96531. */
  96532. subMeshes: SubMesh[];
  96533. /** @hidden */
  96534. _intersectionsInProgress: AbstractMesh[];
  96535. /** @hidden */
  96536. _unIndexed: boolean;
  96537. /** @hidden */
  96538. _lightSources: Light[];
  96539. /** Gets the list of lights affecting that mesh */
  96540. readonly lightSources: Light[];
  96541. /** @hidden */
  96542. readonly _positions: Nullable<Vector3[]>;
  96543. /** @hidden */
  96544. _waitingData: {
  96545. lods: Nullable<any>;
  96546. actions: Nullable<any>;
  96547. freezeWorldMatrix: Nullable<boolean>;
  96548. };
  96549. /** @hidden */
  96550. _bonesTransformMatrices: Nullable<Float32Array>;
  96551. /** @hidden */
  96552. _transformMatrixTexture: Nullable<RawTexture>;
  96553. /**
  96554. * Gets or sets a skeleton to apply skining transformations
  96555. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96556. */
  96557. skeleton: Nullable<Skeleton>;
  96558. /**
  96559. * An event triggered when the mesh is rebuilt.
  96560. */
  96561. onRebuildObservable: Observable<AbstractMesh>;
  96562. /**
  96563. * Creates a new AbstractMesh
  96564. * @param name defines the name of the mesh
  96565. * @param scene defines the hosting scene
  96566. */
  96567. constructor(name: string, scene?: Nullable<Scene>);
  96568. /**
  96569. * Returns the string "AbstractMesh"
  96570. * @returns "AbstractMesh"
  96571. */
  96572. getClassName(): string;
  96573. /**
  96574. * Gets a string representation of the current mesh
  96575. * @param fullDetails defines a boolean indicating if full details must be included
  96576. * @returns a string representation of the current mesh
  96577. */
  96578. toString(fullDetails?: boolean): string;
  96579. /**
  96580. * @hidden
  96581. */
  96582. protected _getEffectiveParent(): Nullable<Node>;
  96583. /** @hidden */
  96584. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  96585. /** @hidden */
  96586. _rebuild(): void;
  96587. /** @hidden */
  96588. _resyncLightSources(): void;
  96589. /** @hidden */
  96590. _resyncLightSource(light: Light): void;
  96591. /** @hidden */
  96592. _unBindEffect(): void;
  96593. /** @hidden */
  96594. _removeLightSource(light: Light, dispose: boolean): void;
  96595. private _markSubMeshesAsDirty;
  96596. /** @hidden */
  96597. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  96598. /** @hidden */
  96599. _markSubMeshesAsAttributesDirty(): void;
  96600. /** @hidden */
  96601. _markSubMeshesAsMiscDirty(): void;
  96602. /**
  96603. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  96604. */
  96605. scaling: Vector3;
  96606. /**
  96607. * Returns true if the mesh is blocked. Implemented by child classes
  96608. */
  96609. readonly isBlocked: boolean;
  96610. /**
  96611. * Returns the mesh itself by default. Implemented by child classes
  96612. * @param camera defines the camera to use to pick the right LOD level
  96613. * @returns the currentAbstractMesh
  96614. */
  96615. getLOD(camera: Camera): Nullable<AbstractMesh>;
  96616. /**
  96617. * Returns 0 by default. Implemented by child classes
  96618. * @returns an integer
  96619. */
  96620. getTotalVertices(): number;
  96621. /**
  96622. * Returns a positive integer : the total number of indices in this mesh geometry.
  96623. * @returns the numner of indices or zero if the mesh has no geometry.
  96624. */
  96625. getTotalIndices(): number;
  96626. /**
  96627. * Returns null by default. Implemented by child classes
  96628. * @returns null
  96629. */
  96630. getIndices(): Nullable<IndicesArray>;
  96631. /**
  96632. * Returns the array of the requested vertex data kind. Implemented by child classes
  96633. * @param kind defines the vertex data kind to use
  96634. * @returns null
  96635. */
  96636. getVerticesData(kind: string): Nullable<FloatArray>;
  96637. /**
  96638. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96639. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96640. * Note that a new underlying VertexBuffer object is created each call.
  96641. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96642. * @param kind defines vertex data kind:
  96643. * * VertexBuffer.PositionKind
  96644. * * VertexBuffer.UVKind
  96645. * * VertexBuffer.UV2Kind
  96646. * * VertexBuffer.UV3Kind
  96647. * * VertexBuffer.UV4Kind
  96648. * * VertexBuffer.UV5Kind
  96649. * * VertexBuffer.UV6Kind
  96650. * * VertexBuffer.ColorKind
  96651. * * VertexBuffer.MatricesIndicesKind
  96652. * * VertexBuffer.MatricesIndicesExtraKind
  96653. * * VertexBuffer.MatricesWeightsKind
  96654. * * VertexBuffer.MatricesWeightsExtraKind
  96655. * @param data defines the data source
  96656. * @param updatable defines if the data must be flagged as updatable (or static)
  96657. * @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
  96658. * @returns the current mesh
  96659. */
  96660. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96661. /**
  96662. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96663. * If the mesh has no geometry, it is simply returned as it is.
  96664. * @param kind defines vertex data kind:
  96665. * * VertexBuffer.PositionKind
  96666. * * VertexBuffer.UVKind
  96667. * * VertexBuffer.UV2Kind
  96668. * * VertexBuffer.UV3Kind
  96669. * * VertexBuffer.UV4Kind
  96670. * * VertexBuffer.UV5Kind
  96671. * * VertexBuffer.UV6Kind
  96672. * * VertexBuffer.ColorKind
  96673. * * VertexBuffer.MatricesIndicesKind
  96674. * * VertexBuffer.MatricesIndicesExtraKind
  96675. * * VertexBuffer.MatricesWeightsKind
  96676. * * VertexBuffer.MatricesWeightsExtraKind
  96677. * @param data defines the data source
  96678. * @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
  96679. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  96680. * @returns the current mesh
  96681. */
  96682. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  96683. /**
  96684. * Sets the mesh indices,
  96685. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96686. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  96687. * @param totalVertices Defines the total number of vertices
  96688. * @returns the current mesh
  96689. */
  96690. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  96691. /**
  96692. * Gets a boolean indicating if specific vertex data is present
  96693. * @param kind defines the vertex data kind to use
  96694. * @returns true is data kind is present
  96695. */
  96696. isVerticesDataPresent(kind: string): boolean;
  96697. /**
  96698. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  96699. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  96700. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  96701. * @returns a BoundingInfo
  96702. */
  96703. getBoundingInfo(): BoundingInfo;
  96704. /**
  96705. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  96706. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  96707. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  96708. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  96709. * @returns the current mesh
  96710. */
  96711. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  96712. /**
  96713. * Overwrite the current bounding info
  96714. * @param boundingInfo defines the new bounding info
  96715. * @returns the current mesh
  96716. */
  96717. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  96718. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  96719. readonly useBones: boolean;
  96720. /** @hidden */
  96721. _preActivate(): void;
  96722. /** @hidden */
  96723. _preActivateForIntermediateRendering(renderId: number): void;
  96724. /** @hidden */
  96725. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96726. /** @hidden */
  96727. _postActivate(): void;
  96728. /** @hidden */
  96729. _freeze(): void;
  96730. /** @hidden */
  96731. _unFreeze(): void;
  96732. /**
  96733. * Gets the current world matrix
  96734. * @returns a Matrix
  96735. */
  96736. getWorldMatrix(): Matrix;
  96737. /** @hidden */
  96738. _getWorldMatrixDeterminant(): number;
  96739. /**
  96740. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  96741. */
  96742. readonly isAnInstance: boolean;
  96743. /**
  96744. * Gets a boolean indicating if this mesh has instances
  96745. */
  96746. readonly hasInstances: boolean;
  96747. /**
  96748. * Perform relative position change from the point of view of behind the front of the mesh.
  96749. * This is performed taking into account the meshes current rotation, so you do not have to care.
  96750. * Supports definition of mesh facing forward or backward
  96751. * @param amountRight defines the distance on the right axis
  96752. * @param amountUp defines the distance on the up axis
  96753. * @param amountForward defines the distance on the forward axis
  96754. * @returns the current mesh
  96755. */
  96756. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  96757. /**
  96758. * Calculate relative position change from the point of view of behind the front of the mesh.
  96759. * This is performed taking into account the meshes current rotation, so you do not have to care.
  96760. * Supports definition of mesh facing forward or backward
  96761. * @param amountRight defines the distance on the right axis
  96762. * @param amountUp defines the distance on the up axis
  96763. * @param amountForward defines the distance on the forward axis
  96764. * @returns the new displacement vector
  96765. */
  96766. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  96767. /**
  96768. * Perform relative rotation change from the point of view of behind the front of the mesh.
  96769. * Supports definition of mesh facing forward or backward
  96770. * @param flipBack defines the flip
  96771. * @param twirlClockwise defines the twirl
  96772. * @param tiltRight defines the tilt
  96773. * @returns the current mesh
  96774. */
  96775. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  96776. /**
  96777. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  96778. * Supports definition of mesh facing forward or backward.
  96779. * @param flipBack defines the flip
  96780. * @param twirlClockwise defines the twirl
  96781. * @param tiltRight defines the tilt
  96782. * @returns the new rotation vector
  96783. */
  96784. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  96785. /**
  96786. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96787. * This means the mesh underlying bounding box and sphere are recomputed.
  96788. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96789. * @returns the current mesh
  96790. */
  96791. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  96792. /** @hidden */
  96793. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  96794. /** @hidden */
  96795. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  96796. /** @hidden */
  96797. _updateBoundingInfo(): AbstractMesh;
  96798. /** @hidden */
  96799. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  96800. /** @hidden */
  96801. protected _afterComputeWorldMatrix(): void;
  96802. /** @hidden */
  96803. readonly _effectiveMesh: AbstractMesh;
  96804. /**
  96805. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  96806. * A mesh is in the frustum if its bounding box intersects the frustum
  96807. * @param frustumPlanes defines the frustum to test
  96808. * @returns true if the mesh is in the frustum planes
  96809. */
  96810. isInFrustum(frustumPlanes: Plane[]): boolean;
  96811. /**
  96812. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  96813. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  96814. * @param frustumPlanes defines the frustum to test
  96815. * @returns true if the mesh is completely in the frustum planes
  96816. */
  96817. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96818. /**
  96819. * True if the mesh intersects another mesh or a SolidParticle object
  96820. * @param mesh defines a target mesh or SolidParticle to test
  96821. * @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)
  96822. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  96823. * @returns true if there is an intersection
  96824. */
  96825. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  96826. /**
  96827. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  96828. * @param point defines the point to test
  96829. * @returns true if there is an intersection
  96830. */
  96831. intersectsPoint(point: Vector3): boolean;
  96832. /**
  96833. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  96834. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96835. */
  96836. checkCollisions: boolean;
  96837. /**
  96838. * Gets Collider object used to compute collisions (not physics)
  96839. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96840. */
  96841. readonly collider: Nullable<Collider>;
  96842. /**
  96843. * Move the mesh using collision engine
  96844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96845. * @param displacement defines the requested displacement vector
  96846. * @returns the current mesh
  96847. */
  96848. moveWithCollisions(displacement: Vector3): AbstractMesh;
  96849. private _onCollisionPositionChange;
  96850. /** @hidden */
  96851. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  96852. /** @hidden */
  96853. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  96854. /** @hidden */
  96855. _checkCollision(collider: Collider): AbstractMesh;
  96856. /** @hidden */
  96857. _generatePointsArray(): boolean;
  96858. /**
  96859. * Checks if the passed Ray intersects with the mesh
  96860. * @param ray defines the ray to use
  96861. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  96862. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96863. * @returns the picking info
  96864. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  96865. */
  96866. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  96867. /**
  96868. * Clones the current mesh
  96869. * @param name defines the mesh name
  96870. * @param newParent defines the new mesh parent
  96871. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  96872. * @returns the new mesh
  96873. */
  96874. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  96875. /**
  96876. * Disposes all the submeshes of the current meshnp
  96877. * @returns the current mesh
  96878. */
  96879. releaseSubMeshes(): AbstractMesh;
  96880. /**
  96881. * Releases resources associated with this abstract mesh.
  96882. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96883. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96884. */
  96885. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96886. /**
  96887. * Adds the passed mesh as a child to the current mesh
  96888. * @param mesh defines the child mesh
  96889. * @returns the current mesh
  96890. */
  96891. addChild(mesh: AbstractMesh): AbstractMesh;
  96892. /**
  96893. * Removes the passed mesh from the current mesh children list
  96894. * @param mesh defines the child mesh
  96895. * @returns the current mesh
  96896. */
  96897. removeChild(mesh: AbstractMesh): AbstractMesh;
  96898. /** @hidden */
  96899. private _initFacetData;
  96900. /**
  96901. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  96902. * This method can be called within the render loop.
  96903. * 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
  96904. * @returns the current mesh
  96905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96906. */
  96907. updateFacetData(): AbstractMesh;
  96908. /**
  96909. * Returns the facetLocalNormals array.
  96910. * The normals are expressed in the mesh local spac
  96911. * @returns an array of Vector3
  96912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96913. */
  96914. getFacetLocalNormals(): Vector3[];
  96915. /**
  96916. * Returns the facetLocalPositions array.
  96917. * The facet positions are expressed in the mesh local space
  96918. * @returns an array of Vector3
  96919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96920. */
  96921. getFacetLocalPositions(): Vector3[];
  96922. /**
  96923. * Returns the facetLocalPartioning array
  96924. * @returns an array of array of numbers
  96925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96926. */
  96927. getFacetLocalPartitioning(): number[][];
  96928. /**
  96929. * Returns the i-th facet position in the world system.
  96930. * This method allocates a new Vector3 per call
  96931. * @param i defines the facet index
  96932. * @returns a new Vector3
  96933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96934. */
  96935. getFacetPosition(i: number): Vector3;
  96936. /**
  96937. * Sets the reference Vector3 with the i-th facet position in the world system
  96938. * @param i defines the facet index
  96939. * @param ref defines the target vector
  96940. * @returns the current mesh
  96941. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96942. */
  96943. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  96944. /**
  96945. * Returns the i-th facet normal in the world system.
  96946. * This method allocates a new Vector3 per call
  96947. * @param i defines the facet index
  96948. * @returns a new Vector3
  96949. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96950. */
  96951. getFacetNormal(i: number): Vector3;
  96952. /**
  96953. * Sets the reference Vector3 with the i-th facet normal in the world system
  96954. * @param i defines the facet index
  96955. * @param ref defines the target vector
  96956. * @returns the current mesh
  96957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96958. */
  96959. getFacetNormalToRef(i: number, ref: Vector3): this;
  96960. /**
  96961. * 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)
  96962. * @param x defines x coordinate
  96963. * @param y defines y coordinate
  96964. * @param z defines z coordinate
  96965. * @returns the array of facet indexes
  96966. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96967. */
  96968. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  96969. /**
  96970. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  96971. * @param projected sets as the (x,y,z) world projection on the facet
  96972. * @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
  96973. * @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
  96974. * @param x defines x coordinate
  96975. * @param y defines y coordinate
  96976. * @param z defines z coordinate
  96977. * @returns the face index if found (or null instead)
  96978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96979. */
  96980. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  96981. /**
  96982. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  96983. * @param projected sets as the (x,y,z) local projection on the facet
  96984. * @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
  96985. * @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
  96986. * @param x defines x coordinate
  96987. * @param y defines y coordinate
  96988. * @param z defines z coordinate
  96989. * @returns the face index if found (or null instead)
  96990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96991. */
  96992. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  96993. /**
  96994. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  96995. * @returns the parameters
  96996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96997. */
  96998. getFacetDataParameters(): any;
  96999. /**
  97000. * Disables the feature FacetData and frees the related memory
  97001. * @returns the current mesh
  97002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97003. */
  97004. disableFacetData(): AbstractMesh;
  97005. /**
  97006. * Updates the AbstractMesh indices array
  97007. * @param indices defines the data source
  97008. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97009. * @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)
  97010. * @returns the current mesh
  97011. */
  97012. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97013. /**
  97014. * Creates new normals data for the mesh
  97015. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  97016. * @returns the current mesh
  97017. */
  97018. createNormals(updatable: boolean): AbstractMesh;
  97019. /**
  97020. * Align the mesh with a normal
  97021. * @param normal defines the normal to use
  97022. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  97023. * @returns the current mesh
  97024. */
  97025. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  97026. /** @hidden */
  97027. _checkOcclusionQuery(): boolean;
  97028. /**
  97029. * Disables the mesh edge rendering mode
  97030. * @returns the currentAbstractMesh
  97031. */
  97032. disableEdgesRendering(): AbstractMesh;
  97033. /**
  97034. * Enables the edge rendering mode on the mesh.
  97035. * This mode makes the mesh edges visible
  97036. * @param epsilon defines the maximal distance between two angles to detect a face
  97037. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97038. * @returns the currentAbstractMesh
  97039. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97040. */
  97041. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97042. }
  97043. }
  97044. declare module BABYLON {
  97045. /**
  97046. * Interface used to define ActionEvent
  97047. */
  97048. export interface IActionEvent {
  97049. /** The mesh or sprite that triggered the action */
  97050. source: any;
  97051. /** The X mouse cursor position at the time of the event */
  97052. pointerX: number;
  97053. /** The Y mouse cursor position at the time of the event */
  97054. pointerY: number;
  97055. /** The mesh that is currently pointed at (can be null) */
  97056. meshUnderPointer: Nullable<AbstractMesh>;
  97057. /** the original (browser) event that triggered the ActionEvent */
  97058. sourceEvent?: any;
  97059. /** additional data for the event */
  97060. additionalData?: any;
  97061. }
  97062. /**
  97063. * ActionEvent is the event being sent when an action is triggered.
  97064. */
  97065. export class ActionEvent implements IActionEvent {
  97066. /** The mesh or sprite that triggered the action */
  97067. source: any;
  97068. /** The X mouse cursor position at the time of the event */
  97069. pointerX: number;
  97070. /** The Y mouse cursor position at the time of the event */
  97071. pointerY: number;
  97072. /** The mesh that is currently pointed at (can be null) */
  97073. meshUnderPointer: Nullable<AbstractMesh>;
  97074. /** the original (browser) event that triggered the ActionEvent */
  97075. sourceEvent?: any;
  97076. /** additional data for the event */
  97077. additionalData?: any;
  97078. /**
  97079. * Creates a new ActionEvent
  97080. * @param source The mesh or sprite that triggered the action
  97081. * @param pointerX The X mouse cursor position at the time of the event
  97082. * @param pointerY The Y mouse cursor position at the time of the event
  97083. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  97084. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  97085. * @param additionalData additional data for the event
  97086. */
  97087. constructor(
  97088. /** The mesh or sprite that triggered the action */
  97089. source: any,
  97090. /** The X mouse cursor position at the time of the event */
  97091. pointerX: number,
  97092. /** The Y mouse cursor position at the time of the event */
  97093. pointerY: number,
  97094. /** The mesh that is currently pointed at (can be null) */
  97095. meshUnderPointer: Nullable<AbstractMesh>,
  97096. /** the original (browser) event that triggered the ActionEvent */
  97097. sourceEvent?: any,
  97098. /** additional data for the event */
  97099. additionalData?: any);
  97100. /**
  97101. * Helper function to auto-create an ActionEvent from a source mesh.
  97102. * @param source The source mesh that triggered the event
  97103. * @param evt The original (browser) event
  97104. * @param additionalData additional data for the event
  97105. * @returns the new ActionEvent
  97106. */
  97107. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  97108. /**
  97109. * Helper function to auto-create an ActionEvent from a source sprite
  97110. * @param source The source sprite that triggered the event
  97111. * @param scene Scene associated with the sprite
  97112. * @param evt The original (browser) event
  97113. * @param additionalData additional data for the event
  97114. * @returns the new ActionEvent
  97115. */
  97116. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  97117. /**
  97118. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  97119. * @param scene the scene where the event occurred
  97120. * @param evt The original (browser) event
  97121. * @returns the new ActionEvent
  97122. */
  97123. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  97124. /**
  97125. * Helper function to auto-create an ActionEvent from a primitive
  97126. * @param prim defines the target primitive
  97127. * @param pointerPos defines the pointer position
  97128. * @param evt The original (browser) event
  97129. * @param additionalData additional data for the event
  97130. * @returns the new ActionEvent
  97131. */
  97132. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  97133. }
  97134. }
  97135. declare module BABYLON {
  97136. /**
  97137. * Abstract class used to decouple action Manager from scene and meshes.
  97138. * Do not instantiate.
  97139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97140. */
  97141. export abstract class AbstractActionManager implements IDisposable {
  97142. /** Gets the list of active triggers */
  97143. static Triggers: {
  97144. [key: string]: number;
  97145. };
  97146. /** Gets the cursor to use when hovering items */
  97147. hoverCursor: string;
  97148. /** Gets the list of actions */
  97149. actions: IAction[];
  97150. /**
  97151. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  97152. */
  97153. isRecursive: boolean;
  97154. /**
  97155. * Releases all associated resources
  97156. */
  97157. abstract dispose(): void;
  97158. /**
  97159. * Does this action manager has pointer triggers
  97160. */
  97161. abstract readonly hasPointerTriggers: boolean;
  97162. /**
  97163. * Does this action manager has pick triggers
  97164. */
  97165. abstract readonly hasPickTriggers: boolean;
  97166. /**
  97167. * Process a specific trigger
  97168. * @param trigger defines the trigger to process
  97169. * @param evt defines the event details to be processed
  97170. */
  97171. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  97172. /**
  97173. * Does this action manager handles actions of any of the given triggers
  97174. * @param triggers defines the triggers to be tested
  97175. * @return a boolean indicating whether one (or more) of the triggers is handled
  97176. */
  97177. abstract hasSpecificTriggers(triggers: number[]): boolean;
  97178. /**
  97179. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  97180. * speed.
  97181. * @param triggerA defines the trigger to be tested
  97182. * @param triggerB defines the trigger to be tested
  97183. * @return a boolean indicating whether one (or more) of the triggers is handled
  97184. */
  97185. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  97186. /**
  97187. * Does this action manager handles actions of a given trigger
  97188. * @param trigger defines the trigger to be tested
  97189. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  97190. * @return whether the trigger is handled
  97191. */
  97192. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  97193. /**
  97194. * Serialize this manager to a JSON object
  97195. * @param name defines the property name to store this manager
  97196. * @returns a JSON representation of this manager
  97197. */
  97198. abstract serialize(name: string): any;
  97199. /**
  97200. * Registers an action to this action manager
  97201. * @param action defines the action to be registered
  97202. * @return the action amended (prepared) after registration
  97203. */
  97204. abstract registerAction(action: IAction): Nullable<IAction>;
  97205. /**
  97206. * Unregisters an action to this action manager
  97207. * @param action defines the action to be unregistered
  97208. * @return a boolean indicating whether the action has been unregistered
  97209. */
  97210. abstract unregisterAction(action: IAction): Boolean;
  97211. /**
  97212. * Does exist one action manager with at least one trigger
  97213. **/
  97214. static readonly HasTriggers: boolean;
  97215. /**
  97216. * Does exist one action manager with at least one pick trigger
  97217. **/
  97218. static readonly HasPickTriggers: boolean;
  97219. /**
  97220. * Does exist one action manager that handles actions of a given trigger
  97221. * @param trigger defines the trigger to be tested
  97222. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  97223. **/
  97224. static HasSpecificTrigger(trigger: number): boolean;
  97225. }
  97226. }
  97227. declare module BABYLON {
  97228. /**
  97229. * Defines how a node can be built from a string name.
  97230. */
  97231. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  97232. /**
  97233. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  97234. */
  97235. export class Node implements IBehaviorAware<Node> {
  97236. /** @hidden */
  97237. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  97238. private static _NodeConstructors;
  97239. /**
  97240. * Add a new node constructor
  97241. * @param type defines the type name of the node to construct
  97242. * @param constructorFunc defines the constructor function
  97243. */
  97244. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  97245. /**
  97246. * Returns a node constructor based on type name
  97247. * @param type defines the type name
  97248. * @param name defines the new node name
  97249. * @param scene defines the hosting scene
  97250. * @param options defines optional options to transmit to constructors
  97251. * @returns the new constructor or null
  97252. */
  97253. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  97254. /**
  97255. * Gets or sets the name of the node
  97256. */
  97257. name: string;
  97258. /**
  97259. * Gets or sets the id of the node
  97260. */
  97261. id: string;
  97262. /**
  97263. * Gets or sets the unique id of the node
  97264. */
  97265. uniqueId: number;
  97266. /**
  97267. * Gets or sets a string used to store user defined state for the node
  97268. */
  97269. state: string;
  97270. /**
  97271. * Gets or sets an object used to store user defined information for the node
  97272. */
  97273. metadata: any;
  97274. /**
  97275. * For internal use only. Please do not use.
  97276. */
  97277. reservedDataStore: any;
  97278. /**
  97279. * List of inspectable custom properties (used by the Inspector)
  97280. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97281. */
  97282. inspectableCustomProperties: IInspectable[];
  97283. private _doNotSerialize;
  97284. /**
  97285. * Gets or sets a boolean used to define if the node must be serialized
  97286. */
  97287. doNotSerialize: boolean;
  97288. /** @hidden */
  97289. _isDisposed: boolean;
  97290. /**
  97291. * Gets a list of Animations associated with the node
  97292. */
  97293. animations: Animation[];
  97294. protected _ranges: {
  97295. [name: string]: Nullable<AnimationRange>;
  97296. };
  97297. /**
  97298. * Callback raised when the node is ready to be used
  97299. */
  97300. onReady: Nullable<(node: Node) => void>;
  97301. private _isEnabled;
  97302. private _isParentEnabled;
  97303. private _isReady;
  97304. /** @hidden */
  97305. _currentRenderId: number;
  97306. private _parentUpdateId;
  97307. /** @hidden */
  97308. _childUpdateId: number;
  97309. /** @hidden */
  97310. _waitingParentId: Nullable<string>;
  97311. /** @hidden */
  97312. _scene: Scene;
  97313. /** @hidden */
  97314. _cache: any;
  97315. private _parentNode;
  97316. private _children;
  97317. /** @hidden */
  97318. _worldMatrix: Matrix;
  97319. /** @hidden */
  97320. _worldMatrixDeterminant: number;
  97321. /** @hidden */
  97322. _worldMatrixDeterminantIsDirty: boolean;
  97323. /** @hidden */
  97324. private _sceneRootNodesIndex;
  97325. /**
  97326. * Gets a boolean indicating if the node has been disposed
  97327. * @returns true if the node was disposed
  97328. */
  97329. isDisposed(): boolean;
  97330. /**
  97331. * Gets or sets the parent of the node (without keeping the current position in the scene)
  97332. * @see https://doc.babylonjs.com/how_to/parenting
  97333. */
  97334. parent: Nullable<Node>;
  97335. /** @hidden */
  97336. _addToSceneRootNodes(): void;
  97337. /** @hidden */
  97338. _removeFromSceneRootNodes(): void;
  97339. private _animationPropertiesOverride;
  97340. /**
  97341. * Gets or sets the animation properties override
  97342. */
  97343. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97344. /**
  97345. * Gets a string idenfifying the name of the class
  97346. * @returns "Node" string
  97347. */
  97348. getClassName(): string;
  97349. /** @hidden */
  97350. readonly _isNode: boolean;
  97351. /**
  97352. * An event triggered when the mesh is disposed
  97353. */
  97354. onDisposeObservable: Observable<Node>;
  97355. private _onDisposeObserver;
  97356. /**
  97357. * Sets a callback that will be raised when the node will be disposed
  97358. */
  97359. onDispose: () => void;
  97360. /**
  97361. * Creates a new Node
  97362. * @param name the name and id to be given to this node
  97363. * @param scene the scene this node will be added to
  97364. */
  97365. constructor(name: string, scene?: Nullable<Scene>);
  97366. /**
  97367. * Gets the scene of the node
  97368. * @returns a scene
  97369. */
  97370. getScene(): Scene;
  97371. /**
  97372. * Gets the engine of the node
  97373. * @returns a Engine
  97374. */
  97375. getEngine(): Engine;
  97376. private _behaviors;
  97377. /**
  97378. * Attach a behavior to the node
  97379. * @see http://doc.babylonjs.com/features/behaviour
  97380. * @param behavior defines the behavior to attach
  97381. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  97382. * @returns the current Node
  97383. */
  97384. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  97385. /**
  97386. * Remove an attached behavior
  97387. * @see http://doc.babylonjs.com/features/behaviour
  97388. * @param behavior defines the behavior to attach
  97389. * @returns the current Node
  97390. */
  97391. removeBehavior(behavior: Behavior<Node>): Node;
  97392. /**
  97393. * Gets the list of attached behaviors
  97394. * @see http://doc.babylonjs.com/features/behaviour
  97395. */
  97396. readonly behaviors: Behavior<Node>[];
  97397. /**
  97398. * Gets an attached behavior by name
  97399. * @param name defines the name of the behavior to look for
  97400. * @see http://doc.babylonjs.com/features/behaviour
  97401. * @returns null if behavior was not found else the requested behavior
  97402. */
  97403. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  97404. /**
  97405. * Returns the latest update of the World matrix
  97406. * @returns a Matrix
  97407. */
  97408. getWorldMatrix(): Matrix;
  97409. /** @hidden */
  97410. _getWorldMatrixDeterminant(): number;
  97411. /**
  97412. * Returns directly the latest state of the mesh World matrix.
  97413. * A Matrix is returned.
  97414. */
  97415. readonly worldMatrixFromCache: Matrix;
  97416. /** @hidden */
  97417. _initCache(): void;
  97418. /** @hidden */
  97419. updateCache(force?: boolean): void;
  97420. /** @hidden */
  97421. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  97422. /** @hidden */
  97423. _updateCache(ignoreParentClass?: boolean): void;
  97424. /** @hidden */
  97425. _isSynchronized(): boolean;
  97426. /** @hidden */
  97427. _markSyncedWithParent(): void;
  97428. /** @hidden */
  97429. isSynchronizedWithParent(): boolean;
  97430. /** @hidden */
  97431. isSynchronized(): boolean;
  97432. /**
  97433. * Is this node ready to be used/rendered
  97434. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97435. * @return true if the node is ready
  97436. */
  97437. isReady(completeCheck?: boolean): boolean;
  97438. /**
  97439. * Is this node enabled?
  97440. * 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
  97441. * @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
  97442. * @return whether this node (and its parent) is enabled
  97443. */
  97444. isEnabled(checkAncestors?: boolean): boolean;
  97445. /** @hidden */
  97446. protected _syncParentEnabledState(): void;
  97447. /**
  97448. * Set the enabled state of this node
  97449. * @param value defines the new enabled state
  97450. */
  97451. setEnabled(value: boolean): void;
  97452. /**
  97453. * Is this node a descendant of the given node?
  97454. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  97455. * @param ancestor defines the parent node to inspect
  97456. * @returns a boolean indicating if this node is a descendant of the given node
  97457. */
  97458. isDescendantOf(ancestor: Node): boolean;
  97459. /** @hidden */
  97460. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  97461. /**
  97462. * Will return all nodes that have this node as ascendant
  97463. * @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
  97464. * @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
  97465. * @return all children nodes of all types
  97466. */
  97467. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  97468. /**
  97469. * Get all child-meshes of this node
  97470. * @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)
  97471. * @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
  97472. * @returns an array of AbstractMesh
  97473. */
  97474. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  97475. /**
  97476. * Get all direct children of this node
  97477. * @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
  97478. * @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)
  97479. * @returns an array of Node
  97480. */
  97481. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  97482. /** @hidden */
  97483. _setReady(state: boolean): void;
  97484. /**
  97485. * Get an animation by name
  97486. * @param name defines the name of the animation to look for
  97487. * @returns null if not found else the requested animation
  97488. */
  97489. getAnimationByName(name: string): Nullable<Animation>;
  97490. /**
  97491. * Creates an animation range for this node
  97492. * @param name defines the name of the range
  97493. * @param from defines the starting key
  97494. * @param to defines the end key
  97495. */
  97496. createAnimationRange(name: string, from: number, to: number): void;
  97497. /**
  97498. * Delete a specific animation range
  97499. * @param name defines the name of the range to delete
  97500. * @param deleteFrames defines if animation frames from the range must be deleted as well
  97501. */
  97502. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97503. /**
  97504. * Get an animation range by name
  97505. * @param name defines the name of the animation range to look for
  97506. * @returns null if not found else the requested animation range
  97507. */
  97508. getAnimationRange(name: string): Nullable<AnimationRange>;
  97509. /**
  97510. * Gets the list of all animation ranges defined on this node
  97511. * @returns an array
  97512. */
  97513. getAnimationRanges(): Nullable<AnimationRange>[];
  97514. /**
  97515. * Will start the animation sequence
  97516. * @param name defines the range frames for animation sequence
  97517. * @param loop defines if the animation should loop (false by default)
  97518. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  97519. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  97520. * @returns the object created for this animation. If range does not exist, it will return null
  97521. */
  97522. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97523. /**
  97524. * Serialize animation ranges into a JSON compatible object
  97525. * @returns serialization object
  97526. */
  97527. serializeAnimationRanges(): any;
  97528. /**
  97529. * Computes the world matrix of the node
  97530. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97531. * @returns the world matrix
  97532. */
  97533. computeWorldMatrix(force?: boolean): Matrix;
  97534. /**
  97535. * Releases resources associated with this node.
  97536. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97537. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97538. */
  97539. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97540. /**
  97541. * Parse animation range data from a serialization object and store them into a given node
  97542. * @param node defines where to store the animation ranges
  97543. * @param parsedNode defines the serialization object to read data from
  97544. * @param scene defines the hosting scene
  97545. */
  97546. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  97547. /**
  97548. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  97549. * @param includeDescendants Include bounding info from descendants as well (true by default)
  97550. * @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
  97551. * @returns the new bounding vectors
  97552. */
  97553. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  97554. min: Vector3;
  97555. max: Vector3;
  97556. };
  97557. }
  97558. }
  97559. declare module BABYLON {
  97560. /**
  97561. * @hidden
  97562. */
  97563. export class _IAnimationState {
  97564. key: number;
  97565. repeatCount: number;
  97566. workValue?: any;
  97567. loopMode?: number;
  97568. offsetValue?: any;
  97569. highLimitValue?: any;
  97570. }
  97571. /**
  97572. * Class used to store any kind of animation
  97573. */
  97574. export class Animation {
  97575. /**Name of the animation */
  97576. name: string;
  97577. /**Property to animate */
  97578. targetProperty: string;
  97579. /**The frames per second of the animation */
  97580. framePerSecond: number;
  97581. /**The data type of the animation */
  97582. dataType: number;
  97583. /**The loop mode of the animation */
  97584. loopMode?: number | undefined;
  97585. /**Specifies if blending should be enabled */
  97586. enableBlending?: boolean | undefined;
  97587. /**
  97588. * Use matrix interpolation instead of using direct key value when animating matrices
  97589. */
  97590. static AllowMatricesInterpolation: boolean;
  97591. /**
  97592. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  97593. */
  97594. static AllowMatrixDecomposeForInterpolation: boolean;
  97595. /**
  97596. * Stores the key frames of the animation
  97597. */
  97598. private _keys;
  97599. /**
  97600. * Stores the easing function of the animation
  97601. */
  97602. private _easingFunction;
  97603. /**
  97604. * @hidden Internal use only
  97605. */
  97606. _runtimeAnimations: RuntimeAnimation[];
  97607. /**
  97608. * The set of event that will be linked to this animation
  97609. */
  97610. private _events;
  97611. /**
  97612. * Stores an array of target property paths
  97613. */
  97614. targetPropertyPath: string[];
  97615. /**
  97616. * Stores the blending speed of the animation
  97617. */
  97618. blendingSpeed: number;
  97619. /**
  97620. * Stores the animation ranges for the animation
  97621. */
  97622. private _ranges;
  97623. /**
  97624. * @hidden Internal use
  97625. */
  97626. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  97627. /**
  97628. * Sets up an animation
  97629. * @param property The property to animate
  97630. * @param animationType The animation type to apply
  97631. * @param framePerSecond The frames per second of the animation
  97632. * @param easingFunction The easing function used in the animation
  97633. * @returns The created animation
  97634. */
  97635. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  97636. /**
  97637. * Create and start an animation on a node
  97638. * @param name defines the name of the global animation that will be run on all nodes
  97639. * @param node defines the root node where the animation will take place
  97640. * @param targetProperty defines property to animate
  97641. * @param framePerSecond defines the number of frame per second yo use
  97642. * @param totalFrame defines the number of frames in total
  97643. * @param from defines the initial value
  97644. * @param to defines the final value
  97645. * @param loopMode defines which loop mode you want to use (off by default)
  97646. * @param easingFunction defines the easing function to use (linear by default)
  97647. * @param onAnimationEnd defines the callback to call when animation end
  97648. * @returns the animatable created for this animation
  97649. */
  97650. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97651. /**
  97652. * Create and start an animation on a node and its descendants
  97653. * @param name defines the name of the global animation that will be run on all nodes
  97654. * @param node defines the root node where the animation will take place
  97655. * @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
  97656. * @param targetProperty defines property to animate
  97657. * @param framePerSecond defines the number of frame per second to use
  97658. * @param totalFrame defines the number of frames in total
  97659. * @param from defines the initial value
  97660. * @param to defines the final value
  97661. * @param loopMode defines which loop mode you want to use (off by default)
  97662. * @param easingFunction defines the easing function to use (linear by default)
  97663. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97664. * @returns the list of animatables created for all nodes
  97665. * @example https://www.babylonjs-playground.com/#MH0VLI
  97666. */
  97667. 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[]>;
  97668. /**
  97669. * Creates a new animation, merges it with the existing animations and starts it
  97670. * @param name Name of the animation
  97671. * @param node Node which contains the scene that begins the animations
  97672. * @param targetProperty Specifies which property to animate
  97673. * @param framePerSecond The frames per second of the animation
  97674. * @param totalFrame The total number of frames
  97675. * @param from The frame at the beginning of the animation
  97676. * @param to The frame at the end of the animation
  97677. * @param loopMode Specifies the loop mode of the animation
  97678. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  97679. * @param onAnimationEnd Callback to run once the animation is complete
  97680. * @returns Nullable animation
  97681. */
  97682. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97683. /**
  97684. * Transition property of an host to the target Value
  97685. * @param property The property to transition
  97686. * @param targetValue The target Value of the property
  97687. * @param host The object where the property to animate belongs
  97688. * @param scene Scene used to run the animation
  97689. * @param frameRate Framerate (in frame/s) to use
  97690. * @param transition The transition type we want to use
  97691. * @param duration The duration of the animation, in milliseconds
  97692. * @param onAnimationEnd Callback trigger at the end of the animation
  97693. * @returns Nullable animation
  97694. */
  97695. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  97696. /**
  97697. * Return the array of runtime animations currently using this animation
  97698. */
  97699. readonly runtimeAnimations: RuntimeAnimation[];
  97700. /**
  97701. * Specifies if any of the runtime animations are currently running
  97702. */
  97703. readonly hasRunningRuntimeAnimations: boolean;
  97704. /**
  97705. * Initializes the animation
  97706. * @param name Name of the animation
  97707. * @param targetProperty Property to animate
  97708. * @param framePerSecond The frames per second of the animation
  97709. * @param dataType The data type of the animation
  97710. * @param loopMode The loop mode of the animation
  97711. * @param enableBlending Specifies if blending should be enabled
  97712. */
  97713. constructor(
  97714. /**Name of the animation */
  97715. name: string,
  97716. /**Property to animate */
  97717. targetProperty: string,
  97718. /**The frames per second of the animation */
  97719. framePerSecond: number,
  97720. /**The data type of the animation */
  97721. dataType: number,
  97722. /**The loop mode of the animation */
  97723. loopMode?: number | undefined,
  97724. /**Specifies if blending should be enabled */
  97725. enableBlending?: boolean | undefined);
  97726. /**
  97727. * Converts the animation to a string
  97728. * @param fullDetails support for multiple levels of logging within scene loading
  97729. * @returns String form of the animation
  97730. */
  97731. toString(fullDetails?: boolean): string;
  97732. /**
  97733. * Add an event to this animation
  97734. * @param event Event to add
  97735. */
  97736. addEvent(event: AnimationEvent): void;
  97737. /**
  97738. * Remove all events found at the given frame
  97739. * @param frame The frame to remove events from
  97740. */
  97741. removeEvents(frame: number): void;
  97742. /**
  97743. * Retrieves all the events from the animation
  97744. * @returns Events from the animation
  97745. */
  97746. getEvents(): AnimationEvent[];
  97747. /**
  97748. * Creates an animation range
  97749. * @param name Name of the animation range
  97750. * @param from Starting frame of the animation range
  97751. * @param to Ending frame of the animation
  97752. */
  97753. createRange(name: string, from: number, to: number): void;
  97754. /**
  97755. * Deletes an animation range by name
  97756. * @param name Name of the animation range to delete
  97757. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  97758. */
  97759. deleteRange(name: string, deleteFrames?: boolean): void;
  97760. /**
  97761. * Gets the animation range by name, or null if not defined
  97762. * @param name Name of the animation range
  97763. * @returns Nullable animation range
  97764. */
  97765. getRange(name: string): Nullable<AnimationRange>;
  97766. /**
  97767. * Gets the key frames from the animation
  97768. * @returns The key frames of the animation
  97769. */
  97770. getKeys(): Array<IAnimationKey>;
  97771. /**
  97772. * Gets the highest frame rate of the animation
  97773. * @returns Highest frame rate of the animation
  97774. */
  97775. getHighestFrame(): number;
  97776. /**
  97777. * Gets the easing function of the animation
  97778. * @returns Easing function of the animation
  97779. */
  97780. getEasingFunction(): IEasingFunction;
  97781. /**
  97782. * Sets the easing function of the animation
  97783. * @param easingFunction A custom mathematical formula for animation
  97784. */
  97785. setEasingFunction(easingFunction: EasingFunction): void;
  97786. /**
  97787. * Interpolates a scalar linearly
  97788. * @param startValue Start value of the animation curve
  97789. * @param endValue End value of the animation curve
  97790. * @param gradient Scalar amount to interpolate
  97791. * @returns Interpolated scalar value
  97792. */
  97793. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  97794. /**
  97795. * Interpolates a scalar cubically
  97796. * @param startValue Start value of the animation curve
  97797. * @param outTangent End tangent of the animation
  97798. * @param endValue End value of the animation curve
  97799. * @param inTangent Start tangent of the animation curve
  97800. * @param gradient Scalar amount to interpolate
  97801. * @returns Interpolated scalar value
  97802. */
  97803. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  97804. /**
  97805. * Interpolates a quaternion using a spherical linear interpolation
  97806. * @param startValue Start value of the animation curve
  97807. * @param endValue End value of the animation curve
  97808. * @param gradient Scalar amount to interpolate
  97809. * @returns Interpolated quaternion value
  97810. */
  97811. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  97812. /**
  97813. * Interpolates a quaternion cubically
  97814. * @param startValue Start value of the animation curve
  97815. * @param outTangent End tangent of the animation curve
  97816. * @param endValue End value of the animation curve
  97817. * @param inTangent Start tangent of the animation curve
  97818. * @param gradient Scalar amount to interpolate
  97819. * @returns Interpolated quaternion value
  97820. */
  97821. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  97822. /**
  97823. * Interpolates a Vector3 linearl
  97824. * @param startValue Start value of the animation curve
  97825. * @param endValue End value of the animation curve
  97826. * @param gradient Scalar amount to interpolate
  97827. * @returns Interpolated scalar value
  97828. */
  97829. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  97830. /**
  97831. * Interpolates a Vector3 cubically
  97832. * @param startValue Start value of the animation curve
  97833. * @param outTangent End tangent of the animation
  97834. * @param endValue End value of the animation curve
  97835. * @param inTangent Start tangent of the animation curve
  97836. * @param gradient Scalar amount to interpolate
  97837. * @returns InterpolatedVector3 value
  97838. */
  97839. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  97840. /**
  97841. * Interpolates a Vector2 linearly
  97842. * @param startValue Start value of the animation curve
  97843. * @param endValue End value of the animation curve
  97844. * @param gradient Scalar amount to interpolate
  97845. * @returns Interpolated Vector2 value
  97846. */
  97847. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  97848. /**
  97849. * Interpolates a Vector2 cubically
  97850. * @param startValue Start value of the animation curve
  97851. * @param outTangent End tangent of the animation
  97852. * @param endValue End value of the animation curve
  97853. * @param inTangent Start tangent of the animation curve
  97854. * @param gradient Scalar amount to interpolate
  97855. * @returns Interpolated Vector2 value
  97856. */
  97857. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  97858. /**
  97859. * Interpolates a size linearly
  97860. * @param startValue Start value of the animation curve
  97861. * @param endValue End value of the animation curve
  97862. * @param gradient Scalar amount to interpolate
  97863. * @returns Interpolated Size value
  97864. */
  97865. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  97866. /**
  97867. * Interpolates a Color3 linearly
  97868. * @param startValue Start value of the animation curve
  97869. * @param endValue End value of the animation curve
  97870. * @param gradient Scalar amount to interpolate
  97871. * @returns Interpolated Color3 value
  97872. */
  97873. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  97874. /**
  97875. * Interpolates a Color4 linearly
  97876. * @param startValue Start value of the animation curve
  97877. * @param endValue End value of the animation curve
  97878. * @param gradient Scalar amount to interpolate
  97879. * @returns Interpolated Color3 value
  97880. */
  97881. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  97882. /**
  97883. * @hidden Internal use only
  97884. */
  97885. _getKeyValue(value: any): any;
  97886. /**
  97887. * @hidden Internal use only
  97888. */
  97889. _interpolate(currentFrame: number, state: _IAnimationState): any;
  97890. /**
  97891. * Defines the function to use to interpolate matrices
  97892. * @param startValue defines the start matrix
  97893. * @param endValue defines the end matrix
  97894. * @param gradient defines the gradient between both matrices
  97895. * @param result defines an optional target matrix where to store the interpolation
  97896. * @returns the interpolated matrix
  97897. */
  97898. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  97899. /**
  97900. * Makes a copy of the animation
  97901. * @returns Cloned animation
  97902. */
  97903. clone(): Animation;
  97904. /**
  97905. * Sets the key frames of the animation
  97906. * @param values The animation key frames to set
  97907. */
  97908. setKeys(values: Array<IAnimationKey>): void;
  97909. /**
  97910. * Serializes the animation to an object
  97911. * @returns Serialized object
  97912. */
  97913. serialize(): any;
  97914. /**
  97915. * Float animation type
  97916. */
  97917. static readonly ANIMATIONTYPE_FLOAT: number;
  97918. /**
  97919. * Vector3 animation type
  97920. */
  97921. static readonly ANIMATIONTYPE_VECTOR3: number;
  97922. /**
  97923. * Quaternion animation type
  97924. */
  97925. static readonly ANIMATIONTYPE_QUATERNION: number;
  97926. /**
  97927. * Matrix animation type
  97928. */
  97929. static readonly ANIMATIONTYPE_MATRIX: number;
  97930. /**
  97931. * Color3 animation type
  97932. */
  97933. static readonly ANIMATIONTYPE_COLOR3: number;
  97934. /**
  97935. * Color3 animation type
  97936. */
  97937. static readonly ANIMATIONTYPE_COLOR4: number;
  97938. /**
  97939. * Vector2 animation type
  97940. */
  97941. static readonly ANIMATIONTYPE_VECTOR2: number;
  97942. /**
  97943. * Size animation type
  97944. */
  97945. static readonly ANIMATIONTYPE_SIZE: number;
  97946. /**
  97947. * Relative Loop Mode
  97948. */
  97949. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  97950. /**
  97951. * Cycle Loop Mode
  97952. */
  97953. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  97954. /**
  97955. * Constant Loop Mode
  97956. */
  97957. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  97958. /** @hidden */
  97959. static _UniversalLerp(left: any, right: any, amount: number): any;
  97960. /**
  97961. * Parses an animation object and creates an animation
  97962. * @param parsedAnimation Parsed animation object
  97963. * @returns Animation object
  97964. */
  97965. static Parse(parsedAnimation: any): Animation;
  97966. /**
  97967. * Appends the serialized animations from the source animations
  97968. * @param source Source containing the animations
  97969. * @param destination Target to store the animations
  97970. */
  97971. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  97972. }
  97973. }
  97974. declare module BABYLON {
  97975. /**
  97976. * Interface containing an array of animations
  97977. */
  97978. export interface IAnimatable {
  97979. /**
  97980. * Array of animations
  97981. */
  97982. animations: Nullable<Array<Animation>>;
  97983. }
  97984. }
  97985. declare module BABYLON {
  97986. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  97987. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97988. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97989. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97990. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97991. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97992. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97993. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97994. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97995. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97996. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97997. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97998. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97999. /**
  98000. * Decorator used to define property that can be serialized as reference to a camera
  98001. * @param sourceName defines the name of the property to decorate
  98002. */
  98003. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98004. /**
  98005. * Class used to help serialization objects
  98006. */
  98007. export class SerializationHelper {
  98008. /** @hidden */
  98009. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  98010. /** @hidden */
  98011. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  98012. /** @hidden */
  98013. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  98014. /** @hidden */
  98015. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  98016. /**
  98017. * Appends the serialized animations from the source animations
  98018. * @param source Source containing the animations
  98019. * @param destination Target to store the animations
  98020. */
  98021. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  98022. /**
  98023. * Static function used to serialized a specific entity
  98024. * @param entity defines the entity to serialize
  98025. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  98026. * @returns a JSON compatible object representing the serialization of the entity
  98027. */
  98028. static Serialize<T>(entity: T, serializationObject?: any): any;
  98029. /**
  98030. * Creates a new entity from a serialization data object
  98031. * @param creationFunction defines a function used to instanciated the new entity
  98032. * @param source defines the source serialization data
  98033. * @param scene defines the hosting scene
  98034. * @param rootUrl defines the root url for resources
  98035. * @returns a new entity
  98036. */
  98037. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  98038. /**
  98039. * Clones an object
  98040. * @param creationFunction defines the function used to instanciate the new object
  98041. * @param source defines the source object
  98042. * @returns the cloned object
  98043. */
  98044. static Clone<T>(creationFunction: () => T, source: T): T;
  98045. /**
  98046. * Instanciates a new object based on a source one (some data will be shared between both object)
  98047. * @param creationFunction defines the function used to instanciate the new object
  98048. * @param source defines the source object
  98049. * @returns the new object
  98050. */
  98051. static Instanciate<T>(creationFunction: () => T, source: T): T;
  98052. }
  98053. }
  98054. declare module BABYLON {
  98055. /**
  98056. * Class used to manipulate GUIDs
  98057. */
  98058. export class GUID {
  98059. /**
  98060. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98061. * Be aware Math.random() could cause collisions, but:
  98062. * "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"
  98063. * @returns a pseudo random id
  98064. */
  98065. static RandomId(): string;
  98066. }
  98067. }
  98068. declare module BABYLON {
  98069. /**
  98070. * Base class of all the textures in babylon.
  98071. * It groups all the common properties the materials, post process, lights... might need
  98072. * in order to make a correct use of the texture.
  98073. */
  98074. export class BaseTexture implements IAnimatable {
  98075. /**
  98076. * Default anisotropic filtering level for the application.
  98077. * It is set to 4 as a good tradeoff between perf and quality.
  98078. */
  98079. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  98080. /**
  98081. * Gets or sets the unique id of the texture
  98082. */
  98083. uniqueId: number;
  98084. /**
  98085. * Define the name of the texture.
  98086. */
  98087. name: string;
  98088. /**
  98089. * Gets or sets an object used to store user defined information.
  98090. */
  98091. metadata: any;
  98092. /**
  98093. * For internal use only. Please do not use.
  98094. */
  98095. reservedDataStore: any;
  98096. private _hasAlpha;
  98097. /**
  98098. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  98099. */
  98100. hasAlpha: boolean;
  98101. /**
  98102. * Defines if the alpha value should be determined via the rgb values.
  98103. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  98104. */
  98105. getAlphaFromRGB: boolean;
  98106. /**
  98107. * Intensity or strength of the texture.
  98108. * It is commonly used by materials to fine tune the intensity of the texture
  98109. */
  98110. level: number;
  98111. /**
  98112. * Define the UV chanel to use starting from 0 and defaulting to 0.
  98113. * This is part of the texture as textures usually maps to one uv set.
  98114. */
  98115. coordinatesIndex: number;
  98116. private _coordinatesMode;
  98117. /**
  98118. * How a texture is mapped.
  98119. *
  98120. * | Value | Type | Description |
  98121. * | ----- | ----------------------------------- | ----------- |
  98122. * | 0 | EXPLICIT_MODE | |
  98123. * | 1 | SPHERICAL_MODE | |
  98124. * | 2 | PLANAR_MODE | |
  98125. * | 3 | CUBIC_MODE | |
  98126. * | 4 | PROJECTION_MODE | |
  98127. * | 5 | SKYBOX_MODE | |
  98128. * | 6 | INVCUBIC_MODE | |
  98129. * | 7 | EQUIRECTANGULAR_MODE | |
  98130. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  98131. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  98132. */
  98133. coordinatesMode: number;
  98134. /**
  98135. * | Value | Type | Description |
  98136. * | ----- | ------------------ | ----------- |
  98137. * | 0 | CLAMP_ADDRESSMODE | |
  98138. * | 1 | WRAP_ADDRESSMODE | |
  98139. * | 2 | MIRROR_ADDRESSMODE | |
  98140. */
  98141. wrapU: number;
  98142. /**
  98143. * | Value | Type | Description |
  98144. * | ----- | ------------------ | ----------- |
  98145. * | 0 | CLAMP_ADDRESSMODE | |
  98146. * | 1 | WRAP_ADDRESSMODE | |
  98147. * | 2 | MIRROR_ADDRESSMODE | |
  98148. */
  98149. wrapV: number;
  98150. /**
  98151. * | Value | Type | Description |
  98152. * | ----- | ------------------ | ----------- |
  98153. * | 0 | CLAMP_ADDRESSMODE | |
  98154. * | 1 | WRAP_ADDRESSMODE | |
  98155. * | 2 | MIRROR_ADDRESSMODE | |
  98156. */
  98157. wrapR: number;
  98158. /**
  98159. * With compliant hardware and browser (supporting anisotropic filtering)
  98160. * this defines the level of anisotropic filtering in the texture.
  98161. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  98162. */
  98163. anisotropicFilteringLevel: number;
  98164. /**
  98165. * Define if the texture is a cube texture or if false a 2d texture.
  98166. */
  98167. isCube: boolean;
  98168. /**
  98169. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  98170. */
  98171. is3D: boolean;
  98172. /**
  98173. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  98174. */
  98175. is2DArray: boolean;
  98176. /**
  98177. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  98178. * HDR texture are usually stored in linear space.
  98179. * This only impacts the PBR and Background materials
  98180. */
  98181. gammaSpace: boolean;
  98182. /**
  98183. * Gets or sets whether or not the texture contains RGBD data.
  98184. */
  98185. isRGBD: boolean;
  98186. /**
  98187. * Is Z inverted in the texture (useful in a cube texture).
  98188. */
  98189. invertZ: boolean;
  98190. /**
  98191. * Are mip maps generated for this texture or not.
  98192. */
  98193. readonly noMipmap: boolean;
  98194. /**
  98195. * @hidden
  98196. */
  98197. lodLevelInAlpha: boolean;
  98198. /**
  98199. * With prefiltered texture, defined the offset used during the prefiltering steps.
  98200. */
  98201. lodGenerationOffset: number;
  98202. /**
  98203. * With prefiltered texture, defined the scale used during the prefiltering steps.
  98204. */
  98205. lodGenerationScale: number;
  98206. /**
  98207. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  98208. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  98209. * average roughness values.
  98210. */
  98211. linearSpecularLOD: boolean;
  98212. /**
  98213. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  98214. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  98215. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  98216. */
  98217. irradianceTexture: Nullable<BaseTexture>;
  98218. /**
  98219. * Define if the texture is a render target.
  98220. */
  98221. isRenderTarget: boolean;
  98222. /**
  98223. * Define the unique id of the texture in the scene.
  98224. */
  98225. readonly uid: string;
  98226. /**
  98227. * Return a string representation of the texture.
  98228. * @returns the texture as a string
  98229. */
  98230. toString(): string;
  98231. /**
  98232. * Get the class name of the texture.
  98233. * @returns "BaseTexture"
  98234. */
  98235. getClassName(): string;
  98236. /**
  98237. * Define the list of animation attached to the texture.
  98238. */
  98239. animations: Animation[];
  98240. /**
  98241. * An event triggered when the texture is disposed.
  98242. */
  98243. onDisposeObservable: Observable<BaseTexture>;
  98244. private _onDisposeObserver;
  98245. /**
  98246. * Callback triggered when the texture has been disposed.
  98247. * Kept for back compatibility, you can use the onDisposeObservable instead.
  98248. */
  98249. onDispose: () => void;
  98250. /**
  98251. * Define the current state of the loading sequence when in delayed load mode.
  98252. */
  98253. delayLoadState: number;
  98254. private _scene;
  98255. /** @hidden */
  98256. _texture: Nullable<InternalTexture>;
  98257. private _uid;
  98258. /**
  98259. * Define if the texture is preventinga material to render or not.
  98260. * If not and the texture is not ready, the engine will use a default black texture instead.
  98261. */
  98262. readonly isBlocking: boolean;
  98263. /**
  98264. * Instantiates a new BaseTexture.
  98265. * Base class of all the textures in babylon.
  98266. * It groups all the common properties the materials, post process, lights... might need
  98267. * in order to make a correct use of the texture.
  98268. * @param scene Define the scene the texture blongs to
  98269. */
  98270. constructor(scene: Nullable<Scene>);
  98271. /**
  98272. * Get the scene the texture belongs to.
  98273. * @returns the scene or null if undefined
  98274. */
  98275. getScene(): Nullable<Scene>;
  98276. /**
  98277. * Get the texture transform matrix used to offset tile the texture for istance.
  98278. * @returns the transformation matrix
  98279. */
  98280. getTextureMatrix(): Matrix;
  98281. /**
  98282. * Get the texture reflection matrix used to rotate/transform the reflection.
  98283. * @returns the reflection matrix
  98284. */
  98285. getReflectionTextureMatrix(): Matrix;
  98286. /**
  98287. * Get the underlying lower level texture from Babylon.
  98288. * @returns the insternal texture
  98289. */
  98290. getInternalTexture(): Nullable<InternalTexture>;
  98291. /**
  98292. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  98293. * @returns true if ready or not blocking
  98294. */
  98295. isReadyOrNotBlocking(): boolean;
  98296. /**
  98297. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  98298. * @returns true if fully ready
  98299. */
  98300. isReady(): boolean;
  98301. private _cachedSize;
  98302. /**
  98303. * Get the size of the texture.
  98304. * @returns the texture size.
  98305. */
  98306. getSize(): ISize;
  98307. /**
  98308. * Get the base size of the texture.
  98309. * It can be different from the size if the texture has been resized for POT for instance
  98310. * @returns the base size
  98311. */
  98312. getBaseSize(): ISize;
  98313. /**
  98314. * Update the sampling mode of the texture.
  98315. * Default is Trilinear mode.
  98316. *
  98317. * | Value | Type | Description |
  98318. * | ----- | ------------------ | ----------- |
  98319. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  98320. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  98321. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  98322. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  98323. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  98324. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  98325. * | 7 | NEAREST_LINEAR | |
  98326. * | 8 | NEAREST_NEAREST | |
  98327. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  98328. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  98329. * | 11 | LINEAR_LINEAR | |
  98330. * | 12 | LINEAR_NEAREST | |
  98331. *
  98332. * > _mag_: magnification filter (close to the viewer)
  98333. * > _min_: minification filter (far from the viewer)
  98334. * > _mip_: filter used between mip map levels
  98335. *@param samplingMode Define the new sampling mode of the texture
  98336. */
  98337. updateSamplingMode(samplingMode: number): void;
  98338. /**
  98339. * Scales the texture if is `canRescale()`
  98340. * @param ratio the resize factor we want to use to rescale
  98341. */
  98342. scale(ratio: number): void;
  98343. /**
  98344. * Get if the texture can rescale.
  98345. */
  98346. readonly canRescale: boolean;
  98347. /** @hidden */
  98348. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  98349. /** @hidden */
  98350. _rebuild(): void;
  98351. /**
  98352. * Triggers the load sequence in delayed load mode.
  98353. */
  98354. delayLoad(): void;
  98355. /**
  98356. * Clones the texture.
  98357. * @returns the cloned texture
  98358. */
  98359. clone(): Nullable<BaseTexture>;
  98360. /**
  98361. * Get the texture underlying type (INT, FLOAT...)
  98362. */
  98363. readonly textureType: number;
  98364. /**
  98365. * Get the texture underlying format (RGB, RGBA...)
  98366. */
  98367. readonly textureFormat: number;
  98368. /**
  98369. * Indicates that textures need to be re-calculated for all materials
  98370. */
  98371. protected _markAllSubMeshesAsTexturesDirty(): void;
  98372. /**
  98373. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  98374. * This will returns an RGBA array buffer containing either in values (0-255) or
  98375. * float values (0-1) depending of the underlying buffer type.
  98376. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  98377. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  98378. * @param buffer defines a user defined buffer to fill with data (can be null)
  98379. * @returns The Array buffer containing the pixels data.
  98380. */
  98381. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  98382. /**
  98383. * Release and destroy the underlying lower level texture aka internalTexture.
  98384. */
  98385. releaseInternalTexture(): void;
  98386. /** @hidden */
  98387. readonly _lodTextureHigh: Nullable<BaseTexture>;
  98388. /** @hidden */
  98389. readonly _lodTextureMid: Nullable<BaseTexture>;
  98390. /** @hidden */
  98391. readonly _lodTextureLow: Nullable<BaseTexture>;
  98392. /**
  98393. * Dispose the texture and release its associated resources.
  98394. */
  98395. dispose(): void;
  98396. /**
  98397. * Serialize the texture into a JSON representation that can be parsed later on.
  98398. * @returns the JSON representation of the texture
  98399. */
  98400. serialize(): any;
  98401. /**
  98402. * Helper function to be called back once a list of texture contains only ready textures.
  98403. * @param textures Define the list of textures to wait for
  98404. * @param callback Define the callback triggered once the entire list will be ready
  98405. */
  98406. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  98407. }
  98408. }
  98409. declare module BABYLON {
  98410. /**
  98411. * Options to be used when creating an effect.
  98412. */
  98413. export interface IEffectCreationOptions {
  98414. /**
  98415. * Atrributes that will be used in the shader.
  98416. */
  98417. attributes: string[];
  98418. /**
  98419. * Uniform varible names that will be set in the shader.
  98420. */
  98421. uniformsNames: string[];
  98422. /**
  98423. * Uniform buffer variable names that will be set in the shader.
  98424. */
  98425. uniformBuffersNames: string[];
  98426. /**
  98427. * Sampler texture variable names that will be set in the shader.
  98428. */
  98429. samplers: string[];
  98430. /**
  98431. * Define statements that will be set in the shader.
  98432. */
  98433. defines: any;
  98434. /**
  98435. * Possible fallbacks for this effect to improve performance when needed.
  98436. */
  98437. fallbacks: Nullable<IEffectFallbacks>;
  98438. /**
  98439. * Callback that will be called when the shader is compiled.
  98440. */
  98441. onCompiled: Nullable<(effect: Effect) => void>;
  98442. /**
  98443. * Callback that will be called if an error occurs during shader compilation.
  98444. */
  98445. onError: Nullable<(effect: Effect, errors: string) => void>;
  98446. /**
  98447. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98448. */
  98449. indexParameters?: any;
  98450. /**
  98451. * Max number of lights that can be used in the shader.
  98452. */
  98453. maxSimultaneousLights?: number;
  98454. /**
  98455. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  98456. */
  98457. transformFeedbackVaryings?: Nullable<string[]>;
  98458. }
  98459. /**
  98460. * Effect containing vertex and fragment shader that can be executed on an object.
  98461. */
  98462. export class Effect implements IDisposable {
  98463. /**
  98464. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  98465. */
  98466. static ShadersRepository: string;
  98467. /**
  98468. * Name of the effect.
  98469. */
  98470. name: any;
  98471. /**
  98472. * String container all the define statements that should be set on the shader.
  98473. */
  98474. defines: string;
  98475. /**
  98476. * Callback that will be called when the shader is compiled.
  98477. */
  98478. onCompiled: Nullable<(effect: Effect) => void>;
  98479. /**
  98480. * Callback that will be called if an error occurs during shader compilation.
  98481. */
  98482. onError: Nullable<(effect: Effect, errors: string) => void>;
  98483. /**
  98484. * Callback that will be called when effect is bound.
  98485. */
  98486. onBind: Nullable<(effect: Effect) => void>;
  98487. /**
  98488. * Unique ID of the effect.
  98489. */
  98490. uniqueId: number;
  98491. /**
  98492. * Observable that will be called when the shader is compiled.
  98493. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  98494. */
  98495. onCompileObservable: Observable<Effect>;
  98496. /**
  98497. * Observable that will be called if an error occurs during shader compilation.
  98498. */
  98499. onErrorObservable: Observable<Effect>;
  98500. /** @hidden */
  98501. _onBindObservable: Nullable<Observable<Effect>>;
  98502. /**
  98503. * Observable that will be called when effect is bound.
  98504. */
  98505. readonly onBindObservable: Observable<Effect>;
  98506. /** @hidden */
  98507. _bonesComputationForcedToCPU: boolean;
  98508. private static _uniqueIdSeed;
  98509. private _engine;
  98510. private _uniformBuffersNames;
  98511. private _uniformsNames;
  98512. private _samplerList;
  98513. private _samplers;
  98514. private _isReady;
  98515. private _compilationError;
  98516. private _allFallbacksProcessed;
  98517. private _attributesNames;
  98518. private _attributes;
  98519. private _uniforms;
  98520. /**
  98521. * Key for the effect.
  98522. * @hidden
  98523. */
  98524. _key: string;
  98525. private _indexParameters;
  98526. private _fallbacks;
  98527. private _vertexSourceCode;
  98528. private _fragmentSourceCode;
  98529. private _vertexSourceCodeOverride;
  98530. private _fragmentSourceCodeOverride;
  98531. private _transformFeedbackVaryings;
  98532. /**
  98533. * Compiled shader to webGL program.
  98534. * @hidden
  98535. */
  98536. _pipelineContext: Nullable<IPipelineContext>;
  98537. private _valueCache;
  98538. private static _baseCache;
  98539. /**
  98540. * Instantiates an effect.
  98541. * An effect can be used to create/manage/execute vertex and fragment shaders.
  98542. * @param baseName Name of the effect.
  98543. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  98544. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  98545. * @param samplers List of sampler variables that will be passed to the shader.
  98546. * @param engine Engine to be used to render the effect
  98547. * @param defines Define statements to be added to the shader.
  98548. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  98549. * @param onCompiled Callback that will be called when the shader is compiled.
  98550. * @param onError Callback that will be called if an error occurs during shader compilation.
  98551. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98552. */
  98553. 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);
  98554. private _useFinalCode;
  98555. /**
  98556. * Unique key for this effect
  98557. */
  98558. readonly key: string;
  98559. /**
  98560. * If the effect has been compiled and prepared.
  98561. * @returns if the effect is compiled and prepared.
  98562. */
  98563. isReady(): boolean;
  98564. private _isReadyInternal;
  98565. /**
  98566. * The engine the effect was initialized with.
  98567. * @returns the engine.
  98568. */
  98569. getEngine(): Engine;
  98570. /**
  98571. * The pipeline context for this effect
  98572. * @returns the associated pipeline context
  98573. */
  98574. getPipelineContext(): Nullable<IPipelineContext>;
  98575. /**
  98576. * The set of names of attribute variables for the shader.
  98577. * @returns An array of attribute names.
  98578. */
  98579. getAttributesNames(): string[];
  98580. /**
  98581. * Returns the attribute at the given index.
  98582. * @param index The index of the attribute.
  98583. * @returns The location of the attribute.
  98584. */
  98585. getAttributeLocation(index: number): number;
  98586. /**
  98587. * Returns the attribute based on the name of the variable.
  98588. * @param name of the attribute to look up.
  98589. * @returns the attribute location.
  98590. */
  98591. getAttributeLocationByName(name: string): number;
  98592. /**
  98593. * The number of attributes.
  98594. * @returns the numnber of attributes.
  98595. */
  98596. getAttributesCount(): number;
  98597. /**
  98598. * Gets the index of a uniform variable.
  98599. * @param uniformName of the uniform to look up.
  98600. * @returns the index.
  98601. */
  98602. getUniformIndex(uniformName: string): number;
  98603. /**
  98604. * Returns the attribute based on the name of the variable.
  98605. * @param uniformName of the uniform to look up.
  98606. * @returns the location of the uniform.
  98607. */
  98608. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  98609. /**
  98610. * Returns an array of sampler variable names
  98611. * @returns The array of sampler variable neames.
  98612. */
  98613. getSamplers(): string[];
  98614. /**
  98615. * The error from the last compilation.
  98616. * @returns the error string.
  98617. */
  98618. getCompilationError(): string;
  98619. /**
  98620. * Gets a boolean indicating that all fallbacks were used during compilation
  98621. * @returns true if all fallbacks were used
  98622. */
  98623. allFallbacksProcessed(): boolean;
  98624. /**
  98625. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  98626. * @param func The callback to be used.
  98627. */
  98628. executeWhenCompiled(func: (effect: Effect) => void): void;
  98629. private _checkIsReady;
  98630. private _loadShader;
  98631. /**
  98632. * Recompiles the webGL program
  98633. * @param vertexSourceCode The source code for the vertex shader.
  98634. * @param fragmentSourceCode The source code for the fragment shader.
  98635. * @param onCompiled Callback called when completed.
  98636. * @param onError Callback called on error.
  98637. * @hidden
  98638. */
  98639. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  98640. /**
  98641. * Prepares the effect
  98642. * @hidden
  98643. */
  98644. _prepareEffect(): void;
  98645. private _processCompilationErrors;
  98646. /**
  98647. * Checks if the effect is supported. (Must be called after compilation)
  98648. */
  98649. readonly isSupported: boolean;
  98650. /**
  98651. * Binds a texture to the engine to be used as output of the shader.
  98652. * @param channel Name of the output variable.
  98653. * @param texture Texture to bind.
  98654. * @hidden
  98655. */
  98656. _bindTexture(channel: string, texture: InternalTexture): void;
  98657. /**
  98658. * Sets a texture on the engine to be used in the shader.
  98659. * @param channel Name of the sampler variable.
  98660. * @param texture Texture to set.
  98661. */
  98662. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  98663. /**
  98664. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  98665. * @param channel Name of the sampler variable.
  98666. * @param texture Texture to set.
  98667. */
  98668. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  98669. /**
  98670. * Sets an array of textures on the engine to be used in the shader.
  98671. * @param channel Name of the variable.
  98672. * @param textures Textures to set.
  98673. */
  98674. setTextureArray(channel: string, textures: BaseTexture[]): void;
  98675. /**
  98676. * 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)
  98677. * @param channel Name of the sampler variable.
  98678. * @param postProcess Post process to get the input texture from.
  98679. */
  98680. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  98681. /**
  98682. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  98683. * 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)
  98684. * @param channel Name of the sampler variable.
  98685. * @param postProcess Post process to get the output texture from.
  98686. */
  98687. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  98688. /** @hidden */
  98689. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  98690. /** @hidden */
  98691. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  98692. /** @hidden */
  98693. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  98694. /** @hidden */
  98695. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  98696. /**
  98697. * Binds a buffer to a uniform.
  98698. * @param buffer Buffer to bind.
  98699. * @param name Name of the uniform variable to bind to.
  98700. */
  98701. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  98702. /**
  98703. * Binds block to a uniform.
  98704. * @param blockName Name of the block to bind.
  98705. * @param index Index to bind.
  98706. */
  98707. bindUniformBlock(blockName: string, index: number): void;
  98708. /**
  98709. * Sets an interger value on a uniform variable.
  98710. * @param uniformName Name of the variable.
  98711. * @param value Value to be set.
  98712. * @returns this effect.
  98713. */
  98714. setInt(uniformName: string, value: number): Effect;
  98715. /**
  98716. * Sets an int array on a uniform variable.
  98717. * @param uniformName Name of the variable.
  98718. * @param array array to be set.
  98719. * @returns this effect.
  98720. */
  98721. setIntArray(uniformName: string, array: Int32Array): Effect;
  98722. /**
  98723. * 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)
  98724. * @param uniformName Name of the variable.
  98725. * @param array array to be set.
  98726. * @returns this effect.
  98727. */
  98728. setIntArray2(uniformName: string, array: Int32Array): Effect;
  98729. /**
  98730. * 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)
  98731. * @param uniformName Name of the variable.
  98732. * @param array array to be set.
  98733. * @returns this effect.
  98734. */
  98735. setIntArray3(uniformName: string, array: Int32Array): Effect;
  98736. /**
  98737. * 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)
  98738. * @param uniformName Name of the variable.
  98739. * @param array array to be set.
  98740. * @returns this effect.
  98741. */
  98742. setIntArray4(uniformName: string, array: Int32Array): Effect;
  98743. /**
  98744. * Sets an float array on a uniform variable.
  98745. * @param uniformName Name of the variable.
  98746. * @param array array to be set.
  98747. * @returns this effect.
  98748. */
  98749. setFloatArray(uniformName: string, array: Float32Array): Effect;
  98750. /**
  98751. * 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)
  98752. * @param uniformName Name of the variable.
  98753. * @param array array to be set.
  98754. * @returns this effect.
  98755. */
  98756. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  98757. /**
  98758. * 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)
  98759. * @param uniformName Name of the variable.
  98760. * @param array array to be set.
  98761. * @returns this effect.
  98762. */
  98763. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  98764. /**
  98765. * 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)
  98766. * @param uniformName Name of the variable.
  98767. * @param array array to be set.
  98768. * @returns this effect.
  98769. */
  98770. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  98771. /**
  98772. * Sets an array on a uniform variable.
  98773. * @param uniformName Name of the variable.
  98774. * @param array array to be set.
  98775. * @returns this effect.
  98776. */
  98777. setArray(uniformName: string, array: number[]): Effect;
  98778. /**
  98779. * 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)
  98780. * @param uniformName Name of the variable.
  98781. * @param array array to be set.
  98782. * @returns this effect.
  98783. */
  98784. setArray2(uniformName: string, array: number[]): Effect;
  98785. /**
  98786. * 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)
  98787. * @param uniformName Name of the variable.
  98788. * @param array array to be set.
  98789. * @returns this effect.
  98790. */
  98791. setArray3(uniformName: string, array: number[]): Effect;
  98792. /**
  98793. * 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)
  98794. * @param uniformName Name of the variable.
  98795. * @param array array to be set.
  98796. * @returns this effect.
  98797. */
  98798. setArray4(uniformName: string, array: number[]): Effect;
  98799. /**
  98800. * Sets matrices on a uniform variable.
  98801. * @param uniformName Name of the variable.
  98802. * @param matrices matrices to be set.
  98803. * @returns this effect.
  98804. */
  98805. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  98806. /**
  98807. * Sets matrix on a uniform variable.
  98808. * @param uniformName Name of the variable.
  98809. * @param matrix matrix to be set.
  98810. * @returns this effect.
  98811. */
  98812. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  98813. /**
  98814. * 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)
  98815. * @param uniformName Name of the variable.
  98816. * @param matrix matrix to be set.
  98817. * @returns this effect.
  98818. */
  98819. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  98820. /**
  98821. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  98822. * @param uniformName Name of the variable.
  98823. * @param matrix matrix to be set.
  98824. * @returns this effect.
  98825. */
  98826. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  98827. /**
  98828. * Sets a float on a uniform variable.
  98829. * @param uniformName Name of the variable.
  98830. * @param value value to be set.
  98831. * @returns this effect.
  98832. */
  98833. setFloat(uniformName: string, value: number): Effect;
  98834. /**
  98835. * Sets a boolean on a uniform variable.
  98836. * @param uniformName Name of the variable.
  98837. * @param bool value to be set.
  98838. * @returns this effect.
  98839. */
  98840. setBool(uniformName: string, bool: boolean): Effect;
  98841. /**
  98842. * Sets a Vector2 on a uniform variable.
  98843. * @param uniformName Name of the variable.
  98844. * @param vector2 vector2 to be set.
  98845. * @returns this effect.
  98846. */
  98847. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  98848. /**
  98849. * Sets a float2 on a uniform variable.
  98850. * @param uniformName Name of the variable.
  98851. * @param x First float in float2.
  98852. * @param y Second float in float2.
  98853. * @returns this effect.
  98854. */
  98855. setFloat2(uniformName: string, x: number, y: number): Effect;
  98856. /**
  98857. * Sets a Vector3 on a uniform variable.
  98858. * @param uniformName Name of the variable.
  98859. * @param vector3 Value to be set.
  98860. * @returns this effect.
  98861. */
  98862. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  98863. /**
  98864. * Sets a float3 on a uniform variable.
  98865. * @param uniformName Name of the variable.
  98866. * @param x First float in float3.
  98867. * @param y Second float in float3.
  98868. * @param z Third float in float3.
  98869. * @returns this effect.
  98870. */
  98871. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  98872. /**
  98873. * Sets a Vector4 on a uniform variable.
  98874. * @param uniformName Name of the variable.
  98875. * @param vector4 Value to be set.
  98876. * @returns this effect.
  98877. */
  98878. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  98879. /**
  98880. * Sets a float4 on a uniform variable.
  98881. * @param uniformName Name of the variable.
  98882. * @param x First float in float4.
  98883. * @param y Second float in float4.
  98884. * @param z Third float in float4.
  98885. * @param w Fourth float in float4.
  98886. * @returns this effect.
  98887. */
  98888. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  98889. /**
  98890. * Sets a Color3 on a uniform variable.
  98891. * @param uniformName Name of the variable.
  98892. * @param color3 Value to be set.
  98893. * @returns this effect.
  98894. */
  98895. setColor3(uniformName: string, color3: IColor3Like): Effect;
  98896. /**
  98897. * Sets a Color4 on a uniform variable.
  98898. * @param uniformName Name of the variable.
  98899. * @param color3 Value to be set.
  98900. * @param alpha Alpha value to be set.
  98901. * @returns this effect.
  98902. */
  98903. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  98904. /**
  98905. * Sets a Color4 on a uniform variable
  98906. * @param uniformName defines the name of the variable
  98907. * @param color4 defines the value to be set
  98908. * @returns this effect.
  98909. */
  98910. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  98911. /** Release all associated resources */
  98912. dispose(): void;
  98913. /**
  98914. * This function will add a new shader to the shader store
  98915. * @param name the name of the shader
  98916. * @param pixelShader optional pixel shader content
  98917. * @param vertexShader optional vertex shader content
  98918. */
  98919. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  98920. /**
  98921. * Store of each shader (The can be looked up using effect.key)
  98922. */
  98923. static ShadersStore: {
  98924. [key: string]: string;
  98925. };
  98926. /**
  98927. * Store of each included file for a shader (The can be looked up using effect.key)
  98928. */
  98929. static IncludesShadersStore: {
  98930. [key: string]: string;
  98931. };
  98932. /**
  98933. * Resets the cache of effects.
  98934. */
  98935. static ResetCache(): void;
  98936. }
  98937. }
  98938. declare module BABYLON {
  98939. /**
  98940. * Interface used to describe the capabilities of the engine relatively to the current browser
  98941. */
  98942. export interface EngineCapabilities {
  98943. /** Maximum textures units per fragment shader */
  98944. maxTexturesImageUnits: number;
  98945. /** Maximum texture units per vertex shader */
  98946. maxVertexTextureImageUnits: number;
  98947. /** Maximum textures units in the entire pipeline */
  98948. maxCombinedTexturesImageUnits: number;
  98949. /** Maximum texture size */
  98950. maxTextureSize: number;
  98951. /** Maximum texture samples */
  98952. maxSamples?: number;
  98953. /** Maximum cube texture size */
  98954. maxCubemapTextureSize: number;
  98955. /** Maximum render texture size */
  98956. maxRenderTextureSize: number;
  98957. /** Maximum number of vertex attributes */
  98958. maxVertexAttribs: number;
  98959. /** Maximum number of varyings */
  98960. maxVaryingVectors: number;
  98961. /** Maximum number of uniforms per vertex shader */
  98962. maxVertexUniformVectors: number;
  98963. /** Maximum number of uniforms per fragment shader */
  98964. maxFragmentUniformVectors: number;
  98965. /** Defines if standard derivates (dx/dy) are supported */
  98966. standardDerivatives: boolean;
  98967. /** Defines if s3tc texture compression is supported */
  98968. s3tc?: WEBGL_compressed_texture_s3tc;
  98969. /** Defines if pvrtc texture compression is supported */
  98970. pvrtc: any;
  98971. /** Defines if etc1 texture compression is supported */
  98972. etc1: any;
  98973. /** Defines if etc2 texture compression is supported */
  98974. etc2: any;
  98975. /** Defines if astc texture compression is supported */
  98976. astc: any;
  98977. /** Defines if float textures are supported */
  98978. textureFloat: boolean;
  98979. /** Defines if vertex array objects are supported */
  98980. vertexArrayObject: boolean;
  98981. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  98982. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  98983. /** Gets the maximum level of anisotropy supported */
  98984. maxAnisotropy: number;
  98985. /** Defines if instancing is supported */
  98986. instancedArrays: boolean;
  98987. /** Defines if 32 bits indices are supported */
  98988. uintIndices: boolean;
  98989. /** Defines if high precision shaders are supported */
  98990. highPrecisionShaderSupported: boolean;
  98991. /** Defines if depth reading in the fragment shader is supported */
  98992. fragmentDepthSupported: boolean;
  98993. /** Defines if float texture linear filtering is supported*/
  98994. textureFloatLinearFiltering: boolean;
  98995. /** Defines if rendering to float textures is supported */
  98996. textureFloatRender: boolean;
  98997. /** Defines if half float textures are supported*/
  98998. textureHalfFloat: boolean;
  98999. /** Defines if half float texture linear filtering is supported*/
  99000. textureHalfFloatLinearFiltering: boolean;
  99001. /** Defines if rendering to half float textures is supported */
  99002. textureHalfFloatRender: boolean;
  99003. /** Defines if textureLOD shader command is supported */
  99004. textureLOD: boolean;
  99005. /** Defines if draw buffers extension is supported */
  99006. drawBuffersExtension: boolean;
  99007. /** Defines if depth textures are supported */
  99008. depthTextureExtension: boolean;
  99009. /** Defines if float color buffer are supported */
  99010. colorBufferFloat: boolean;
  99011. /** Gets disjoint timer query extension (null if not supported) */
  99012. timerQuery?: EXT_disjoint_timer_query;
  99013. /** Defines if timestamp can be used with timer query */
  99014. canUseTimestampForTimerQuery: boolean;
  99015. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  99016. multiview?: any;
  99017. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  99018. oculusMultiview?: any;
  99019. /** Function used to let the system compiles shaders in background */
  99020. parallelShaderCompile?: {
  99021. COMPLETION_STATUS_KHR: number;
  99022. };
  99023. /** Max number of texture samples for MSAA */
  99024. maxMSAASamples: number;
  99025. /** Defines if the blend min max extension is supported */
  99026. blendMinMax: boolean;
  99027. }
  99028. }
  99029. declare module BABYLON {
  99030. /**
  99031. * @hidden
  99032. **/
  99033. export class DepthCullingState {
  99034. private _isDepthTestDirty;
  99035. private _isDepthMaskDirty;
  99036. private _isDepthFuncDirty;
  99037. private _isCullFaceDirty;
  99038. private _isCullDirty;
  99039. private _isZOffsetDirty;
  99040. private _isFrontFaceDirty;
  99041. private _depthTest;
  99042. private _depthMask;
  99043. private _depthFunc;
  99044. private _cull;
  99045. private _cullFace;
  99046. private _zOffset;
  99047. private _frontFace;
  99048. /**
  99049. * Initializes the state.
  99050. */
  99051. constructor();
  99052. readonly isDirty: boolean;
  99053. zOffset: number;
  99054. cullFace: Nullable<number>;
  99055. cull: Nullable<boolean>;
  99056. depthFunc: Nullable<number>;
  99057. depthMask: boolean;
  99058. depthTest: boolean;
  99059. frontFace: Nullable<number>;
  99060. reset(): void;
  99061. apply(gl: WebGLRenderingContext): void;
  99062. }
  99063. }
  99064. declare module BABYLON {
  99065. /**
  99066. * @hidden
  99067. **/
  99068. export class StencilState {
  99069. /** 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 */
  99070. static readonly ALWAYS: number;
  99071. /** Passed to stencilOperation to specify that stencil value must be kept */
  99072. static readonly KEEP: number;
  99073. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99074. static readonly REPLACE: number;
  99075. private _isStencilTestDirty;
  99076. private _isStencilMaskDirty;
  99077. private _isStencilFuncDirty;
  99078. private _isStencilOpDirty;
  99079. private _stencilTest;
  99080. private _stencilMask;
  99081. private _stencilFunc;
  99082. private _stencilFuncRef;
  99083. private _stencilFuncMask;
  99084. private _stencilOpStencilFail;
  99085. private _stencilOpDepthFail;
  99086. private _stencilOpStencilDepthPass;
  99087. readonly isDirty: boolean;
  99088. stencilFunc: number;
  99089. stencilFuncRef: number;
  99090. stencilFuncMask: number;
  99091. stencilOpStencilFail: number;
  99092. stencilOpDepthFail: number;
  99093. stencilOpStencilDepthPass: number;
  99094. stencilMask: number;
  99095. stencilTest: boolean;
  99096. constructor();
  99097. reset(): void;
  99098. apply(gl: WebGLRenderingContext): void;
  99099. }
  99100. }
  99101. declare module BABYLON {
  99102. /**
  99103. * @hidden
  99104. **/
  99105. export class AlphaState {
  99106. private _isAlphaBlendDirty;
  99107. private _isBlendFunctionParametersDirty;
  99108. private _isBlendEquationParametersDirty;
  99109. private _isBlendConstantsDirty;
  99110. private _alphaBlend;
  99111. private _blendFunctionParameters;
  99112. private _blendEquationParameters;
  99113. private _blendConstants;
  99114. /**
  99115. * Initializes the state.
  99116. */
  99117. constructor();
  99118. readonly isDirty: boolean;
  99119. alphaBlend: boolean;
  99120. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  99121. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  99122. setAlphaEquationParameters(rgb: number, alpha: number): void;
  99123. reset(): void;
  99124. apply(gl: WebGLRenderingContext): void;
  99125. }
  99126. }
  99127. declare module BABYLON {
  99128. /** @hidden */
  99129. export class WebGL2ShaderProcessor implements IShaderProcessor {
  99130. attributeProcessor(attribute: string): string;
  99131. varyingProcessor(varying: string, isFragment: boolean): string;
  99132. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  99133. }
  99134. }
  99135. declare module BABYLON {
  99136. /**
  99137. * Interface for attribute information associated with buffer instanciation
  99138. */
  99139. export interface InstancingAttributeInfo {
  99140. /**
  99141. * Index/offset of the attribute in the vertex shader
  99142. */
  99143. index: number;
  99144. /**
  99145. * size of the attribute, 1, 2, 3 or 4
  99146. */
  99147. attributeSize: number;
  99148. /**
  99149. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  99150. * default is FLOAT
  99151. */
  99152. attributeType: number;
  99153. /**
  99154. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  99155. */
  99156. normalized: boolean;
  99157. /**
  99158. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  99159. */
  99160. offset: number;
  99161. /**
  99162. * Name of the GLSL attribute, for debugging purpose only
  99163. */
  99164. attributeName: string;
  99165. }
  99166. }
  99167. declare module BABYLON {
  99168. interface ThinEngine {
  99169. /**
  99170. * Update a video texture
  99171. * @param texture defines the texture to update
  99172. * @param video defines the video element to use
  99173. * @param invertY defines if data must be stored with Y axis inverted
  99174. */
  99175. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  99176. }
  99177. }
  99178. declare module BABYLON {
  99179. /**
  99180. * Settings for finer control over video usage
  99181. */
  99182. export interface VideoTextureSettings {
  99183. /**
  99184. * Applies `autoplay` to video, if specified
  99185. */
  99186. autoPlay?: boolean;
  99187. /**
  99188. * Applies `loop` to video, if specified
  99189. */
  99190. loop?: boolean;
  99191. /**
  99192. * Automatically updates internal texture from video at every frame in the render loop
  99193. */
  99194. autoUpdateTexture: boolean;
  99195. /**
  99196. * Image src displayed during the video loading or until the user interacts with the video.
  99197. */
  99198. poster?: string;
  99199. }
  99200. /**
  99201. * If you want to display a video in your scene, this is the special texture for that.
  99202. * This special texture works similar to other textures, with the exception of a few parameters.
  99203. * @see https://doc.babylonjs.com/how_to/video_texture
  99204. */
  99205. export class VideoTexture extends Texture {
  99206. /**
  99207. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  99208. */
  99209. readonly autoUpdateTexture: boolean;
  99210. /**
  99211. * The video instance used by the texture internally
  99212. */
  99213. readonly video: HTMLVideoElement;
  99214. private _onUserActionRequestedObservable;
  99215. /**
  99216. * Event triggerd when a dom action is required by the user to play the video.
  99217. * This happens due to recent changes in browser policies preventing video to auto start.
  99218. */
  99219. readonly onUserActionRequestedObservable: Observable<Texture>;
  99220. private _generateMipMaps;
  99221. private _engine;
  99222. private _stillImageCaptured;
  99223. private _displayingPosterTexture;
  99224. private _settings;
  99225. private _createInternalTextureOnEvent;
  99226. private _frameId;
  99227. /**
  99228. * Creates a video texture.
  99229. * If you want to display a video in your scene, this is the special texture for that.
  99230. * This special texture works similar to other textures, with the exception of a few parameters.
  99231. * @see https://doc.babylonjs.com/how_to/video_texture
  99232. * @param name optional name, will detect from video source, if not defined
  99233. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  99234. * @param scene is obviously the current scene.
  99235. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  99236. * @param invertY is false by default but can be used to invert video on Y axis
  99237. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  99238. * @param settings allows finer control over video usage
  99239. */
  99240. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  99241. private _getName;
  99242. private _getVideo;
  99243. private _createInternalTexture;
  99244. private reset;
  99245. /**
  99246. * @hidden Internal method to initiate `update`.
  99247. */
  99248. _rebuild(): void;
  99249. /**
  99250. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  99251. */
  99252. update(): void;
  99253. /**
  99254. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  99255. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  99256. */
  99257. updateTexture(isVisible: boolean): void;
  99258. protected _updateInternalTexture: () => void;
  99259. /**
  99260. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  99261. * @param url New url.
  99262. */
  99263. updateURL(url: string): void;
  99264. /**
  99265. * Dispose the texture and release its associated resources.
  99266. */
  99267. dispose(): void;
  99268. /**
  99269. * Creates a video texture straight from a stream.
  99270. * @param scene Define the scene the texture should be created in
  99271. * @param stream Define the stream the texture should be created from
  99272. * @returns The created video texture as a promise
  99273. */
  99274. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  99275. /**
  99276. * Creates a video texture straight from your WebCam video feed.
  99277. * @param scene Define the scene the texture should be created in
  99278. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99279. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99280. * @returns The created video texture as a promise
  99281. */
  99282. static CreateFromWebCamAsync(scene: Scene, constraints: {
  99283. minWidth: number;
  99284. maxWidth: number;
  99285. minHeight: number;
  99286. maxHeight: number;
  99287. deviceId: string;
  99288. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  99289. /**
  99290. * Creates a video texture straight from your WebCam video feed.
  99291. * @param scene Define the scene the texture should be created in
  99292. * @param onReady Define a callback to triggered once the texture will be ready
  99293. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99294. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99295. */
  99296. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  99297. minWidth: number;
  99298. maxWidth: number;
  99299. minHeight: number;
  99300. maxHeight: number;
  99301. deviceId: string;
  99302. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  99303. }
  99304. }
  99305. declare module BABYLON {
  99306. /**
  99307. * Defines the interface used by objects working like Scene
  99308. * @hidden
  99309. */
  99310. interface ISceneLike {
  99311. _addPendingData(data: any): void;
  99312. _removePendingData(data: any): void;
  99313. offlineProvider: IOfflineProvider;
  99314. }
  99315. /** Interface defining initialization parameters for Engine class */
  99316. export interface EngineOptions extends WebGLContextAttributes {
  99317. /**
  99318. * Defines if the engine should no exceed a specified device ratio
  99319. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  99320. */
  99321. limitDeviceRatio?: number;
  99322. /**
  99323. * Defines if webvr should be enabled automatically
  99324. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99325. */
  99326. autoEnableWebVR?: boolean;
  99327. /**
  99328. * Defines if webgl2 should be turned off even if supported
  99329. * @see http://doc.babylonjs.com/features/webgl2
  99330. */
  99331. disableWebGL2Support?: boolean;
  99332. /**
  99333. * Defines if webaudio should be initialized as well
  99334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99335. */
  99336. audioEngine?: boolean;
  99337. /**
  99338. * Defines if animations should run using a deterministic lock step
  99339. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99340. */
  99341. deterministicLockstep?: boolean;
  99342. /** Defines the maximum steps to use with deterministic lock step mode */
  99343. lockstepMaxSteps?: number;
  99344. /** Defines the seconds between each deterministic lock step */
  99345. timeStep?: number;
  99346. /**
  99347. * Defines that engine should ignore context lost events
  99348. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  99349. */
  99350. doNotHandleContextLost?: boolean;
  99351. /**
  99352. * Defines that engine should ignore modifying touch action attribute and style
  99353. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  99354. */
  99355. doNotHandleTouchAction?: boolean;
  99356. /**
  99357. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  99358. */
  99359. useHighPrecisionFloats?: boolean;
  99360. }
  99361. /**
  99362. * The base engine class (root of all engines)
  99363. */
  99364. export class ThinEngine {
  99365. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  99366. static ExceptionList: ({
  99367. key: string;
  99368. capture: string;
  99369. captureConstraint: number;
  99370. targets: string[];
  99371. } | {
  99372. key: string;
  99373. capture: null;
  99374. captureConstraint: null;
  99375. targets: string[];
  99376. })[];
  99377. /** @hidden */
  99378. static _TextureLoaders: IInternalTextureLoader[];
  99379. /**
  99380. * Returns the current npm package of the sdk
  99381. */
  99382. static readonly NpmPackage: string;
  99383. /**
  99384. * Returns the current version of the framework
  99385. */
  99386. static readonly Version: string;
  99387. /**
  99388. * Returns a string describing the current engine
  99389. */
  99390. readonly description: string;
  99391. /**
  99392. * Gets or sets the epsilon value used by collision engine
  99393. */
  99394. static CollisionsEpsilon: number;
  99395. /**
  99396. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  99397. */
  99398. static ShadersRepository: string;
  99399. /**
  99400. * Gets or sets the textures that the engine should not attempt to load as compressed
  99401. */
  99402. protected _excludedCompressedTextures: string[];
  99403. /**
  99404. * Filters the compressed texture formats to only include
  99405. * files that are not included in the skippable list
  99406. *
  99407. * @param url the current extension
  99408. * @param textureFormatInUse the current compressed texture format
  99409. * @returns "format" string
  99410. */
  99411. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  99412. /** @hidden */
  99413. _shaderProcessor: IShaderProcessor;
  99414. /**
  99415. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  99416. */
  99417. forcePOTTextures: boolean;
  99418. /**
  99419. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  99420. */
  99421. isFullscreen: boolean;
  99422. /**
  99423. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  99424. */
  99425. cullBackFaces: boolean;
  99426. /**
  99427. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  99428. */
  99429. renderEvenInBackground: boolean;
  99430. /**
  99431. * Gets or sets a boolean indicating that cache can be kept between frames
  99432. */
  99433. preventCacheWipeBetweenFrames: boolean;
  99434. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  99435. validateShaderPrograms: boolean;
  99436. /**
  99437. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  99438. * This can provide greater z depth for distant objects.
  99439. */
  99440. useReverseDepthBuffer: boolean;
  99441. /**
  99442. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  99443. */
  99444. disableUniformBuffers: boolean;
  99445. /** @hidden */
  99446. _uniformBuffers: UniformBuffer[];
  99447. /**
  99448. * Gets a boolean indicating that the engine supports uniform buffers
  99449. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  99450. */
  99451. readonly supportsUniformBuffers: boolean;
  99452. /** @hidden */
  99453. _gl: WebGLRenderingContext;
  99454. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  99455. protected _windowIsBackground: boolean;
  99456. protected _webGLVersion: number;
  99457. protected _creationOptions: EngineOptions;
  99458. protected _highPrecisionShadersAllowed: boolean;
  99459. /** @hidden */
  99460. readonly _shouldUseHighPrecisionShader: boolean;
  99461. /**
  99462. * Gets a boolean indicating that only power of 2 textures are supported
  99463. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  99464. */
  99465. readonly needPOTTextures: boolean;
  99466. /** @hidden */
  99467. _badOS: boolean;
  99468. /** @hidden */
  99469. _badDesktopOS: boolean;
  99470. private _hardwareScalingLevel;
  99471. /** @hidden */
  99472. _caps: EngineCapabilities;
  99473. private _isStencilEnable;
  99474. protected _colorWrite: boolean;
  99475. private _glVersion;
  99476. private _glRenderer;
  99477. private _glVendor;
  99478. /** @hidden */
  99479. _videoTextureSupported: boolean;
  99480. protected _renderingQueueLaunched: boolean;
  99481. protected _activeRenderLoops: (() => void)[];
  99482. /**
  99483. * Observable signaled when a context lost event is raised
  99484. */
  99485. onContextLostObservable: Observable<ThinEngine>;
  99486. /**
  99487. * Observable signaled when a context restored event is raised
  99488. */
  99489. onContextRestoredObservable: Observable<ThinEngine>;
  99490. private _onContextLost;
  99491. private _onContextRestored;
  99492. protected _contextWasLost: boolean;
  99493. /** @hidden */
  99494. _doNotHandleContextLost: boolean;
  99495. /**
  99496. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  99497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  99498. */
  99499. doNotHandleContextLost: boolean;
  99500. /**
  99501. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  99502. */
  99503. disableVertexArrayObjects: boolean;
  99504. /** @hidden */
  99505. protected _depthCullingState: DepthCullingState;
  99506. /** @hidden */
  99507. protected _stencilState: StencilState;
  99508. /** @hidden */
  99509. protected _alphaState: AlphaState;
  99510. /** @hidden */
  99511. _internalTexturesCache: InternalTexture[];
  99512. /** @hidden */
  99513. protected _activeChannel: number;
  99514. private _currentTextureChannel;
  99515. /** @hidden */
  99516. protected _boundTexturesCache: {
  99517. [key: string]: Nullable<InternalTexture>;
  99518. };
  99519. /** @hidden */
  99520. protected _currentEffect: Nullable<Effect>;
  99521. /** @hidden */
  99522. protected _currentProgram: Nullable<WebGLProgram>;
  99523. private _compiledEffects;
  99524. private _vertexAttribArraysEnabled;
  99525. /** @hidden */
  99526. protected _cachedViewport: Nullable<IViewportLike>;
  99527. private _cachedVertexArrayObject;
  99528. /** @hidden */
  99529. protected _cachedVertexBuffers: any;
  99530. /** @hidden */
  99531. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  99532. /** @hidden */
  99533. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  99534. /** @hidden */
  99535. _currentRenderTarget: Nullable<InternalTexture>;
  99536. private _uintIndicesCurrentlySet;
  99537. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  99538. /** @hidden */
  99539. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  99540. private _currentBufferPointers;
  99541. private _currentInstanceLocations;
  99542. private _currentInstanceBuffers;
  99543. private _textureUnits;
  99544. /** @hidden */
  99545. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99546. /** @hidden */
  99547. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  99548. /** @hidden */
  99549. _boundRenderFunction: any;
  99550. private _vaoRecordInProgress;
  99551. private _mustWipeVertexAttributes;
  99552. private _emptyTexture;
  99553. private _emptyCubeTexture;
  99554. private _emptyTexture3D;
  99555. private _emptyTexture2DArray;
  99556. /** @hidden */
  99557. _frameHandler: number;
  99558. private _nextFreeTextureSlots;
  99559. private _maxSimultaneousTextures;
  99560. private _activeRequests;
  99561. protected _texturesSupported: string[];
  99562. /** @hidden */
  99563. _textureFormatInUse: Nullable<string>;
  99564. protected readonly _supportsHardwareTextureRescaling: boolean;
  99565. /**
  99566. * Gets the list of texture formats supported
  99567. */
  99568. readonly texturesSupported: Array<string>;
  99569. /**
  99570. * Gets the list of texture formats in use
  99571. */
  99572. readonly textureFormatInUse: Nullable<string>;
  99573. /**
  99574. * Gets the current viewport
  99575. */
  99576. readonly currentViewport: Nullable<IViewportLike>;
  99577. /**
  99578. * Gets the default empty texture
  99579. */
  99580. readonly emptyTexture: InternalTexture;
  99581. /**
  99582. * Gets the default empty 3D texture
  99583. */
  99584. readonly emptyTexture3D: InternalTexture;
  99585. /**
  99586. * Gets the default empty 2D array texture
  99587. */
  99588. readonly emptyTexture2DArray: InternalTexture;
  99589. /**
  99590. * Gets the default empty cube texture
  99591. */
  99592. readonly emptyCubeTexture: InternalTexture;
  99593. /**
  99594. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  99595. */
  99596. readonly premultipliedAlpha: boolean;
  99597. /**
  99598. * Observable event triggered before each texture is initialized
  99599. */
  99600. onBeforeTextureInitObservable: Observable<Texture>;
  99601. /**
  99602. * Creates a new engine
  99603. * @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
  99604. * @param antialias defines enable antialiasing (default: false)
  99605. * @param options defines further options to be sent to the getContext() function
  99606. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99607. */
  99608. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99609. private _rebuildInternalTextures;
  99610. private _rebuildEffects;
  99611. /**
  99612. * Gets a boolean indicating if all created effects are ready
  99613. * @returns true if all effects are ready
  99614. */
  99615. areAllEffectsReady(): boolean;
  99616. protected _rebuildBuffers(): void;
  99617. private _initGLContext;
  99618. /**
  99619. * Gets version of the current webGL context
  99620. */
  99621. readonly webGLVersion: number;
  99622. /**
  99623. * Gets a string idenfifying the name of the class
  99624. * @returns "Engine" string
  99625. */
  99626. getClassName(): string;
  99627. /**
  99628. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  99629. */
  99630. readonly isStencilEnable: boolean;
  99631. /** @hidden */
  99632. _prepareWorkingCanvas(): void;
  99633. /**
  99634. * Reset the texture cache to empty state
  99635. */
  99636. resetTextureCache(): void;
  99637. /**
  99638. * Gets an object containing information about the current webGL context
  99639. * @returns an object containing the vender, the renderer and the version of the current webGL context
  99640. */
  99641. getGlInfo(): {
  99642. vendor: string;
  99643. renderer: string;
  99644. version: string;
  99645. };
  99646. /**
  99647. * Defines the hardware scaling level.
  99648. * By default the hardware scaling level is computed from the window device ratio.
  99649. * 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.
  99650. * @param level defines the level to use
  99651. */
  99652. setHardwareScalingLevel(level: number): void;
  99653. /**
  99654. * Gets the current hardware scaling level.
  99655. * By default the hardware scaling level is computed from the window device ratio.
  99656. * 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.
  99657. * @returns a number indicating the current hardware scaling level
  99658. */
  99659. getHardwareScalingLevel(): number;
  99660. /**
  99661. * Gets the list of loaded textures
  99662. * @returns an array containing all loaded textures
  99663. */
  99664. getLoadedTexturesCache(): InternalTexture[];
  99665. /**
  99666. * Gets the object containing all engine capabilities
  99667. * @returns the EngineCapabilities object
  99668. */
  99669. getCaps(): EngineCapabilities;
  99670. /**
  99671. * stop executing a render loop function and remove it from the execution array
  99672. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  99673. */
  99674. stopRenderLoop(renderFunction?: () => void): void;
  99675. /** @hidden */
  99676. _renderLoop(): void;
  99677. /**
  99678. * Gets the HTML canvas attached with the current webGL context
  99679. * @returns a HTML canvas
  99680. */
  99681. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  99682. /**
  99683. * Gets host window
  99684. * @returns the host window object
  99685. */
  99686. getHostWindow(): Nullable<Window>;
  99687. /**
  99688. * Gets the current render width
  99689. * @param useScreen defines if screen size must be used (or the current render target if any)
  99690. * @returns a number defining the current render width
  99691. */
  99692. getRenderWidth(useScreen?: boolean): number;
  99693. /**
  99694. * Gets the current render height
  99695. * @param useScreen defines if screen size must be used (or the current render target if any)
  99696. * @returns a number defining the current render height
  99697. */
  99698. getRenderHeight(useScreen?: boolean): number;
  99699. /**
  99700. * Can be used to override the current requestAnimationFrame requester.
  99701. * @hidden
  99702. */
  99703. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  99704. /**
  99705. * Register and execute a render loop. The engine can have more than one render function
  99706. * @param renderFunction defines the function to continuously execute
  99707. */
  99708. runRenderLoop(renderFunction: () => void): void;
  99709. /**
  99710. * Clear the current render buffer or the current render target (if any is set up)
  99711. * @param color defines the color to use
  99712. * @param backBuffer defines if the back buffer must be cleared
  99713. * @param depth defines if the depth buffer must be cleared
  99714. * @param stencil defines if the stencil buffer must be cleared
  99715. */
  99716. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99717. private _viewportCached;
  99718. /** @hidden */
  99719. _viewport(x: number, y: number, width: number, height: number): void;
  99720. /**
  99721. * Set the WebGL's viewport
  99722. * @param viewport defines the viewport element to be used
  99723. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  99724. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  99725. */
  99726. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  99727. /**
  99728. * Begin a new frame
  99729. */
  99730. beginFrame(): void;
  99731. /**
  99732. * Enf the current frame
  99733. */
  99734. endFrame(): void;
  99735. /**
  99736. * Resize the view according to the canvas' size
  99737. */
  99738. resize(): void;
  99739. /**
  99740. * Force a specific size of the canvas
  99741. * @param width defines the new canvas' width
  99742. * @param height defines the new canvas' height
  99743. */
  99744. setSize(width: number, height: number): void;
  99745. /**
  99746. * Binds the frame buffer to the specified texture.
  99747. * @param texture The texture to render to or null for the default canvas
  99748. * @param faceIndex The face of the texture to render to in case of cube texture
  99749. * @param requiredWidth The width of the target to render to
  99750. * @param requiredHeight The height of the target to render to
  99751. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  99752. * @param depthStencilTexture The depth stencil texture to use to render
  99753. * @param lodLevel defines le lod level to bind to the frame buffer
  99754. */
  99755. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  99756. /** @hidden */
  99757. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  99758. /**
  99759. * Unbind the current render target texture from the webGL context
  99760. * @param texture defines the render target texture to unbind
  99761. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  99762. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  99763. */
  99764. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99765. /**
  99766. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  99767. */
  99768. flushFramebuffer(): void;
  99769. /**
  99770. * Unbind the current render target and bind the default framebuffer
  99771. */
  99772. restoreDefaultFramebuffer(): void;
  99773. /** @hidden */
  99774. protected _resetVertexBufferBinding(): void;
  99775. /**
  99776. * Creates a vertex buffer
  99777. * @param data the data for the vertex buffer
  99778. * @returns the new WebGL static buffer
  99779. */
  99780. createVertexBuffer(data: DataArray): DataBuffer;
  99781. private _createVertexBuffer;
  99782. /**
  99783. * Creates a dynamic vertex buffer
  99784. * @param data the data for the dynamic vertex buffer
  99785. * @returns the new WebGL dynamic buffer
  99786. */
  99787. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  99788. protected _resetIndexBufferBinding(): void;
  99789. /**
  99790. * Creates a new index buffer
  99791. * @param indices defines the content of the index buffer
  99792. * @param updatable defines if the index buffer must be updatable
  99793. * @returns a new webGL buffer
  99794. */
  99795. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  99796. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  99797. /**
  99798. * Bind a webGL buffer to the webGL context
  99799. * @param buffer defines the buffer to bind
  99800. */
  99801. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  99802. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  99803. private bindBuffer;
  99804. /**
  99805. * update the bound buffer with the given data
  99806. * @param data defines the data to update
  99807. */
  99808. updateArrayBuffer(data: Float32Array): void;
  99809. private _vertexAttribPointer;
  99810. private _bindIndexBufferWithCache;
  99811. private _bindVertexBuffersAttributes;
  99812. /**
  99813. * Records a vertex array object
  99814. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  99815. * @param vertexBuffers defines the list of vertex buffers to store
  99816. * @param indexBuffer defines the index buffer to store
  99817. * @param effect defines the effect to store
  99818. * @returns the new vertex array object
  99819. */
  99820. recordVertexArrayObject(vertexBuffers: {
  99821. [key: string]: VertexBuffer;
  99822. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  99823. /**
  99824. * Bind a specific vertex array object
  99825. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  99826. * @param vertexArrayObject defines the vertex array object to bind
  99827. * @param indexBuffer defines the index buffer to bind
  99828. */
  99829. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  99830. /**
  99831. * Bind webGl buffers directly to the webGL context
  99832. * @param vertexBuffer defines the vertex buffer to bind
  99833. * @param indexBuffer defines the index buffer to bind
  99834. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  99835. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  99836. * @param effect defines the effect associated with the vertex buffer
  99837. */
  99838. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  99839. private _unbindVertexArrayObject;
  99840. /**
  99841. * Bind a list of vertex buffers to the webGL context
  99842. * @param vertexBuffers defines the list of vertex buffers to bind
  99843. * @param indexBuffer defines the index buffer to bind
  99844. * @param effect defines the effect associated with the vertex buffers
  99845. */
  99846. bindBuffers(vertexBuffers: {
  99847. [key: string]: Nullable<VertexBuffer>;
  99848. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  99849. /**
  99850. * Unbind all instance attributes
  99851. */
  99852. unbindInstanceAttributes(): void;
  99853. /**
  99854. * Release and free the memory of a vertex array object
  99855. * @param vao defines the vertex array object to delete
  99856. */
  99857. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  99858. /** @hidden */
  99859. _releaseBuffer(buffer: DataBuffer): boolean;
  99860. protected _deleteBuffer(buffer: DataBuffer): void;
  99861. /**
  99862. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  99863. * @param instancesBuffer defines the webGL buffer to update and bind
  99864. * @param data defines the data to store in the buffer
  99865. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  99866. */
  99867. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  99868. /**
  99869. * Apply all cached states (depth, culling, stencil and alpha)
  99870. */
  99871. applyStates(): void;
  99872. /**
  99873. * Send a draw order
  99874. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  99875. * @param indexStart defines the starting index
  99876. * @param indexCount defines the number of index to draw
  99877. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99878. */
  99879. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99880. /**
  99881. * Draw a list of points
  99882. * @param verticesStart defines the index of first vertex to draw
  99883. * @param verticesCount defines the count of vertices to draw
  99884. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99885. */
  99886. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99887. /**
  99888. * Draw a list of unindexed primitives
  99889. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  99890. * @param verticesStart defines the index of first vertex to draw
  99891. * @param verticesCount defines the count of vertices to draw
  99892. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99893. */
  99894. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99895. /**
  99896. * Draw a list of indexed primitives
  99897. * @param fillMode defines the primitive to use
  99898. * @param indexStart defines the starting index
  99899. * @param indexCount defines the number of index to draw
  99900. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99901. */
  99902. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99903. /**
  99904. * Draw a list of unindexed primitives
  99905. * @param fillMode defines the primitive to use
  99906. * @param verticesStart defines the index of first vertex to draw
  99907. * @param verticesCount defines the count of vertices to draw
  99908. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99909. */
  99910. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99911. private _drawMode;
  99912. /** @hidden */
  99913. protected _reportDrawCall(): void;
  99914. /** @hidden */
  99915. _releaseEffect(effect: Effect): void;
  99916. /** @hidden */
  99917. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99918. /**
  99919. * Create a new effect (used to store vertex/fragment shaders)
  99920. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  99921. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  99922. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  99923. * @param samplers defines an array of string used to represent textures
  99924. * @param defines defines the string containing the defines to use to compile the shaders
  99925. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  99926. * @param onCompiled defines a function to call when the effect creation is successful
  99927. * @param onError defines a function to call when the effect creation has failed
  99928. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  99929. * @returns the new Effect
  99930. */
  99931. 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;
  99932. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  99933. private _compileShader;
  99934. private _compileRawShader;
  99935. /**
  99936. * Directly creates a webGL program
  99937. * @param pipelineContext defines the pipeline context to attach to
  99938. * @param vertexCode defines the vertex shader code to use
  99939. * @param fragmentCode defines the fragment shader code to use
  99940. * @param context defines the webGL context to use (if not set, the current one will be used)
  99941. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  99942. * @returns the new webGL program
  99943. */
  99944. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99945. /**
  99946. * Creates a webGL program
  99947. * @param pipelineContext defines the pipeline context to attach to
  99948. * @param vertexCode defines the vertex shader code to use
  99949. * @param fragmentCode defines the fragment shader code to use
  99950. * @param defines defines the string containing the defines to use to compile the shaders
  99951. * @param context defines the webGL context to use (if not set, the current one will be used)
  99952. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  99953. * @returns the new webGL program
  99954. */
  99955. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99956. /**
  99957. * Creates a new pipeline context
  99958. * @returns the new pipeline
  99959. */
  99960. createPipelineContext(): IPipelineContext;
  99961. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99962. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  99963. /** @hidden */
  99964. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  99965. /** @hidden */
  99966. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  99967. /** @hidden */
  99968. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  99969. /**
  99970. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  99971. * @param pipelineContext defines the pipeline context to use
  99972. * @param uniformsNames defines the list of uniform names
  99973. * @returns an array of webGL uniform locations
  99974. */
  99975. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  99976. /**
  99977. * Gets the lsit of active attributes for a given webGL program
  99978. * @param pipelineContext defines the pipeline context to use
  99979. * @param attributesNames defines the list of attribute names to get
  99980. * @returns an array of indices indicating the offset of each attribute
  99981. */
  99982. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  99983. /**
  99984. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  99985. * @param effect defines the effect to activate
  99986. */
  99987. enableEffect(effect: Nullable<Effect>): void;
  99988. /**
  99989. * Set the value of an uniform to a number (int)
  99990. * @param uniform defines the webGL uniform location where to store the value
  99991. * @param value defines the int number to store
  99992. */
  99993. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  99994. /**
  99995. * Set the value of an uniform to an array of int32
  99996. * @param uniform defines the webGL uniform location where to store the value
  99997. * @param array defines the array of int32 to store
  99998. */
  99999. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100000. /**
  100001. * Set the value of an uniform to an array of int32 (stored as vec2)
  100002. * @param uniform defines the webGL uniform location where to store the value
  100003. * @param array defines the array of int32 to store
  100004. */
  100005. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100006. /**
  100007. * Set the value of an uniform to an array of int32 (stored as vec3)
  100008. * @param uniform defines the webGL uniform location where to store the value
  100009. * @param array defines the array of int32 to store
  100010. */
  100011. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100012. /**
  100013. * Set the value of an uniform to an array of int32 (stored as vec4)
  100014. * @param uniform defines the webGL uniform location where to store the value
  100015. * @param array defines the array of int32 to store
  100016. */
  100017. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100018. /**
  100019. * Set the value of an uniform to an array of number
  100020. * @param uniform defines the webGL uniform location where to store the value
  100021. * @param array defines the array of number to store
  100022. */
  100023. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100024. /**
  100025. * Set the value of an uniform to an array of number (stored as vec2)
  100026. * @param uniform defines the webGL uniform location where to store the value
  100027. * @param array defines the array of number to store
  100028. */
  100029. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100030. /**
  100031. * Set the value of an uniform to an array of number (stored as vec3)
  100032. * @param uniform defines the webGL uniform location where to store the value
  100033. * @param array defines the array of number to store
  100034. */
  100035. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100036. /**
  100037. * Set the value of an uniform to an array of number (stored as vec4)
  100038. * @param uniform defines the webGL uniform location where to store the value
  100039. * @param array defines the array of number to store
  100040. */
  100041. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100042. /**
  100043. * Set the value of an uniform to an array of float32 (stored as matrices)
  100044. * @param uniform defines the webGL uniform location where to store the value
  100045. * @param matrices defines the array of float32 to store
  100046. */
  100047. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  100048. /**
  100049. * Set the value of an uniform to a matrix (3x3)
  100050. * @param uniform defines the webGL uniform location where to store the value
  100051. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  100052. */
  100053. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100054. /**
  100055. * Set the value of an uniform to a matrix (2x2)
  100056. * @param uniform defines the webGL uniform location where to store the value
  100057. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  100058. */
  100059. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100060. /**
  100061. * Set the value of an uniform to a number (float)
  100062. * @param uniform defines the webGL uniform location where to store the value
  100063. * @param value defines the float number to store
  100064. */
  100065. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  100066. /**
  100067. * Set the value of an uniform to a vec2
  100068. * @param uniform defines the webGL uniform location where to store the value
  100069. * @param x defines the 1st component of the value
  100070. * @param y defines the 2nd component of the value
  100071. */
  100072. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  100073. /**
  100074. * Set the value of an uniform to a vec3
  100075. * @param uniform defines the webGL uniform location where to store the value
  100076. * @param x defines the 1st component of the value
  100077. * @param y defines the 2nd component of the value
  100078. * @param z defines the 3rd component of the value
  100079. */
  100080. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  100081. /**
  100082. * Set the value of an uniform to a vec4
  100083. * @param uniform defines the webGL uniform location where to store the value
  100084. * @param x defines the 1st component of the value
  100085. * @param y defines the 2nd component of the value
  100086. * @param z defines the 3rd component of the value
  100087. * @param w defines the 4th component of the value
  100088. */
  100089. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  100090. /**
  100091. * Gets the depth culling state manager
  100092. */
  100093. readonly depthCullingState: DepthCullingState;
  100094. /**
  100095. * Gets the alpha state manager
  100096. */
  100097. readonly alphaState: AlphaState;
  100098. /**
  100099. * Gets the stencil state manager
  100100. */
  100101. readonly stencilState: StencilState;
  100102. /**
  100103. * Clears the list of texture accessible through engine.
  100104. * This can help preventing texture load conflict due to name collision.
  100105. */
  100106. clearInternalTexturesCache(): void;
  100107. /**
  100108. * Force the entire cache to be cleared
  100109. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  100110. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  100111. */
  100112. wipeCaches(bruteForce?: boolean): void;
  100113. /** @hidden */
  100114. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  100115. min: number;
  100116. mag: number;
  100117. };
  100118. /** @hidden */
  100119. _createTexture(): WebGLTexture;
  100120. /**
  100121. * Usually called from Texture.ts.
  100122. * Passed information to create a WebGLTexture
  100123. * @param urlArg defines a value which contains one of the following:
  100124. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  100125. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  100126. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  100127. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  100128. * @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)
  100129. * @param scene needed for loading to the correct scene
  100130. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  100131. * @param onLoad optional callback to be called upon successful completion
  100132. * @param onError optional callback to be called upon failure
  100133. * @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
  100134. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  100135. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  100136. * @param forcedExtension defines the extension to use to pick the right loader
  100137. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  100138. * @param mimeType defines an optional mime type
  100139. * @returns a InternalTexture for assignment back into BABYLON.Texture
  100140. */
  100141. 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;
  100142. /**
  100143. * @hidden
  100144. */
  100145. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100146. /**
  100147. * Creates a raw texture
  100148. * @param data defines the data to store in the texture
  100149. * @param width defines the width of the texture
  100150. * @param height defines the height of the texture
  100151. * @param format defines the format of the data
  100152. * @param generateMipMaps defines if the engine should generate the mip levels
  100153. * @param invertY defines if data must be stored with Y axis inverted
  100154. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  100155. * @param compression defines the compression used (null by default)
  100156. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  100157. * @returns the raw texture inside an InternalTexture
  100158. */
  100159. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  100160. /**
  100161. * Creates a new raw cube texture
  100162. * @param data defines the array of data to use to create each face
  100163. * @param size defines the size of the textures
  100164. * @param format defines the format of the data
  100165. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  100166. * @param generateMipMaps defines if the engine should generate the mip levels
  100167. * @param invertY defines if data must be stored with Y axis inverted
  100168. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100169. * @param compression defines the compression used (null by default)
  100170. * @returns the cube texture as an InternalTexture
  100171. */
  100172. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  100173. /**
  100174. * Creates a new raw 3D texture
  100175. * @param data defines the data used to create the texture
  100176. * @param width defines the width of the texture
  100177. * @param height defines the height of the texture
  100178. * @param depth defines the depth of the texture
  100179. * @param format defines the format of the texture
  100180. * @param generateMipMaps defines if the engine must generate mip levels
  100181. * @param invertY defines if data must be stored with Y axis inverted
  100182. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100183. * @param compression defines the compressed used (can be null)
  100184. * @param textureType defines the compressed used (can be null)
  100185. * @returns a new raw 3D texture (stored in an InternalTexture)
  100186. */
  100187. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100188. /**
  100189. * Creates a new raw 2D array texture
  100190. * @param data defines the data used to create the texture
  100191. * @param width defines the width of the texture
  100192. * @param height defines the height of the texture
  100193. * @param depth defines the number of layers of the texture
  100194. * @param format defines the format of the texture
  100195. * @param generateMipMaps defines if the engine must generate mip levels
  100196. * @param invertY defines if data must be stored with Y axis inverted
  100197. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100198. * @param compression defines the compressed used (can be null)
  100199. * @param textureType defines the compressed used (can be null)
  100200. * @returns a new raw 2D array texture (stored in an InternalTexture)
  100201. */
  100202. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100203. private _unpackFlipYCached;
  100204. /**
  100205. * In case you are sharing the context with other applications, it might
  100206. * be interested to not cache the unpack flip y state to ensure a consistent
  100207. * value would be set.
  100208. */
  100209. enableUnpackFlipYCached: boolean;
  100210. /** @hidden */
  100211. _unpackFlipY(value: boolean): void;
  100212. /** @hidden */
  100213. _getUnpackAlignement(): number;
  100214. /**
  100215. * Update the sampling mode of a given texture
  100216. * @param samplingMode defines the required sampling mode
  100217. * @param texture defines the texture to update
  100218. */
  100219. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100220. /** @hidden */
  100221. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  100222. width: number;
  100223. height: number;
  100224. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  100225. /** @hidden */
  100226. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100227. /** @hidden */
  100228. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  100229. /** @hidden */
  100230. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100231. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  100232. private _prepareWebGLTexture;
  100233. /** @hidden */
  100234. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  100235. /** @hidden */
  100236. _releaseFramebufferObjects(texture: InternalTexture): void;
  100237. /** @hidden */
  100238. _releaseTexture(texture: InternalTexture): void;
  100239. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  100240. protected _setProgram(program: WebGLProgram): void;
  100241. protected _boundUniforms: {
  100242. [key: number]: WebGLUniformLocation;
  100243. };
  100244. /**
  100245. * Binds an effect to the webGL context
  100246. * @param effect defines the effect to bind
  100247. */
  100248. bindSamplers(effect: Effect): void;
  100249. private _activateCurrentTexture;
  100250. /** @hidden */
  100251. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  100252. /** @hidden */
  100253. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  100254. /**
  100255. * Unbind all textures from the webGL context
  100256. */
  100257. unbindAllTextures(): void;
  100258. /**
  100259. * Sets a texture to the according uniform.
  100260. * @param channel The texture channel
  100261. * @param uniform The uniform to set
  100262. * @param texture The texture to apply
  100263. */
  100264. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  100265. private _bindSamplerUniformToChannel;
  100266. private _getTextureWrapMode;
  100267. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  100268. /**
  100269. * Sets an array of texture to the webGL context
  100270. * @param channel defines the channel where the texture array must be set
  100271. * @param uniform defines the associated uniform location
  100272. * @param textures defines the array of textures to bind
  100273. */
  100274. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  100275. /** @hidden */
  100276. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  100277. private _setTextureParameterFloat;
  100278. private _setTextureParameterInteger;
  100279. /**
  100280. * Unbind all vertex attributes from the webGL context
  100281. */
  100282. unbindAllAttributes(): void;
  100283. /**
  100284. * 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
  100285. */
  100286. releaseEffects(): void;
  100287. /**
  100288. * Dispose and release all associated resources
  100289. */
  100290. dispose(): void;
  100291. /**
  100292. * Attach a new callback raised when context lost event is fired
  100293. * @param callback defines the callback to call
  100294. */
  100295. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100296. /**
  100297. * Attach a new callback raised when context restored event is fired
  100298. * @param callback defines the callback to call
  100299. */
  100300. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100301. /**
  100302. * Get the current error code of the webGL context
  100303. * @returns the error code
  100304. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100305. */
  100306. getError(): number;
  100307. private _canRenderToFloatFramebuffer;
  100308. private _canRenderToHalfFloatFramebuffer;
  100309. private _canRenderToFramebuffer;
  100310. /** @hidden */
  100311. _getWebGLTextureType(type: number): number;
  100312. /** @hidden */
  100313. _getInternalFormat(format: number): number;
  100314. /** @hidden */
  100315. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  100316. /** @hidden */
  100317. _getRGBAMultiSampleBufferFormat(type: number): number;
  100318. /** @hidden */
  100319. _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;
  100320. /**
  100321. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  100322. * @returns true if the engine can be created
  100323. * @ignorenaming
  100324. */
  100325. static isSupported(): boolean;
  100326. /**
  100327. * Find the next highest power of two.
  100328. * @param x Number to start search from.
  100329. * @return Next highest power of two.
  100330. */
  100331. static CeilingPOT(x: number): number;
  100332. /**
  100333. * Find the next lowest power of two.
  100334. * @param x Number to start search from.
  100335. * @return Next lowest power of two.
  100336. */
  100337. static FloorPOT(x: number): number;
  100338. /**
  100339. * Find the nearest power of two.
  100340. * @param x Number to start search from.
  100341. * @return Next nearest power of two.
  100342. */
  100343. static NearestPOT(x: number): number;
  100344. /**
  100345. * Get the closest exponent of two
  100346. * @param value defines the value to approximate
  100347. * @param max defines the maximum value to return
  100348. * @param mode defines how to define the closest value
  100349. * @returns closest exponent of two of the given value
  100350. */
  100351. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  100352. /**
  100353. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  100354. * @param func - the function to be called
  100355. * @param requester - the object that will request the next frame. Falls back to window.
  100356. * @returns frame number
  100357. */
  100358. static QueueNewFrame(func: () => void, requester?: any): number;
  100359. /**
  100360. * Gets host document
  100361. * @returns the host document object
  100362. */
  100363. getHostDocument(): Document;
  100364. }
  100365. }
  100366. declare module BABYLON {
  100367. /**
  100368. * Class representing spherical harmonics coefficients to the 3rd degree
  100369. */
  100370. export class SphericalHarmonics {
  100371. /**
  100372. * Defines whether or not the harmonics have been prescaled for rendering.
  100373. */
  100374. preScaled: boolean;
  100375. /**
  100376. * The l0,0 coefficients of the spherical harmonics
  100377. */
  100378. l00: Vector3;
  100379. /**
  100380. * The l1,-1 coefficients of the spherical harmonics
  100381. */
  100382. l1_1: Vector3;
  100383. /**
  100384. * The l1,0 coefficients of the spherical harmonics
  100385. */
  100386. l10: Vector3;
  100387. /**
  100388. * The l1,1 coefficients of the spherical harmonics
  100389. */
  100390. l11: Vector3;
  100391. /**
  100392. * The l2,-2 coefficients of the spherical harmonics
  100393. */
  100394. l2_2: Vector3;
  100395. /**
  100396. * The l2,-1 coefficients of the spherical harmonics
  100397. */
  100398. l2_1: Vector3;
  100399. /**
  100400. * The l2,0 coefficients of the spherical harmonics
  100401. */
  100402. l20: Vector3;
  100403. /**
  100404. * The l2,1 coefficients of the spherical harmonics
  100405. */
  100406. l21: Vector3;
  100407. /**
  100408. * The l2,2 coefficients of the spherical harmonics
  100409. */
  100410. l22: Vector3;
  100411. /**
  100412. * Adds a light to the spherical harmonics
  100413. * @param direction the direction of the light
  100414. * @param color the color of the light
  100415. * @param deltaSolidAngle the delta solid angle of the light
  100416. */
  100417. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  100418. /**
  100419. * Scales the spherical harmonics by the given amount
  100420. * @param scale the amount to scale
  100421. */
  100422. scaleInPlace(scale: number): void;
  100423. /**
  100424. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  100425. *
  100426. * ```
  100427. * E_lm = A_l * L_lm
  100428. * ```
  100429. *
  100430. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  100431. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  100432. * the scaling factors are given in equation 9.
  100433. */
  100434. convertIncidentRadianceToIrradiance(): void;
  100435. /**
  100436. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  100437. *
  100438. * ```
  100439. * L = (1/pi) * E * rho
  100440. * ```
  100441. *
  100442. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  100443. */
  100444. convertIrradianceToLambertianRadiance(): void;
  100445. /**
  100446. * Integrates the reconstruction coefficients directly in to the SH preventing further
  100447. * required operations at run time.
  100448. *
  100449. * This is simply done by scaling back the SH with Ylm constants parameter.
  100450. * The trigonometric part being applied by the shader at run time.
  100451. */
  100452. preScaleForRendering(): void;
  100453. /**
  100454. * Constructs a spherical harmonics from an array.
  100455. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  100456. * @returns the spherical harmonics
  100457. */
  100458. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  100459. /**
  100460. * Gets the spherical harmonics from polynomial
  100461. * @param polynomial the spherical polynomial
  100462. * @returns the spherical harmonics
  100463. */
  100464. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  100465. }
  100466. /**
  100467. * Class representing spherical polynomial coefficients to the 3rd degree
  100468. */
  100469. export class SphericalPolynomial {
  100470. private _harmonics;
  100471. /**
  100472. * The spherical harmonics used to create the polynomials.
  100473. */
  100474. readonly preScaledHarmonics: SphericalHarmonics;
  100475. /**
  100476. * The x coefficients of the spherical polynomial
  100477. */
  100478. x: Vector3;
  100479. /**
  100480. * The y coefficients of the spherical polynomial
  100481. */
  100482. y: Vector3;
  100483. /**
  100484. * The z coefficients of the spherical polynomial
  100485. */
  100486. z: Vector3;
  100487. /**
  100488. * The xx coefficients of the spherical polynomial
  100489. */
  100490. xx: Vector3;
  100491. /**
  100492. * The yy coefficients of the spherical polynomial
  100493. */
  100494. yy: Vector3;
  100495. /**
  100496. * The zz coefficients of the spherical polynomial
  100497. */
  100498. zz: Vector3;
  100499. /**
  100500. * The xy coefficients of the spherical polynomial
  100501. */
  100502. xy: Vector3;
  100503. /**
  100504. * The yz coefficients of the spherical polynomial
  100505. */
  100506. yz: Vector3;
  100507. /**
  100508. * The zx coefficients of the spherical polynomial
  100509. */
  100510. zx: Vector3;
  100511. /**
  100512. * Adds an ambient color to the spherical polynomial
  100513. * @param color the color to add
  100514. */
  100515. addAmbient(color: Color3): void;
  100516. /**
  100517. * Scales the spherical polynomial by the given amount
  100518. * @param scale the amount to scale
  100519. */
  100520. scaleInPlace(scale: number): void;
  100521. /**
  100522. * Gets the spherical polynomial from harmonics
  100523. * @param harmonics the spherical harmonics
  100524. * @returns the spherical polynomial
  100525. */
  100526. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  100527. /**
  100528. * Constructs a spherical polynomial from an array.
  100529. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  100530. * @returns the spherical polynomial
  100531. */
  100532. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  100533. }
  100534. }
  100535. declare module BABYLON {
  100536. /**
  100537. * Defines the source of the internal texture
  100538. */
  100539. export enum InternalTextureSource {
  100540. /**
  100541. * The source of the texture data is unknown
  100542. */
  100543. Unknown = 0,
  100544. /**
  100545. * Texture data comes from an URL
  100546. */
  100547. Url = 1,
  100548. /**
  100549. * Texture data is only used for temporary storage
  100550. */
  100551. Temp = 2,
  100552. /**
  100553. * Texture data comes from raw data (ArrayBuffer)
  100554. */
  100555. Raw = 3,
  100556. /**
  100557. * Texture content is dynamic (video or dynamic texture)
  100558. */
  100559. Dynamic = 4,
  100560. /**
  100561. * Texture content is generated by rendering to it
  100562. */
  100563. RenderTarget = 5,
  100564. /**
  100565. * Texture content is part of a multi render target process
  100566. */
  100567. MultiRenderTarget = 6,
  100568. /**
  100569. * Texture data comes from a cube data file
  100570. */
  100571. Cube = 7,
  100572. /**
  100573. * Texture data comes from a raw cube data
  100574. */
  100575. CubeRaw = 8,
  100576. /**
  100577. * Texture data come from a prefiltered cube data file
  100578. */
  100579. CubePrefiltered = 9,
  100580. /**
  100581. * Texture content is raw 3D data
  100582. */
  100583. Raw3D = 10,
  100584. /**
  100585. * Texture content is raw 2D array data
  100586. */
  100587. Raw2DArray = 11,
  100588. /**
  100589. * Texture content is a depth texture
  100590. */
  100591. Depth = 12,
  100592. /**
  100593. * Texture data comes from a raw cube data encoded with RGBD
  100594. */
  100595. CubeRawRGBD = 13
  100596. }
  100597. /**
  100598. * Class used to store data associated with WebGL texture data for the engine
  100599. * This class should not be used directly
  100600. */
  100601. export class InternalTexture {
  100602. /** @hidden */
  100603. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  100604. /**
  100605. * Defines if the texture is ready
  100606. */
  100607. isReady: boolean;
  100608. /**
  100609. * Defines if the texture is a cube texture
  100610. */
  100611. isCube: boolean;
  100612. /**
  100613. * Defines if the texture contains 3D data
  100614. */
  100615. is3D: boolean;
  100616. /**
  100617. * Defines if the texture contains 2D array data
  100618. */
  100619. is2DArray: boolean;
  100620. /**
  100621. * Defines if the texture contains multiview data
  100622. */
  100623. isMultiview: boolean;
  100624. /**
  100625. * Gets the URL used to load this texture
  100626. */
  100627. url: string;
  100628. /**
  100629. * Gets the sampling mode of the texture
  100630. */
  100631. samplingMode: number;
  100632. /**
  100633. * Gets a boolean indicating if the texture needs mipmaps generation
  100634. */
  100635. generateMipMaps: boolean;
  100636. /**
  100637. * Gets the number of samples used by the texture (WebGL2+ only)
  100638. */
  100639. samples: number;
  100640. /**
  100641. * Gets the type of the texture (int, float...)
  100642. */
  100643. type: number;
  100644. /**
  100645. * Gets the format of the texture (RGB, RGBA...)
  100646. */
  100647. format: number;
  100648. /**
  100649. * Observable called when the texture is loaded
  100650. */
  100651. onLoadedObservable: Observable<InternalTexture>;
  100652. /**
  100653. * Gets the width of the texture
  100654. */
  100655. width: number;
  100656. /**
  100657. * Gets the height of the texture
  100658. */
  100659. height: number;
  100660. /**
  100661. * Gets the depth of the texture
  100662. */
  100663. depth: number;
  100664. /**
  100665. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  100666. */
  100667. baseWidth: number;
  100668. /**
  100669. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  100670. */
  100671. baseHeight: number;
  100672. /**
  100673. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  100674. */
  100675. baseDepth: number;
  100676. /**
  100677. * Gets a boolean indicating if the texture is inverted on Y axis
  100678. */
  100679. invertY: boolean;
  100680. /** @hidden */
  100681. _invertVScale: boolean;
  100682. /** @hidden */
  100683. _associatedChannel: number;
  100684. /** @hidden */
  100685. _source: InternalTextureSource;
  100686. /** @hidden */
  100687. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100688. /** @hidden */
  100689. _bufferView: Nullable<ArrayBufferView>;
  100690. /** @hidden */
  100691. _bufferViewArray: Nullable<ArrayBufferView[]>;
  100692. /** @hidden */
  100693. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  100694. /** @hidden */
  100695. _size: number;
  100696. /** @hidden */
  100697. _extension: string;
  100698. /** @hidden */
  100699. _files: Nullable<string[]>;
  100700. /** @hidden */
  100701. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  100702. /** @hidden */
  100703. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  100704. /** @hidden */
  100705. _framebuffer: Nullable<WebGLFramebuffer>;
  100706. /** @hidden */
  100707. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  100708. /** @hidden */
  100709. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  100710. /** @hidden */
  100711. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  100712. /** @hidden */
  100713. _attachments: Nullable<number[]>;
  100714. /** @hidden */
  100715. _cachedCoordinatesMode: Nullable<number>;
  100716. /** @hidden */
  100717. _cachedWrapU: Nullable<number>;
  100718. /** @hidden */
  100719. _cachedWrapV: Nullable<number>;
  100720. /** @hidden */
  100721. _cachedWrapR: Nullable<number>;
  100722. /** @hidden */
  100723. _cachedAnisotropicFilteringLevel: Nullable<number>;
  100724. /** @hidden */
  100725. _isDisabled: boolean;
  100726. /** @hidden */
  100727. _compression: Nullable<string>;
  100728. /** @hidden */
  100729. _generateStencilBuffer: boolean;
  100730. /** @hidden */
  100731. _generateDepthBuffer: boolean;
  100732. /** @hidden */
  100733. _comparisonFunction: number;
  100734. /** @hidden */
  100735. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  100736. /** @hidden */
  100737. _lodGenerationScale: number;
  100738. /** @hidden */
  100739. _lodGenerationOffset: number;
  100740. /** @hidden */
  100741. _colorTextureArray: Nullable<WebGLTexture>;
  100742. /** @hidden */
  100743. _depthStencilTextureArray: Nullable<WebGLTexture>;
  100744. /** @hidden */
  100745. _lodTextureHigh: Nullable<BaseTexture>;
  100746. /** @hidden */
  100747. _lodTextureMid: Nullable<BaseTexture>;
  100748. /** @hidden */
  100749. _lodTextureLow: Nullable<BaseTexture>;
  100750. /** @hidden */
  100751. _isRGBD: boolean;
  100752. /** @hidden */
  100753. _linearSpecularLOD: boolean;
  100754. /** @hidden */
  100755. _irradianceTexture: Nullable<BaseTexture>;
  100756. /** @hidden */
  100757. _webGLTexture: Nullable<WebGLTexture>;
  100758. /** @hidden */
  100759. _references: number;
  100760. private _engine;
  100761. /**
  100762. * Gets the Engine the texture belongs to.
  100763. * @returns The babylon engine
  100764. */
  100765. getEngine(): ThinEngine;
  100766. /**
  100767. * Gets the data source type of the texture
  100768. */
  100769. readonly source: InternalTextureSource;
  100770. /**
  100771. * Creates a new InternalTexture
  100772. * @param engine defines the engine to use
  100773. * @param source defines the type of data that will be used
  100774. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100775. */
  100776. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  100777. /**
  100778. * Increments the number of references (ie. the number of Texture that point to it)
  100779. */
  100780. incrementReferences(): void;
  100781. /**
  100782. * Change the size of the texture (not the size of the content)
  100783. * @param width defines the new width
  100784. * @param height defines the new height
  100785. * @param depth defines the new depth (1 by default)
  100786. */
  100787. updateSize(width: int, height: int, depth?: int): void;
  100788. /** @hidden */
  100789. _rebuild(): void;
  100790. /** @hidden */
  100791. _swapAndDie(target: InternalTexture): void;
  100792. /**
  100793. * Dispose the current allocated resources
  100794. */
  100795. dispose(): void;
  100796. }
  100797. }
  100798. declare module BABYLON {
  100799. /**
  100800. * Class used to work with sound analyzer using fast fourier transform (FFT)
  100801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100802. */
  100803. export class Analyser {
  100804. /**
  100805. * Gets or sets the smoothing
  100806. * @ignorenaming
  100807. */
  100808. SMOOTHING: number;
  100809. /**
  100810. * Gets or sets the FFT table size
  100811. * @ignorenaming
  100812. */
  100813. FFT_SIZE: number;
  100814. /**
  100815. * Gets or sets the bar graph amplitude
  100816. * @ignorenaming
  100817. */
  100818. BARGRAPHAMPLITUDE: number;
  100819. /**
  100820. * Gets or sets the position of the debug canvas
  100821. * @ignorenaming
  100822. */
  100823. DEBUGCANVASPOS: {
  100824. x: number;
  100825. y: number;
  100826. };
  100827. /**
  100828. * Gets or sets the debug canvas size
  100829. * @ignorenaming
  100830. */
  100831. DEBUGCANVASSIZE: {
  100832. width: number;
  100833. height: number;
  100834. };
  100835. private _byteFreqs;
  100836. private _byteTime;
  100837. private _floatFreqs;
  100838. private _webAudioAnalyser;
  100839. private _debugCanvas;
  100840. private _debugCanvasContext;
  100841. private _scene;
  100842. private _registerFunc;
  100843. private _audioEngine;
  100844. /**
  100845. * Creates a new analyser
  100846. * @param scene defines hosting scene
  100847. */
  100848. constructor(scene: Scene);
  100849. /**
  100850. * Get the number of data values you will have to play with for the visualization
  100851. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  100852. * @returns a number
  100853. */
  100854. getFrequencyBinCount(): number;
  100855. /**
  100856. * Gets the current frequency data as a byte array
  100857. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  100858. * @returns a Uint8Array
  100859. */
  100860. getByteFrequencyData(): Uint8Array;
  100861. /**
  100862. * Gets the current waveform as a byte array
  100863. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  100864. * @returns a Uint8Array
  100865. */
  100866. getByteTimeDomainData(): Uint8Array;
  100867. /**
  100868. * Gets the current frequency data as a float array
  100869. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  100870. * @returns a Float32Array
  100871. */
  100872. getFloatFrequencyData(): Float32Array;
  100873. /**
  100874. * Renders the debug canvas
  100875. */
  100876. drawDebugCanvas(): void;
  100877. /**
  100878. * Stops rendering the debug canvas and removes it
  100879. */
  100880. stopDebugCanvas(): void;
  100881. /**
  100882. * Connects two audio nodes
  100883. * @param inputAudioNode defines first node to connect
  100884. * @param outputAudioNode defines second node to connect
  100885. */
  100886. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  100887. /**
  100888. * Releases all associated resources
  100889. */
  100890. dispose(): void;
  100891. }
  100892. }
  100893. declare module BABYLON {
  100894. /**
  100895. * This represents an audio engine and it is responsible
  100896. * to play, synchronize and analyse sounds throughout the application.
  100897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100898. */
  100899. export interface IAudioEngine extends IDisposable {
  100900. /**
  100901. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  100902. */
  100903. readonly canUseWebAudio: boolean;
  100904. /**
  100905. * Gets the current AudioContext if available.
  100906. */
  100907. readonly audioContext: Nullable<AudioContext>;
  100908. /**
  100909. * The master gain node defines the global audio volume of your audio engine.
  100910. */
  100911. readonly masterGain: GainNode;
  100912. /**
  100913. * Gets whether or not mp3 are supported by your browser.
  100914. */
  100915. readonly isMP3supported: boolean;
  100916. /**
  100917. * Gets whether or not ogg are supported by your browser.
  100918. */
  100919. readonly isOGGsupported: boolean;
  100920. /**
  100921. * Defines if Babylon should emit a warning if WebAudio is not supported.
  100922. * @ignoreNaming
  100923. */
  100924. WarnedWebAudioUnsupported: boolean;
  100925. /**
  100926. * Defines if the audio engine relies on a custom unlocked button.
  100927. * In this case, the embedded button will not be displayed.
  100928. */
  100929. useCustomUnlockedButton: boolean;
  100930. /**
  100931. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  100932. */
  100933. readonly unlocked: boolean;
  100934. /**
  100935. * Event raised when audio has been unlocked on the browser.
  100936. */
  100937. onAudioUnlockedObservable: Observable<AudioEngine>;
  100938. /**
  100939. * Event raised when audio has been locked on the browser.
  100940. */
  100941. onAudioLockedObservable: Observable<AudioEngine>;
  100942. /**
  100943. * Flags the audio engine in Locked state.
  100944. * This happens due to new browser policies preventing audio to autoplay.
  100945. */
  100946. lock(): void;
  100947. /**
  100948. * Unlocks the audio engine once a user action has been done on the dom.
  100949. * This is helpful to resume play once browser policies have been satisfied.
  100950. */
  100951. unlock(): void;
  100952. }
  100953. /**
  100954. * This represents the default audio engine used in babylon.
  100955. * It is responsible to play, synchronize and analyse sounds throughout the application.
  100956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100957. */
  100958. export class AudioEngine implements IAudioEngine {
  100959. private _audioContext;
  100960. private _audioContextInitialized;
  100961. private _muteButton;
  100962. private _hostElement;
  100963. /**
  100964. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  100965. */
  100966. canUseWebAudio: boolean;
  100967. /**
  100968. * The master gain node defines the global audio volume of your audio engine.
  100969. */
  100970. masterGain: GainNode;
  100971. /**
  100972. * Defines if Babylon should emit a warning if WebAudio is not supported.
  100973. * @ignoreNaming
  100974. */
  100975. WarnedWebAudioUnsupported: boolean;
  100976. /**
  100977. * Gets whether or not mp3 are supported by your browser.
  100978. */
  100979. isMP3supported: boolean;
  100980. /**
  100981. * Gets whether or not ogg are supported by your browser.
  100982. */
  100983. isOGGsupported: boolean;
  100984. /**
  100985. * Gets whether audio has been unlocked on the device.
  100986. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  100987. * a user interaction has happened.
  100988. */
  100989. unlocked: boolean;
  100990. /**
  100991. * Defines if the audio engine relies on a custom unlocked button.
  100992. * In this case, the embedded button will not be displayed.
  100993. */
  100994. useCustomUnlockedButton: boolean;
  100995. /**
  100996. * Event raised when audio has been unlocked on the browser.
  100997. */
  100998. onAudioUnlockedObservable: Observable<AudioEngine>;
  100999. /**
  101000. * Event raised when audio has been locked on the browser.
  101001. */
  101002. onAudioLockedObservable: Observable<AudioEngine>;
  101003. /**
  101004. * Gets the current AudioContext if available.
  101005. */
  101006. readonly audioContext: Nullable<AudioContext>;
  101007. private _connectedAnalyser;
  101008. /**
  101009. * Instantiates a new audio engine.
  101010. *
  101011. * There should be only one per page as some browsers restrict the number
  101012. * of audio contexts you can create.
  101013. * @param hostElement defines the host element where to display the mute icon if necessary
  101014. */
  101015. constructor(hostElement?: Nullable<HTMLElement>);
  101016. /**
  101017. * Flags the audio engine in Locked state.
  101018. * This happens due to new browser policies preventing audio to autoplay.
  101019. */
  101020. lock(): void;
  101021. /**
  101022. * Unlocks the audio engine once a user action has been done on the dom.
  101023. * This is helpful to resume play once browser policies have been satisfied.
  101024. */
  101025. unlock(): void;
  101026. private _resumeAudioContext;
  101027. private _initializeAudioContext;
  101028. private _tryToRun;
  101029. private _triggerRunningState;
  101030. private _triggerSuspendedState;
  101031. private _displayMuteButton;
  101032. private _moveButtonToTopLeft;
  101033. private _onResize;
  101034. private _hideMuteButton;
  101035. /**
  101036. * Destroy and release the resources associated with the audio ccontext.
  101037. */
  101038. dispose(): void;
  101039. /**
  101040. * Gets the global volume sets on the master gain.
  101041. * @returns the global volume if set or -1 otherwise
  101042. */
  101043. getGlobalVolume(): number;
  101044. /**
  101045. * Sets the global volume of your experience (sets on the master gain).
  101046. * @param newVolume Defines the new global volume of the application
  101047. */
  101048. setGlobalVolume(newVolume: number): void;
  101049. /**
  101050. * Connect the audio engine to an audio analyser allowing some amazing
  101051. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101053. * @param analyser The analyser to connect to the engine
  101054. */
  101055. connectToAnalyser(analyser: Analyser): void;
  101056. }
  101057. }
  101058. declare module BABYLON {
  101059. /**
  101060. * Interface used to present a loading screen while loading a scene
  101061. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101062. */
  101063. export interface ILoadingScreen {
  101064. /**
  101065. * Function called to display the loading screen
  101066. */
  101067. displayLoadingUI: () => void;
  101068. /**
  101069. * Function called to hide the loading screen
  101070. */
  101071. hideLoadingUI: () => void;
  101072. /**
  101073. * Gets or sets the color to use for the background
  101074. */
  101075. loadingUIBackgroundColor: string;
  101076. /**
  101077. * Gets or sets the text to display while loading
  101078. */
  101079. loadingUIText: string;
  101080. }
  101081. /**
  101082. * Class used for the default loading screen
  101083. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101084. */
  101085. export class DefaultLoadingScreen implements ILoadingScreen {
  101086. private _renderingCanvas;
  101087. private _loadingText;
  101088. private _loadingDivBackgroundColor;
  101089. private _loadingDiv;
  101090. private _loadingTextDiv;
  101091. /** Gets or sets the logo url to use for the default loading screen */
  101092. static DefaultLogoUrl: string;
  101093. /** Gets or sets the spinner url to use for the default loading screen */
  101094. static DefaultSpinnerUrl: string;
  101095. /**
  101096. * Creates a new default loading screen
  101097. * @param _renderingCanvas defines the canvas used to render the scene
  101098. * @param _loadingText defines the default text to display
  101099. * @param _loadingDivBackgroundColor defines the default background color
  101100. */
  101101. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  101102. /**
  101103. * Function called to display the loading screen
  101104. */
  101105. displayLoadingUI(): void;
  101106. /**
  101107. * Function called to hide the loading screen
  101108. */
  101109. hideLoadingUI(): void;
  101110. /**
  101111. * Gets or sets the text to display while loading
  101112. */
  101113. loadingUIText: string;
  101114. /**
  101115. * Gets or sets the color to use for the background
  101116. */
  101117. loadingUIBackgroundColor: string;
  101118. private _resizeLoadingUI;
  101119. }
  101120. }
  101121. declare module BABYLON {
  101122. /**
  101123. * Interface for any object that can request an animation frame
  101124. */
  101125. export interface ICustomAnimationFrameRequester {
  101126. /**
  101127. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  101128. */
  101129. renderFunction?: Function;
  101130. /**
  101131. * Called to request the next frame to render to
  101132. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  101133. */
  101134. requestAnimationFrame: Function;
  101135. /**
  101136. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  101137. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  101138. */
  101139. requestID?: number;
  101140. }
  101141. }
  101142. declare module BABYLON {
  101143. /**
  101144. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  101145. */
  101146. export class PerformanceMonitor {
  101147. private _enabled;
  101148. private _rollingFrameTime;
  101149. private _lastFrameTimeMs;
  101150. /**
  101151. * constructor
  101152. * @param frameSampleSize The number of samples required to saturate the sliding window
  101153. */
  101154. constructor(frameSampleSize?: number);
  101155. /**
  101156. * Samples current frame
  101157. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  101158. */
  101159. sampleFrame(timeMs?: number): void;
  101160. /**
  101161. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101162. */
  101163. readonly averageFrameTime: number;
  101164. /**
  101165. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101166. */
  101167. readonly averageFrameTimeVariance: number;
  101168. /**
  101169. * Returns the frame time of the most recent frame
  101170. */
  101171. readonly instantaneousFrameTime: number;
  101172. /**
  101173. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  101174. */
  101175. readonly averageFPS: number;
  101176. /**
  101177. * Returns the average framerate in frames per second using the most recent frame time
  101178. */
  101179. readonly instantaneousFPS: number;
  101180. /**
  101181. * Returns true if enough samples have been taken to completely fill the sliding window
  101182. */
  101183. readonly isSaturated: boolean;
  101184. /**
  101185. * Enables contributions to the sliding window sample set
  101186. */
  101187. enable(): void;
  101188. /**
  101189. * Disables contributions to the sliding window sample set
  101190. * Samples will not be interpolated over the disabled period
  101191. */
  101192. disable(): void;
  101193. /**
  101194. * Returns true if sampling is enabled
  101195. */
  101196. readonly isEnabled: boolean;
  101197. /**
  101198. * Resets performance monitor
  101199. */
  101200. reset(): void;
  101201. }
  101202. /**
  101203. * RollingAverage
  101204. *
  101205. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  101206. */
  101207. export class RollingAverage {
  101208. /**
  101209. * Current average
  101210. */
  101211. average: number;
  101212. /**
  101213. * Current variance
  101214. */
  101215. variance: number;
  101216. protected _samples: Array<number>;
  101217. protected _sampleCount: number;
  101218. protected _pos: number;
  101219. protected _m2: number;
  101220. /**
  101221. * constructor
  101222. * @param length The number of samples required to saturate the sliding window
  101223. */
  101224. constructor(length: number);
  101225. /**
  101226. * Adds a sample to the sample set
  101227. * @param v The sample value
  101228. */
  101229. add(v: number): void;
  101230. /**
  101231. * Returns previously added values or null if outside of history or outside the sliding window domain
  101232. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  101233. * @return Value previously recorded with add() or null if outside of range
  101234. */
  101235. history(i: number): number;
  101236. /**
  101237. * Returns true if enough samples have been taken to completely fill the sliding window
  101238. * @return true if sample-set saturated
  101239. */
  101240. isSaturated(): boolean;
  101241. /**
  101242. * Resets the rolling average (equivalent to 0 samples taken so far)
  101243. */
  101244. reset(): void;
  101245. /**
  101246. * Wraps a value around the sample range boundaries
  101247. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  101248. * @return Wrapped position in sample range
  101249. */
  101250. protected _wrapPosition(i: number): number;
  101251. }
  101252. }
  101253. declare module BABYLON {
  101254. /**
  101255. * This class is used to track a performance counter which is number based.
  101256. * The user has access to many properties which give statistics of different nature.
  101257. *
  101258. * The implementer can track two kinds of Performance Counter: time and count.
  101259. * 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.
  101260. * 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.
  101261. */
  101262. export class PerfCounter {
  101263. /**
  101264. * Gets or sets a global boolean to turn on and off all the counters
  101265. */
  101266. static Enabled: boolean;
  101267. /**
  101268. * Returns the smallest value ever
  101269. */
  101270. readonly min: number;
  101271. /**
  101272. * Returns the biggest value ever
  101273. */
  101274. readonly max: number;
  101275. /**
  101276. * Returns the average value since the performance counter is running
  101277. */
  101278. readonly average: number;
  101279. /**
  101280. * Returns the average value of the last second the counter was monitored
  101281. */
  101282. readonly lastSecAverage: number;
  101283. /**
  101284. * Returns the current value
  101285. */
  101286. readonly current: number;
  101287. /**
  101288. * Gets the accumulated total
  101289. */
  101290. readonly total: number;
  101291. /**
  101292. * Gets the total value count
  101293. */
  101294. readonly count: number;
  101295. /**
  101296. * Creates a new counter
  101297. */
  101298. constructor();
  101299. /**
  101300. * Call this method to start monitoring a new frame.
  101301. * 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.
  101302. */
  101303. fetchNewFrame(): void;
  101304. /**
  101305. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  101306. * @param newCount the count value to add to the monitored count
  101307. * @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.
  101308. */
  101309. addCount(newCount: number, fetchResult: boolean): void;
  101310. /**
  101311. * Start monitoring this performance counter
  101312. */
  101313. beginMonitoring(): void;
  101314. /**
  101315. * Compute the time lapsed since the previous beginMonitoring() call.
  101316. * @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
  101317. */
  101318. endMonitoring(newFrame?: boolean): void;
  101319. private _fetchResult;
  101320. private _startMonitoringTime;
  101321. private _min;
  101322. private _max;
  101323. private _average;
  101324. private _current;
  101325. private _totalValueCount;
  101326. private _totalAccumulated;
  101327. private _lastSecAverage;
  101328. private _lastSecAccumulated;
  101329. private _lastSecTime;
  101330. private _lastSecValueCount;
  101331. }
  101332. }
  101333. declare module BABYLON {
  101334. /**
  101335. * Defines the interface used by display changed events
  101336. */
  101337. export interface IDisplayChangedEventArgs {
  101338. /** Gets the vrDisplay object (if any) */
  101339. vrDisplay: Nullable<any>;
  101340. /** Gets a boolean indicating if webVR is supported */
  101341. vrSupported: boolean;
  101342. }
  101343. /**
  101344. * Defines the interface used by objects containing a viewport (like a camera)
  101345. */
  101346. interface IViewportOwnerLike {
  101347. /**
  101348. * Gets or sets the viewport
  101349. */
  101350. viewport: IViewportLike;
  101351. }
  101352. /**
  101353. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  101354. */
  101355. export class Engine extends ThinEngine {
  101356. /** Defines that alpha blending is disabled */
  101357. static readonly ALPHA_DISABLE: number;
  101358. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  101359. static readonly ALPHA_ADD: number;
  101360. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  101361. static readonly ALPHA_COMBINE: number;
  101362. /** Defines that alpha blending to DEST - SRC * DEST */
  101363. static readonly ALPHA_SUBTRACT: number;
  101364. /** Defines that alpha blending to SRC * DEST */
  101365. static readonly ALPHA_MULTIPLY: number;
  101366. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  101367. static readonly ALPHA_MAXIMIZED: number;
  101368. /** Defines that alpha blending to SRC + DEST */
  101369. static readonly ALPHA_ONEONE: number;
  101370. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  101371. static readonly ALPHA_PREMULTIPLIED: number;
  101372. /**
  101373. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  101374. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  101375. */
  101376. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  101377. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  101378. static readonly ALPHA_INTERPOLATE: number;
  101379. /**
  101380. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  101381. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  101382. */
  101383. static readonly ALPHA_SCREENMODE: number;
  101384. /** Defines that the ressource is not delayed*/
  101385. static readonly DELAYLOADSTATE_NONE: number;
  101386. /** Defines that the ressource was successfully delay loaded */
  101387. static readonly DELAYLOADSTATE_LOADED: number;
  101388. /** Defines that the ressource is currently delay loading */
  101389. static readonly DELAYLOADSTATE_LOADING: number;
  101390. /** Defines that the ressource is delayed and has not started loading */
  101391. static readonly DELAYLOADSTATE_NOTLOADED: number;
  101392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  101393. static readonly NEVER: number;
  101394. /** 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 */
  101395. static readonly ALWAYS: number;
  101396. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  101397. static readonly LESS: number;
  101398. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  101399. static readonly EQUAL: number;
  101400. /** 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 */
  101401. static readonly LEQUAL: number;
  101402. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  101403. static readonly GREATER: number;
  101404. /** 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 */
  101405. static readonly GEQUAL: number;
  101406. /** 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 */
  101407. static readonly NOTEQUAL: number;
  101408. /** Passed to stencilOperation to specify that stencil value must be kept */
  101409. static readonly KEEP: number;
  101410. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101411. static readonly REPLACE: number;
  101412. /** Passed to stencilOperation to specify that stencil value must be incremented */
  101413. static readonly INCR: number;
  101414. /** Passed to stencilOperation to specify that stencil value must be decremented */
  101415. static readonly DECR: number;
  101416. /** Passed to stencilOperation to specify that stencil value must be inverted */
  101417. static readonly INVERT: number;
  101418. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  101419. static readonly INCR_WRAP: number;
  101420. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  101421. static readonly DECR_WRAP: number;
  101422. /** Texture is not repeating outside of 0..1 UVs */
  101423. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  101424. /** Texture is repeating outside of 0..1 UVs */
  101425. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  101426. /** Texture is repeating and mirrored */
  101427. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  101428. /** ALPHA */
  101429. static readonly TEXTUREFORMAT_ALPHA: number;
  101430. /** LUMINANCE */
  101431. static readonly TEXTUREFORMAT_LUMINANCE: number;
  101432. /** LUMINANCE_ALPHA */
  101433. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  101434. /** RGB */
  101435. static readonly TEXTUREFORMAT_RGB: number;
  101436. /** RGBA */
  101437. static readonly TEXTUREFORMAT_RGBA: number;
  101438. /** RED */
  101439. static readonly TEXTUREFORMAT_RED: number;
  101440. /** RED (2nd reference) */
  101441. static readonly TEXTUREFORMAT_R: number;
  101442. /** RG */
  101443. static readonly TEXTUREFORMAT_RG: number;
  101444. /** RED_INTEGER */
  101445. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  101446. /** RED_INTEGER (2nd reference) */
  101447. static readonly TEXTUREFORMAT_R_INTEGER: number;
  101448. /** RG_INTEGER */
  101449. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  101450. /** RGB_INTEGER */
  101451. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  101452. /** RGBA_INTEGER */
  101453. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  101454. /** UNSIGNED_BYTE */
  101455. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  101456. /** UNSIGNED_BYTE (2nd reference) */
  101457. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  101458. /** FLOAT */
  101459. static readonly TEXTURETYPE_FLOAT: number;
  101460. /** HALF_FLOAT */
  101461. static readonly TEXTURETYPE_HALF_FLOAT: number;
  101462. /** BYTE */
  101463. static readonly TEXTURETYPE_BYTE: number;
  101464. /** SHORT */
  101465. static readonly TEXTURETYPE_SHORT: number;
  101466. /** UNSIGNED_SHORT */
  101467. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  101468. /** INT */
  101469. static readonly TEXTURETYPE_INT: number;
  101470. /** UNSIGNED_INT */
  101471. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  101472. /** UNSIGNED_SHORT_4_4_4_4 */
  101473. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  101474. /** UNSIGNED_SHORT_5_5_5_1 */
  101475. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  101476. /** UNSIGNED_SHORT_5_6_5 */
  101477. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  101478. /** UNSIGNED_INT_2_10_10_10_REV */
  101479. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  101480. /** UNSIGNED_INT_24_8 */
  101481. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  101482. /** UNSIGNED_INT_10F_11F_11F_REV */
  101483. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  101484. /** UNSIGNED_INT_5_9_9_9_REV */
  101485. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  101486. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  101487. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  101488. /** nearest is mag = nearest and min = nearest and mip = linear */
  101489. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  101490. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101491. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  101492. /** Trilinear is mag = linear and min = linear and mip = linear */
  101493. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  101494. /** nearest is mag = nearest and min = nearest and mip = linear */
  101495. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  101496. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101497. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  101498. /** Trilinear is mag = linear and min = linear and mip = linear */
  101499. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  101500. /** mag = nearest and min = nearest and mip = nearest */
  101501. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  101502. /** mag = nearest and min = linear and mip = nearest */
  101503. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  101504. /** mag = nearest and min = linear and mip = linear */
  101505. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  101506. /** mag = nearest and min = linear and mip = none */
  101507. static readonly TEXTURE_NEAREST_LINEAR: number;
  101508. /** mag = nearest and min = nearest and mip = none */
  101509. static readonly TEXTURE_NEAREST_NEAREST: number;
  101510. /** mag = linear and min = nearest and mip = nearest */
  101511. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  101512. /** mag = linear and min = nearest and mip = linear */
  101513. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  101514. /** mag = linear and min = linear and mip = none */
  101515. static readonly TEXTURE_LINEAR_LINEAR: number;
  101516. /** mag = linear and min = nearest and mip = none */
  101517. static readonly TEXTURE_LINEAR_NEAREST: number;
  101518. /** Explicit coordinates mode */
  101519. static readonly TEXTURE_EXPLICIT_MODE: number;
  101520. /** Spherical coordinates mode */
  101521. static readonly TEXTURE_SPHERICAL_MODE: number;
  101522. /** Planar coordinates mode */
  101523. static readonly TEXTURE_PLANAR_MODE: number;
  101524. /** Cubic coordinates mode */
  101525. static readonly TEXTURE_CUBIC_MODE: number;
  101526. /** Projection coordinates mode */
  101527. static readonly TEXTURE_PROJECTION_MODE: number;
  101528. /** Skybox coordinates mode */
  101529. static readonly TEXTURE_SKYBOX_MODE: number;
  101530. /** Inverse Cubic coordinates mode */
  101531. static readonly TEXTURE_INVCUBIC_MODE: number;
  101532. /** Equirectangular coordinates mode */
  101533. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  101534. /** Equirectangular Fixed coordinates mode */
  101535. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  101536. /** Equirectangular Fixed Mirrored coordinates mode */
  101537. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101538. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  101539. static readonly SCALEMODE_FLOOR: number;
  101540. /** Defines that texture rescaling will look for the nearest power of 2 size */
  101541. static readonly SCALEMODE_NEAREST: number;
  101542. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  101543. static readonly SCALEMODE_CEILING: number;
  101544. /**
  101545. * Returns the current npm package of the sdk
  101546. */
  101547. static readonly NpmPackage: string;
  101548. /**
  101549. * Returns the current version of the framework
  101550. */
  101551. static readonly Version: string;
  101552. /** Gets the list of created engines */
  101553. static readonly Instances: Engine[];
  101554. /**
  101555. * Gets the latest created engine
  101556. */
  101557. static readonly LastCreatedEngine: Nullable<Engine>;
  101558. /**
  101559. * Gets the latest created scene
  101560. */
  101561. static readonly LastCreatedScene: Nullable<Scene>;
  101562. /**
  101563. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  101564. * @param flag defines which part of the materials must be marked as dirty
  101565. * @param predicate defines a predicate used to filter which materials should be affected
  101566. */
  101567. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101568. /**
  101569. * Method called to create the default loading screen.
  101570. * This can be overriden in your own app.
  101571. * @param canvas The rendering canvas element
  101572. * @returns The loading screen
  101573. */
  101574. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  101575. /**
  101576. * Method called to create the default rescale post process on each engine.
  101577. */
  101578. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  101579. /**
  101580. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  101581. **/
  101582. enableOfflineSupport: boolean;
  101583. /**
  101584. * 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)
  101585. **/
  101586. disableManifestCheck: boolean;
  101587. /**
  101588. * Gets the list of created scenes
  101589. */
  101590. scenes: Scene[];
  101591. /**
  101592. * Event raised when a new scene is created
  101593. */
  101594. onNewSceneAddedObservable: Observable<Scene>;
  101595. /**
  101596. * Gets the list of created postprocesses
  101597. */
  101598. postProcesses: PostProcess[];
  101599. /**
  101600. * Gets a boolean indicating if the pointer is currently locked
  101601. */
  101602. isPointerLock: boolean;
  101603. /**
  101604. * Observable event triggered each time the rendering canvas is resized
  101605. */
  101606. onResizeObservable: Observable<Engine>;
  101607. /**
  101608. * Observable event triggered each time the canvas loses focus
  101609. */
  101610. onCanvasBlurObservable: Observable<Engine>;
  101611. /**
  101612. * Observable event triggered each time the canvas gains focus
  101613. */
  101614. onCanvasFocusObservable: Observable<Engine>;
  101615. /**
  101616. * Observable event triggered each time the canvas receives pointerout event
  101617. */
  101618. onCanvasPointerOutObservable: Observable<PointerEvent>;
  101619. /**
  101620. * Observable raised when the engine begins a new frame
  101621. */
  101622. onBeginFrameObservable: Observable<Engine>;
  101623. /**
  101624. * If set, will be used to request the next animation frame for the render loop
  101625. */
  101626. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  101627. /**
  101628. * Observable raised when the engine ends the current frame
  101629. */
  101630. onEndFrameObservable: Observable<Engine>;
  101631. /**
  101632. * Observable raised when the engine is about to compile a shader
  101633. */
  101634. onBeforeShaderCompilationObservable: Observable<Engine>;
  101635. /**
  101636. * Observable raised when the engine has jsut compiled a shader
  101637. */
  101638. onAfterShaderCompilationObservable: Observable<Engine>;
  101639. /**
  101640. * Gets the audio engine
  101641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101642. * @ignorenaming
  101643. */
  101644. static audioEngine: IAudioEngine;
  101645. /**
  101646. * Default AudioEngine factory responsible of creating the Audio Engine.
  101647. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  101648. */
  101649. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  101650. /**
  101651. * Default offline support factory responsible of creating a tool used to store data locally.
  101652. * By default, this will create a Database object if the workload has been embedded.
  101653. */
  101654. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  101655. private _loadingScreen;
  101656. private _pointerLockRequested;
  101657. private _dummyFramebuffer;
  101658. private _rescalePostProcess;
  101659. /** @hidden */
  101660. protected _alphaMode: number;
  101661. /** @hidden */
  101662. protected _alphaEquation: number;
  101663. private _deterministicLockstep;
  101664. private _lockstepMaxSteps;
  101665. private _timeStep;
  101666. protected readonly _supportsHardwareTextureRescaling: boolean;
  101667. private _fps;
  101668. private _deltaTime;
  101669. /** @hidden */
  101670. _drawCalls: PerfCounter;
  101671. /**
  101672. * Turn this value on if you want to pause FPS computation when in background
  101673. */
  101674. disablePerformanceMonitorInBackground: boolean;
  101675. private _performanceMonitor;
  101676. /**
  101677. * Gets the performance monitor attached to this engine
  101678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101679. */
  101680. readonly performanceMonitor: PerformanceMonitor;
  101681. private _onFocus;
  101682. private _onBlur;
  101683. private _onCanvasPointerOut;
  101684. private _onCanvasBlur;
  101685. private _onCanvasFocus;
  101686. private _onFullscreenChange;
  101687. private _onPointerLockChange;
  101688. /**
  101689. * Gets the HTML element used to attach event listeners
  101690. * @returns a HTML element
  101691. */
  101692. getInputElement(): Nullable<HTMLElement>;
  101693. /**
  101694. * Creates a new engine
  101695. * @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
  101696. * @param antialias defines enable antialiasing (default: false)
  101697. * @param options defines further options to be sent to the getContext() function
  101698. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101699. */
  101700. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101701. /**
  101702. * Gets current aspect ratio
  101703. * @param viewportOwner defines the camera to use to get the aspect ratio
  101704. * @param useScreen defines if screen size must be used (or the current render target if any)
  101705. * @returns a number defining the aspect ratio
  101706. */
  101707. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  101708. /**
  101709. * Gets current screen aspect ratio
  101710. * @returns a number defining the aspect ratio
  101711. */
  101712. getScreenAspectRatio(): number;
  101713. /**
  101714. * Gets the client rect of the HTML canvas attached with the current webGL context
  101715. * @returns a client rectanglee
  101716. */
  101717. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  101718. /**
  101719. * Gets the client rect of the HTML element used for events
  101720. * @returns a client rectanglee
  101721. */
  101722. getInputElementClientRect(): Nullable<ClientRect>;
  101723. /**
  101724. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  101725. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101726. * @returns true if engine is in deterministic lock step mode
  101727. */
  101728. isDeterministicLockStep(): boolean;
  101729. /**
  101730. * Gets the max steps when engine is running in deterministic lock step
  101731. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101732. * @returns the max steps
  101733. */
  101734. getLockstepMaxSteps(): number;
  101735. /**
  101736. * Returns the time in ms between steps when using deterministic lock step.
  101737. * @returns time step in (ms)
  101738. */
  101739. getTimeStep(): number;
  101740. /**
  101741. * Force the mipmap generation for the given render target texture
  101742. * @param texture defines the render target texture to use
  101743. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  101744. */
  101745. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  101746. /** States */
  101747. /**
  101748. * Set various states to the webGL context
  101749. * @param culling defines backface culling state
  101750. * @param zOffset defines the value to apply to zOffset (0 by default)
  101751. * @param force defines if states must be applied even if cache is up to date
  101752. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  101753. */
  101754. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101755. /**
  101756. * Set the z offset to apply to current rendering
  101757. * @param value defines the offset to apply
  101758. */
  101759. setZOffset(value: number): void;
  101760. /**
  101761. * Gets the current value of the zOffset
  101762. * @returns the current zOffset state
  101763. */
  101764. getZOffset(): number;
  101765. /**
  101766. * Enable or disable depth buffering
  101767. * @param enable defines the state to set
  101768. */
  101769. setDepthBuffer(enable: boolean): void;
  101770. /**
  101771. * Gets a boolean indicating if depth writing is enabled
  101772. * @returns the current depth writing state
  101773. */
  101774. getDepthWrite(): boolean;
  101775. /**
  101776. * Enable or disable depth writing
  101777. * @param enable defines the state to set
  101778. */
  101779. setDepthWrite(enable: boolean): void;
  101780. /**
  101781. * Enable or disable color writing
  101782. * @param enable defines the state to set
  101783. */
  101784. setColorWrite(enable: boolean): void;
  101785. /**
  101786. * Gets a boolean indicating if color writing is enabled
  101787. * @returns the current color writing state
  101788. */
  101789. getColorWrite(): boolean;
  101790. /**
  101791. * Sets alpha constants used by some alpha blending modes
  101792. * @param r defines the red component
  101793. * @param g defines the green component
  101794. * @param b defines the blue component
  101795. * @param a defines the alpha component
  101796. */
  101797. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  101798. /**
  101799. * Sets the current alpha mode
  101800. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  101801. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  101802. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101803. */
  101804. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101805. /**
  101806. * Gets the current alpha mode
  101807. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101808. * @returns the current alpha mode
  101809. */
  101810. getAlphaMode(): number;
  101811. /**
  101812. * Sets the current alpha equation
  101813. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  101814. */
  101815. setAlphaEquation(equation: number): void;
  101816. /**
  101817. * Gets the current alpha equation.
  101818. * @returns the current alpha equation
  101819. */
  101820. getAlphaEquation(): number;
  101821. /**
  101822. * Gets a boolean indicating if stencil buffer is enabled
  101823. * @returns the current stencil buffer state
  101824. */
  101825. getStencilBuffer(): boolean;
  101826. /**
  101827. * Enable or disable the stencil buffer
  101828. * @param enable defines if the stencil buffer must be enabled or disabled
  101829. */
  101830. setStencilBuffer(enable: boolean): void;
  101831. /**
  101832. * Gets the current stencil mask
  101833. * @returns a number defining the new stencil mask to use
  101834. */
  101835. getStencilMask(): number;
  101836. /**
  101837. * Sets the current stencil mask
  101838. * @param mask defines the new stencil mask to use
  101839. */
  101840. setStencilMask(mask: number): void;
  101841. /**
  101842. * Gets the current stencil function
  101843. * @returns a number defining the stencil function to use
  101844. */
  101845. getStencilFunction(): number;
  101846. /**
  101847. * Gets the current stencil reference value
  101848. * @returns a number defining the stencil reference value to use
  101849. */
  101850. getStencilFunctionReference(): number;
  101851. /**
  101852. * Gets the current stencil mask
  101853. * @returns a number defining the stencil mask to use
  101854. */
  101855. getStencilFunctionMask(): number;
  101856. /**
  101857. * Sets the current stencil function
  101858. * @param stencilFunc defines the new stencil function to use
  101859. */
  101860. setStencilFunction(stencilFunc: number): void;
  101861. /**
  101862. * Sets the current stencil reference
  101863. * @param reference defines the new stencil reference to use
  101864. */
  101865. setStencilFunctionReference(reference: number): void;
  101866. /**
  101867. * Sets the current stencil mask
  101868. * @param mask defines the new stencil mask to use
  101869. */
  101870. setStencilFunctionMask(mask: number): void;
  101871. /**
  101872. * Gets the current stencil operation when stencil fails
  101873. * @returns a number defining stencil operation to use when stencil fails
  101874. */
  101875. getStencilOperationFail(): number;
  101876. /**
  101877. * Gets the current stencil operation when depth fails
  101878. * @returns a number defining stencil operation to use when depth fails
  101879. */
  101880. getStencilOperationDepthFail(): number;
  101881. /**
  101882. * Gets the current stencil operation when stencil passes
  101883. * @returns a number defining stencil operation to use when stencil passes
  101884. */
  101885. getStencilOperationPass(): number;
  101886. /**
  101887. * Sets the stencil operation to use when stencil fails
  101888. * @param operation defines the stencil operation to use when stencil fails
  101889. */
  101890. setStencilOperationFail(operation: number): void;
  101891. /**
  101892. * Sets the stencil operation to use when depth fails
  101893. * @param operation defines the stencil operation to use when depth fails
  101894. */
  101895. setStencilOperationDepthFail(operation: number): void;
  101896. /**
  101897. * Sets the stencil operation to use when stencil passes
  101898. * @param operation defines the stencil operation to use when stencil passes
  101899. */
  101900. setStencilOperationPass(operation: number): void;
  101901. /**
  101902. * Sets a boolean indicating if the dithering state is enabled or disabled
  101903. * @param value defines the dithering state
  101904. */
  101905. setDitheringState(value: boolean): void;
  101906. /**
  101907. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  101908. * @param value defines the rasterizer state
  101909. */
  101910. setRasterizerState(value: boolean): void;
  101911. /**
  101912. * Gets the current depth function
  101913. * @returns a number defining the depth function
  101914. */
  101915. getDepthFunction(): Nullable<number>;
  101916. /**
  101917. * Sets the current depth function
  101918. * @param depthFunc defines the function to use
  101919. */
  101920. setDepthFunction(depthFunc: number): void;
  101921. /**
  101922. * Sets the current depth function to GREATER
  101923. */
  101924. setDepthFunctionToGreater(): void;
  101925. /**
  101926. * Sets the current depth function to GEQUAL
  101927. */
  101928. setDepthFunctionToGreaterOrEqual(): void;
  101929. /**
  101930. * Sets the current depth function to LESS
  101931. */
  101932. setDepthFunctionToLess(): void;
  101933. /**
  101934. * Sets the current depth function to LEQUAL
  101935. */
  101936. setDepthFunctionToLessOrEqual(): void;
  101937. private _cachedStencilBuffer;
  101938. private _cachedStencilFunction;
  101939. private _cachedStencilMask;
  101940. private _cachedStencilOperationPass;
  101941. private _cachedStencilOperationFail;
  101942. private _cachedStencilOperationDepthFail;
  101943. private _cachedStencilReference;
  101944. /**
  101945. * Caches the the state of the stencil buffer
  101946. */
  101947. cacheStencilState(): void;
  101948. /**
  101949. * Restores the state of the stencil buffer
  101950. */
  101951. restoreStencilState(): void;
  101952. /**
  101953. * Directly set the WebGL Viewport
  101954. * @param x defines the x coordinate of the viewport (in screen space)
  101955. * @param y defines the y coordinate of the viewport (in screen space)
  101956. * @param width defines the width of the viewport (in screen space)
  101957. * @param height defines the height of the viewport (in screen space)
  101958. * @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
  101959. */
  101960. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  101961. /**
  101962. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  101963. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  101964. * @param y defines the y-coordinate of the corner of the clear rectangle
  101965. * @param width defines the width of the clear rectangle
  101966. * @param height defines the height of the clear rectangle
  101967. * @param clearColor defines the clear color
  101968. */
  101969. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  101970. /**
  101971. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  101972. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  101973. * @param y defines the y-coordinate of the corner of the clear rectangle
  101974. * @param width defines the width of the clear rectangle
  101975. * @param height defines the height of the clear rectangle
  101976. */
  101977. enableScissor(x: number, y: number, width: number, height: number): void;
  101978. /**
  101979. * Disable previously set scissor test rectangle
  101980. */
  101981. disableScissor(): void;
  101982. protected _reportDrawCall(): void;
  101983. /**
  101984. * Initializes a webVR display and starts listening to display change events
  101985. * The onVRDisplayChangedObservable will be notified upon these changes
  101986. * @returns The onVRDisplayChangedObservable
  101987. */
  101988. initWebVR(): Observable<IDisplayChangedEventArgs>;
  101989. /** @hidden */
  101990. _prepareVRComponent(): void;
  101991. /** @hidden */
  101992. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  101993. /** @hidden */
  101994. _submitVRFrame(): void;
  101995. /**
  101996. * Call this function to leave webVR mode
  101997. * Will do nothing if webVR is not supported or if there is no webVR device
  101998. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101999. */
  102000. disableVR(): void;
  102001. /**
  102002. * Gets a boolean indicating that the system is in VR mode and is presenting
  102003. * @returns true if VR mode is engaged
  102004. */
  102005. isVRPresenting(): boolean;
  102006. /** @hidden */
  102007. _requestVRFrame(): void;
  102008. /** @hidden */
  102009. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102010. /**
  102011. * Gets the source code of the vertex shader associated with a specific webGL program
  102012. * @param program defines the program to use
  102013. * @returns a string containing the source code of the vertex shader associated with the program
  102014. */
  102015. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  102016. /**
  102017. * Gets the source code of the fragment shader associated with a specific webGL program
  102018. * @param program defines the program to use
  102019. * @returns a string containing the source code of the fragment shader associated with the program
  102020. */
  102021. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  102022. /**
  102023. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102024. * @param x defines the x coordinate of the rectangle where pixels must be read
  102025. * @param y defines the y coordinate of the rectangle where pixels must be read
  102026. * @param width defines the width of the rectangle where pixels must be read
  102027. * @param height defines the height of the rectangle where pixels must be read
  102028. * @returns a Uint8Array containing RGBA colors
  102029. */
  102030. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  102031. /**
  102032. * Sets a depth stencil texture from a render target to the according uniform.
  102033. * @param channel The texture channel
  102034. * @param uniform The uniform to set
  102035. * @param texture The render target texture containing the depth stencil texture to apply
  102036. */
  102037. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  102038. /**
  102039. * Sets a texture to the webGL context from a postprocess
  102040. * @param channel defines the channel to use
  102041. * @param postProcess defines the source postprocess
  102042. */
  102043. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  102044. /**
  102045. * Binds the output of the passed in post process to the texture channel specified
  102046. * @param channel The channel the texture should be bound to
  102047. * @param postProcess The post process which's output should be bound
  102048. */
  102049. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  102050. /** @hidden */
  102051. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  102052. protected _rebuildBuffers(): void;
  102053. /** @hidden */
  102054. _renderFrame(): void;
  102055. _renderLoop(): void;
  102056. /** @hidden */
  102057. _renderViews(): boolean;
  102058. /**
  102059. * Toggle full screen mode
  102060. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102061. */
  102062. switchFullscreen(requestPointerLock: boolean): void;
  102063. /**
  102064. * Enters full screen mode
  102065. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102066. */
  102067. enterFullscreen(requestPointerLock: boolean): void;
  102068. /**
  102069. * Exits full screen mode
  102070. */
  102071. exitFullscreen(): void;
  102072. /**
  102073. * Enters Pointerlock mode
  102074. */
  102075. enterPointerlock(): void;
  102076. /**
  102077. * Exits Pointerlock mode
  102078. */
  102079. exitPointerlock(): void;
  102080. /**
  102081. * Begin a new frame
  102082. */
  102083. beginFrame(): void;
  102084. /**
  102085. * Enf the current frame
  102086. */
  102087. endFrame(): void;
  102088. resize(): void;
  102089. /**
  102090. * Set the compressed texture format to use, based on the formats you have, and the formats
  102091. * supported by the hardware / browser.
  102092. *
  102093. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  102094. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  102095. * to API arguments needed to compressed textures. This puts the burden on the container
  102096. * generator to house the arcane code for determining these for current & future formats.
  102097. *
  102098. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102099. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102100. *
  102101. * Note: The result of this call is not taken into account when a texture is base64.
  102102. *
  102103. * @param formatsAvailable defines the list of those format families you have created
  102104. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  102105. *
  102106. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  102107. * @returns The extension selected.
  102108. */
  102109. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  102110. /**
  102111. * Set the compressed texture extensions or file names to skip.
  102112. *
  102113. * @param skippedFiles defines the list of those texture files you want to skip
  102114. * Example: [".dds", ".env", "myfile.png"]
  102115. */
  102116. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  102117. /**
  102118. * Force a specific size of the canvas
  102119. * @param width defines the new canvas' width
  102120. * @param height defines the new canvas' height
  102121. */
  102122. setSize(width: number, height: number): void;
  102123. /**
  102124. * Updates a dynamic vertex buffer.
  102125. * @param vertexBuffer the vertex buffer to update
  102126. * @param data the data used to update the vertex buffer
  102127. * @param byteOffset the byte offset of the data
  102128. * @param byteLength the byte length of the data
  102129. */
  102130. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  102131. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  102132. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102133. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102134. _releaseTexture(texture: InternalTexture): void;
  102135. /**
  102136. * @hidden
  102137. * Rescales a texture
  102138. * @param source input texutre
  102139. * @param destination destination texture
  102140. * @param scene scene to use to render the resize
  102141. * @param internalFormat format to use when resizing
  102142. * @param onComplete callback to be called when resize has completed
  102143. */
  102144. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102145. /**
  102146. * Gets the current framerate
  102147. * @returns a number representing the framerate
  102148. */
  102149. getFps(): number;
  102150. /**
  102151. * Gets the time spent between current and previous frame
  102152. * @returns a number representing the delta time in ms
  102153. */
  102154. getDeltaTime(): number;
  102155. private _measureFps;
  102156. /** @hidden */
  102157. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  102158. /**
  102159. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  102160. * @param renderTarget The render target to set the frame buffer for
  102161. */
  102162. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  102163. /**
  102164. * Update a dynamic index buffer
  102165. * @param indexBuffer defines the target index buffer
  102166. * @param indices defines the data to update
  102167. * @param offset defines the offset in the target index buffer where update should start
  102168. */
  102169. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  102170. /**
  102171. * Updates the sample count of a render target texture
  102172. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102173. * @param texture defines the texture to update
  102174. * @param samples defines the sample count to set
  102175. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102176. */
  102177. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  102178. /**
  102179. * Updates a depth texture Comparison Mode and Function.
  102180. * If the comparison Function is equal to 0, the mode will be set to none.
  102181. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  102182. * @param texture The texture to set the comparison function for
  102183. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  102184. */
  102185. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  102186. /**
  102187. * Creates a webGL buffer to use with instanciation
  102188. * @param capacity defines the size of the buffer
  102189. * @returns the webGL buffer
  102190. */
  102191. createInstancesBuffer(capacity: number): DataBuffer;
  102192. /**
  102193. * Delete a webGL buffer used with instanciation
  102194. * @param buffer defines the webGL buffer to delete
  102195. */
  102196. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  102197. /** @hidden */
  102198. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  102199. dispose(): void;
  102200. private _disableTouchAction;
  102201. /**
  102202. * Display the loading screen
  102203. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102204. */
  102205. displayLoadingUI(): void;
  102206. /**
  102207. * Hide the loading screen
  102208. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102209. */
  102210. hideLoadingUI(): void;
  102211. /**
  102212. * Gets the current loading screen object
  102213. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102214. */
  102215. /**
  102216. * Sets the current loading screen object
  102217. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102218. */
  102219. loadingScreen: ILoadingScreen;
  102220. /**
  102221. * Sets the current loading screen text
  102222. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102223. */
  102224. loadingUIText: string;
  102225. /**
  102226. * Sets the current loading screen background color
  102227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102228. */
  102229. loadingUIBackgroundColor: string;
  102230. /** Pointerlock and fullscreen */
  102231. /**
  102232. * Ask the browser to promote the current element to pointerlock mode
  102233. * @param element defines the DOM element to promote
  102234. */
  102235. static _RequestPointerlock(element: HTMLElement): void;
  102236. /**
  102237. * Asks the browser to exit pointerlock mode
  102238. */
  102239. static _ExitPointerlock(): void;
  102240. /**
  102241. * Ask the browser to promote the current element to fullscreen rendering mode
  102242. * @param element defines the DOM element to promote
  102243. */
  102244. static _RequestFullscreen(element: HTMLElement): void;
  102245. /**
  102246. * Asks the browser to exit fullscreen mode
  102247. */
  102248. static _ExitFullscreen(): void;
  102249. }
  102250. }
  102251. declare module BABYLON {
  102252. /**
  102253. * The engine store class is responsible to hold all the instances of Engine and Scene created
  102254. * during the life time of the application.
  102255. */
  102256. export class EngineStore {
  102257. /** Gets the list of created engines */
  102258. static Instances: Engine[];
  102259. /** @hidden */
  102260. static _LastCreatedScene: Nullable<Scene>;
  102261. /**
  102262. * Gets the latest created engine
  102263. */
  102264. static readonly LastCreatedEngine: Nullable<Engine>;
  102265. /**
  102266. * Gets the latest created scene
  102267. */
  102268. static readonly LastCreatedScene: Nullable<Scene>;
  102269. /**
  102270. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102271. * @ignorenaming
  102272. */
  102273. static UseFallbackTexture: boolean;
  102274. /**
  102275. * Texture content used if a texture cannot loaded
  102276. * @ignorenaming
  102277. */
  102278. static FallbackTexture: string;
  102279. }
  102280. }
  102281. declare module BABYLON {
  102282. /**
  102283. * Helper class that provides a small promise polyfill
  102284. */
  102285. export class PromisePolyfill {
  102286. /**
  102287. * Static function used to check if the polyfill is required
  102288. * If this is the case then the function will inject the polyfill to window.Promise
  102289. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  102290. */
  102291. static Apply(force?: boolean): void;
  102292. }
  102293. }
  102294. declare module BABYLON {
  102295. /**
  102296. * Interface for screenshot methods with describe argument called `size` as object with options
  102297. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  102298. */
  102299. export interface IScreenshotSize {
  102300. /**
  102301. * number in pixels for canvas height
  102302. */
  102303. height?: number;
  102304. /**
  102305. * multiplier allowing render at a higher or lower resolution
  102306. * If value is defined then height and width will be ignored and taken from camera
  102307. */
  102308. precision?: number;
  102309. /**
  102310. * number in pixels for canvas width
  102311. */
  102312. width?: number;
  102313. }
  102314. }
  102315. declare module BABYLON {
  102316. interface IColor4Like {
  102317. r: float;
  102318. g: float;
  102319. b: float;
  102320. a: float;
  102321. }
  102322. /**
  102323. * Class containing a set of static utilities functions
  102324. */
  102325. export class Tools {
  102326. /**
  102327. * Gets or sets the base URL to use to load assets
  102328. */
  102329. static BaseUrl: string;
  102330. /**
  102331. * Enable/Disable Custom HTTP Request Headers globally.
  102332. * default = false
  102333. * @see CustomRequestHeaders
  102334. */
  102335. static UseCustomRequestHeaders: boolean;
  102336. /**
  102337. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  102338. * i.e. when loading files, where the server/service expects an Authorization header
  102339. */
  102340. static CustomRequestHeaders: {
  102341. [key: string]: string;
  102342. };
  102343. /**
  102344. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  102345. */
  102346. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  102347. /**
  102348. * Default behaviour for cors in the application.
  102349. * It can be a string if the expected behavior is identical in the entire app.
  102350. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  102351. */
  102352. static CorsBehavior: string | ((url: string | string[]) => string);
  102353. /**
  102354. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102355. * @ignorenaming
  102356. */
  102357. static UseFallbackTexture: boolean;
  102358. /**
  102359. * Use this object to register external classes like custom textures or material
  102360. * to allow the laoders to instantiate them
  102361. */
  102362. static RegisteredExternalClasses: {
  102363. [key: string]: Object;
  102364. };
  102365. /**
  102366. * Texture content used if a texture cannot loaded
  102367. * @ignorenaming
  102368. */
  102369. static fallbackTexture: string;
  102370. /**
  102371. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  102372. * @param u defines the coordinate on X axis
  102373. * @param v defines the coordinate on Y axis
  102374. * @param width defines the width of the source data
  102375. * @param height defines the height of the source data
  102376. * @param pixels defines the source byte array
  102377. * @param color defines the output color
  102378. */
  102379. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  102380. /**
  102381. * Interpolates between a and b via alpha
  102382. * @param a The lower value (returned when alpha = 0)
  102383. * @param b The upper value (returned when alpha = 1)
  102384. * @param alpha The interpolation-factor
  102385. * @return The mixed value
  102386. */
  102387. static Mix(a: number, b: number, alpha: number): number;
  102388. /**
  102389. * Tries to instantiate a new object from a given class name
  102390. * @param className defines the class name to instantiate
  102391. * @returns the new object or null if the system was not able to do the instantiation
  102392. */
  102393. static Instantiate(className: string): any;
  102394. /**
  102395. * Provides a slice function that will work even on IE
  102396. * @param data defines the array to slice
  102397. * @param start defines the start of the data (optional)
  102398. * @param end defines the end of the data (optional)
  102399. * @returns the new sliced array
  102400. */
  102401. static Slice<T>(data: T, start?: number, end?: number): T;
  102402. /**
  102403. * Polyfill for setImmediate
  102404. * @param action defines the action to execute after the current execution block
  102405. */
  102406. static SetImmediate(action: () => void): void;
  102407. /**
  102408. * Function indicating if a number is an exponent of 2
  102409. * @param value defines the value to test
  102410. * @returns true if the value is an exponent of 2
  102411. */
  102412. static IsExponentOfTwo(value: number): boolean;
  102413. private static _tmpFloatArray;
  102414. /**
  102415. * Returns the nearest 32-bit single precision float representation of a Number
  102416. * @param value A Number. If the parameter is of a different type, it will get converted
  102417. * to a number or to NaN if it cannot be converted
  102418. * @returns number
  102419. */
  102420. static FloatRound(value: number): number;
  102421. /**
  102422. * Extracts the filename from a path
  102423. * @param path defines the path to use
  102424. * @returns the filename
  102425. */
  102426. static GetFilename(path: string): string;
  102427. /**
  102428. * Extracts the "folder" part of a path (everything before the filename).
  102429. * @param uri The URI to extract the info from
  102430. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  102431. * @returns The "folder" part of the path
  102432. */
  102433. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  102434. /**
  102435. * Extracts text content from a DOM element hierarchy
  102436. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  102437. */
  102438. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  102439. /**
  102440. * Convert an angle in radians to degrees
  102441. * @param angle defines the angle to convert
  102442. * @returns the angle in degrees
  102443. */
  102444. static ToDegrees(angle: number): number;
  102445. /**
  102446. * Convert an angle in degrees to radians
  102447. * @param angle defines the angle to convert
  102448. * @returns the angle in radians
  102449. */
  102450. static ToRadians(angle: number): number;
  102451. /**
  102452. * Returns an array if obj is not an array
  102453. * @param obj defines the object to evaluate as an array
  102454. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  102455. * @returns either obj directly if obj is an array or a new array containing obj
  102456. */
  102457. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  102458. /**
  102459. * Gets the pointer prefix to use
  102460. * @returns "pointer" if touch is enabled. Else returns "mouse"
  102461. */
  102462. static GetPointerPrefix(): string;
  102463. /**
  102464. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  102465. * @param url define the url we are trying
  102466. * @param element define the dom element where to configure the cors policy
  102467. */
  102468. static SetCorsBehavior(url: string | string[], element: {
  102469. crossOrigin: string | null;
  102470. }): void;
  102471. /**
  102472. * Removes unwanted characters from an url
  102473. * @param url defines the url to clean
  102474. * @returns the cleaned url
  102475. */
  102476. static CleanUrl(url: string): string;
  102477. /**
  102478. * Gets or sets a function used to pre-process url before using them to load assets
  102479. */
  102480. static PreprocessUrl: (url: string) => string;
  102481. /**
  102482. * Loads an image as an HTMLImageElement.
  102483. * @param input url string, ArrayBuffer, or Blob to load
  102484. * @param onLoad callback called when the image successfully loads
  102485. * @param onError callback called when the image fails to load
  102486. * @param offlineProvider offline provider for caching
  102487. * @param mimeType optional mime type
  102488. * @returns the HTMLImageElement of the loaded image
  102489. */
  102490. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  102491. /**
  102492. * Loads a file from a url
  102493. * @param url url string, ArrayBuffer, or Blob to load
  102494. * @param onSuccess callback called when the file successfully loads
  102495. * @param onProgress callback called while file is loading (if the server supports this mode)
  102496. * @param offlineProvider defines the offline provider for caching
  102497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102498. * @param onError callback called when the file fails to load
  102499. * @returns a file request object
  102500. */
  102501. 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;
  102502. /**
  102503. * Loads a file from a url
  102504. * @param url the file url to load
  102505. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  102506. */
  102507. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  102508. /**
  102509. * Load a script (identified by an url). When the url returns, the
  102510. * content of this file is added into a new script element, attached to the DOM (body element)
  102511. * @param scriptUrl defines the url of the script to laod
  102512. * @param onSuccess defines the callback called when the script is loaded
  102513. * @param onError defines the callback to call if an error occurs
  102514. * @param scriptId defines the id of the script element
  102515. */
  102516. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  102517. /**
  102518. * Load an asynchronous script (identified by an url). When the url returns, the
  102519. * content of this file is added into a new script element, attached to the DOM (body element)
  102520. * @param scriptUrl defines the url of the script to laod
  102521. * @param scriptId defines the id of the script element
  102522. * @returns a promise request object
  102523. */
  102524. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  102525. /**
  102526. * Loads a file from a blob
  102527. * @param fileToLoad defines the blob to use
  102528. * @param callback defines the callback to call when data is loaded
  102529. * @param progressCallback defines the callback to call during loading process
  102530. * @returns a file request object
  102531. */
  102532. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  102533. /**
  102534. * Reads a file from a File object
  102535. * @param file defines the file to load
  102536. * @param onSuccess defines the callback to call when data is loaded
  102537. * @param onProgress defines the callback to call during loading process
  102538. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  102539. * @param onError defines the callback to call when an error occurs
  102540. * @returns a file request object
  102541. */
  102542. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102543. /**
  102544. * Creates a data url from a given string content
  102545. * @param content defines the content to convert
  102546. * @returns the new data url link
  102547. */
  102548. static FileAsURL(content: string): string;
  102549. /**
  102550. * Format the given number to a specific decimal format
  102551. * @param value defines the number to format
  102552. * @param decimals defines the number of decimals to use
  102553. * @returns the formatted string
  102554. */
  102555. static Format(value: number, decimals?: number): string;
  102556. /**
  102557. * Tries to copy an object by duplicating every property
  102558. * @param source defines the source object
  102559. * @param destination defines the target object
  102560. * @param doNotCopyList defines a list of properties to avoid
  102561. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  102562. */
  102563. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  102564. /**
  102565. * Gets a boolean indicating if the given object has no own property
  102566. * @param obj defines the object to test
  102567. * @returns true if object has no own property
  102568. */
  102569. static IsEmpty(obj: any): boolean;
  102570. /**
  102571. * Function used to register events at window level
  102572. * @param windowElement defines the Window object to use
  102573. * @param events defines the events to register
  102574. */
  102575. static RegisterTopRootEvents(windowElement: Window, events: {
  102576. name: string;
  102577. handler: Nullable<(e: FocusEvent) => any>;
  102578. }[]): void;
  102579. /**
  102580. * Function used to unregister events from window level
  102581. * @param windowElement defines the Window object to use
  102582. * @param events defines the events to unregister
  102583. */
  102584. static UnregisterTopRootEvents(windowElement: Window, events: {
  102585. name: string;
  102586. handler: Nullable<(e: FocusEvent) => any>;
  102587. }[]): void;
  102588. /**
  102589. * @ignore
  102590. */
  102591. static _ScreenshotCanvas: HTMLCanvasElement;
  102592. /**
  102593. * Dumps the current bound framebuffer
  102594. * @param width defines the rendering width
  102595. * @param height defines the rendering height
  102596. * @param engine defines the hosting engine
  102597. * @param successCallback defines the callback triggered once the data are available
  102598. * @param mimeType defines the mime type of the result
  102599. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  102600. */
  102601. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102602. /**
  102603. * Converts the canvas data to blob.
  102604. * This acts as a polyfill for browsers not supporting the to blob function.
  102605. * @param canvas Defines the canvas to extract the data from
  102606. * @param successCallback Defines the callback triggered once the data are available
  102607. * @param mimeType Defines the mime type of the result
  102608. */
  102609. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  102610. /**
  102611. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  102612. * @param successCallback defines the callback triggered once the data are available
  102613. * @param mimeType defines the mime type of the result
  102614. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  102615. */
  102616. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102617. /**
  102618. * Downloads a blob in the browser
  102619. * @param blob defines the blob to download
  102620. * @param fileName defines the name of the downloaded file
  102621. */
  102622. static Download(blob: Blob, fileName: string): void;
  102623. /**
  102624. * Captures a screenshot of the current rendering
  102625. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102626. * @param engine defines the rendering engine
  102627. * @param camera defines the source camera
  102628. * @param size This parameter can be set to a single number or to an object with the
  102629. * following (optional) properties: precision, width, height. If a single number is passed,
  102630. * it will be used for both width and height. If an object is passed, the screenshot size
  102631. * will be derived from the parameters. The precision property is a multiplier allowing
  102632. * rendering at a higher or lower resolution
  102633. * @param successCallback defines the callback receives a single parameter which contains the
  102634. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102635. * src parameter of an <img> to display it
  102636. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102637. * Check your browser for supported MIME types
  102638. */
  102639. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  102640. /**
  102641. * Captures a screenshot of the current rendering
  102642. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102643. * @param engine defines the rendering engine
  102644. * @param camera defines the source camera
  102645. * @param size This parameter can be set to a single number or to an object with the
  102646. * following (optional) properties: precision, width, height. If a single number is passed,
  102647. * it will be used for both width and height. If an object is passed, the screenshot size
  102648. * will be derived from the parameters. The precision property is a multiplier allowing
  102649. * rendering at a higher or lower resolution
  102650. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102651. * Check your browser for supported MIME types
  102652. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102653. * to the src parameter of an <img> to display it
  102654. */
  102655. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  102656. /**
  102657. * Generates an image screenshot from the specified camera.
  102658. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102659. * @param engine The engine to use for rendering
  102660. * @param camera The camera to use for rendering
  102661. * @param size This parameter can be set to a single number or to an object with the
  102662. * following (optional) properties: precision, width, height. If a single number is passed,
  102663. * it will be used for both width and height. If an object is passed, the screenshot size
  102664. * will be derived from the parameters. The precision property is a multiplier allowing
  102665. * rendering at a higher or lower resolution
  102666. * @param successCallback The callback receives a single parameter which contains the
  102667. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102668. * src parameter of an <img> to display it
  102669. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102670. * Check your browser for supported MIME types
  102671. * @param samples Texture samples (default: 1)
  102672. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102673. * @param fileName A name for for the downloaded file.
  102674. */
  102675. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  102676. /**
  102677. * Generates an image screenshot from the specified camera.
  102678. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102679. * @param engine The engine to use for rendering
  102680. * @param camera The camera to use for rendering
  102681. * @param size This parameter can be set to a single number or to an object with the
  102682. * following (optional) properties: precision, width, height. If a single number is passed,
  102683. * it will be used for both width and height. If an object is passed, the screenshot size
  102684. * will be derived from the parameters. The precision property is a multiplier allowing
  102685. * rendering at a higher or lower resolution
  102686. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102687. * Check your browser for supported MIME types
  102688. * @param samples Texture samples (default: 1)
  102689. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102690. * @param fileName A name for for the downloaded file.
  102691. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102692. * to the src parameter of an <img> to display it
  102693. */
  102694. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  102695. /**
  102696. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102697. * Be aware Math.random() could cause collisions, but:
  102698. * "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"
  102699. * @returns a pseudo random id
  102700. */
  102701. static RandomId(): string;
  102702. /**
  102703. * Test if the given uri is a base64 string
  102704. * @param uri The uri to test
  102705. * @return True if the uri is a base64 string or false otherwise
  102706. */
  102707. static IsBase64(uri: string): boolean;
  102708. /**
  102709. * Decode the given base64 uri.
  102710. * @param uri The uri to decode
  102711. * @return The decoded base64 data.
  102712. */
  102713. static DecodeBase64(uri: string): ArrayBuffer;
  102714. /**
  102715. * Gets the absolute url.
  102716. * @param url the input url
  102717. * @return the absolute url
  102718. */
  102719. static GetAbsoluteUrl(url: string): string;
  102720. /**
  102721. * No log
  102722. */
  102723. static readonly NoneLogLevel: number;
  102724. /**
  102725. * Only message logs
  102726. */
  102727. static readonly MessageLogLevel: number;
  102728. /**
  102729. * Only warning logs
  102730. */
  102731. static readonly WarningLogLevel: number;
  102732. /**
  102733. * Only error logs
  102734. */
  102735. static readonly ErrorLogLevel: number;
  102736. /**
  102737. * All logs
  102738. */
  102739. static readonly AllLogLevel: number;
  102740. /**
  102741. * Gets a value indicating the number of loading errors
  102742. * @ignorenaming
  102743. */
  102744. static readonly errorsCount: number;
  102745. /**
  102746. * Callback called when a new log is added
  102747. */
  102748. static OnNewCacheEntry: (entry: string) => void;
  102749. /**
  102750. * Log a message to the console
  102751. * @param message defines the message to log
  102752. */
  102753. static Log(message: string): void;
  102754. /**
  102755. * Write a warning message to the console
  102756. * @param message defines the message to log
  102757. */
  102758. static Warn(message: string): void;
  102759. /**
  102760. * Write an error message to the console
  102761. * @param message defines the message to log
  102762. */
  102763. static Error(message: string): void;
  102764. /**
  102765. * Gets current log cache (list of logs)
  102766. */
  102767. static readonly LogCache: string;
  102768. /**
  102769. * Clears the log cache
  102770. */
  102771. static ClearLogCache(): void;
  102772. /**
  102773. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  102774. */
  102775. static LogLevels: number;
  102776. /**
  102777. * Checks if the window object exists
  102778. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  102779. */
  102780. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  102781. /**
  102782. * No performance log
  102783. */
  102784. static readonly PerformanceNoneLogLevel: number;
  102785. /**
  102786. * Use user marks to log performance
  102787. */
  102788. static readonly PerformanceUserMarkLogLevel: number;
  102789. /**
  102790. * Log performance to the console
  102791. */
  102792. static readonly PerformanceConsoleLogLevel: number;
  102793. private static _performance;
  102794. /**
  102795. * Sets the current performance log level
  102796. */
  102797. static PerformanceLogLevel: number;
  102798. private static _StartPerformanceCounterDisabled;
  102799. private static _EndPerformanceCounterDisabled;
  102800. private static _StartUserMark;
  102801. private static _EndUserMark;
  102802. private static _StartPerformanceConsole;
  102803. private static _EndPerformanceConsole;
  102804. /**
  102805. * Starts a performance counter
  102806. */
  102807. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  102808. /**
  102809. * Ends a specific performance coutner
  102810. */
  102811. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  102812. /**
  102813. * Gets either window.performance.now() if supported or Date.now() else
  102814. */
  102815. static readonly Now: number;
  102816. /**
  102817. * This method will return the name of the class used to create the instance of the given object.
  102818. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  102819. * @param object the object to get the class name from
  102820. * @param isType defines if the object is actually a type
  102821. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  102822. */
  102823. static GetClassName(object: any, isType?: boolean): string;
  102824. /**
  102825. * Gets the first element of an array satisfying a given predicate
  102826. * @param array defines the array to browse
  102827. * @param predicate defines the predicate to use
  102828. * @returns null if not found or the element
  102829. */
  102830. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  102831. /**
  102832. * This method will return the name of the full name of the class, including its owning module (if any).
  102833. * 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).
  102834. * @param object the object to get the class name from
  102835. * @param isType defines if the object is actually a type
  102836. * @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.
  102837. * @ignorenaming
  102838. */
  102839. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  102840. /**
  102841. * Returns a promise that resolves after the given amount of time.
  102842. * @param delay Number of milliseconds to delay
  102843. * @returns Promise that resolves after the given amount of time
  102844. */
  102845. static DelayAsync(delay: number): Promise<void>;
  102846. }
  102847. /**
  102848. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  102849. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  102850. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  102851. * @param name The name of the class, case should be preserved
  102852. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  102853. */
  102854. export function className(name: string, module?: string): (target: Object) => void;
  102855. /**
  102856. * An implementation of a loop for asynchronous functions.
  102857. */
  102858. export class AsyncLoop {
  102859. /**
  102860. * Defines the number of iterations for the loop
  102861. */
  102862. iterations: number;
  102863. /**
  102864. * Defines the current index of the loop.
  102865. */
  102866. index: number;
  102867. private _done;
  102868. private _fn;
  102869. private _successCallback;
  102870. /**
  102871. * Constructor.
  102872. * @param iterations the number of iterations.
  102873. * @param func the function to run each iteration
  102874. * @param successCallback the callback that will be called upon succesful execution
  102875. * @param offset starting offset.
  102876. */
  102877. constructor(
  102878. /**
  102879. * Defines the number of iterations for the loop
  102880. */
  102881. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  102882. /**
  102883. * Execute the next iteration. Must be called after the last iteration was finished.
  102884. */
  102885. executeNext(): void;
  102886. /**
  102887. * Break the loop and run the success callback.
  102888. */
  102889. breakLoop(): void;
  102890. /**
  102891. * Create and run an async loop.
  102892. * @param iterations the number of iterations.
  102893. * @param fn the function to run each iteration
  102894. * @param successCallback the callback that will be called upon succesful execution
  102895. * @param offset starting offset.
  102896. * @returns the created async loop object
  102897. */
  102898. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  102899. /**
  102900. * A for-loop that will run a given number of iterations synchronous and the rest async.
  102901. * @param iterations total number of iterations
  102902. * @param syncedIterations number of synchronous iterations in each async iteration.
  102903. * @param fn the function to call each iteration.
  102904. * @param callback a success call back that will be called when iterating stops.
  102905. * @param breakFunction a break condition (optional)
  102906. * @param timeout timeout settings for the setTimeout function. default - 0.
  102907. * @returns the created async loop object
  102908. */
  102909. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  102910. }
  102911. }
  102912. declare module BABYLON {
  102913. /**
  102914. * This class implement a typical dictionary using a string as key and the generic type T as value.
  102915. * The underlying implementation relies on an associative array to ensure the best performances.
  102916. * The value can be anything including 'null' but except 'undefined'
  102917. */
  102918. export class StringDictionary<T> {
  102919. /**
  102920. * This will clear this dictionary and copy the content from the 'source' one.
  102921. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  102922. * @param source the dictionary to take the content from and copy to this dictionary
  102923. */
  102924. copyFrom(source: StringDictionary<T>): void;
  102925. /**
  102926. * Get a value based from its key
  102927. * @param key the given key to get the matching value from
  102928. * @return the value if found, otherwise undefined is returned
  102929. */
  102930. get(key: string): T | undefined;
  102931. /**
  102932. * Get a value from its key or add it if it doesn't exist.
  102933. * This method will ensure you that a given key/data will be present in the dictionary.
  102934. * @param key the given key to get the matching value from
  102935. * @param factory the factory that will create the value if the key is not present in the dictionary.
  102936. * The factory will only be invoked if there's no data for the given key.
  102937. * @return the value corresponding to the key.
  102938. */
  102939. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  102940. /**
  102941. * Get a value from its key if present in the dictionary otherwise add it
  102942. * @param key the key to get the value from
  102943. * @param val if there's no such key/value pair in the dictionary add it with this value
  102944. * @return the value corresponding to the key
  102945. */
  102946. getOrAdd(key: string, val: T): T;
  102947. /**
  102948. * Check if there's a given key in the dictionary
  102949. * @param key the key to check for
  102950. * @return true if the key is present, false otherwise
  102951. */
  102952. contains(key: string): boolean;
  102953. /**
  102954. * Add a new key and its corresponding value
  102955. * @param key the key to add
  102956. * @param value the value corresponding to the key
  102957. * @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
  102958. */
  102959. add(key: string, value: T): boolean;
  102960. /**
  102961. * Update a specific value associated to a key
  102962. * @param key defines the key to use
  102963. * @param value defines the value to store
  102964. * @returns true if the value was updated (or false if the key was not found)
  102965. */
  102966. set(key: string, value: T): boolean;
  102967. /**
  102968. * Get the element of the given key and remove it from the dictionary
  102969. * @param key defines the key to search
  102970. * @returns the value associated with the key or null if not found
  102971. */
  102972. getAndRemove(key: string): Nullable<T>;
  102973. /**
  102974. * Remove a key/value from the dictionary.
  102975. * @param key the key to remove
  102976. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  102977. */
  102978. remove(key: string): boolean;
  102979. /**
  102980. * Clear the whole content of the dictionary
  102981. */
  102982. clear(): void;
  102983. /**
  102984. * Gets the current count
  102985. */
  102986. readonly count: number;
  102987. /**
  102988. * Execute a callback on each key/val of the dictionary.
  102989. * Note that you can remove any element in this dictionary in the callback implementation
  102990. * @param callback the callback to execute on a given key/value pair
  102991. */
  102992. forEach(callback: (key: string, val: T) => void): void;
  102993. /**
  102994. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  102995. * If the callback returns null or undefined the method will iterate to the next key/value pair
  102996. * Note that you can remove any element in this dictionary in the callback implementation
  102997. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  102998. * @returns the first item
  102999. */
  103000. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  103001. private _count;
  103002. private _data;
  103003. }
  103004. }
  103005. declare module BABYLON {
  103006. /** @hidden */
  103007. export interface ICollisionCoordinator {
  103008. createCollider(): Collider;
  103009. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  103010. init(scene: Scene): void;
  103011. }
  103012. /** @hidden */
  103013. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  103014. private _scene;
  103015. private _scaledPosition;
  103016. private _scaledVelocity;
  103017. private _finalPosition;
  103018. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  103019. createCollider(): Collider;
  103020. init(scene: Scene): void;
  103021. private _collideWithWorld;
  103022. }
  103023. }
  103024. declare module BABYLON {
  103025. /**
  103026. * Class used to manage all inputs for the scene.
  103027. */
  103028. export class InputManager {
  103029. /** The distance in pixel that you have to move to prevent some events */
  103030. static DragMovementThreshold: number;
  103031. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  103032. static LongPressDelay: number;
  103033. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  103034. static DoubleClickDelay: number;
  103035. /** If you need to check double click without raising a single click at first click, enable this flag */
  103036. static ExclusiveDoubleClickMode: boolean;
  103037. private _wheelEventName;
  103038. private _onPointerMove;
  103039. private _onPointerDown;
  103040. private _onPointerUp;
  103041. private _initClickEvent;
  103042. private _initActionManager;
  103043. private _delayedSimpleClick;
  103044. private _delayedSimpleClickTimeout;
  103045. private _previousDelayedSimpleClickTimeout;
  103046. private _meshPickProceed;
  103047. private _previousButtonPressed;
  103048. private _currentPickResult;
  103049. private _previousPickResult;
  103050. private _totalPointersPressed;
  103051. private _doubleClickOccured;
  103052. private _pointerOverMesh;
  103053. private _pickedDownMesh;
  103054. private _pickedUpMesh;
  103055. private _pointerX;
  103056. private _pointerY;
  103057. private _unTranslatedPointerX;
  103058. private _unTranslatedPointerY;
  103059. private _startingPointerPosition;
  103060. private _previousStartingPointerPosition;
  103061. private _startingPointerTime;
  103062. private _previousStartingPointerTime;
  103063. private _pointerCaptures;
  103064. private _onKeyDown;
  103065. private _onKeyUp;
  103066. private _onCanvasFocusObserver;
  103067. private _onCanvasBlurObserver;
  103068. private _scene;
  103069. /**
  103070. * Creates a new InputManager
  103071. * @param scene defines the hosting scene
  103072. */
  103073. constructor(scene: Scene);
  103074. /**
  103075. * Gets the mesh that is currently under the pointer
  103076. */
  103077. readonly meshUnderPointer: Nullable<AbstractMesh>;
  103078. /**
  103079. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  103080. */
  103081. readonly unTranslatedPointer: Vector2;
  103082. /**
  103083. * Gets or sets the current on-screen X position of the pointer
  103084. */
  103085. pointerX: number;
  103086. /**
  103087. * Gets or sets the current on-screen Y position of the pointer
  103088. */
  103089. pointerY: number;
  103090. private _updatePointerPosition;
  103091. private _processPointerMove;
  103092. private _setRayOnPointerInfo;
  103093. private _checkPrePointerObservable;
  103094. /**
  103095. * Use this method to simulate a pointer move on a mesh
  103096. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103097. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103098. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103099. */
  103100. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103101. /**
  103102. * Use this method to simulate a pointer down on a mesh
  103103. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103104. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103105. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103106. */
  103107. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103108. private _processPointerDown;
  103109. /** @hidden */
  103110. _isPointerSwiping(): boolean;
  103111. /**
  103112. * Use this method to simulate a pointer up on a mesh
  103113. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103114. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103115. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103116. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  103117. */
  103118. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  103119. private _processPointerUp;
  103120. /**
  103121. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  103122. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  103123. * @returns true if the pointer was captured
  103124. */
  103125. isPointerCaptured(pointerId?: number): boolean;
  103126. /**
  103127. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  103128. * @param attachUp defines if you want to attach events to pointerup
  103129. * @param attachDown defines if you want to attach events to pointerdown
  103130. * @param attachMove defines if you want to attach events to pointermove
  103131. */
  103132. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  103133. /**
  103134. * Detaches all event handlers
  103135. */
  103136. detachControl(): void;
  103137. /**
  103138. * Force the value of meshUnderPointer
  103139. * @param mesh defines the mesh to use
  103140. */
  103141. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103142. /**
  103143. * Gets the mesh under the pointer
  103144. * @returns a Mesh or null if no mesh is under the pointer
  103145. */
  103146. getPointerOverMesh(): Nullable<AbstractMesh>;
  103147. }
  103148. }
  103149. declare module BABYLON {
  103150. /**
  103151. * Helper class used to generate session unique ID
  103152. */
  103153. export class UniqueIdGenerator {
  103154. private static _UniqueIdCounter;
  103155. /**
  103156. * Gets an unique (relatively to the current scene) Id
  103157. */
  103158. static readonly UniqueId: number;
  103159. }
  103160. }
  103161. declare module BABYLON {
  103162. /**
  103163. * This class defines the direct association between an animation and a target
  103164. */
  103165. export class TargetedAnimation {
  103166. /**
  103167. * Animation to perform
  103168. */
  103169. animation: Animation;
  103170. /**
  103171. * Target to animate
  103172. */
  103173. target: any;
  103174. /**
  103175. * Serialize the object
  103176. * @returns the JSON object representing the current entity
  103177. */
  103178. serialize(): any;
  103179. }
  103180. /**
  103181. * Use this class to create coordinated animations on multiple targets
  103182. */
  103183. export class AnimationGroup implements IDisposable {
  103184. /** The name of the animation group */
  103185. name: string;
  103186. private _scene;
  103187. private _targetedAnimations;
  103188. private _animatables;
  103189. private _from;
  103190. private _to;
  103191. private _isStarted;
  103192. private _isPaused;
  103193. private _speedRatio;
  103194. private _loopAnimation;
  103195. /**
  103196. * Gets or sets the unique id of the node
  103197. */
  103198. uniqueId: number;
  103199. /**
  103200. * This observable will notify when one animation have ended
  103201. */
  103202. onAnimationEndObservable: Observable<TargetedAnimation>;
  103203. /**
  103204. * Observer raised when one animation loops
  103205. */
  103206. onAnimationLoopObservable: Observable<TargetedAnimation>;
  103207. /**
  103208. * Observer raised when all animations have looped
  103209. */
  103210. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  103211. /**
  103212. * This observable will notify when all animations have ended.
  103213. */
  103214. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  103215. /**
  103216. * This observable will notify when all animations have paused.
  103217. */
  103218. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  103219. /**
  103220. * This observable will notify when all animations are playing.
  103221. */
  103222. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  103223. /**
  103224. * Gets the first frame
  103225. */
  103226. readonly from: number;
  103227. /**
  103228. * Gets the last frame
  103229. */
  103230. readonly to: number;
  103231. /**
  103232. * Define if the animations are started
  103233. */
  103234. readonly isStarted: boolean;
  103235. /**
  103236. * Gets a value indicating that the current group is playing
  103237. */
  103238. readonly isPlaying: boolean;
  103239. /**
  103240. * Gets or sets the speed ratio to use for all animations
  103241. */
  103242. /**
  103243. * Gets or sets the speed ratio to use for all animations
  103244. */
  103245. speedRatio: number;
  103246. /**
  103247. * Gets or sets if all animations should loop or not
  103248. */
  103249. loopAnimation: boolean;
  103250. /**
  103251. * Gets the targeted animations for this animation group
  103252. */
  103253. readonly targetedAnimations: Array<TargetedAnimation>;
  103254. /**
  103255. * returning the list of animatables controlled by this animation group.
  103256. */
  103257. readonly animatables: Array<Animatable>;
  103258. /**
  103259. * Instantiates a new Animation Group.
  103260. * This helps managing several animations at once.
  103261. * @see http://doc.babylonjs.com/how_to/group
  103262. * @param name Defines the name of the group
  103263. * @param scene Defines the scene the group belongs to
  103264. */
  103265. constructor(
  103266. /** The name of the animation group */
  103267. name: string, scene?: Nullable<Scene>);
  103268. /**
  103269. * Add an animation (with its target) in the group
  103270. * @param animation defines the animation we want to add
  103271. * @param target defines the target of the animation
  103272. * @returns the TargetedAnimation object
  103273. */
  103274. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  103275. /**
  103276. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  103277. * It can add constant keys at begin or end
  103278. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  103279. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  103280. * @returns the animation group
  103281. */
  103282. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  103283. private _animationLoopCount;
  103284. private _animationLoopFlags;
  103285. private _processLoop;
  103286. /**
  103287. * Start all animations on given targets
  103288. * @param loop defines if animations must loop
  103289. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  103290. * @param from defines the from key (optional)
  103291. * @param to defines the to key (optional)
  103292. * @returns the current animation group
  103293. */
  103294. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  103295. /**
  103296. * Pause all animations
  103297. * @returns the animation group
  103298. */
  103299. pause(): AnimationGroup;
  103300. /**
  103301. * Play all animations to initial state
  103302. * This function will start() the animations if they were not started or will restart() them if they were paused
  103303. * @param loop defines if animations must loop
  103304. * @returns the animation group
  103305. */
  103306. play(loop?: boolean): AnimationGroup;
  103307. /**
  103308. * Reset all animations to initial state
  103309. * @returns the animation group
  103310. */
  103311. reset(): AnimationGroup;
  103312. /**
  103313. * Restart animations from key 0
  103314. * @returns the animation group
  103315. */
  103316. restart(): AnimationGroup;
  103317. /**
  103318. * Stop all animations
  103319. * @returns the animation group
  103320. */
  103321. stop(): AnimationGroup;
  103322. /**
  103323. * Set animation weight for all animatables
  103324. * @param weight defines the weight to use
  103325. * @return the animationGroup
  103326. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103327. */
  103328. setWeightForAllAnimatables(weight: number): AnimationGroup;
  103329. /**
  103330. * Synchronize and normalize all animatables with a source animatable
  103331. * @param root defines the root animatable to synchronize with
  103332. * @return the animationGroup
  103333. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103334. */
  103335. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  103336. /**
  103337. * Goes to a specific frame in this animation group
  103338. * @param frame the frame number to go to
  103339. * @return the animationGroup
  103340. */
  103341. goToFrame(frame: number): AnimationGroup;
  103342. /**
  103343. * Dispose all associated resources
  103344. */
  103345. dispose(): void;
  103346. private _checkAnimationGroupEnded;
  103347. /**
  103348. * Clone the current animation group and returns a copy
  103349. * @param newName defines the name of the new group
  103350. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  103351. * @returns the new aniamtion group
  103352. */
  103353. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  103354. /**
  103355. * Serializes the animationGroup to an object
  103356. * @returns Serialized object
  103357. */
  103358. serialize(): any;
  103359. /**
  103360. * Returns a new AnimationGroup object parsed from the source provided.
  103361. * @param parsedAnimationGroup defines the source
  103362. * @param scene defines the scene that will receive the animationGroup
  103363. * @returns a new AnimationGroup
  103364. */
  103365. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  103366. /**
  103367. * Returns the string "AnimationGroup"
  103368. * @returns "AnimationGroup"
  103369. */
  103370. getClassName(): string;
  103371. /**
  103372. * Creates a detailled string about the object
  103373. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  103374. * @returns a string representing the object
  103375. */
  103376. toString(fullDetails?: boolean): string;
  103377. }
  103378. }
  103379. declare module BABYLON {
  103380. /**
  103381. * Define an interface for all classes that will hold resources
  103382. */
  103383. export interface IDisposable {
  103384. /**
  103385. * Releases all held resources
  103386. */
  103387. dispose(): void;
  103388. }
  103389. /** Interface defining initialization parameters for Scene class */
  103390. export interface SceneOptions {
  103391. /**
  103392. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  103393. * It will improve performance when the number of geometries becomes important.
  103394. */
  103395. useGeometryUniqueIdsMap?: boolean;
  103396. /**
  103397. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  103398. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103399. */
  103400. useMaterialMeshMap?: boolean;
  103401. /**
  103402. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  103403. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103404. */
  103405. useClonedMeshhMap?: boolean;
  103406. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  103407. virtual?: boolean;
  103408. }
  103409. /**
  103410. * Represents a scene to be rendered by the engine.
  103411. * @see http://doc.babylonjs.com/features/scene
  103412. */
  103413. export class Scene extends AbstractScene implements IAnimatable {
  103414. /** The fog is deactivated */
  103415. static readonly FOGMODE_NONE: number;
  103416. /** The fog density is following an exponential function */
  103417. static readonly FOGMODE_EXP: number;
  103418. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  103419. static readonly FOGMODE_EXP2: number;
  103420. /** The fog density is following a linear function. */
  103421. static readonly FOGMODE_LINEAR: number;
  103422. /**
  103423. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  103424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103425. */
  103426. static MinDeltaTime: number;
  103427. /**
  103428. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  103429. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103430. */
  103431. static MaxDeltaTime: number;
  103432. /**
  103433. * Factory used to create the default material.
  103434. * @param name The name of the material to create
  103435. * @param scene The scene to create the material for
  103436. * @returns The default material
  103437. */
  103438. static DefaultMaterialFactory(scene: Scene): Material;
  103439. /**
  103440. * Factory used to create the a collision coordinator.
  103441. * @returns The collision coordinator
  103442. */
  103443. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  103444. /** @hidden */
  103445. _inputManager: InputManager;
  103446. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  103447. cameraToUseForPointers: Nullable<Camera>;
  103448. /** @hidden */
  103449. readonly _isScene: boolean;
  103450. /**
  103451. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  103452. */
  103453. autoClear: boolean;
  103454. /**
  103455. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  103456. */
  103457. autoClearDepthAndStencil: boolean;
  103458. /**
  103459. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  103460. */
  103461. clearColor: Color4;
  103462. /**
  103463. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  103464. */
  103465. ambientColor: Color3;
  103466. /**
  103467. * This is use to store the default BRDF lookup for PBR materials in your scene.
  103468. * It should only be one of the following (if not the default embedded one):
  103469. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103470. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  103471. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103472. * The material properties need to be setup according to the type of texture in use.
  103473. */
  103474. environmentBRDFTexture: BaseTexture;
  103475. /** @hidden */
  103476. protected _environmentTexture: Nullable<BaseTexture>;
  103477. /**
  103478. * Texture used in all pbr material as the reflection texture.
  103479. * As in the majority of the scene they are the same (exception for multi room and so on),
  103480. * this is easier to reference from here than from all the materials.
  103481. */
  103482. /**
  103483. * Texture used in all pbr material as the reflection texture.
  103484. * As in the majority of the scene they are the same (exception for multi room and so on),
  103485. * this is easier to set here than in all the materials.
  103486. */
  103487. environmentTexture: Nullable<BaseTexture>;
  103488. /** @hidden */
  103489. protected _environmentIntensity: number;
  103490. /**
  103491. * Intensity of the environment in all pbr material.
  103492. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103493. * As in the majority of the scene they are the same (exception for multi room and so on),
  103494. * this is easier to reference from here than from all the materials.
  103495. */
  103496. /**
  103497. * Intensity of the environment in all pbr material.
  103498. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103499. * As in the majority of the scene they are the same (exception for multi room and so on),
  103500. * this is easier to set here than in all the materials.
  103501. */
  103502. environmentIntensity: number;
  103503. /** @hidden */
  103504. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103505. /**
  103506. * Default image processing configuration used either in the rendering
  103507. * Forward main pass or through the imageProcessingPostProcess if present.
  103508. * As in the majority of the scene they are the same (exception for multi camera),
  103509. * this is easier to reference from here than from all the materials and post process.
  103510. *
  103511. * No setter as we it is a shared configuration, you can set the values instead.
  103512. */
  103513. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  103514. private _forceWireframe;
  103515. /**
  103516. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  103517. */
  103518. forceWireframe: boolean;
  103519. private _forcePointsCloud;
  103520. /**
  103521. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  103522. */
  103523. forcePointsCloud: boolean;
  103524. /**
  103525. * Gets or sets the active clipplane 1
  103526. */
  103527. clipPlane: Nullable<Plane>;
  103528. /**
  103529. * Gets or sets the active clipplane 2
  103530. */
  103531. clipPlane2: Nullable<Plane>;
  103532. /**
  103533. * Gets or sets the active clipplane 3
  103534. */
  103535. clipPlane3: Nullable<Plane>;
  103536. /**
  103537. * Gets or sets the active clipplane 4
  103538. */
  103539. clipPlane4: Nullable<Plane>;
  103540. /**
  103541. * Gets or sets a boolean indicating if animations are enabled
  103542. */
  103543. animationsEnabled: boolean;
  103544. private _animationPropertiesOverride;
  103545. /**
  103546. * Gets or sets the animation properties override
  103547. */
  103548. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  103549. /**
  103550. * Gets or sets a boolean indicating if a constant deltatime has to be used
  103551. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  103552. */
  103553. useConstantAnimationDeltaTime: boolean;
  103554. /**
  103555. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  103556. * Please note that it requires to run a ray cast through the scene on every frame
  103557. */
  103558. constantlyUpdateMeshUnderPointer: boolean;
  103559. /**
  103560. * Defines the HTML cursor to use when hovering over interactive elements
  103561. */
  103562. hoverCursor: string;
  103563. /**
  103564. * Defines the HTML default cursor to use (empty by default)
  103565. */
  103566. defaultCursor: string;
  103567. /**
  103568. * Defines wether cursors are handled by the scene.
  103569. */
  103570. doNotHandleCursors: boolean;
  103571. /**
  103572. * This is used to call preventDefault() on pointer down
  103573. * in order to block unwanted artifacts like system double clicks
  103574. */
  103575. preventDefaultOnPointerDown: boolean;
  103576. /**
  103577. * This is used to call preventDefault() on pointer up
  103578. * in order to block unwanted artifacts like system double clicks
  103579. */
  103580. preventDefaultOnPointerUp: boolean;
  103581. /**
  103582. * Gets or sets user defined metadata
  103583. */
  103584. metadata: any;
  103585. /**
  103586. * For internal use only. Please do not use.
  103587. */
  103588. reservedDataStore: any;
  103589. /**
  103590. * Gets the name of the plugin used to load this scene (null by default)
  103591. */
  103592. loadingPluginName: string;
  103593. /**
  103594. * Use this array to add regular expressions used to disable offline support for specific urls
  103595. */
  103596. disableOfflineSupportExceptionRules: RegExp[];
  103597. /**
  103598. * An event triggered when the scene is disposed.
  103599. */
  103600. onDisposeObservable: Observable<Scene>;
  103601. private _onDisposeObserver;
  103602. /** Sets a function to be executed when this scene is disposed. */
  103603. onDispose: () => void;
  103604. /**
  103605. * An event triggered before rendering the scene (right after animations and physics)
  103606. */
  103607. onBeforeRenderObservable: Observable<Scene>;
  103608. private _onBeforeRenderObserver;
  103609. /** Sets a function to be executed before rendering this scene */
  103610. beforeRender: Nullable<() => void>;
  103611. /**
  103612. * An event triggered after rendering the scene
  103613. */
  103614. onAfterRenderObservable: Observable<Scene>;
  103615. /**
  103616. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  103617. */
  103618. onAfterRenderCameraObservable: Observable<Camera>;
  103619. private _onAfterRenderObserver;
  103620. /** Sets a function to be executed after rendering this scene */
  103621. afterRender: Nullable<() => void>;
  103622. /**
  103623. * An event triggered before animating the scene
  103624. */
  103625. onBeforeAnimationsObservable: Observable<Scene>;
  103626. /**
  103627. * An event triggered after animations processing
  103628. */
  103629. onAfterAnimationsObservable: Observable<Scene>;
  103630. /**
  103631. * An event triggered before draw calls are ready to be sent
  103632. */
  103633. onBeforeDrawPhaseObservable: Observable<Scene>;
  103634. /**
  103635. * An event triggered after draw calls have been sent
  103636. */
  103637. onAfterDrawPhaseObservable: Observable<Scene>;
  103638. /**
  103639. * An event triggered when the scene is ready
  103640. */
  103641. onReadyObservable: Observable<Scene>;
  103642. /**
  103643. * An event triggered before rendering a camera
  103644. */
  103645. onBeforeCameraRenderObservable: Observable<Camera>;
  103646. private _onBeforeCameraRenderObserver;
  103647. /** Sets a function to be executed before rendering a camera*/
  103648. beforeCameraRender: () => void;
  103649. /**
  103650. * An event triggered after rendering a camera
  103651. */
  103652. onAfterCameraRenderObservable: Observable<Camera>;
  103653. private _onAfterCameraRenderObserver;
  103654. /** Sets a function to be executed after rendering a camera*/
  103655. afterCameraRender: () => void;
  103656. /**
  103657. * An event triggered when active meshes evaluation is about to start
  103658. */
  103659. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  103660. /**
  103661. * An event triggered when active meshes evaluation is done
  103662. */
  103663. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  103664. /**
  103665. * An event triggered when particles rendering is about to start
  103666. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103667. */
  103668. onBeforeParticlesRenderingObservable: Observable<Scene>;
  103669. /**
  103670. * An event triggered when particles rendering is done
  103671. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103672. */
  103673. onAfterParticlesRenderingObservable: Observable<Scene>;
  103674. /**
  103675. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  103676. */
  103677. onDataLoadedObservable: Observable<Scene>;
  103678. /**
  103679. * An event triggered when a camera is created
  103680. */
  103681. onNewCameraAddedObservable: Observable<Camera>;
  103682. /**
  103683. * An event triggered when a camera is removed
  103684. */
  103685. onCameraRemovedObservable: Observable<Camera>;
  103686. /**
  103687. * An event triggered when a light is created
  103688. */
  103689. onNewLightAddedObservable: Observable<Light>;
  103690. /**
  103691. * An event triggered when a light is removed
  103692. */
  103693. onLightRemovedObservable: Observable<Light>;
  103694. /**
  103695. * An event triggered when a geometry is created
  103696. */
  103697. onNewGeometryAddedObservable: Observable<Geometry>;
  103698. /**
  103699. * An event triggered when a geometry is removed
  103700. */
  103701. onGeometryRemovedObservable: Observable<Geometry>;
  103702. /**
  103703. * An event triggered when a transform node is created
  103704. */
  103705. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  103706. /**
  103707. * An event triggered when a transform node is removed
  103708. */
  103709. onTransformNodeRemovedObservable: Observable<TransformNode>;
  103710. /**
  103711. * An event triggered when a mesh is created
  103712. */
  103713. onNewMeshAddedObservable: Observable<AbstractMesh>;
  103714. /**
  103715. * An event triggered when a mesh is removed
  103716. */
  103717. onMeshRemovedObservable: Observable<AbstractMesh>;
  103718. /**
  103719. * An event triggered when a skeleton is created
  103720. */
  103721. onNewSkeletonAddedObservable: Observable<Skeleton>;
  103722. /**
  103723. * An event triggered when a skeleton is removed
  103724. */
  103725. onSkeletonRemovedObservable: Observable<Skeleton>;
  103726. /**
  103727. * An event triggered when a material is created
  103728. */
  103729. onNewMaterialAddedObservable: Observable<Material>;
  103730. /**
  103731. * An event triggered when a material is removed
  103732. */
  103733. onMaterialRemovedObservable: Observable<Material>;
  103734. /**
  103735. * An event triggered when a texture is created
  103736. */
  103737. onNewTextureAddedObservable: Observable<BaseTexture>;
  103738. /**
  103739. * An event triggered when a texture is removed
  103740. */
  103741. onTextureRemovedObservable: Observable<BaseTexture>;
  103742. /**
  103743. * An event triggered when render targets are about to be rendered
  103744. * Can happen multiple times per frame.
  103745. */
  103746. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  103747. /**
  103748. * An event triggered when render targets were rendered.
  103749. * Can happen multiple times per frame.
  103750. */
  103751. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  103752. /**
  103753. * An event triggered before calculating deterministic simulation step
  103754. */
  103755. onBeforeStepObservable: Observable<Scene>;
  103756. /**
  103757. * An event triggered after calculating deterministic simulation step
  103758. */
  103759. onAfterStepObservable: Observable<Scene>;
  103760. /**
  103761. * An event triggered when the activeCamera property is updated
  103762. */
  103763. onActiveCameraChanged: Observable<Scene>;
  103764. /**
  103765. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  103766. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  103767. * 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)
  103768. */
  103769. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  103770. /**
  103771. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  103772. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  103773. * 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)
  103774. */
  103775. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  103776. /**
  103777. * This Observable will when a mesh has been imported into the scene.
  103778. */
  103779. onMeshImportedObservable: Observable<AbstractMesh>;
  103780. /**
  103781. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  103782. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  103783. */
  103784. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  103785. /** @hidden */
  103786. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  103787. /**
  103788. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  103789. */
  103790. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  103791. /**
  103792. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  103793. */
  103794. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  103795. /**
  103796. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  103797. */
  103798. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  103799. /** Callback called when a pointer move is detected */
  103800. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  103801. /** Callback called when a pointer down is detected */
  103802. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  103803. /** Callback called when a pointer up is detected */
  103804. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  103805. /** Callback called when a pointer pick is detected */
  103806. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  103807. /**
  103808. * 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).
  103809. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  103810. */
  103811. onPrePointerObservable: Observable<PointerInfoPre>;
  103812. /**
  103813. * Observable event triggered each time an input event is received from the rendering canvas
  103814. */
  103815. onPointerObservable: Observable<PointerInfo>;
  103816. /**
  103817. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  103818. */
  103819. readonly unTranslatedPointer: Vector2;
  103820. /**
  103821. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  103822. */
  103823. static DragMovementThreshold: number;
  103824. /**
  103825. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  103826. */
  103827. static LongPressDelay: number;
  103828. /**
  103829. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  103830. */
  103831. static DoubleClickDelay: number;
  103832. /** If you need to check double click without raising a single click at first click, enable this flag */
  103833. static ExclusiveDoubleClickMode: boolean;
  103834. /** @hidden */
  103835. _mirroredCameraPosition: Nullable<Vector3>;
  103836. /**
  103837. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  103838. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  103839. */
  103840. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  103841. /**
  103842. * Observable event triggered each time an keyboard event is received from the hosting window
  103843. */
  103844. onKeyboardObservable: Observable<KeyboardInfo>;
  103845. private _useRightHandedSystem;
  103846. /**
  103847. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  103848. */
  103849. useRightHandedSystem: boolean;
  103850. private _timeAccumulator;
  103851. private _currentStepId;
  103852. private _currentInternalStep;
  103853. /**
  103854. * Sets the step Id used by deterministic lock step
  103855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103856. * @param newStepId defines the step Id
  103857. */
  103858. setStepId(newStepId: number): void;
  103859. /**
  103860. * Gets the step Id used by deterministic lock step
  103861. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103862. * @returns the step Id
  103863. */
  103864. getStepId(): number;
  103865. /**
  103866. * Gets the internal step used by deterministic lock step
  103867. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103868. * @returns the internal step
  103869. */
  103870. getInternalStep(): number;
  103871. private _fogEnabled;
  103872. /**
  103873. * Gets or sets a boolean indicating if fog is enabled on this scene
  103874. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103875. * (Default is true)
  103876. */
  103877. fogEnabled: boolean;
  103878. private _fogMode;
  103879. /**
  103880. * Gets or sets the fog mode to use
  103881. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103882. * | mode | value |
  103883. * | --- | --- |
  103884. * | FOGMODE_NONE | 0 |
  103885. * | FOGMODE_EXP | 1 |
  103886. * | FOGMODE_EXP2 | 2 |
  103887. * | FOGMODE_LINEAR | 3 |
  103888. */
  103889. fogMode: number;
  103890. /**
  103891. * Gets or sets the fog color to use
  103892. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103893. * (Default is Color3(0.2, 0.2, 0.3))
  103894. */
  103895. fogColor: Color3;
  103896. /**
  103897. * Gets or sets the fog density to use
  103898. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103899. * (Default is 0.1)
  103900. */
  103901. fogDensity: number;
  103902. /**
  103903. * Gets or sets the fog start distance to use
  103904. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103905. * (Default is 0)
  103906. */
  103907. fogStart: number;
  103908. /**
  103909. * Gets or sets the fog end distance to use
  103910. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103911. * (Default is 1000)
  103912. */
  103913. fogEnd: number;
  103914. private _shadowsEnabled;
  103915. /**
  103916. * Gets or sets a boolean indicating if shadows are enabled on this scene
  103917. */
  103918. shadowsEnabled: boolean;
  103919. private _lightsEnabled;
  103920. /**
  103921. * Gets or sets a boolean indicating if lights are enabled on this scene
  103922. */
  103923. lightsEnabled: boolean;
  103924. /** All of the active cameras added to this scene. */
  103925. activeCameras: Camera[];
  103926. /** @hidden */
  103927. _activeCamera: Nullable<Camera>;
  103928. /** Gets or sets the current active camera */
  103929. activeCamera: Nullable<Camera>;
  103930. private _defaultMaterial;
  103931. /** The default material used on meshes when no material is affected */
  103932. /** The default material used on meshes when no material is affected */
  103933. defaultMaterial: Material;
  103934. private _texturesEnabled;
  103935. /**
  103936. * Gets or sets a boolean indicating if textures are enabled on this scene
  103937. */
  103938. texturesEnabled: boolean;
  103939. /**
  103940. * Gets or sets a boolean indicating if particles are enabled on this scene
  103941. */
  103942. particlesEnabled: boolean;
  103943. /**
  103944. * Gets or sets a boolean indicating if sprites are enabled on this scene
  103945. */
  103946. spritesEnabled: boolean;
  103947. private _skeletonsEnabled;
  103948. /**
  103949. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  103950. */
  103951. skeletonsEnabled: boolean;
  103952. /**
  103953. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  103954. */
  103955. lensFlaresEnabled: boolean;
  103956. /**
  103957. * Gets or sets a boolean indicating if collisions are enabled on this scene
  103958. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103959. */
  103960. collisionsEnabled: boolean;
  103961. private _collisionCoordinator;
  103962. /** @hidden */
  103963. readonly collisionCoordinator: ICollisionCoordinator;
  103964. /**
  103965. * Defines the gravity applied to this scene (used only for collisions)
  103966. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103967. */
  103968. gravity: Vector3;
  103969. /**
  103970. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  103971. */
  103972. postProcessesEnabled: boolean;
  103973. /**
  103974. * The list of postprocesses added to the scene
  103975. */
  103976. postProcesses: PostProcess[];
  103977. /**
  103978. * Gets the current postprocess manager
  103979. */
  103980. postProcessManager: PostProcessManager;
  103981. /**
  103982. * Gets or sets a boolean indicating if render targets are enabled on this scene
  103983. */
  103984. renderTargetsEnabled: boolean;
  103985. /**
  103986. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  103987. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  103988. */
  103989. dumpNextRenderTargets: boolean;
  103990. /**
  103991. * The list of user defined render targets added to the scene
  103992. */
  103993. customRenderTargets: RenderTargetTexture[];
  103994. /**
  103995. * Defines if texture loading must be delayed
  103996. * If true, textures will only be loaded when they need to be rendered
  103997. */
  103998. useDelayedTextureLoading: boolean;
  103999. /**
  104000. * Gets the list of meshes imported to the scene through SceneLoader
  104001. */
  104002. importedMeshesFiles: String[];
  104003. /**
  104004. * Gets or sets a boolean indicating if probes are enabled on this scene
  104005. */
  104006. probesEnabled: boolean;
  104007. /**
  104008. * Gets or sets the current offline provider to use to store scene data
  104009. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104010. */
  104011. offlineProvider: IOfflineProvider;
  104012. /**
  104013. * Gets or sets the action manager associated with the scene
  104014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104015. */
  104016. actionManager: AbstractActionManager;
  104017. private _meshesForIntersections;
  104018. /**
  104019. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  104020. */
  104021. proceduralTexturesEnabled: boolean;
  104022. private _engine;
  104023. private _totalVertices;
  104024. /** @hidden */
  104025. _activeIndices: PerfCounter;
  104026. /** @hidden */
  104027. _activeParticles: PerfCounter;
  104028. /** @hidden */
  104029. _activeBones: PerfCounter;
  104030. private _animationRatio;
  104031. /** @hidden */
  104032. _animationTimeLast: number;
  104033. /** @hidden */
  104034. _animationTime: number;
  104035. /**
  104036. * Gets or sets a general scale for animation speed
  104037. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  104038. */
  104039. animationTimeScale: number;
  104040. /** @hidden */
  104041. _cachedMaterial: Nullable<Material>;
  104042. /** @hidden */
  104043. _cachedEffect: Nullable<Effect>;
  104044. /** @hidden */
  104045. _cachedVisibility: Nullable<number>;
  104046. private _renderId;
  104047. private _frameId;
  104048. private _executeWhenReadyTimeoutId;
  104049. private _intermediateRendering;
  104050. private _viewUpdateFlag;
  104051. private _projectionUpdateFlag;
  104052. /** @hidden */
  104053. _toBeDisposed: Nullable<IDisposable>[];
  104054. private _activeRequests;
  104055. /** @hidden */
  104056. _pendingData: any[];
  104057. private _isDisposed;
  104058. /**
  104059. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  104060. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  104061. */
  104062. dispatchAllSubMeshesOfActiveMeshes: boolean;
  104063. private _activeMeshes;
  104064. private _processedMaterials;
  104065. private _renderTargets;
  104066. /** @hidden */
  104067. _activeParticleSystems: SmartArray<IParticleSystem>;
  104068. private _activeSkeletons;
  104069. private _softwareSkinnedMeshes;
  104070. private _renderingManager;
  104071. /** @hidden */
  104072. _activeAnimatables: Animatable[];
  104073. private _transformMatrix;
  104074. private _sceneUbo;
  104075. /** @hidden */
  104076. _viewMatrix: Matrix;
  104077. private _projectionMatrix;
  104078. /** @hidden */
  104079. _forcedViewPosition: Nullable<Vector3>;
  104080. /** @hidden */
  104081. _frustumPlanes: Plane[];
  104082. /**
  104083. * Gets the list of frustum planes (built from the active camera)
  104084. */
  104085. readonly frustumPlanes: Plane[];
  104086. /**
  104087. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  104088. * This is useful if there are more lights that the maximum simulteanous authorized
  104089. */
  104090. requireLightSorting: boolean;
  104091. /** @hidden */
  104092. readonly useMaterialMeshMap: boolean;
  104093. /** @hidden */
  104094. readonly useClonedMeshhMap: boolean;
  104095. private _externalData;
  104096. private _uid;
  104097. /**
  104098. * @hidden
  104099. * Backing store of defined scene components.
  104100. */
  104101. _components: ISceneComponent[];
  104102. /**
  104103. * @hidden
  104104. * Backing store of defined scene components.
  104105. */
  104106. _serializableComponents: ISceneSerializableComponent[];
  104107. /**
  104108. * List of components to register on the next registration step.
  104109. */
  104110. private _transientComponents;
  104111. /**
  104112. * Registers the transient components if needed.
  104113. */
  104114. private _registerTransientComponents;
  104115. /**
  104116. * @hidden
  104117. * Add a component to the scene.
  104118. * Note that the ccomponent could be registered on th next frame if this is called after
  104119. * the register component stage.
  104120. * @param component Defines the component to add to the scene
  104121. */
  104122. _addComponent(component: ISceneComponent): void;
  104123. /**
  104124. * @hidden
  104125. * Gets a component from the scene.
  104126. * @param name defines the name of the component to retrieve
  104127. * @returns the component or null if not present
  104128. */
  104129. _getComponent(name: string): Nullable<ISceneComponent>;
  104130. /**
  104131. * @hidden
  104132. * Defines the actions happening before camera updates.
  104133. */
  104134. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  104135. /**
  104136. * @hidden
  104137. * Defines the actions happening before clear the canvas.
  104138. */
  104139. _beforeClearStage: Stage<SimpleStageAction>;
  104140. /**
  104141. * @hidden
  104142. * Defines the actions when collecting render targets for the frame.
  104143. */
  104144. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104145. /**
  104146. * @hidden
  104147. * Defines the actions happening for one camera in the frame.
  104148. */
  104149. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104150. /**
  104151. * @hidden
  104152. * Defines the actions happening during the per mesh ready checks.
  104153. */
  104154. _isReadyForMeshStage: Stage<MeshStageAction>;
  104155. /**
  104156. * @hidden
  104157. * Defines the actions happening before evaluate active mesh checks.
  104158. */
  104159. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  104160. /**
  104161. * @hidden
  104162. * Defines the actions happening during the evaluate sub mesh checks.
  104163. */
  104164. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  104165. /**
  104166. * @hidden
  104167. * Defines the actions happening during the active mesh stage.
  104168. */
  104169. _activeMeshStage: Stage<ActiveMeshStageAction>;
  104170. /**
  104171. * @hidden
  104172. * Defines the actions happening during the per camera render target step.
  104173. */
  104174. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  104175. /**
  104176. * @hidden
  104177. * Defines the actions happening just before the active camera is drawing.
  104178. */
  104179. _beforeCameraDrawStage: Stage<CameraStageAction>;
  104180. /**
  104181. * @hidden
  104182. * Defines the actions happening just before a render target is drawing.
  104183. */
  104184. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104185. /**
  104186. * @hidden
  104187. * Defines the actions happening just before a rendering group is drawing.
  104188. */
  104189. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104190. /**
  104191. * @hidden
  104192. * Defines the actions happening just before a mesh is drawing.
  104193. */
  104194. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104195. /**
  104196. * @hidden
  104197. * Defines the actions happening just after a mesh has been drawn.
  104198. */
  104199. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104200. /**
  104201. * @hidden
  104202. * Defines the actions happening just after a rendering group has been drawn.
  104203. */
  104204. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104205. /**
  104206. * @hidden
  104207. * Defines the actions happening just after the active camera has been drawn.
  104208. */
  104209. _afterCameraDrawStage: Stage<CameraStageAction>;
  104210. /**
  104211. * @hidden
  104212. * Defines the actions happening just after a render target has been drawn.
  104213. */
  104214. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104215. /**
  104216. * @hidden
  104217. * Defines the actions happening just after rendering all cameras and computing intersections.
  104218. */
  104219. _afterRenderStage: Stage<SimpleStageAction>;
  104220. /**
  104221. * @hidden
  104222. * Defines the actions happening when a pointer move event happens.
  104223. */
  104224. _pointerMoveStage: Stage<PointerMoveStageAction>;
  104225. /**
  104226. * @hidden
  104227. * Defines the actions happening when a pointer down event happens.
  104228. */
  104229. _pointerDownStage: Stage<PointerUpDownStageAction>;
  104230. /**
  104231. * @hidden
  104232. * Defines the actions happening when a pointer up event happens.
  104233. */
  104234. _pointerUpStage: Stage<PointerUpDownStageAction>;
  104235. /**
  104236. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  104237. */
  104238. private geometriesByUniqueId;
  104239. /**
  104240. * Creates a new Scene
  104241. * @param engine defines the engine to use to render this scene
  104242. * @param options defines the scene options
  104243. */
  104244. constructor(engine: Engine, options?: SceneOptions);
  104245. /**
  104246. * Gets a string idenfifying the name of the class
  104247. * @returns "Scene" string
  104248. */
  104249. getClassName(): string;
  104250. private _defaultMeshCandidates;
  104251. /**
  104252. * @hidden
  104253. */
  104254. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  104255. private _defaultSubMeshCandidates;
  104256. /**
  104257. * @hidden
  104258. */
  104259. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  104260. /**
  104261. * Sets the default candidate providers for the scene.
  104262. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  104263. * and getCollidingSubMeshCandidates to their default function
  104264. */
  104265. setDefaultCandidateProviders(): void;
  104266. /**
  104267. * Gets the mesh that is currently under the pointer
  104268. */
  104269. readonly meshUnderPointer: Nullable<AbstractMesh>;
  104270. /**
  104271. * Gets or sets the current on-screen X position of the pointer
  104272. */
  104273. pointerX: number;
  104274. /**
  104275. * Gets or sets the current on-screen Y position of the pointer
  104276. */
  104277. pointerY: number;
  104278. /**
  104279. * Gets the cached material (ie. the latest rendered one)
  104280. * @returns the cached material
  104281. */
  104282. getCachedMaterial(): Nullable<Material>;
  104283. /**
  104284. * Gets the cached effect (ie. the latest rendered one)
  104285. * @returns the cached effect
  104286. */
  104287. getCachedEffect(): Nullable<Effect>;
  104288. /**
  104289. * Gets the cached visibility state (ie. the latest rendered one)
  104290. * @returns the cached visibility state
  104291. */
  104292. getCachedVisibility(): Nullable<number>;
  104293. /**
  104294. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  104295. * @param material defines the current material
  104296. * @param effect defines the current effect
  104297. * @param visibility defines the current visibility state
  104298. * @returns true if one parameter is not cached
  104299. */
  104300. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  104301. /**
  104302. * Gets the engine associated with the scene
  104303. * @returns an Engine
  104304. */
  104305. getEngine(): Engine;
  104306. /**
  104307. * Gets the total number of vertices rendered per frame
  104308. * @returns the total number of vertices rendered per frame
  104309. */
  104310. getTotalVertices(): number;
  104311. /**
  104312. * Gets the performance counter for total vertices
  104313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104314. */
  104315. readonly totalVerticesPerfCounter: PerfCounter;
  104316. /**
  104317. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  104318. * @returns the total number of active indices rendered per frame
  104319. */
  104320. getActiveIndices(): number;
  104321. /**
  104322. * Gets the performance counter for active indices
  104323. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104324. */
  104325. readonly totalActiveIndicesPerfCounter: PerfCounter;
  104326. /**
  104327. * Gets the total number of active particles rendered per frame
  104328. * @returns the total number of active particles rendered per frame
  104329. */
  104330. getActiveParticles(): number;
  104331. /**
  104332. * Gets the performance counter for active particles
  104333. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104334. */
  104335. readonly activeParticlesPerfCounter: PerfCounter;
  104336. /**
  104337. * Gets the total number of active bones rendered per frame
  104338. * @returns the total number of active bones rendered per frame
  104339. */
  104340. getActiveBones(): number;
  104341. /**
  104342. * Gets the performance counter for active bones
  104343. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104344. */
  104345. readonly activeBonesPerfCounter: PerfCounter;
  104346. /**
  104347. * Gets the array of active meshes
  104348. * @returns an array of AbstractMesh
  104349. */
  104350. getActiveMeshes(): SmartArray<AbstractMesh>;
  104351. /**
  104352. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  104353. * @returns a number
  104354. */
  104355. getAnimationRatio(): number;
  104356. /**
  104357. * Gets an unique Id for the current render phase
  104358. * @returns a number
  104359. */
  104360. getRenderId(): number;
  104361. /**
  104362. * Gets an unique Id for the current frame
  104363. * @returns a number
  104364. */
  104365. getFrameId(): number;
  104366. /** Call this function if you want to manually increment the render Id*/
  104367. incrementRenderId(): void;
  104368. private _createUbo;
  104369. /**
  104370. * Use this method to simulate a pointer move on a mesh
  104371. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104372. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104373. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104374. * @returns the current scene
  104375. */
  104376. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104377. /**
  104378. * Use this method to simulate a pointer down on a mesh
  104379. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104380. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104381. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104382. * @returns the current scene
  104383. */
  104384. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104385. /**
  104386. * Use this method to simulate a pointer up on a mesh
  104387. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104388. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104389. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104390. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  104391. * @returns the current scene
  104392. */
  104393. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  104394. /**
  104395. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  104396. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  104397. * @returns true if the pointer was captured
  104398. */
  104399. isPointerCaptured(pointerId?: number): boolean;
  104400. /**
  104401. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  104402. * @param attachUp defines if you want to attach events to pointerup
  104403. * @param attachDown defines if you want to attach events to pointerdown
  104404. * @param attachMove defines if you want to attach events to pointermove
  104405. */
  104406. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  104407. /** Detaches all event handlers*/
  104408. detachControl(): void;
  104409. /**
  104410. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  104411. * Delay loaded resources are not taking in account
  104412. * @return true if all required resources are ready
  104413. */
  104414. isReady(): boolean;
  104415. /** Resets all cached information relative to material (including effect and visibility) */
  104416. resetCachedMaterial(): void;
  104417. /**
  104418. * Registers a function to be called before every frame render
  104419. * @param func defines the function to register
  104420. */
  104421. registerBeforeRender(func: () => void): void;
  104422. /**
  104423. * Unregisters a function called before every frame render
  104424. * @param func defines the function to unregister
  104425. */
  104426. unregisterBeforeRender(func: () => void): void;
  104427. /**
  104428. * Registers a function to be called after every frame render
  104429. * @param func defines the function to register
  104430. */
  104431. registerAfterRender(func: () => void): void;
  104432. /**
  104433. * Unregisters a function called after every frame render
  104434. * @param func defines the function to unregister
  104435. */
  104436. unregisterAfterRender(func: () => void): void;
  104437. private _executeOnceBeforeRender;
  104438. /**
  104439. * The provided function will run before render once and will be disposed afterwards.
  104440. * A timeout delay can be provided so that the function will be executed in N ms.
  104441. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  104442. * @param func The function to be executed.
  104443. * @param timeout optional delay in ms
  104444. */
  104445. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  104446. /** @hidden */
  104447. _addPendingData(data: any): void;
  104448. /** @hidden */
  104449. _removePendingData(data: any): void;
  104450. /**
  104451. * Returns the number of items waiting to be loaded
  104452. * @returns the number of items waiting to be loaded
  104453. */
  104454. getWaitingItemsCount(): number;
  104455. /**
  104456. * Returns a boolean indicating if the scene is still loading data
  104457. */
  104458. readonly isLoading: boolean;
  104459. /**
  104460. * Registers a function to be executed when the scene is ready
  104461. * @param {Function} func - the function to be executed
  104462. */
  104463. executeWhenReady(func: () => void): void;
  104464. /**
  104465. * Returns a promise that resolves when the scene is ready
  104466. * @returns A promise that resolves when the scene is ready
  104467. */
  104468. whenReadyAsync(): Promise<void>;
  104469. /** @hidden */
  104470. _checkIsReady(): void;
  104471. /**
  104472. * Gets all animatable attached to the scene
  104473. */
  104474. readonly animatables: Animatable[];
  104475. /**
  104476. * Resets the last animation time frame.
  104477. * Useful to override when animations start running when loading a scene for the first time.
  104478. */
  104479. resetLastAnimationTimeFrame(): void;
  104480. /**
  104481. * Gets the current view matrix
  104482. * @returns a Matrix
  104483. */
  104484. getViewMatrix(): Matrix;
  104485. /**
  104486. * Gets the current projection matrix
  104487. * @returns a Matrix
  104488. */
  104489. getProjectionMatrix(): Matrix;
  104490. /**
  104491. * Gets the current transform matrix
  104492. * @returns a Matrix made of View * Projection
  104493. */
  104494. getTransformMatrix(): Matrix;
  104495. /**
  104496. * Sets the current transform matrix
  104497. * @param viewL defines the View matrix to use
  104498. * @param projectionL defines the Projection matrix to use
  104499. * @param viewR defines the right View matrix to use (if provided)
  104500. * @param projectionR defines the right Projection matrix to use (if provided)
  104501. */
  104502. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  104503. /**
  104504. * Gets the uniform buffer used to store scene data
  104505. * @returns a UniformBuffer
  104506. */
  104507. getSceneUniformBuffer(): UniformBuffer;
  104508. /**
  104509. * Gets an unique (relatively to the current scene) Id
  104510. * @returns an unique number for the scene
  104511. */
  104512. getUniqueId(): number;
  104513. /**
  104514. * Add a mesh to the list of scene's meshes
  104515. * @param newMesh defines the mesh to add
  104516. * @param recursive if all child meshes should also be added to the scene
  104517. */
  104518. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  104519. /**
  104520. * Remove a mesh for the list of scene's meshes
  104521. * @param toRemove defines the mesh to remove
  104522. * @param recursive if all child meshes should also be removed from the scene
  104523. * @returns the index where the mesh was in the mesh list
  104524. */
  104525. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  104526. /**
  104527. * Add a transform node to the list of scene's transform nodes
  104528. * @param newTransformNode defines the transform node to add
  104529. */
  104530. addTransformNode(newTransformNode: TransformNode): void;
  104531. /**
  104532. * Remove a transform node for the list of scene's transform nodes
  104533. * @param toRemove defines the transform node to remove
  104534. * @returns the index where the transform node was in the transform node list
  104535. */
  104536. removeTransformNode(toRemove: TransformNode): number;
  104537. /**
  104538. * Remove a skeleton for the list of scene's skeletons
  104539. * @param toRemove defines the skeleton to remove
  104540. * @returns the index where the skeleton was in the skeleton list
  104541. */
  104542. removeSkeleton(toRemove: Skeleton): number;
  104543. /**
  104544. * Remove a morph target for the list of scene's morph targets
  104545. * @param toRemove defines the morph target to remove
  104546. * @returns the index where the morph target was in the morph target list
  104547. */
  104548. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  104549. /**
  104550. * Remove a light for the list of scene's lights
  104551. * @param toRemove defines the light to remove
  104552. * @returns the index where the light was in the light list
  104553. */
  104554. removeLight(toRemove: Light): number;
  104555. /**
  104556. * Remove a camera for the list of scene's cameras
  104557. * @param toRemove defines the camera to remove
  104558. * @returns the index where the camera was in the camera list
  104559. */
  104560. removeCamera(toRemove: Camera): number;
  104561. /**
  104562. * Remove a particle system for the list of scene's particle systems
  104563. * @param toRemove defines the particle system to remove
  104564. * @returns the index where the particle system was in the particle system list
  104565. */
  104566. removeParticleSystem(toRemove: IParticleSystem): number;
  104567. /**
  104568. * Remove a animation for the list of scene's animations
  104569. * @param toRemove defines the animation to remove
  104570. * @returns the index where the animation was in the animation list
  104571. */
  104572. removeAnimation(toRemove: Animation): number;
  104573. /**
  104574. * Will stop the animation of the given target
  104575. * @param target - the target
  104576. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  104577. * @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)
  104578. */
  104579. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  104580. /**
  104581. * Removes the given animation group from this scene.
  104582. * @param toRemove The animation group to remove
  104583. * @returns The index of the removed animation group
  104584. */
  104585. removeAnimationGroup(toRemove: AnimationGroup): number;
  104586. /**
  104587. * Removes the given multi-material from this scene.
  104588. * @param toRemove The multi-material to remove
  104589. * @returns The index of the removed multi-material
  104590. */
  104591. removeMultiMaterial(toRemove: MultiMaterial): number;
  104592. /**
  104593. * Removes the given material from this scene.
  104594. * @param toRemove The material to remove
  104595. * @returns The index of the removed material
  104596. */
  104597. removeMaterial(toRemove: Material): number;
  104598. /**
  104599. * Removes the given action manager from this scene.
  104600. * @param toRemove The action manager to remove
  104601. * @returns The index of the removed action manager
  104602. */
  104603. removeActionManager(toRemove: AbstractActionManager): number;
  104604. /**
  104605. * Removes the given texture from this scene.
  104606. * @param toRemove The texture to remove
  104607. * @returns The index of the removed texture
  104608. */
  104609. removeTexture(toRemove: BaseTexture): number;
  104610. /**
  104611. * Adds the given light to this scene
  104612. * @param newLight The light to add
  104613. */
  104614. addLight(newLight: Light): void;
  104615. /**
  104616. * Sorts the list list based on light priorities
  104617. */
  104618. sortLightsByPriority(): void;
  104619. /**
  104620. * Adds the given camera to this scene
  104621. * @param newCamera The camera to add
  104622. */
  104623. addCamera(newCamera: Camera): void;
  104624. /**
  104625. * Adds the given skeleton to this scene
  104626. * @param newSkeleton The skeleton to add
  104627. */
  104628. addSkeleton(newSkeleton: Skeleton): void;
  104629. /**
  104630. * Adds the given particle system to this scene
  104631. * @param newParticleSystem The particle system to add
  104632. */
  104633. addParticleSystem(newParticleSystem: IParticleSystem): void;
  104634. /**
  104635. * Adds the given animation to this scene
  104636. * @param newAnimation The animation to add
  104637. */
  104638. addAnimation(newAnimation: Animation): void;
  104639. /**
  104640. * Adds the given animation group to this scene.
  104641. * @param newAnimationGroup The animation group to add
  104642. */
  104643. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  104644. /**
  104645. * Adds the given multi-material to this scene
  104646. * @param newMultiMaterial The multi-material to add
  104647. */
  104648. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  104649. /**
  104650. * Adds the given material to this scene
  104651. * @param newMaterial The material to add
  104652. */
  104653. addMaterial(newMaterial: Material): void;
  104654. /**
  104655. * Adds the given morph target to this scene
  104656. * @param newMorphTargetManager The morph target to add
  104657. */
  104658. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  104659. /**
  104660. * Adds the given geometry to this scene
  104661. * @param newGeometry The geometry to add
  104662. */
  104663. addGeometry(newGeometry: Geometry): void;
  104664. /**
  104665. * Adds the given action manager to this scene
  104666. * @param newActionManager The action manager to add
  104667. */
  104668. addActionManager(newActionManager: AbstractActionManager): void;
  104669. /**
  104670. * Adds the given texture to this scene.
  104671. * @param newTexture The texture to add
  104672. */
  104673. addTexture(newTexture: BaseTexture): void;
  104674. /**
  104675. * Switch active camera
  104676. * @param newCamera defines the new active camera
  104677. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  104678. */
  104679. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  104680. /**
  104681. * sets the active camera of the scene using its ID
  104682. * @param id defines the camera's ID
  104683. * @return the new active camera or null if none found.
  104684. */
  104685. setActiveCameraByID(id: string): Nullable<Camera>;
  104686. /**
  104687. * sets the active camera of the scene using its name
  104688. * @param name defines the camera's name
  104689. * @returns the new active camera or null if none found.
  104690. */
  104691. setActiveCameraByName(name: string): Nullable<Camera>;
  104692. /**
  104693. * get an animation group using its name
  104694. * @param name defines the material's name
  104695. * @return the animation group or null if none found.
  104696. */
  104697. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  104698. /**
  104699. * Get a material using its unique id
  104700. * @param uniqueId defines the material's unique id
  104701. * @return the material or null if none found.
  104702. */
  104703. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  104704. /**
  104705. * get a material using its id
  104706. * @param id defines the material's ID
  104707. * @return the material or null if none found.
  104708. */
  104709. getMaterialByID(id: string): Nullable<Material>;
  104710. /**
  104711. * Gets a the last added material using a given id
  104712. * @param id defines the material's ID
  104713. * @return the last material with the given id or null if none found.
  104714. */
  104715. getLastMaterialByID(id: string): Nullable<Material>;
  104716. /**
  104717. * Gets a material using its name
  104718. * @param name defines the material's name
  104719. * @return the material or null if none found.
  104720. */
  104721. getMaterialByName(name: string): Nullable<Material>;
  104722. /**
  104723. * Get a texture using its unique id
  104724. * @param uniqueId defines the texture's unique id
  104725. * @return the texture or null if none found.
  104726. */
  104727. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  104728. /**
  104729. * Gets a camera using its id
  104730. * @param id defines the id to look for
  104731. * @returns the camera or null if not found
  104732. */
  104733. getCameraByID(id: string): Nullable<Camera>;
  104734. /**
  104735. * Gets a camera using its unique id
  104736. * @param uniqueId defines the unique id to look for
  104737. * @returns the camera or null if not found
  104738. */
  104739. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  104740. /**
  104741. * Gets a camera using its name
  104742. * @param name defines the camera's name
  104743. * @return the camera or null if none found.
  104744. */
  104745. getCameraByName(name: string): Nullable<Camera>;
  104746. /**
  104747. * Gets a bone using its id
  104748. * @param id defines the bone's id
  104749. * @return the bone or null if not found
  104750. */
  104751. getBoneByID(id: string): Nullable<Bone>;
  104752. /**
  104753. * Gets a bone using its id
  104754. * @param name defines the bone's name
  104755. * @return the bone or null if not found
  104756. */
  104757. getBoneByName(name: string): Nullable<Bone>;
  104758. /**
  104759. * Gets a light node using its name
  104760. * @param name defines the the light's name
  104761. * @return the light or null if none found.
  104762. */
  104763. getLightByName(name: string): Nullable<Light>;
  104764. /**
  104765. * Gets a light node using its id
  104766. * @param id defines the light's id
  104767. * @return the light or null if none found.
  104768. */
  104769. getLightByID(id: string): Nullable<Light>;
  104770. /**
  104771. * Gets a light node using its scene-generated unique ID
  104772. * @param uniqueId defines the light's unique id
  104773. * @return the light or null if none found.
  104774. */
  104775. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  104776. /**
  104777. * Gets a particle system by id
  104778. * @param id defines the particle system id
  104779. * @return the corresponding system or null if none found
  104780. */
  104781. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  104782. /**
  104783. * Gets a geometry using its ID
  104784. * @param id defines the geometry's id
  104785. * @return the geometry or null if none found.
  104786. */
  104787. getGeometryByID(id: string): Nullable<Geometry>;
  104788. private _getGeometryByUniqueID;
  104789. /**
  104790. * Add a new geometry to this scene
  104791. * @param geometry defines the geometry to be added to the scene.
  104792. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  104793. * @return a boolean defining if the geometry was added or not
  104794. */
  104795. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  104796. /**
  104797. * Removes an existing geometry
  104798. * @param geometry defines the geometry to be removed from the scene
  104799. * @return a boolean defining if the geometry was removed or not
  104800. */
  104801. removeGeometry(geometry: Geometry): boolean;
  104802. /**
  104803. * Gets the list of geometries attached to the scene
  104804. * @returns an array of Geometry
  104805. */
  104806. getGeometries(): Geometry[];
  104807. /**
  104808. * Gets the first added mesh found of a given ID
  104809. * @param id defines the id to search for
  104810. * @return the mesh found or null if not found at all
  104811. */
  104812. getMeshByID(id: string): Nullable<AbstractMesh>;
  104813. /**
  104814. * Gets a list of meshes using their id
  104815. * @param id defines the id to search for
  104816. * @returns a list of meshes
  104817. */
  104818. getMeshesByID(id: string): Array<AbstractMesh>;
  104819. /**
  104820. * Gets the first added transform node found of a given ID
  104821. * @param id defines the id to search for
  104822. * @return the found transform node or null if not found at all.
  104823. */
  104824. getTransformNodeByID(id: string): Nullable<TransformNode>;
  104825. /**
  104826. * Gets a transform node with its auto-generated unique id
  104827. * @param uniqueId efines the unique id to search for
  104828. * @return the found transform node or null if not found at all.
  104829. */
  104830. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  104831. /**
  104832. * Gets a list of transform nodes using their id
  104833. * @param id defines the id to search for
  104834. * @returns a list of transform nodes
  104835. */
  104836. getTransformNodesByID(id: string): Array<TransformNode>;
  104837. /**
  104838. * Gets a mesh with its auto-generated unique id
  104839. * @param uniqueId defines the unique id to search for
  104840. * @return the found mesh or null if not found at all.
  104841. */
  104842. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  104843. /**
  104844. * Gets a the last added mesh using a given id
  104845. * @param id defines the id to search for
  104846. * @return the found mesh or null if not found at all.
  104847. */
  104848. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  104849. /**
  104850. * Gets a the last added node (Mesh, Camera, Light) using a given id
  104851. * @param id defines the id to search for
  104852. * @return the found node or null if not found at all
  104853. */
  104854. getLastEntryByID(id: string): Nullable<Node>;
  104855. /**
  104856. * Gets a node (Mesh, Camera, Light) using a given id
  104857. * @param id defines the id to search for
  104858. * @return the found node or null if not found at all
  104859. */
  104860. getNodeByID(id: string): Nullable<Node>;
  104861. /**
  104862. * Gets a node (Mesh, Camera, Light) using a given name
  104863. * @param name defines the name to search for
  104864. * @return the found node or null if not found at all.
  104865. */
  104866. getNodeByName(name: string): Nullable<Node>;
  104867. /**
  104868. * Gets a mesh using a given name
  104869. * @param name defines the name to search for
  104870. * @return the found mesh or null if not found at all.
  104871. */
  104872. getMeshByName(name: string): Nullable<AbstractMesh>;
  104873. /**
  104874. * Gets a transform node using a given name
  104875. * @param name defines the name to search for
  104876. * @return the found transform node or null if not found at all.
  104877. */
  104878. getTransformNodeByName(name: string): Nullable<TransformNode>;
  104879. /**
  104880. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  104881. * @param id defines the id to search for
  104882. * @return the found skeleton or null if not found at all.
  104883. */
  104884. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  104885. /**
  104886. * Gets a skeleton using a given auto generated unique id
  104887. * @param uniqueId defines the unique id to search for
  104888. * @return the found skeleton or null if not found at all.
  104889. */
  104890. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  104891. /**
  104892. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  104893. * @param id defines the id to search for
  104894. * @return the found skeleton or null if not found at all.
  104895. */
  104896. getSkeletonById(id: string): Nullable<Skeleton>;
  104897. /**
  104898. * Gets a skeleton using a given name
  104899. * @param name defines the name to search for
  104900. * @return the found skeleton or null if not found at all.
  104901. */
  104902. getSkeletonByName(name: string): Nullable<Skeleton>;
  104903. /**
  104904. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  104905. * @param id defines the id to search for
  104906. * @return the found morph target manager or null if not found at all.
  104907. */
  104908. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  104909. /**
  104910. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  104911. * @param id defines the id to search for
  104912. * @return the found morph target or null if not found at all.
  104913. */
  104914. getMorphTargetById(id: string): Nullable<MorphTarget>;
  104915. /**
  104916. * Gets a boolean indicating if the given mesh is active
  104917. * @param mesh defines the mesh to look for
  104918. * @returns true if the mesh is in the active list
  104919. */
  104920. isActiveMesh(mesh: AbstractMesh): boolean;
  104921. /**
  104922. * Return a unique id as a string which can serve as an identifier for the scene
  104923. */
  104924. readonly uid: string;
  104925. /**
  104926. * Add an externaly attached data from its key.
  104927. * This method call will fail and return false, if such key already exists.
  104928. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  104929. * @param key the unique key that identifies the data
  104930. * @param data the data object to associate to the key for this Engine instance
  104931. * @return true if no such key were already present and the data was added successfully, false otherwise
  104932. */
  104933. addExternalData<T>(key: string, data: T): boolean;
  104934. /**
  104935. * Get an externaly attached data from its key
  104936. * @param key the unique key that identifies the data
  104937. * @return the associated data, if present (can be null), or undefined if not present
  104938. */
  104939. getExternalData<T>(key: string): Nullable<T>;
  104940. /**
  104941. * Get an externaly attached data from its key, create it using a factory if it's not already present
  104942. * @param key the unique key that identifies the data
  104943. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  104944. * @return the associated data, can be null if the factory returned null.
  104945. */
  104946. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  104947. /**
  104948. * Remove an externaly attached data from the Engine instance
  104949. * @param key the unique key that identifies the data
  104950. * @return true if the data was successfully removed, false if it doesn't exist
  104951. */
  104952. removeExternalData(key: string): boolean;
  104953. private _evaluateSubMesh;
  104954. /**
  104955. * Clear the processed materials smart array preventing retention point in material dispose.
  104956. */
  104957. freeProcessedMaterials(): void;
  104958. private _preventFreeActiveMeshesAndRenderingGroups;
  104959. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  104960. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  104961. * when disposing several meshes in a row or a hierarchy of meshes.
  104962. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  104963. */
  104964. blockfreeActiveMeshesAndRenderingGroups: boolean;
  104965. /**
  104966. * Clear the active meshes smart array preventing retention point in mesh dispose.
  104967. */
  104968. freeActiveMeshes(): void;
  104969. /**
  104970. * Clear the info related to rendering groups preventing retention points during dispose.
  104971. */
  104972. freeRenderingGroups(): void;
  104973. /** @hidden */
  104974. _isInIntermediateRendering(): boolean;
  104975. /**
  104976. * Lambda returning the list of potentially active meshes.
  104977. */
  104978. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  104979. /**
  104980. * Lambda returning the list of potentially active sub meshes.
  104981. */
  104982. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  104983. /**
  104984. * Lambda returning the list of potentially intersecting sub meshes.
  104985. */
  104986. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  104987. /**
  104988. * Lambda returning the list of potentially colliding sub meshes.
  104989. */
  104990. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  104991. private _activeMeshesFrozen;
  104992. private _skipEvaluateActiveMeshesCompletely;
  104993. /**
  104994. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  104995. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  104996. * @returns the current scene
  104997. */
  104998. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  104999. /**
  105000. * Use this function to restart evaluating active meshes on every frame
  105001. * @returns the current scene
  105002. */
  105003. unfreezeActiveMeshes(): Scene;
  105004. private _evaluateActiveMeshes;
  105005. private _activeMesh;
  105006. /**
  105007. * Update the transform matrix to update from the current active camera
  105008. * @param force defines a boolean used to force the update even if cache is up to date
  105009. */
  105010. updateTransformMatrix(force?: boolean): void;
  105011. private _bindFrameBuffer;
  105012. /** @hidden */
  105013. _allowPostProcessClearColor: boolean;
  105014. /** @hidden */
  105015. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  105016. private _processSubCameras;
  105017. private _checkIntersections;
  105018. /** @hidden */
  105019. _advancePhysicsEngineStep(step: number): void;
  105020. /**
  105021. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  105022. */
  105023. getDeterministicFrameTime: () => number;
  105024. /** @hidden */
  105025. _animate(): void;
  105026. /** Execute all animations (for a frame) */
  105027. animate(): void;
  105028. /**
  105029. * Render the scene
  105030. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  105031. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  105032. */
  105033. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  105034. /**
  105035. * Freeze all materials
  105036. * A frozen material will not be updatable but should be faster to render
  105037. */
  105038. freezeMaterials(): void;
  105039. /**
  105040. * Unfreeze all materials
  105041. * A frozen material will not be updatable but should be faster to render
  105042. */
  105043. unfreezeMaterials(): void;
  105044. /**
  105045. * Releases all held ressources
  105046. */
  105047. dispose(): void;
  105048. /**
  105049. * Gets if the scene is already disposed
  105050. */
  105051. readonly isDisposed: boolean;
  105052. /**
  105053. * Call this function to reduce memory footprint of the scene.
  105054. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  105055. */
  105056. clearCachedVertexData(): void;
  105057. /**
  105058. * This function will remove the local cached buffer data from texture.
  105059. * It will save memory but will prevent the texture from being rebuilt
  105060. */
  105061. cleanCachedTextureBuffer(): void;
  105062. /**
  105063. * Get the world extend vectors with an optional filter
  105064. *
  105065. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  105066. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  105067. */
  105068. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  105069. min: Vector3;
  105070. max: Vector3;
  105071. };
  105072. /**
  105073. * Creates a ray that can be used to pick in the scene
  105074. * @param x defines the x coordinate of the origin (on-screen)
  105075. * @param y defines the y coordinate of the origin (on-screen)
  105076. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105077. * @param camera defines the camera to use for the picking
  105078. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105079. * @returns a Ray
  105080. */
  105081. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  105082. /**
  105083. * Creates a ray that can be used to pick in the scene
  105084. * @param x defines the x coordinate of the origin (on-screen)
  105085. * @param y defines the y coordinate of the origin (on-screen)
  105086. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105087. * @param result defines the ray where to store the picking ray
  105088. * @param camera defines the camera to use for the picking
  105089. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105090. * @returns the current scene
  105091. */
  105092. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  105093. /**
  105094. * Creates a ray that can be used to pick in the scene
  105095. * @param x defines the x coordinate of the origin (on-screen)
  105096. * @param y defines the y coordinate of the origin (on-screen)
  105097. * @param camera defines the camera to use for the picking
  105098. * @returns a Ray
  105099. */
  105100. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  105101. /**
  105102. * Creates a ray that can be used to pick in the scene
  105103. * @param x defines the x coordinate of the origin (on-screen)
  105104. * @param y defines the y coordinate of the origin (on-screen)
  105105. * @param result defines the ray where to store the picking ray
  105106. * @param camera defines the camera to use for the picking
  105107. * @returns the current scene
  105108. */
  105109. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  105110. /** Launch a ray to try to pick a mesh in the scene
  105111. * @param x position on screen
  105112. * @param y position on screen
  105113. * @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
  105114. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  105115. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105116. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105117. * @returns a PickingInfo
  105118. */
  105119. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105120. /** Use the given ray to pick a mesh in the scene
  105121. * @param ray The ray to use to pick meshes
  105122. * @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
  105123. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  105124. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105125. * @returns a PickingInfo
  105126. */
  105127. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105128. /**
  105129. * Launch a ray to try to pick a mesh in the scene
  105130. * @param x X position on screen
  105131. * @param y Y position on screen
  105132. * @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
  105133. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105134. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105135. * @returns an array of PickingInfo
  105136. */
  105137. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105138. /**
  105139. * Launch a ray to try to pick a mesh in the scene
  105140. * @param ray Ray to use
  105141. * @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
  105142. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105143. * @returns an array of PickingInfo
  105144. */
  105145. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105146. /**
  105147. * Force the value of meshUnderPointer
  105148. * @param mesh defines the mesh to use
  105149. */
  105150. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105151. /**
  105152. * Gets the mesh under the pointer
  105153. * @returns a Mesh or null if no mesh is under the pointer
  105154. */
  105155. getPointerOverMesh(): Nullable<AbstractMesh>;
  105156. /** @hidden */
  105157. _rebuildGeometries(): void;
  105158. /** @hidden */
  105159. _rebuildTextures(): void;
  105160. private _getByTags;
  105161. /**
  105162. * Get a list of meshes by tags
  105163. * @param tagsQuery defines the tags query to use
  105164. * @param forEach defines a predicate used to filter results
  105165. * @returns an array of Mesh
  105166. */
  105167. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  105168. /**
  105169. * Get a list of cameras by tags
  105170. * @param tagsQuery defines the tags query to use
  105171. * @param forEach defines a predicate used to filter results
  105172. * @returns an array of Camera
  105173. */
  105174. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  105175. /**
  105176. * Get a list of lights by tags
  105177. * @param tagsQuery defines the tags query to use
  105178. * @param forEach defines a predicate used to filter results
  105179. * @returns an array of Light
  105180. */
  105181. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  105182. /**
  105183. * Get a list of materials by tags
  105184. * @param tagsQuery defines the tags query to use
  105185. * @param forEach defines a predicate used to filter results
  105186. * @returns an array of Material
  105187. */
  105188. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  105189. /**
  105190. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  105191. * This allowed control for front to back rendering or reversly depending of the special needs.
  105192. *
  105193. * @param renderingGroupId The rendering group id corresponding to its index
  105194. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  105195. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  105196. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  105197. */
  105198. 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;
  105199. /**
  105200. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  105201. *
  105202. * @param renderingGroupId The rendering group id corresponding to its index
  105203. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105204. * @param depth Automatically clears depth between groups if true and autoClear is true.
  105205. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  105206. */
  105207. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  105208. /**
  105209. * Gets the current auto clear configuration for one rendering group of the rendering
  105210. * manager.
  105211. * @param index the rendering group index to get the information for
  105212. * @returns The auto clear setup for the requested rendering group
  105213. */
  105214. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  105215. private _blockMaterialDirtyMechanism;
  105216. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  105217. blockMaterialDirtyMechanism: boolean;
  105218. /**
  105219. * Will flag all materials as dirty to trigger new shader compilation
  105220. * @param flag defines the flag used to specify which material part must be marked as dirty
  105221. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  105222. */
  105223. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105224. /** @hidden */
  105225. _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;
  105226. /** @hidden */
  105227. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105228. /** @hidden */
  105229. _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;
  105230. /** @hidden */
  105231. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  105232. /** @hidden */
  105233. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  105234. /** @hidden */
  105235. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105236. }
  105237. }
  105238. declare module BABYLON {
  105239. /**
  105240. * Set of assets to keep when moving a scene into an asset container.
  105241. */
  105242. export class KeepAssets extends AbstractScene {
  105243. }
  105244. /**
  105245. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  105246. */
  105247. export class InstantiatedEntries {
  105248. /**
  105249. * List of new root nodes (eg. nodes with no parent)
  105250. */
  105251. rootNodes: TransformNode[];
  105252. /**
  105253. * List of new skeletons
  105254. */
  105255. skeletons: Skeleton[];
  105256. /**
  105257. * List of new animation groups
  105258. */
  105259. animationGroups: AnimationGroup[];
  105260. }
  105261. /**
  105262. * Container with a set of assets that can be added or removed from a scene.
  105263. */
  105264. export class AssetContainer extends AbstractScene {
  105265. /**
  105266. * The scene the AssetContainer belongs to.
  105267. */
  105268. scene: Scene;
  105269. /**
  105270. * Instantiates an AssetContainer.
  105271. * @param scene The scene the AssetContainer belongs to.
  105272. */
  105273. constructor(scene: Scene);
  105274. /**
  105275. * Instantiate or clone all meshes and add the new ones to the scene.
  105276. * Skeletons and animation groups will all be cloned
  105277. * @param nameFunction defines an optional function used to get new names for clones
  105278. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  105279. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  105280. */
  105281. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  105282. /**
  105283. * Adds all the assets from the container to the scene.
  105284. */
  105285. addAllToScene(): void;
  105286. /**
  105287. * Removes all the assets in the container from the scene
  105288. */
  105289. removeAllFromScene(): void;
  105290. /**
  105291. * Disposes all the assets in the container
  105292. */
  105293. dispose(): void;
  105294. private _moveAssets;
  105295. /**
  105296. * Removes all the assets contained in the scene and adds them to the container.
  105297. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  105298. */
  105299. moveAllFromScene(keepAssets?: KeepAssets): void;
  105300. /**
  105301. * 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.
  105302. * @returns the root mesh
  105303. */
  105304. createRootMesh(): Mesh;
  105305. }
  105306. }
  105307. declare module BABYLON {
  105308. /**
  105309. * Defines how the parser contract is defined.
  105310. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  105311. */
  105312. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  105313. /**
  105314. * Defines how the individual parser contract is defined.
  105315. * These parser can parse an individual asset
  105316. */
  105317. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  105318. /**
  105319. * Base class of the scene acting as a container for the different elements composing a scene.
  105320. * This class is dynamically extended by the different components of the scene increasing
  105321. * flexibility and reducing coupling
  105322. */
  105323. export abstract class AbstractScene {
  105324. /**
  105325. * Stores the list of available parsers in the application.
  105326. */
  105327. private static _BabylonFileParsers;
  105328. /**
  105329. * Stores the list of available individual parsers in the application.
  105330. */
  105331. private static _IndividualBabylonFileParsers;
  105332. /**
  105333. * Adds a parser in the list of available ones
  105334. * @param name Defines the name of the parser
  105335. * @param parser Defines the parser to add
  105336. */
  105337. static AddParser(name: string, parser: BabylonFileParser): void;
  105338. /**
  105339. * Gets a general parser from the list of avaialble ones
  105340. * @param name Defines the name of the parser
  105341. * @returns the requested parser or null
  105342. */
  105343. static GetParser(name: string): Nullable<BabylonFileParser>;
  105344. /**
  105345. * Adds n individual parser in the list of available ones
  105346. * @param name Defines the name of the parser
  105347. * @param parser Defines the parser to add
  105348. */
  105349. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  105350. /**
  105351. * Gets an individual parser from the list of avaialble ones
  105352. * @param name Defines the name of the parser
  105353. * @returns the requested parser or null
  105354. */
  105355. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  105356. /**
  105357. * Parser json data and populate both a scene and its associated container object
  105358. * @param jsonData Defines the data to parse
  105359. * @param scene Defines the scene to parse the data for
  105360. * @param container Defines the container attached to the parsing sequence
  105361. * @param rootUrl Defines the root url of the data
  105362. */
  105363. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  105364. /**
  105365. * Gets the list of root nodes (ie. nodes with no parent)
  105366. */
  105367. rootNodes: Node[];
  105368. /** All of the cameras added to this scene
  105369. * @see http://doc.babylonjs.com/babylon101/cameras
  105370. */
  105371. cameras: Camera[];
  105372. /**
  105373. * All of the lights added to this scene
  105374. * @see http://doc.babylonjs.com/babylon101/lights
  105375. */
  105376. lights: Light[];
  105377. /**
  105378. * All of the (abstract) meshes added to this scene
  105379. */
  105380. meshes: AbstractMesh[];
  105381. /**
  105382. * The list of skeletons added to the scene
  105383. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  105384. */
  105385. skeletons: Skeleton[];
  105386. /**
  105387. * All of the particle systems added to this scene
  105388. * @see http://doc.babylonjs.com/babylon101/particles
  105389. */
  105390. particleSystems: IParticleSystem[];
  105391. /**
  105392. * Gets a list of Animations associated with the scene
  105393. */
  105394. animations: Animation[];
  105395. /**
  105396. * All of the animation groups added to this scene
  105397. * @see http://doc.babylonjs.com/how_to/group
  105398. */
  105399. animationGroups: AnimationGroup[];
  105400. /**
  105401. * All of the multi-materials added to this scene
  105402. * @see http://doc.babylonjs.com/how_to/multi_materials
  105403. */
  105404. multiMaterials: MultiMaterial[];
  105405. /**
  105406. * All of the materials added to this scene
  105407. * In the context of a Scene, it is not supposed to be modified manually.
  105408. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  105409. * Note also that the order of the Material within the array is not significant and might change.
  105410. * @see http://doc.babylonjs.com/babylon101/materials
  105411. */
  105412. materials: Material[];
  105413. /**
  105414. * The list of morph target managers added to the scene
  105415. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  105416. */
  105417. morphTargetManagers: MorphTargetManager[];
  105418. /**
  105419. * The list of geometries used in the scene.
  105420. */
  105421. geometries: Geometry[];
  105422. /**
  105423. * All of the tranform nodes added to this scene
  105424. * In the context of a Scene, it is not supposed to be modified manually.
  105425. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  105426. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  105427. * @see http://doc.babylonjs.com/how_to/transformnode
  105428. */
  105429. transformNodes: TransformNode[];
  105430. /**
  105431. * ActionManagers available on the scene.
  105432. */
  105433. actionManagers: AbstractActionManager[];
  105434. /**
  105435. * Textures to keep.
  105436. */
  105437. textures: BaseTexture[];
  105438. /**
  105439. * Environment texture for the scene
  105440. */
  105441. environmentTexture: Nullable<BaseTexture>;
  105442. }
  105443. }
  105444. declare module BABYLON {
  105445. /**
  105446. * Interface used to define options for Sound class
  105447. */
  105448. export interface ISoundOptions {
  105449. /**
  105450. * Does the sound autoplay once loaded.
  105451. */
  105452. autoplay?: boolean;
  105453. /**
  105454. * Does the sound loop after it finishes playing once.
  105455. */
  105456. loop?: boolean;
  105457. /**
  105458. * Sound's volume
  105459. */
  105460. volume?: number;
  105461. /**
  105462. * Is it a spatial sound?
  105463. */
  105464. spatialSound?: boolean;
  105465. /**
  105466. * Maximum distance to hear that sound
  105467. */
  105468. maxDistance?: number;
  105469. /**
  105470. * Uses user defined attenuation function
  105471. */
  105472. useCustomAttenuation?: boolean;
  105473. /**
  105474. * Define the roll off factor of spatial sounds.
  105475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105476. */
  105477. rolloffFactor?: number;
  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 distance attenuation model the sound will follow.
  105485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105486. */
  105487. distanceModel?: string;
  105488. /**
  105489. * Defines the playback speed (1 by default)
  105490. */
  105491. playbackRate?: number;
  105492. /**
  105493. * Defines if the sound is from a streaming source
  105494. */
  105495. streaming?: boolean;
  105496. /**
  105497. * Defines an optional length (in seconds) inside the sound file
  105498. */
  105499. length?: number;
  105500. /**
  105501. * Defines an optional offset (in seconds) inside the sound file
  105502. */
  105503. offset?: number;
  105504. /**
  105505. * If true, URLs will not be required to state the audio file codec to use.
  105506. */
  105507. skipCodecCheck?: boolean;
  105508. }
  105509. /**
  105510. * Defines a sound that can be played in the application.
  105511. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  105512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105513. */
  105514. export class Sound {
  105515. /**
  105516. * The name of the sound in the scene.
  105517. */
  105518. name: string;
  105519. /**
  105520. * Does the sound autoplay once loaded.
  105521. */
  105522. autoplay: boolean;
  105523. /**
  105524. * Does the sound loop after it finishes playing once.
  105525. */
  105526. loop: boolean;
  105527. /**
  105528. * Does the sound use a custom attenuation curve to simulate the falloff
  105529. * happening when the source gets further away from the camera.
  105530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105531. */
  105532. useCustomAttenuation: boolean;
  105533. /**
  105534. * The sound track id this sound belongs to.
  105535. */
  105536. soundTrackId: number;
  105537. /**
  105538. * Is this sound currently played.
  105539. */
  105540. isPlaying: boolean;
  105541. /**
  105542. * Is this sound currently paused.
  105543. */
  105544. isPaused: boolean;
  105545. /**
  105546. * Does this sound enables spatial sound.
  105547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105548. */
  105549. spatialSound: boolean;
  105550. /**
  105551. * Define the reference distance the sound should be heard perfectly.
  105552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105553. */
  105554. refDistance: number;
  105555. /**
  105556. * Define the roll off factor of spatial sounds.
  105557. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105558. */
  105559. rolloffFactor: number;
  105560. /**
  105561. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  105562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105563. */
  105564. maxDistance: number;
  105565. /**
  105566. * Define the distance attenuation model the sound will follow.
  105567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105568. */
  105569. distanceModel: string;
  105570. /**
  105571. * @hidden
  105572. * Back Compat
  105573. **/
  105574. onended: () => any;
  105575. /**
  105576. * Observable event when the current playing sound finishes.
  105577. */
  105578. onEndedObservable: Observable<Sound>;
  105579. private _panningModel;
  105580. private _playbackRate;
  105581. private _streaming;
  105582. private _startTime;
  105583. private _startOffset;
  105584. private _position;
  105585. /** @hidden */
  105586. _positionInEmitterSpace: boolean;
  105587. private _localDirection;
  105588. private _volume;
  105589. private _isReadyToPlay;
  105590. private _isDirectional;
  105591. private _readyToPlayCallback;
  105592. private _audioBuffer;
  105593. private _soundSource;
  105594. private _streamingSource;
  105595. private _soundPanner;
  105596. private _soundGain;
  105597. private _inputAudioNode;
  105598. private _outputAudioNode;
  105599. private _coneInnerAngle;
  105600. private _coneOuterAngle;
  105601. private _coneOuterGain;
  105602. private _scene;
  105603. private _connectedTransformNode;
  105604. private _customAttenuationFunction;
  105605. private _registerFunc;
  105606. private _isOutputConnected;
  105607. private _htmlAudioElement;
  105608. private _urlType;
  105609. private _length?;
  105610. private _offset?;
  105611. /** @hidden */
  105612. static _SceneComponentInitialization: (scene: Scene) => void;
  105613. /**
  105614. * Create a sound and attach it to a scene
  105615. * @param name Name of your sound
  105616. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  105617. * @param scene defines the scene the sound belongs to
  105618. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  105619. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  105620. */
  105621. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  105622. /**
  105623. * Release the sound and its associated resources
  105624. */
  105625. dispose(): void;
  105626. /**
  105627. * Gets if the sounds is ready to be played or not.
  105628. * @returns true if ready, otherwise false
  105629. */
  105630. isReady(): boolean;
  105631. private _soundLoaded;
  105632. /**
  105633. * Sets the data of the sound from an audiobuffer
  105634. * @param audioBuffer The audioBuffer containing the data
  105635. */
  105636. setAudioBuffer(audioBuffer: AudioBuffer): void;
  105637. /**
  105638. * Updates the current sounds options such as maxdistance, loop...
  105639. * @param options A JSON object containing values named as the object properties
  105640. */
  105641. updateOptions(options: ISoundOptions): void;
  105642. private _createSpatialParameters;
  105643. private _updateSpatialParameters;
  105644. /**
  105645. * Switch the panning model to HRTF:
  105646. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  105647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105648. */
  105649. switchPanningModelToHRTF(): void;
  105650. /**
  105651. * Switch the panning model to Equal Power:
  105652. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  105653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105654. */
  105655. switchPanningModelToEqualPower(): void;
  105656. private _switchPanningModel;
  105657. /**
  105658. * Connect this sound to a sound track audio node like gain...
  105659. * @param soundTrackAudioNode the sound track audio node to connect to
  105660. */
  105661. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  105662. /**
  105663. * Transform this sound into a directional source
  105664. * @param coneInnerAngle Size of the inner cone in degree
  105665. * @param coneOuterAngle Size of the outer cone in degree
  105666. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  105667. */
  105668. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  105669. /**
  105670. * Gets or sets the inner angle for the directional cone.
  105671. */
  105672. /**
  105673. * Gets or sets the inner angle for the directional cone.
  105674. */
  105675. directionalConeInnerAngle: number;
  105676. /**
  105677. * Gets or sets the outer angle for the directional cone.
  105678. */
  105679. /**
  105680. * Gets or sets the outer angle for the directional cone.
  105681. */
  105682. directionalConeOuterAngle: number;
  105683. /**
  105684. * Sets the position of the emitter if spatial sound is enabled
  105685. * @param newPosition Defines the new posisiton
  105686. */
  105687. setPosition(newPosition: Vector3): void;
  105688. /**
  105689. * Sets the local direction of the emitter if spatial sound is enabled
  105690. * @param newLocalDirection Defines the new local direction
  105691. */
  105692. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  105693. private _updateDirection;
  105694. /** @hidden */
  105695. updateDistanceFromListener(): void;
  105696. /**
  105697. * Sets a new custom attenuation function for the sound.
  105698. * @param callback Defines the function used for the attenuation
  105699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105700. */
  105701. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  105702. /**
  105703. * Play the sound
  105704. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  105705. * @param offset (optional) Start the sound at a specific time in seconds
  105706. * @param length (optional) Sound duration (in seconds)
  105707. */
  105708. play(time?: number, offset?: number, length?: number): void;
  105709. private _onended;
  105710. /**
  105711. * Stop the sound
  105712. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  105713. */
  105714. stop(time?: number): void;
  105715. /**
  105716. * Put the sound in pause
  105717. */
  105718. pause(): void;
  105719. /**
  105720. * Sets a dedicated volume for this sounds
  105721. * @param newVolume Define the new volume of the sound
  105722. * @param time Define time for gradual change to new volume
  105723. */
  105724. setVolume(newVolume: number, time?: number): void;
  105725. /**
  105726. * Set the sound play back rate
  105727. * @param newPlaybackRate Define the playback rate the sound should be played at
  105728. */
  105729. setPlaybackRate(newPlaybackRate: number): void;
  105730. /**
  105731. * Gets the volume of the sound.
  105732. * @returns the volume of the sound
  105733. */
  105734. getVolume(): number;
  105735. /**
  105736. * Attach the sound to a dedicated mesh
  105737. * @param transformNode The transform node to connect the sound with
  105738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  105739. */
  105740. attachToMesh(transformNode: TransformNode): void;
  105741. /**
  105742. * Detach the sound from the previously attached mesh
  105743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  105744. */
  105745. detachFromMesh(): void;
  105746. private _onRegisterAfterWorldMatrixUpdate;
  105747. /**
  105748. * Clone the current sound in the scene.
  105749. * @returns the new sound clone
  105750. */
  105751. clone(): Nullable<Sound>;
  105752. /**
  105753. * Gets the current underlying audio buffer containing the data
  105754. * @returns the audio buffer
  105755. */
  105756. getAudioBuffer(): Nullable<AudioBuffer>;
  105757. /**
  105758. * Serializes the Sound in a JSON representation
  105759. * @returns the JSON representation of the sound
  105760. */
  105761. serialize(): any;
  105762. /**
  105763. * Parse a JSON representation of a sound to innstantiate in a given scene
  105764. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  105765. * @param scene Define the scene the new parsed sound should be created in
  105766. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  105767. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  105768. * @returns the newly parsed sound
  105769. */
  105770. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  105771. }
  105772. }
  105773. declare module BABYLON {
  105774. /**
  105775. * This defines an action helpful to play a defined sound on a triggered action.
  105776. */
  105777. export class PlaySoundAction extends Action {
  105778. private _sound;
  105779. /**
  105780. * Instantiate the action
  105781. * @param triggerOptions defines the trigger options
  105782. * @param sound defines the sound to play
  105783. * @param condition defines the trigger related conditions
  105784. */
  105785. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  105786. /** @hidden */
  105787. _prepare(): void;
  105788. /**
  105789. * Execute the action and play the sound.
  105790. */
  105791. execute(): void;
  105792. /**
  105793. * Serializes the actions and its related information.
  105794. * @param parent defines the object to serialize in
  105795. * @returns the serialized object
  105796. */
  105797. serialize(parent: any): any;
  105798. }
  105799. /**
  105800. * This defines an action helpful to stop a defined sound on a triggered action.
  105801. */
  105802. export class StopSoundAction extends Action {
  105803. private _sound;
  105804. /**
  105805. * Instantiate the action
  105806. * @param triggerOptions defines the trigger options
  105807. * @param sound defines the sound to stop
  105808. * @param condition defines the trigger related conditions
  105809. */
  105810. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  105811. /** @hidden */
  105812. _prepare(): void;
  105813. /**
  105814. * Execute the action and stop the sound.
  105815. */
  105816. execute(): void;
  105817. /**
  105818. * Serializes the actions and its related information.
  105819. * @param parent defines the object to serialize in
  105820. * @returns the serialized object
  105821. */
  105822. serialize(parent: any): any;
  105823. }
  105824. }
  105825. declare module BABYLON {
  105826. /**
  105827. * This defines an action responsible to change the value of a property
  105828. * by interpolating between its current value and the newly set one once triggered.
  105829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105830. */
  105831. export class InterpolateValueAction extends Action {
  105832. /**
  105833. * Defines the path of the property where the value should be interpolated
  105834. */
  105835. propertyPath: string;
  105836. /**
  105837. * Defines the target value at the end of the interpolation.
  105838. */
  105839. value: any;
  105840. /**
  105841. * Defines the time it will take for the property to interpolate to the value.
  105842. */
  105843. duration: number;
  105844. /**
  105845. * Defines if the other scene animations should be stopped when the action has been triggered
  105846. */
  105847. stopOtherAnimations?: boolean;
  105848. /**
  105849. * Defines a callback raised once the interpolation animation has been done.
  105850. */
  105851. onInterpolationDone?: () => void;
  105852. /**
  105853. * Observable triggered once the interpolation animation has been done.
  105854. */
  105855. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  105856. private _target;
  105857. private _effectiveTarget;
  105858. private _property;
  105859. /**
  105860. * Instantiate the action
  105861. * @param triggerOptions defines the trigger options
  105862. * @param target defines the object containing the value to interpolate
  105863. * @param propertyPath defines the path to the property in the target object
  105864. * @param value defines the target value at the end of the interpolation
  105865. * @param duration deines the time it will take for the property to interpolate to the value.
  105866. * @param condition defines the trigger related conditions
  105867. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  105868. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  105869. */
  105870. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  105871. /** @hidden */
  105872. _prepare(): void;
  105873. /**
  105874. * Execute the action starts the value interpolation.
  105875. */
  105876. execute(): void;
  105877. /**
  105878. * Serializes the actions and its related information.
  105879. * @param parent defines the object to serialize in
  105880. * @returns the serialized object
  105881. */
  105882. serialize(parent: any): any;
  105883. }
  105884. }
  105885. declare module BABYLON {
  105886. /**
  105887. * Options allowed during the creation of a sound track.
  105888. */
  105889. export interface ISoundTrackOptions {
  105890. /**
  105891. * The volume the sound track should take during creation
  105892. */
  105893. volume?: number;
  105894. /**
  105895. * Define if the sound track is the main sound track of the scene
  105896. */
  105897. mainTrack?: boolean;
  105898. }
  105899. /**
  105900. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  105901. * It will be also used in a future release to apply effects on a specific track.
  105902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  105903. */
  105904. export class SoundTrack {
  105905. /**
  105906. * The unique identifier of the sound track in the scene.
  105907. */
  105908. id: number;
  105909. /**
  105910. * The list of sounds included in the sound track.
  105911. */
  105912. soundCollection: Array<Sound>;
  105913. private _outputAudioNode;
  105914. private _scene;
  105915. private _connectedAnalyser;
  105916. private _options;
  105917. private _isInitialized;
  105918. /**
  105919. * Creates a new sound track.
  105920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  105921. * @param scene Define the scene the sound track belongs to
  105922. * @param options
  105923. */
  105924. constructor(scene: Scene, options?: ISoundTrackOptions);
  105925. private _initializeSoundTrackAudioGraph;
  105926. /**
  105927. * Release the sound track and its associated resources
  105928. */
  105929. dispose(): void;
  105930. /**
  105931. * Adds a sound to this sound track
  105932. * @param sound define the cound to add
  105933. * @ignoreNaming
  105934. */
  105935. AddSound(sound: Sound): void;
  105936. /**
  105937. * Removes a sound to this sound track
  105938. * @param sound define the cound to remove
  105939. * @ignoreNaming
  105940. */
  105941. RemoveSound(sound: Sound): void;
  105942. /**
  105943. * Set a global volume for the full sound track.
  105944. * @param newVolume Define the new volume of the sound track
  105945. */
  105946. setVolume(newVolume: number): void;
  105947. /**
  105948. * Switch the panning model to HRTF:
  105949. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  105950. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105951. */
  105952. switchPanningModelToHRTF(): void;
  105953. /**
  105954. * Switch the panning model to Equal Power:
  105955. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  105956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105957. */
  105958. switchPanningModelToEqualPower(): void;
  105959. /**
  105960. * Connect the sound track to an audio analyser allowing some amazing
  105961. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105962. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105963. * @param analyser The analyser to connect to the engine
  105964. */
  105965. connectToAnalyser(analyser: Analyser): void;
  105966. }
  105967. }
  105968. declare module BABYLON {
  105969. interface AbstractScene {
  105970. /**
  105971. * The list of sounds used in the scene.
  105972. */
  105973. sounds: Nullable<Array<Sound>>;
  105974. }
  105975. interface Scene {
  105976. /**
  105977. * @hidden
  105978. * Backing field
  105979. */
  105980. _mainSoundTrack: SoundTrack;
  105981. /**
  105982. * The main sound track played by the scene.
  105983. * It cotains your primary collection of sounds.
  105984. */
  105985. mainSoundTrack: SoundTrack;
  105986. /**
  105987. * The list of sound tracks added to the scene
  105988. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105989. */
  105990. soundTracks: Nullable<Array<SoundTrack>>;
  105991. /**
  105992. * Gets a sound using a given name
  105993. * @param name defines the name to search for
  105994. * @return the found sound or null if not found at all.
  105995. */
  105996. getSoundByName(name: string): Nullable<Sound>;
  105997. /**
  105998. * Gets or sets if audio support is enabled
  105999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106000. */
  106001. audioEnabled: boolean;
  106002. /**
  106003. * Gets or sets if audio will be output to headphones
  106004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106005. */
  106006. headphone: boolean;
  106007. /**
  106008. * Gets or sets custom audio listener position provider
  106009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106010. */
  106011. audioListenerPositionProvider: Nullable<() => Vector3>;
  106012. /**
  106013. * Gets or sets a refresh rate when using 3D audio positioning
  106014. */
  106015. audioPositioningRefreshRate: number;
  106016. }
  106017. /**
  106018. * Defines the sound scene component responsible to manage any sounds
  106019. * in a given scene.
  106020. */
  106021. export class AudioSceneComponent implements ISceneSerializableComponent {
  106022. /**
  106023. * The component name helpfull to identify the component in the list of scene components.
  106024. */
  106025. readonly name: string;
  106026. /**
  106027. * The scene the component belongs to.
  106028. */
  106029. scene: Scene;
  106030. private _audioEnabled;
  106031. /**
  106032. * Gets whether audio is enabled or not.
  106033. * Please use related enable/disable method to switch state.
  106034. */
  106035. readonly audioEnabled: boolean;
  106036. private _headphone;
  106037. /**
  106038. * Gets whether audio is outputing to headphone or not.
  106039. * Please use the according Switch methods to change output.
  106040. */
  106041. readonly headphone: boolean;
  106042. /**
  106043. * Gets or sets a refresh rate when using 3D audio positioning
  106044. */
  106045. audioPositioningRefreshRate: number;
  106046. private _audioListenerPositionProvider;
  106047. /**
  106048. * Gets the current audio listener position provider
  106049. */
  106050. /**
  106051. * Sets a custom listener position for all sounds in the scene
  106052. * By default, this is the position of the first active camera
  106053. */
  106054. audioListenerPositionProvider: Nullable<() => Vector3>;
  106055. /**
  106056. * Creates a new instance of the component for the given scene
  106057. * @param scene Defines the scene to register the component in
  106058. */
  106059. constructor(scene: Scene);
  106060. /**
  106061. * Registers the component in a given scene
  106062. */
  106063. register(): void;
  106064. /**
  106065. * Rebuilds the elements related to this component in case of
  106066. * context lost for instance.
  106067. */
  106068. rebuild(): void;
  106069. /**
  106070. * Serializes the component data to the specified json object
  106071. * @param serializationObject The object to serialize to
  106072. */
  106073. serialize(serializationObject: any): void;
  106074. /**
  106075. * Adds all the elements from the container to the scene
  106076. * @param container the container holding the elements
  106077. */
  106078. addFromContainer(container: AbstractScene): void;
  106079. /**
  106080. * Removes all the elements in the container from the scene
  106081. * @param container contains the elements to remove
  106082. * @param dispose if the removed element should be disposed (default: false)
  106083. */
  106084. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106085. /**
  106086. * Disposes the component and the associated ressources.
  106087. */
  106088. dispose(): void;
  106089. /**
  106090. * Disables audio in the associated scene.
  106091. */
  106092. disableAudio(): void;
  106093. /**
  106094. * Enables audio in the associated scene.
  106095. */
  106096. enableAudio(): void;
  106097. /**
  106098. * Switch audio to headphone output.
  106099. */
  106100. switchAudioModeForHeadphones(): void;
  106101. /**
  106102. * Switch audio to normal speakers.
  106103. */
  106104. switchAudioModeForNormalSpeakers(): void;
  106105. private _cachedCameraDirection;
  106106. private _cachedCameraPosition;
  106107. private _lastCheck;
  106108. private _afterRender;
  106109. }
  106110. }
  106111. declare module BABYLON {
  106112. /**
  106113. * Wraps one or more Sound objects and selects one with random weight for playback.
  106114. */
  106115. export class WeightedSound {
  106116. /** When true a Sound will be selected and played when the current playing Sound completes. */
  106117. loop: boolean;
  106118. private _coneInnerAngle;
  106119. private _coneOuterAngle;
  106120. private _volume;
  106121. /** A Sound is currently playing. */
  106122. isPlaying: boolean;
  106123. /** A Sound is currently paused. */
  106124. isPaused: boolean;
  106125. private _sounds;
  106126. private _weights;
  106127. private _currentIndex?;
  106128. /**
  106129. * Creates a new WeightedSound from the list of sounds given.
  106130. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  106131. * @param sounds Array of Sounds that will be selected from.
  106132. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  106133. */
  106134. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  106135. /**
  106136. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  106137. */
  106138. /**
  106139. * The size of cone in degress for a directional sound in which there will be no attenuation.
  106140. */
  106141. directionalConeInnerAngle: number;
  106142. /**
  106143. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106144. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106145. */
  106146. /**
  106147. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106148. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106149. */
  106150. directionalConeOuterAngle: number;
  106151. /**
  106152. * Playback volume.
  106153. */
  106154. /**
  106155. * Playback volume.
  106156. */
  106157. volume: number;
  106158. private _onended;
  106159. /**
  106160. * Suspend playback
  106161. */
  106162. pause(): void;
  106163. /**
  106164. * Stop playback
  106165. */
  106166. stop(): void;
  106167. /**
  106168. * Start playback.
  106169. * @param startOffset Position the clip head at a specific time in seconds.
  106170. */
  106171. play(startOffset?: number): void;
  106172. }
  106173. }
  106174. declare module BABYLON {
  106175. /**
  106176. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  106177. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106178. */
  106179. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  106180. /**
  106181. * Gets the name of the behavior.
  106182. */
  106183. readonly name: string;
  106184. /**
  106185. * The easing function used by animations
  106186. */
  106187. static EasingFunction: BackEase;
  106188. /**
  106189. * The easing mode used by animations
  106190. */
  106191. static EasingMode: number;
  106192. /**
  106193. * The duration of the animation, in milliseconds
  106194. */
  106195. transitionDuration: number;
  106196. /**
  106197. * Length of the distance animated by the transition when lower radius is reached
  106198. */
  106199. lowerRadiusTransitionRange: number;
  106200. /**
  106201. * Length of the distance animated by the transition when upper radius is reached
  106202. */
  106203. upperRadiusTransitionRange: number;
  106204. private _autoTransitionRange;
  106205. /**
  106206. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106207. */
  106208. /**
  106209. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106210. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  106211. */
  106212. autoTransitionRange: boolean;
  106213. private _attachedCamera;
  106214. private _onAfterCheckInputsObserver;
  106215. private _onMeshTargetChangedObserver;
  106216. /**
  106217. * Initializes the behavior.
  106218. */
  106219. init(): void;
  106220. /**
  106221. * Attaches the behavior to its arc rotate camera.
  106222. * @param camera Defines the camera to attach the behavior to
  106223. */
  106224. attach(camera: ArcRotateCamera): void;
  106225. /**
  106226. * Detaches the behavior from its current arc rotate camera.
  106227. */
  106228. detach(): void;
  106229. private _radiusIsAnimating;
  106230. private _radiusBounceTransition;
  106231. private _animatables;
  106232. private _cachedWheelPrecision;
  106233. /**
  106234. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  106235. * @param radiusLimit The limit to check against.
  106236. * @return Bool to indicate if at limit.
  106237. */
  106238. private _isRadiusAtLimit;
  106239. /**
  106240. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  106241. * @param radiusDelta The delta by which to animate to. Can be negative.
  106242. */
  106243. private _applyBoundRadiusAnimation;
  106244. /**
  106245. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  106246. */
  106247. protected _clearAnimationLocks(): void;
  106248. /**
  106249. * Stops and removes all animations that have been applied to the camera
  106250. */
  106251. stopAllAnimations(): void;
  106252. }
  106253. }
  106254. declare module BABYLON {
  106255. /**
  106256. * 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.
  106257. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106258. */
  106259. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  106260. /**
  106261. * Gets the name of the behavior.
  106262. */
  106263. readonly name: string;
  106264. private _mode;
  106265. private _radiusScale;
  106266. private _positionScale;
  106267. private _defaultElevation;
  106268. private _elevationReturnTime;
  106269. private _elevationReturnWaitTime;
  106270. private _zoomStopsAnimation;
  106271. private _framingTime;
  106272. /**
  106273. * The easing function used by animations
  106274. */
  106275. static EasingFunction: ExponentialEase;
  106276. /**
  106277. * The easing mode used by animations
  106278. */
  106279. static EasingMode: number;
  106280. /**
  106281. * Sets the current mode used by the behavior
  106282. */
  106283. /**
  106284. * Gets current mode used by the behavior.
  106285. */
  106286. mode: number;
  106287. /**
  106288. * Sets the scale applied to the radius (1 by default)
  106289. */
  106290. /**
  106291. * Gets the scale applied to the radius
  106292. */
  106293. radiusScale: number;
  106294. /**
  106295. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106296. */
  106297. /**
  106298. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106299. */
  106300. positionScale: number;
  106301. /**
  106302. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106303. * behaviour is triggered, in radians.
  106304. */
  106305. /**
  106306. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106307. * behaviour is triggered, in radians.
  106308. */
  106309. defaultElevation: number;
  106310. /**
  106311. * Sets the time (in milliseconds) taken to return to the default beta position.
  106312. * Negative value indicates camera should not return to default.
  106313. */
  106314. /**
  106315. * Gets the time (in milliseconds) taken to return to the default beta position.
  106316. * Negative value indicates camera should not return to default.
  106317. */
  106318. elevationReturnTime: number;
  106319. /**
  106320. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106321. */
  106322. /**
  106323. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106324. */
  106325. elevationReturnWaitTime: number;
  106326. /**
  106327. * Sets the flag that indicates if user zooming should stop animation.
  106328. */
  106329. /**
  106330. * Gets the flag that indicates if user zooming should stop animation.
  106331. */
  106332. zoomStopsAnimation: boolean;
  106333. /**
  106334. * Sets the transition time when framing the mesh, in milliseconds
  106335. */
  106336. /**
  106337. * Gets the transition time when framing the mesh, in milliseconds
  106338. */
  106339. framingTime: number;
  106340. /**
  106341. * Define if the behavior should automatically change the configured
  106342. * camera limits and sensibilities.
  106343. */
  106344. autoCorrectCameraLimitsAndSensibility: boolean;
  106345. private _onPrePointerObservableObserver;
  106346. private _onAfterCheckInputsObserver;
  106347. private _onMeshTargetChangedObserver;
  106348. private _attachedCamera;
  106349. private _isPointerDown;
  106350. private _lastInteractionTime;
  106351. /**
  106352. * Initializes the behavior.
  106353. */
  106354. init(): void;
  106355. /**
  106356. * Attaches the behavior to its arc rotate camera.
  106357. * @param camera Defines the camera to attach the behavior to
  106358. */
  106359. attach(camera: ArcRotateCamera): void;
  106360. /**
  106361. * Detaches the behavior from its current arc rotate camera.
  106362. */
  106363. detach(): void;
  106364. private _animatables;
  106365. private _betaIsAnimating;
  106366. private _betaTransition;
  106367. private _radiusTransition;
  106368. private _vectorTransition;
  106369. /**
  106370. * Targets the given mesh and updates zoom level accordingly.
  106371. * @param mesh The mesh to target.
  106372. * @param radius Optional. If a cached radius position already exists, overrides default.
  106373. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106374. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106375. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106376. */
  106377. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106378. /**
  106379. * Targets the given mesh with its children and updates zoom level accordingly.
  106380. * @param mesh The mesh to target.
  106381. * @param radius Optional. If a cached radius position already exists, overrides default.
  106382. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106383. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106384. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106385. */
  106386. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106387. /**
  106388. * Targets the given meshes with their children and updates zoom level accordingly.
  106389. * @param meshes The mesh to target.
  106390. * @param radius Optional. If a cached radius position already exists, overrides default.
  106391. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106392. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106393. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106394. */
  106395. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106396. /**
  106397. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  106398. * @param minimumWorld Determines the smaller position of the bounding box extend
  106399. * @param maximumWorld Determines the bigger position of the bounding box extend
  106400. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106401. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106402. */
  106403. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106404. /**
  106405. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  106406. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  106407. * frustum width.
  106408. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  106409. * to fully enclose the mesh in the viewing frustum.
  106410. */
  106411. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  106412. /**
  106413. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  106414. * is automatically returned to its default position (expected to be above ground plane).
  106415. */
  106416. private _maintainCameraAboveGround;
  106417. /**
  106418. * Returns the frustum slope based on the canvas ratio and camera FOV
  106419. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  106420. */
  106421. private _getFrustumSlope;
  106422. /**
  106423. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  106424. */
  106425. private _clearAnimationLocks;
  106426. /**
  106427. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  106428. */
  106429. private _applyUserInteraction;
  106430. /**
  106431. * Stops and removes all animations that have been applied to the camera
  106432. */
  106433. stopAllAnimations(): void;
  106434. /**
  106435. * Gets a value indicating if the user is moving the camera
  106436. */
  106437. readonly isUserIsMoving: boolean;
  106438. /**
  106439. * The camera can move all the way towards the mesh.
  106440. */
  106441. static IgnoreBoundsSizeMode: number;
  106442. /**
  106443. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  106444. */
  106445. static FitFrustumSidesMode: number;
  106446. }
  106447. }
  106448. declare module BABYLON {
  106449. /**
  106450. * Base class for Camera Pointer Inputs.
  106451. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  106452. * for example usage.
  106453. */
  106454. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  106455. /**
  106456. * Defines the camera the input is attached to.
  106457. */
  106458. abstract camera: Camera;
  106459. /**
  106460. * Whether keyboard modifier keys are pressed at time of last mouse event.
  106461. */
  106462. protected _altKey: boolean;
  106463. protected _ctrlKey: boolean;
  106464. protected _metaKey: boolean;
  106465. protected _shiftKey: boolean;
  106466. /**
  106467. * Which mouse buttons were pressed at time of last mouse event.
  106468. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  106469. */
  106470. protected _buttonsPressed: number;
  106471. /**
  106472. * Defines the buttons associated with the input to handle camera move.
  106473. */
  106474. buttons: number[];
  106475. /**
  106476. * Attach the input controls to a specific dom element to get the input from.
  106477. * @param element Defines the element the controls should be listened from
  106478. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106479. */
  106480. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106481. /**
  106482. * Detach the current controls from the specified dom element.
  106483. * @param element Defines the element to stop listening the inputs from
  106484. */
  106485. detachControl(element: Nullable<HTMLElement>): void;
  106486. /**
  106487. * Gets the class name of the current input.
  106488. * @returns the class name
  106489. */
  106490. getClassName(): string;
  106491. /**
  106492. * Get the friendly name associated with the input class.
  106493. * @returns the input friendly name
  106494. */
  106495. getSimpleName(): string;
  106496. /**
  106497. * Called on pointer POINTERDOUBLETAP event.
  106498. * Override this method to provide functionality on POINTERDOUBLETAP event.
  106499. */
  106500. protected onDoubleTap(type: string): void;
  106501. /**
  106502. * Called on pointer POINTERMOVE event if only a single touch is active.
  106503. * Override this method to provide functionality.
  106504. */
  106505. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106506. /**
  106507. * Called on pointer POINTERMOVE event if multiple touches are active.
  106508. * Override this method to provide functionality.
  106509. */
  106510. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106511. /**
  106512. * Called on JS contextmenu event.
  106513. * Override this method to provide functionality.
  106514. */
  106515. protected onContextMenu(evt: PointerEvent): void;
  106516. /**
  106517. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106518. * press.
  106519. * Override this method to provide functionality.
  106520. */
  106521. protected onButtonDown(evt: PointerEvent): void;
  106522. /**
  106523. * Called each time a new POINTERUP event occurs. Ie, for each button
  106524. * release.
  106525. * Override this method to provide functionality.
  106526. */
  106527. protected onButtonUp(evt: PointerEvent): void;
  106528. /**
  106529. * Called when window becomes inactive.
  106530. * Override this method to provide functionality.
  106531. */
  106532. protected onLostFocus(): void;
  106533. private _pointerInput;
  106534. private _observer;
  106535. private _onLostFocus;
  106536. private pointA;
  106537. private pointB;
  106538. }
  106539. }
  106540. declare module BABYLON {
  106541. /**
  106542. * Manage the pointers inputs to control an arc rotate camera.
  106543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106544. */
  106545. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  106546. /**
  106547. * Defines the camera the input is attached to.
  106548. */
  106549. camera: ArcRotateCamera;
  106550. /**
  106551. * Gets the class name of the current input.
  106552. * @returns the class name
  106553. */
  106554. getClassName(): string;
  106555. /**
  106556. * Defines the buttons associated with the input to handle camera move.
  106557. */
  106558. buttons: number[];
  106559. /**
  106560. * Defines the pointer angular sensibility along the X axis or how fast is
  106561. * the camera rotating.
  106562. */
  106563. angularSensibilityX: number;
  106564. /**
  106565. * Defines the pointer angular sensibility along the Y axis or how fast is
  106566. * the camera rotating.
  106567. */
  106568. angularSensibilityY: number;
  106569. /**
  106570. * Defines the pointer pinch precision or how fast is the camera zooming.
  106571. */
  106572. pinchPrecision: number;
  106573. /**
  106574. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106575. * from 0.
  106576. * It defines the percentage of current camera.radius to use as delta when
  106577. * pinch zoom is used.
  106578. */
  106579. pinchDeltaPercentage: number;
  106580. /**
  106581. * Defines the pointer panning sensibility or how fast is the camera moving.
  106582. */
  106583. panningSensibility: number;
  106584. /**
  106585. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  106586. */
  106587. multiTouchPanning: boolean;
  106588. /**
  106589. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  106590. * zoom (pinch) through multitouch.
  106591. */
  106592. multiTouchPanAndZoom: boolean;
  106593. /**
  106594. * Revers pinch action direction.
  106595. */
  106596. pinchInwards: boolean;
  106597. private _isPanClick;
  106598. private _twoFingerActivityCount;
  106599. private _isPinching;
  106600. /**
  106601. * Called on pointer POINTERMOVE event if only a single touch is active.
  106602. */
  106603. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106604. /**
  106605. * Called on pointer POINTERDOUBLETAP event.
  106606. */
  106607. protected onDoubleTap(type: string): void;
  106608. /**
  106609. * Called on pointer POINTERMOVE event if multiple touches are active.
  106610. */
  106611. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106612. /**
  106613. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106614. * press.
  106615. */
  106616. protected onButtonDown(evt: PointerEvent): void;
  106617. /**
  106618. * Called each time a new POINTERUP event occurs. Ie, for each button
  106619. * release.
  106620. */
  106621. protected onButtonUp(evt: PointerEvent): void;
  106622. /**
  106623. * Called when window becomes inactive.
  106624. */
  106625. protected onLostFocus(): void;
  106626. }
  106627. }
  106628. declare module BABYLON {
  106629. /**
  106630. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  106631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106632. */
  106633. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  106634. /**
  106635. * Defines the camera the input is attached to.
  106636. */
  106637. camera: ArcRotateCamera;
  106638. /**
  106639. * Defines the list of key codes associated with the up action (increase alpha)
  106640. */
  106641. keysUp: number[];
  106642. /**
  106643. * Defines the list of key codes associated with the down action (decrease alpha)
  106644. */
  106645. keysDown: number[];
  106646. /**
  106647. * Defines the list of key codes associated with the left action (increase beta)
  106648. */
  106649. keysLeft: number[];
  106650. /**
  106651. * Defines the list of key codes associated with the right action (decrease beta)
  106652. */
  106653. keysRight: number[];
  106654. /**
  106655. * Defines the list of key codes associated with the reset action.
  106656. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  106657. */
  106658. keysReset: number[];
  106659. /**
  106660. * Defines the panning sensibility of the inputs.
  106661. * (How fast is the camera paning)
  106662. */
  106663. panningSensibility: number;
  106664. /**
  106665. * Defines the zooming sensibility of the inputs.
  106666. * (How fast is the camera zooming)
  106667. */
  106668. zoomingSensibility: number;
  106669. /**
  106670. * Defines wether maintaining the alt key down switch the movement mode from
  106671. * orientation to zoom.
  106672. */
  106673. useAltToZoom: boolean;
  106674. /**
  106675. * Rotation speed of the camera
  106676. */
  106677. angularSpeed: number;
  106678. private _keys;
  106679. private _ctrlPressed;
  106680. private _altPressed;
  106681. private _onCanvasBlurObserver;
  106682. private _onKeyboardObserver;
  106683. private _engine;
  106684. private _scene;
  106685. /**
  106686. * Attach the input controls to a specific dom element to get the input from.
  106687. * @param element Defines the element the controls should be listened from
  106688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106689. */
  106690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106691. /**
  106692. * Detach the current controls from the specified dom element.
  106693. * @param element Defines the element to stop listening the inputs from
  106694. */
  106695. detachControl(element: Nullable<HTMLElement>): void;
  106696. /**
  106697. * Update the current camera state depending on the inputs that have been used this frame.
  106698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106699. */
  106700. checkInputs(): void;
  106701. /**
  106702. * Gets the class name of the current intput.
  106703. * @returns the class name
  106704. */
  106705. getClassName(): string;
  106706. /**
  106707. * Get the friendly name associated with the input class.
  106708. * @returns the input friendly name
  106709. */
  106710. getSimpleName(): string;
  106711. }
  106712. }
  106713. declare module BABYLON {
  106714. /**
  106715. * Manage the mouse wheel inputs to control an arc rotate camera.
  106716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106717. */
  106718. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  106719. /**
  106720. * Defines the camera the input is attached to.
  106721. */
  106722. camera: ArcRotateCamera;
  106723. /**
  106724. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  106725. */
  106726. wheelPrecision: number;
  106727. /**
  106728. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106729. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106730. */
  106731. wheelDeltaPercentage: number;
  106732. private _wheel;
  106733. private _observer;
  106734. private computeDeltaFromMouseWheelLegacyEvent;
  106735. /**
  106736. * Attach the input controls to a specific dom element to get the input from.
  106737. * @param element Defines the element the controls should be listened from
  106738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106739. */
  106740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106741. /**
  106742. * Detach the current controls from the specified dom element.
  106743. * @param element Defines the element to stop listening the inputs from
  106744. */
  106745. detachControl(element: Nullable<HTMLElement>): void;
  106746. /**
  106747. * Gets the class name of the current intput.
  106748. * @returns the class name
  106749. */
  106750. getClassName(): string;
  106751. /**
  106752. * Get the friendly name associated with the input class.
  106753. * @returns the input friendly name
  106754. */
  106755. getSimpleName(): string;
  106756. }
  106757. }
  106758. declare module BABYLON {
  106759. /**
  106760. * Default Inputs manager for the ArcRotateCamera.
  106761. * It groups all the default supported inputs for ease of use.
  106762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106763. */
  106764. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  106765. /**
  106766. * Instantiates a new ArcRotateCameraInputsManager.
  106767. * @param camera Defines the camera the inputs belong to
  106768. */
  106769. constructor(camera: ArcRotateCamera);
  106770. /**
  106771. * Add mouse wheel input support to the input manager.
  106772. * @returns the current input manager
  106773. */
  106774. addMouseWheel(): ArcRotateCameraInputsManager;
  106775. /**
  106776. * Add pointers input support to the input manager.
  106777. * @returns the current input manager
  106778. */
  106779. addPointers(): ArcRotateCameraInputsManager;
  106780. /**
  106781. * Add keyboard input support to the input manager.
  106782. * @returns the current input manager
  106783. */
  106784. addKeyboard(): ArcRotateCameraInputsManager;
  106785. }
  106786. }
  106787. declare module BABYLON {
  106788. /**
  106789. * This represents an orbital type of camera.
  106790. *
  106791. * 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.
  106792. * 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.
  106793. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  106794. */
  106795. export class ArcRotateCamera extends TargetCamera {
  106796. /**
  106797. * Defines the rotation angle of the camera along the longitudinal axis.
  106798. */
  106799. alpha: number;
  106800. /**
  106801. * Defines the rotation angle of the camera along the latitudinal axis.
  106802. */
  106803. beta: number;
  106804. /**
  106805. * Defines the radius of the camera from it s target point.
  106806. */
  106807. radius: number;
  106808. protected _target: Vector3;
  106809. protected _targetHost: Nullable<AbstractMesh>;
  106810. /**
  106811. * Defines the target point of the camera.
  106812. * The camera looks towards it form the radius distance.
  106813. */
  106814. target: Vector3;
  106815. /**
  106816. * Define the current local position of the camera in the scene
  106817. */
  106818. position: Vector3;
  106819. protected _upVector: Vector3;
  106820. protected _upToYMatrix: Matrix;
  106821. protected _YToUpMatrix: Matrix;
  106822. /**
  106823. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  106824. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  106825. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  106826. */
  106827. upVector: Vector3;
  106828. /**
  106829. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  106830. */
  106831. setMatUp(): void;
  106832. /**
  106833. * Current inertia value on the longitudinal axis.
  106834. * The bigger this number the longer it will take for the camera to stop.
  106835. */
  106836. inertialAlphaOffset: number;
  106837. /**
  106838. * Current inertia value on the latitudinal axis.
  106839. * The bigger this number the longer it will take for the camera to stop.
  106840. */
  106841. inertialBetaOffset: number;
  106842. /**
  106843. * Current inertia value on the radius axis.
  106844. * The bigger this number the longer it will take for the camera to stop.
  106845. */
  106846. inertialRadiusOffset: number;
  106847. /**
  106848. * Minimum allowed angle on the longitudinal axis.
  106849. * This can help limiting how the Camera is able to move in the scene.
  106850. */
  106851. lowerAlphaLimit: Nullable<number>;
  106852. /**
  106853. * Maximum allowed angle on the longitudinal axis.
  106854. * This can help limiting how the Camera is able to move in the scene.
  106855. */
  106856. upperAlphaLimit: Nullable<number>;
  106857. /**
  106858. * Minimum allowed angle on the latitudinal axis.
  106859. * This can help limiting how the Camera is able to move in the scene.
  106860. */
  106861. lowerBetaLimit: number;
  106862. /**
  106863. * Maximum allowed angle on the latitudinal axis.
  106864. * This can help limiting how the Camera is able to move in the scene.
  106865. */
  106866. upperBetaLimit: number;
  106867. /**
  106868. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  106869. * This can help limiting how the Camera is able to move in the scene.
  106870. */
  106871. lowerRadiusLimit: Nullable<number>;
  106872. /**
  106873. * Maximum allowed distance of the camera to the target (The camera can not get further).
  106874. * This can help limiting how the Camera is able to move in the scene.
  106875. */
  106876. upperRadiusLimit: Nullable<number>;
  106877. /**
  106878. * Defines the current inertia value used during panning of the camera along the X axis.
  106879. */
  106880. inertialPanningX: number;
  106881. /**
  106882. * Defines the current inertia value used during panning of the camera along the Y axis.
  106883. */
  106884. inertialPanningY: number;
  106885. /**
  106886. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  106887. * Basically if your fingers moves away from more than this distance you will be considered
  106888. * in pinch mode.
  106889. */
  106890. pinchToPanMaxDistance: number;
  106891. /**
  106892. * Defines the maximum distance the camera can pan.
  106893. * This could help keeping the cammera always in your scene.
  106894. */
  106895. panningDistanceLimit: Nullable<number>;
  106896. /**
  106897. * Defines the target of the camera before paning.
  106898. */
  106899. panningOriginTarget: Vector3;
  106900. /**
  106901. * Defines the value of the inertia used during panning.
  106902. * 0 would mean stop inertia and one would mean no decelleration at all.
  106903. */
  106904. panningInertia: number;
  106905. /**
  106906. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  106907. */
  106908. angularSensibilityX: number;
  106909. /**
  106910. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  106911. */
  106912. angularSensibilityY: number;
  106913. /**
  106914. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  106915. */
  106916. pinchPrecision: number;
  106917. /**
  106918. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  106919. * It will be used instead of pinchDeltaPrecision if different from 0.
  106920. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  106921. */
  106922. pinchDeltaPercentage: number;
  106923. /**
  106924. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  106925. */
  106926. panningSensibility: number;
  106927. /**
  106928. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  106929. */
  106930. keysUp: number[];
  106931. /**
  106932. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  106933. */
  106934. keysDown: number[];
  106935. /**
  106936. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  106937. */
  106938. keysLeft: number[];
  106939. /**
  106940. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  106941. */
  106942. keysRight: number[];
  106943. /**
  106944. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  106945. */
  106946. wheelPrecision: number;
  106947. /**
  106948. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  106949. * It will be used instead of pinchDeltaPrecision if different from 0.
  106950. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  106951. */
  106952. wheelDeltaPercentage: number;
  106953. /**
  106954. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  106955. */
  106956. zoomOnFactor: number;
  106957. /**
  106958. * Defines a screen offset for the camera position.
  106959. */
  106960. targetScreenOffset: Vector2;
  106961. /**
  106962. * Allows the camera to be completely reversed.
  106963. * If false the camera can not arrive upside down.
  106964. */
  106965. allowUpsideDown: boolean;
  106966. /**
  106967. * Define if double tap/click is used to restore the previously saved state of the camera.
  106968. */
  106969. useInputToRestoreState: boolean;
  106970. /** @hidden */
  106971. _viewMatrix: Matrix;
  106972. /** @hidden */
  106973. _useCtrlForPanning: boolean;
  106974. /** @hidden */
  106975. _panningMouseButton: number;
  106976. /**
  106977. * Defines the input associated to the camera.
  106978. */
  106979. inputs: ArcRotateCameraInputsManager;
  106980. /** @hidden */
  106981. _reset: () => void;
  106982. /**
  106983. * Defines the allowed panning axis.
  106984. */
  106985. panningAxis: Vector3;
  106986. protected _localDirection: Vector3;
  106987. protected _transformedDirection: Vector3;
  106988. private _bouncingBehavior;
  106989. /**
  106990. * Gets the bouncing behavior of the camera if it has been enabled.
  106991. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106992. */
  106993. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  106994. /**
  106995. * Defines if the bouncing behavior of the camera is enabled on the camera.
  106996. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106997. */
  106998. useBouncingBehavior: boolean;
  106999. private _framingBehavior;
  107000. /**
  107001. * Gets the framing behavior of the camera if it has been enabled.
  107002. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  107003. */
  107004. readonly framingBehavior: Nullable<FramingBehavior>;
  107005. /**
  107006. * Defines if the framing behavior of the camera is enabled on the camera.
  107007. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  107008. */
  107009. useFramingBehavior: boolean;
  107010. private _autoRotationBehavior;
  107011. /**
  107012. * Gets the auto rotation behavior of the camera if it has been enabled.
  107013. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107014. */
  107015. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  107016. /**
  107017. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  107018. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107019. */
  107020. useAutoRotationBehavior: boolean;
  107021. /**
  107022. * Observable triggered when the mesh target has been changed on the camera.
  107023. */
  107024. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  107025. /**
  107026. * Event raised when the camera is colliding with a mesh.
  107027. */
  107028. onCollide: (collidedMesh: AbstractMesh) => void;
  107029. /**
  107030. * Defines whether the camera should check collision with the objects oh the scene.
  107031. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  107032. */
  107033. checkCollisions: boolean;
  107034. /**
  107035. * Defines the collision radius of the camera.
  107036. * This simulates a sphere around the camera.
  107037. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  107038. */
  107039. collisionRadius: Vector3;
  107040. protected _collider: Collider;
  107041. protected _previousPosition: Vector3;
  107042. protected _collisionVelocity: Vector3;
  107043. protected _newPosition: Vector3;
  107044. protected _previousAlpha: number;
  107045. protected _previousBeta: number;
  107046. protected _previousRadius: number;
  107047. protected _collisionTriggered: boolean;
  107048. protected _targetBoundingCenter: Nullable<Vector3>;
  107049. private _computationVector;
  107050. /**
  107051. * Instantiates a new ArcRotateCamera in a given scene
  107052. * @param name Defines the name of the camera
  107053. * @param alpha Defines the camera rotation along the logitudinal axis
  107054. * @param beta Defines the camera rotation along the latitudinal axis
  107055. * @param radius Defines the camera distance from its target
  107056. * @param target Defines the camera target
  107057. * @param scene Defines the scene the camera belongs to
  107058. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  107059. */
  107060. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  107061. /** @hidden */
  107062. _initCache(): void;
  107063. /** @hidden */
  107064. _updateCache(ignoreParentClass?: boolean): void;
  107065. protected _getTargetPosition(): Vector3;
  107066. private _storedAlpha;
  107067. private _storedBeta;
  107068. private _storedRadius;
  107069. private _storedTarget;
  107070. private _storedTargetScreenOffset;
  107071. /**
  107072. * Stores the current state of the camera (alpha, beta, radius and target)
  107073. * @returns the camera itself
  107074. */
  107075. storeState(): Camera;
  107076. /**
  107077. * @hidden
  107078. * Restored camera state. You must call storeState() first
  107079. */
  107080. _restoreStateValues(): boolean;
  107081. /** @hidden */
  107082. _isSynchronizedViewMatrix(): boolean;
  107083. /**
  107084. * Attached controls to the current camera.
  107085. * @param element Defines the element the controls should be listened from
  107086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107087. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  107088. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  107089. */
  107090. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  107091. /**
  107092. * Detach the current controls from the camera.
  107093. * The camera will stop reacting to inputs.
  107094. * @param element Defines the element to stop listening the inputs from
  107095. */
  107096. detachControl(element: HTMLElement): void;
  107097. /** @hidden */
  107098. _checkInputs(): void;
  107099. protected _checkLimits(): void;
  107100. /**
  107101. * Rebuilds angles (alpha, beta) and radius from the give position and target
  107102. */
  107103. rebuildAnglesAndRadius(): void;
  107104. /**
  107105. * Use a position to define the current camera related information like alpha, beta and radius
  107106. * @param position Defines the position to set the camera at
  107107. */
  107108. setPosition(position: Vector3): void;
  107109. /**
  107110. * Defines the target the camera should look at.
  107111. * This will automatically adapt alpha beta and radius to fit within the new target.
  107112. * @param target Defines the new target as a Vector or a mesh
  107113. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  107114. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  107115. */
  107116. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  107117. /** @hidden */
  107118. _getViewMatrix(): Matrix;
  107119. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  107120. /**
  107121. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  107122. * @param meshes Defines the mesh to zoom on
  107123. * @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)
  107124. */
  107125. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  107126. /**
  107127. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  107128. * The target will be changed but the radius
  107129. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  107130. * @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)
  107131. */
  107132. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  107133. min: Vector3;
  107134. max: Vector3;
  107135. distance: number;
  107136. }, doNotUpdateMaxZ?: boolean): void;
  107137. /**
  107138. * @override
  107139. * Override Camera.createRigCamera
  107140. */
  107141. createRigCamera(name: string, cameraIndex: number): Camera;
  107142. /**
  107143. * @hidden
  107144. * @override
  107145. * Override Camera._updateRigCameras
  107146. */
  107147. _updateRigCameras(): void;
  107148. /**
  107149. * Destroy the camera and release the current resources hold by it.
  107150. */
  107151. dispose(): void;
  107152. /**
  107153. * Gets the current object class name.
  107154. * @return the class name
  107155. */
  107156. getClassName(): string;
  107157. }
  107158. }
  107159. declare module BABYLON {
  107160. /**
  107161. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  107162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107163. */
  107164. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  107165. /**
  107166. * Gets the name of the behavior.
  107167. */
  107168. readonly name: string;
  107169. private _zoomStopsAnimation;
  107170. private _idleRotationSpeed;
  107171. private _idleRotationWaitTime;
  107172. private _idleRotationSpinupTime;
  107173. /**
  107174. * Sets the flag that indicates if user zooming should stop animation.
  107175. */
  107176. /**
  107177. * Gets the flag that indicates if user zooming should stop animation.
  107178. */
  107179. zoomStopsAnimation: boolean;
  107180. /**
  107181. * Sets the default speed at which the camera rotates around the model.
  107182. */
  107183. /**
  107184. * Gets the default speed at which the camera rotates around the model.
  107185. */
  107186. idleRotationSpeed: number;
  107187. /**
  107188. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  107189. */
  107190. /**
  107191. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  107192. */
  107193. idleRotationWaitTime: number;
  107194. /**
  107195. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107196. */
  107197. /**
  107198. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107199. */
  107200. idleRotationSpinupTime: number;
  107201. /**
  107202. * Gets a value indicating if the camera is currently rotating because of this behavior
  107203. */
  107204. readonly rotationInProgress: boolean;
  107205. private _onPrePointerObservableObserver;
  107206. private _onAfterCheckInputsObserver;
  107207. private _attachedCamera;
  107208. private _isPointerDown;
  107209. private _lastFrameTime;
  107210. private _lastInteractionTime;
  107211. private _cameraRotationSpeed;
  107212. /**
  107213. * Initializes the behavior.
  107214. */
  107215. init(): void;
  107216. /**
  107217. * Attaches the behavior to its arc rotate camera.
  107218. * @param camera Defines the camera to attach the behavior to
  107219. */
  107220. attach(camera: ArcRotateCamera): void;
  107221. /**
  107222. * Detaches the behavior from its current arc rotate camera.
  107223. */
  107224. detach(): void;
  107225. /**
  107226. * Returns true if user is scrolling.
  107227. * @return true if user is scrolling.
  107228. */
  107229. private _userIsZooming;
  107230. private _lastFrameRadius;
  107231. private _shouldAnimationStopForInteraction;
  107232. /**
  107233. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  107234. */
  107235. private _applyUserInteraction;
  107236. private _userIsMoving;
  107237. }
  107238. }
  107239. declare module BABYLON {
  107240. /**
  107241. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  107242. */
  107243. export class AttachToBoxBehavior implements Behavior<Mesh> {
  107244. private ui;
  107245. /**
  107246. * The name of the behavior
  107247. */
  107248. name: string;
  107249. /**
  107250. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  107251. */
  107252. distanceAwayFromFace: number;
  107253. /**
  107254. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  107255. */
  107256. distanceAwayFromBottomOfFace: number;
  107257. private _faceVectors;
  107258. private _target;
  107259. private _scene;
  107260. private _onRenderObserver;
  107261. private _tmpMatrix;
  107262. private _tmpVector;
  107263. /**
  107264. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  107265. * @param ui The transform node that should be attched to the mesh
  107266. */
  107267. constructor(ui: TransformNode);
  107268. /**
  107269. * Initializes the behavior
  107270. */
  107271. init(): void;
  107272. private _closestFace;
  107273. private _zeroVector;
  107274. private _lookAtTmpMatrix;
  107275. private _lookAtToRef;
  107276. /**
  107277. * Attaches the AttachToBoxBehavior to the passed in mesh
  107278. * @param target The mesh that the specified node will be attached to
  107279. */
  107280. attach(target: Mesh): void;
  107281. /**
  107282. * Detaches the behavior from the mesh
  107283. */
  107284. detach(): void;
  107285. }
  107286. }
  107287. declare module BABYLON {
  107288. /**
  107289. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  107290. */
  107291. export class FadeInOutBehavior implements Behavior<Mesh> {
  107292. /**
  107293. * Time in milliseconds to delay before fading in (Default: 0)
  107294. */
  107295. delay: number;
  107296. /**
  107297. * Time in milliseconds for the mesh to fade in (Default: 300)
  107298. */
  107299. fadeInTime: number;
  107300. private _millisecondsPerFrame;
  107301. private _hovered;
  107302. private _hoverValue;
  107303. private _ownerNode;
  107304. /**
  107305. * Instatiates the FadeInOutBehavior
  107306. */
  107307. constructor();
  107308. /**
  107309. * The name of the behavior
  107310. */
  107311. readonly name: string;
  107312. /**
  107313. * Initializes the behavior
  107314. */
  107315. init(): void;
  107316. /**
  107317. * Attaches the fade behavior on the passed in mesh
  107318. * @param ownerNode The mesh that will be faded in/out once attached
  107319. */
  107320. attach(ownerNode: Mesh): void;
  107321. /**
  107322. * Detaches the behavior from the mesh
  107323. */
  107324. detach(): void;
  107325. /**
  107326. * Triggers the mesh to begin fading in or out
  107327. * @param value if the object should fade in or out (true to fade in)
  107328. */
  107329. fadeIn(value: boolean): void;
  107330. private _update;
  107331. private _setAllVisibility;
  107332. }
  107333. }
  107334. declare module BABYLON {
  107335. /**
  107336. * Class containing a set of static utilities functions for managing Pivots
  107337. * @hidden
  107338. */
  107339. export class PivotTools {
  107340. private static _PivotCached;
  107341. private static _OldPivotPoint;
  107342. private static _PivotTranslation;
  107343. private static _PivotTmpVector;
  107344. /** @hidden */
  107345. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  107346. /** @hidden */
  107347. static _RestorePivotPoint(mesh: AbstractMesh): void;
  107348. }
  107349. }
  107350. declare module BABYLON {
  107351. /**
  107352. * Class containing static functions to help procedurally build meshes
  107353. */
  107354. export class PlaneBuilder {
  107355. /**
  107356. * Creates a plane mesh
  107357. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107358. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107359. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107363. * @param name defines the name of the mesh
  107364. * @param options defines the options used to create the mesh
  107365. * @param scene defines the hosting scene
  107366. * @returns the plane mesh
  107367. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107368. */
  107369. static CreatePlane(name: string, options: {
  107370. size?: number;
  107371. width?: number;
  107372. height?: number;
  107373. sideOrientation?: number;
  107374. frontUVs?: Vector4;
  107375. backUVs?: Vector4;
  107376. updatable?: boolean;
  107377. sourcePlane?: Plane;
  107378. }, scene?: Nullable<Scene>): Mesh;
  107379. }
  107380. }
  107381. declare module BABYLON {
  107382. /**
  107383. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  107384. */
  107385. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  107386. private static _AnyMouseID;
  107387. /**
  107388. * Abstract mesh the behavior is set on
  107389. */
  107390. attachedNode: AbstractMesh;
  107391. private _dragPlane;
  107392. private _scene;
  107393. private _pointerObserver;
  107394. private _beforeRenderObserver;
  107395. private static _planeScene;
  107396. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  107397. /**
  107398. * 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)
  107399. */
  107400. maxDragAngle: number;
  107401. /**
  107402. * @hidden
  107403. */
  107404. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  107405. /**
  107406. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107407. */
  107408. currentDraggingPointerID: number;
  107409. /**
  107410. * The last position where the pointer hit the drag plane in world space
  107411. */
  107412. lastDragPosition: Vector3;
  107413. /**
  107414. * If the behavior is currently in a dragging state
  107415. */
  107416. dragging: boolean;
  107417. /**
  107418. * 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)
  107419. */
  107420. dragDeltaRatio: number;
  107421. /**
  107422. * If the drag plane orientation should be updated during the dragging (Default: true)
  107423. */
  107424. updateDragPlane: boolean;
  107425. private _debugMode;
  107426. private _moving;
  107427. /**
  107428. * Fires each time the attached mesh is dragged with the pointer
  107429. * * delta between last drag position and current drag position in world space
  107430. * * dragDistance along the drag axis
  107431. * * dragPlaneNormal normal of the current drag plane used during the drag
  107432. * * dragPlanePoint in world space where the drag intersects the drag plane
  107433. */
  107434. onDragObservable: Observable<{
  107435. delta: Vector3;
  107436. dragPlanePoint: Vector3;
  107437. dragPlaneNormal: Vector3;
  107438. dragDistance: number;
  107439. pointerId: number;
  107440. }>;
  107441. /**
  107442. * Fires each time a drag begins (eg. mouse down on mesh)
  107443. */
  107444. onDragStartObservable: Observable<{
  107445. dragPlanePoint: Vector3;
  107446. pointerId: number;
  107447. }>;
  107448. /**
  107449. * Fires each time a drag ends (eg. mouse release after drag)
  107450. */
  107451. onDragEndObservable: Observable<{
  107452. dragPlanePoint: Vector3;
  107453. pointerId: number;
  107454. }>;
  107455. /**
  107456. * If the attached mesh should be moved when dragged
  107457. */
  107458. moveAttached: boolean;
  107459. /**
  107460. * If the drag behavior will react to drag events (Default: true)
  107461. */
  107462. enabled: boolean;
  107463. /**
  107464. * If pointer events should start and release the drag (Default: true)
  107465. */
  107466. startAndReleaseDragOnPointerEvents: boolean;
  107467. /**
  107468. * If camera controls should be detached during the drag
  107469. */
  107470. detachCameraControls: boolean;
  107471. /**
  107472. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  107473. */
  107474. useObjectOrienationForDragging: boolean;
  107475. private _options;
  107476. /**
  107477. * Gets the options used by the behavior
  107478. */
  107479. /**
  107480. * Sets the options used by the behavior
  107481. */
  107482. options: {
  107483. dragAxis?: Vector3;
  107484. dragPlaneNormal?: Vector3;
  107485. };
  107486. /**
  107487. * Creates a pointer drag behavior that can be attached to a mesh
  107488. * @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)
  107489. */
  107490. constructor(options?: {
  107491. dragAxis?: Vector3;
  107492. dragPlaneNormal?: Vector3;
  107493. });
  107494. /**
  107495. * Predicate to determine if it is valid to move the object to a new position when it is moved
  107496. */
  107497. validateDrag: (targetPosition: Vector3) => boolean;
  107498. /**
  107499. * The name of the behavior
  107500. */
  107501. readonly name: string;
  107502. /**
  107503. * Initializes the behavior
  107504. */
  107505. init(): void;
  107506. private _tmpVector;
  107507. private _alternatePickedPoint;
  107508. private _worldDragAxis;
  107509. private _targetPosition;
  107510. private _attachedElement;
  107511. /**
  107512. * Attaches the drag behavior the passed in mesh
  107513. * @param ownerNode The mesh that will be dragged around once attached
  107514. * @param predicate Predicate to use for pick filtering
  107515. */
  107516. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  107517. /**
  107518. * Force relase the drag action by code.
  107519. */
  107520. releaseDrag(): void;
  107521. private _startDragRay;
  107522. private _lastPointerRay;
  107523. /**
  107524. * Simulates the start of a pointer drag event on the behavior
  107525. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  107526. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  107527. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  107528. */
  107529. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  107530. private _startDrag;
  107531. private _dragDelta;
  107532. private _moveDrag;
  107533. private _pickWithRayOnDragPlane;
  107534. private _pointA;
  107535. private _pointB;
  107536. private _pointC;
  107537. private _lineA;
  107538. private _lineB;
  107539. private _localAxis;
  107540. private _lookAt;
  107541. private _updateDragPlanePosition;
  107542. /**
  107543. * Detaches the behavior from the mesh
  107544. */
  107545. detach(): void;
  107546. }
  107547. }
  107548. declare module BABYLON {
  107549. /**
  107550. * A behavior that when attached to a mesh will allow the mesh to be scaled
  107551. */
  107552. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  107553. private _dragBehaviorA;
  107554. private _dragBehaviorB;
  107555. private _startDistance;
  107556. private _initialScale;
  107557. private _targetScale;
  107558. private _ownerNode;
  107559. private _sceneRenderObserver;
  107560. /**
  107561. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  107562. */
  107563. constructor();
  107564. /**
  107565. * The name of the behavior
  107566. */
  107567. readonly name: string;
  107568. /**
  107569. * Initializes the behavior
  107570. */
  107571. init(): void;
  107572. private _getCurrentDistance;
  107573. /**
  107574. * Attaches the scale behavior the passed in mesh
  107575. * @param ownerNode The mesh that will be scaled around once attached
  107576. */
  107577. attach(ownerNode: Mesh): void;
  107578. /**
  107579. * Detaches the behavior from the mesh
  107580. */
  107581. detach(): void;
  107582. }
  107583. }
  107584. declare module BABYLON {
  107585. /**
  107586. * 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
  107587. */
  107588. export class SixDofDragBehavior implements Behavior<Mesh> {
  107589. private static _virtualScene;
  107590. private _ownerNode;
  107591. private _sceneRenderObserver;
  107592. private _scene;
  107593. private _targetPosition;
  107594. private _virtualOriginMesh;
  107595. private _virtualDragMesh;
  107596. private _pointerObserver;
  107597. private _moving;
  107598. private _startingOrientation;
  107599. /**
  107600. * 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)
  107601. */
  107602. private zDragFactor;
  107603. /**
  107604. * If the object should rotate to face the drag origin
  107605. */
  107606. rotateDraggedObject: boolean;
  107607. /**
  107608. * If the behavior is currently in a dragging state
  107609. */
  107610. dragging: boolean;
  107611. /**
  107612. * 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)
  107613. */
  107614. dragDeltaRatio: number;
  107615. /**
  107616. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107617. */
  107618. currentDraggingPointerID: number;
  107619. /**
  107620. * If camera controls should be detached during the drag
  107621. */
  107622. detachCameraControls: boolean;
  107623. /**
  107624. * Fires each time a drag starts
  107625. */
  107626. onDragStartObservable: Observable<{}>;
  107627. /**
  107628. * Fires each time a drag ends (eg. mouse release after drag)
  107629. */
  107630. onDragEndObservable: Observable<{}>;
  107631. /**
  107632. * 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
  107633. */
  107634. constructor();
  107635. /**
  107636. * The name of the behavior
  107637. */
  107638. readonly name: string;
  107639. /**
  107640. * Initializes the behavior
  107641. */
  107642. init(): void;
  107643. /**
  107644. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  107645. */
  107646. private readonly _pointerCamera;
  107647. /**
  107648. * Attaches the scale behavior the passed in mesh
  107649. * @param ownerNode The mesh that will be scaled around once attached
  107650. */
  107651. attach(ownerNode: Mesh): void;
  107652. /**
  107653. * Detaches the behavior from the mesh
  107654. */
  107655. detach(): void;
  107656. }
  107657. }
  107658. declare module BABYLON {
  107659. /**
  107660. * Class used to apply inverse kinematics to bones
  107661. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  107662. */
  107663. export class BoneIKController {
  107664. private static _tmpVecs;
  107665. private static _tmpQuat;
  107666. private static _tmpMats;
  107667. /**
  107668. * Gets or sets the target mesh
  107669. */
  107670. targetMesh: AbstractMesh;
  107671. /** Gets or sets the mesh used as pole */
  107672. poleTargetMesh: AbstractMesh;
  107673. /**
  107674. * Gets or sets the bone used as pole
  107675. */
  107676. poleTargetBone: Nullable<Bone>;
  107677. /**
  107678. * Gets or sets the target position
  107679. */
  107680. targetPosition: Vector3;
  107681. /**
  107682. * Gets or sets the pole target position
  107683. */
  107684. poleTargetPosition: Vector3;
  107685. /**
  107686. * Gets or sets the pole target local offset
  107687. */
  107688. poleTargetLocalOffset: Vector3;
  107689. /**
  107690. * Gets or sets the pole angle
  107691. */
  107692. poleAngle: number;
  107693. /**
  107694. * Gets or sets the mesh associated with the controller
  107695. */
  107696. mesh: AbstractMesh;
  107697. /**
  107698. * 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)
  107699. */
  107700. slerpAmount: number;
  107701. private _bone1Quat;
  107702. private _bone1Mat;
  107703. private _bone2Ang;
  107704. private _bone1;
  107705. private _bone2;
  107706. private _bone1Length;
  107707. private _bone2Length;
  107708. private _maxAngle;
  107709. private _maxReach;
  107710. private _rightHandedSystem;
  107711. private _bendAxis;
  107712. private _slerping;
  107713. private _adjustRoll;
  107714. /**
  107715. * Gets or sets maximum allowed angle
  107716. */
  107717. maxAngle: number;
  107718. /**
  107719. * Creates a new BoneIKController
  107720. * @param mesh defines the mesh to control
  107721. * @param bone defines the bone to control
  107722. * @param options defines options to set up the controller
  107723. */
  107724. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  107725. targetMesh?: AbstractMesh;
  107726. poleTargetMesh?: AbstractMesh;
  107727. poleTargetBone?: Bone;
  107728. poleTargetLocalOffset?: Vector3;
  107729. poleAngle?: number;
  107730. bendAxis?: Vector3;
  107731. maxAngle?: number;
  107732. slerpAmount?: number;
  107733. });
  107734. private _setMaxAngle;
  107735. /**
  107736. * Force the controller to update the bones
  107737. */
  107738. update(): void;
  107739. }
  107740. }
  107741. declare module BABYLON {
  107742. /**
  107743. * Class used to make a bone look toward a point in space
  107744. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  107745. */
  107746. export class BoneLookController {
  107747. private static _tmpVecs;
  107748. private static _tmpQuat;
  107749. private static _tmpMats;
  107750. /**
  107751. * The target Vector3 that the bone will look at
  107752. */
  107753. target: Vector3;
  107754. /**
  107755. * The mesh that the bone is attached to
  107756. */
  107757. mesh: AbstractMesh;
  107758. /**
  107759. * The bone that will be looking to the target
  107760. */
  107761. bone: Bone;
  107762. /**
  107763. * The up axis of the coordinate system that is used when the bone is rotated
  107764. */
  107765. upAxis: Vector3;
  107766. /**
  107767. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  107768. */
  107769. upAxisSpace: Space;
  107770. /**
  107771. * Used to make an adjustment to the yaw of the bone
  107772. */
  107773. adjustYaw: number;
  107774. /**
  107775. * Used to make an adjustment to the pitch of the bone
  107776. */
  107777. adjustPitch: number;
  107778. /**
  107779. * Used to make an adjustment to the roll of the bone
  107780. */
  107781. adjustRoll: number;
  107782. /**
  107783. * 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)
  107784. */
  107785. slerpAmount: number;
  107786. private _minYaw;
  107787. private _maxYaw;
  107788. private _minPitch;
  107789. private _maxPitch;
  107790. private _minYawSin;
  107791. private _minYawCos;
  107792. private _maxYawSin;
  107793. private _maxYawCos;
  107794. private _midYawConstraint;
  107795. private _minPitchTan;
  107796. private _maxPitchTan;
  107797. private _boneQuat;
  107798. private _slerping;
  107799. private _transformYawPitch;
  107800. private _transformYawPitchInv;
  107801. private _firstFrameSkipped;
  107802. private _yawRange;
  107803. private _fowardAxis;
  107804. /**
  107805. * Gets or sets the minimum yaw angle that the bone can look to
  107806. */
  107807. minYaw: number;
  107808. /**
  107809. * Gets or sets the maximum yaw angle that the bone can look to
  107810. */
  107811. maxYaw: number;
  107812. /**
  107813. * Gets or sets the minimum pitch angle that the bone can look to
  107814. */
  107815. minPitch: number;
  107816. /**
  107817. * Gets or sets the maximum pitch angle that the bone can look to
  107818. */
  107819. maxPitch: number;
  107820. /**
  107821. * Create a BoneLookController
  107822. * @param mesh the mesh that the bone belongs to
  107823. * @param bone the bone that will be looking to the target
  107824. * @param target the target Vector3 to look at
  107825. * @param options optional settings:
  107826. * * maxYaw: the maximum angle the bone will yaw to
  107827. * * minYaw: the minimum angle the bone will yaw to
  107828. * * maxPitch: the maximum angle the bone will pitch to
  107829. * * minPitch: the minimum angle the bone will yaw to
  107830. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  107831. * * upAxis: the up axis of the coordinate system
  107832. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  107833. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  107834. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  107835. * * adjustYaw: used to make an adjustment to the yaw of the bone
  107836. * * adjustPitch: used to make an adjustment to the pitch of the bone
  107837. * * adjustRoll: used to make an adjustment to the roll of the bone
  107838. **/
  107839. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  107840. maxYaw?: number;
  107841. minYaw?: number;
  107842. maxPitch?: number;
  107843. minPitch?: number;
  107844. slerpAmount?: number;
  107845. upAxis?: Vector3;
  107846. upAxisSpace?: Space;
  107847. yawAxis?: Vector3;
  107848. pitchAxis?: Vector3;
  107849. adjustYaw?: number;
  107850. adjustPitch?: number;
  107851. adjustRoll?: number;
  107852. });
  107853. /**
  107854. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  107855. */
  107856. update(): void;
  107857. private _getAngleDiff;
  107858. private _getAngleBetween;
  107859. private _isAngleBetween;
  107860. }
  107861. }
  107862. declare module BABYLON {
  107863. /**
  107864. * Manage the gamepad inputs to control an arc rotate camera.
  107865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107866. */
  107867. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  107868. /**
  107869. * Defines the camera the input is attached to.
  107870. */
  107871. camera: ArcRotateCamera;
  107872. /**
  107873. * Defines the gamepad the input is gathering event from.
  107874. */
  107875. gamepad: Nullable<Gamepad>;
  107876. /**
  107877. * Defines the gamepad rotation sensiblity.
  107878. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107879. */
  107880. gamepadRotationSensibility: number;
  107881. /**
  107882. * Defines the gamepad move sensiblity.
  107883. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107884. */
  107885. gamepadMoveSensibility: number;
  107886. private _yAxisScale;
  107887. /**
  107888. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107889. */
  107890. invertYAxis: boolean;
  107891. private _onGamepadConnectedObserver;
  107892. private _onGamepadDisconnectedObserver;
  107893. /**
  107894. * Attach the input controls to a specific dom element to get the input from.
  107895. * @param element Defines the element the controls should be listened from
  107896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107897. */
  107898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107899. /**
  107900. * Detach the current controls from the specified dom element.
  107901. * @param element Defines the element to stop listening the inputs from
  107902. */
  107903. detachControl(element: Nullable<HTMLElement>): void;
  107904. /**
  107905. * Update the current camera state depending on the inputs that have been used this frame.
  107906. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107907. */
  107908. checkInputs(): void;
  107909. /**
  107910. * Gets the class name of the current intput.
  107911. * @returns the class name
  107912. */
  107913. getClassName(): string;
  107914. /**
  107915. * Get the friendly name associated with the input class.
  107916. * @returns the input friendly name
  107917. */
  107918. getSimpleName(): string;
  107919. }
  107920. }
  107921. declare module BABYLON {
  107922. interface ArcRotateCameraInputsManager {
  107923. /**
  107924. * Add orientation input support to the input manager.
  107925. * @returns the current input manager
  107926. */
  107927. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  107928. }
  107929. /**
  107930. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  107931. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107932. */
  107933. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  107934. /**
  107935. * Defines the camera the input is attached to.
  107936. */
  107937. camera: ArcRotateCamera;
  107938. /**
  107939. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  107940. */
  107941. alphaCorrection: number;
  107942. /**
  107943. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  107944. */
  107945. gammaCorrection: number;
  107946. private _alpha;
  107947. private _gamma;
  107948. private _dirty;
  107949. private _deviceOrientationHandler;
  107950. /**
  107951. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  107952. */
  107953. constructor();
  107954. /**
  107955. * Attach the input controls to a specific dom element to get the input from.
  107956. * @param element Defines the element the controls should be listened from
  107957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107958. */
  107959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107960. /** @hidden */
  107961. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  107962. /**
  107963. * Update the current camera state depending on the inputs that have been used this frame.
  107964. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107965. */
  107966. checkInputs(): void;
  107967. /**
  107968. * Detach the current controls from the specified dom element.
  107969. * @param element Defines the element to stop listening the inputs from
  107970. */
  107971. detachControl(element: Nullable<HTMLElement>): void;
  107972. /**
  107973. * Gets the class name of the current intput.
  107974. * @returns the class name
  107975. */
  107976. getClassName(): string;
  107977. /**
  107978. * Get the friendly name associated with the input class.
  107979. * @returns the input friendly name
  107980. */
  107981. getSimpleName(): string;
  107982. }
  107983. }
  107984. declare module BABYLON {
  107985. /**
  107986. * Listen to mouse events to control the camera.
  107987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107988. */
  107989. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  107990. /**
  107991. * Defines the camera the input is attached to.
  107992. */
  107993. camera: FlyCamera;
  107994. /**
  107995. * Defines if touch is enabled. (Default is true.)
  107996. */
  107997. touchEnabled: boolean;
  107998. /**
  107999. * Defines the buttons associated with the input to handle camera rotation.
  108000. */
  108001. buttons: number[];
  108002. /**
  108003. * Assign buttons for Yaw control.
  108004. */
  108005. buttonsYaw: number[];
  108006. /**
  108007. * Assign buttons for Pitch control.
  108008. */
  108009. buttonsPitch: number[];
  108010. /**
  108011. * Assign buttons for Roll control.
  108012. */
  108013. buttonsRoll: number[];
  108014. /**
  108015. * Detect if any button is being pressed while mouse is moved.
  108016. * -1 = Mouse locked.
  108017. * 0 = Left button.
  108018. * 1 = Middle Button.
  108019. * 2 = Right Button.
  108020. */
  108021. activeButton: number;
  108022. /**
  108023. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  108024. * Higher values reduce its sensitivity.
  108025. */
  108026. angularSensibility: number;
  108027. private _mousemoveCallback;
  108028. private _observer;
  108029. private _rollObserver;
  108030. private previousPosition;
  108031. private noPreventDefault;
  108032. private element;
  108033. /**
  108034. * Listen to mouse events to control the camera.
  108035. * @param touchEnabled Define if touch is enabled. (Default is true.)
  108036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108037. */
  108038. constructor(touchEnabled?: boolean);
  108039. /**
  108040. * Attach the mouse control to the HTML DOM element.
  108041. * @param element Defines the element that listens to the input events.
  108042. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  108043. */
  108044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108045. /**
  108046. * Detach the current controls from the specified dom element.
  108047. * @param element Defines the element to stop listening the inputs from
  108048. */
  108049. detachControl(element: Nullable<HTMLElement>): void;
  108050. /**
  108051. * Gets the class name of the current input.
  108052. * @returns the class name.
  108053. */
  108054. getClassName(): string;
  108055. /**
  108056. * Get the friendly name associated with the input class.
  108057. * @returns the input's friendly name.
  108058. */
  108059. getSimpleName(): string;
  108060. private _pointerInput;
  108061. private _onMouseMove;
  108062. /**
  108063. * Rotate camera by mouse offset.
  108064. */
  108065. private rotateCamera;
  108066. }
  108067. }
  108068. declare module BABYLON {
  108069. /**
  108070. * Default Inputs manager for the FlyCamera.
  108071. * It groups all the default supported inputs for ease of use.
  108072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108073. */
  108074. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  108075. /**
  108076. * Instantiates a new FlyCameraInputsManager.
  108077. * @param camera Defines the camera the inputs belong to.
  108078. */
  108079. constructor(camera: FlyCamera);
  108080. /**
  108081. * Add keyboard input support to the input manager.
  108082. * @returns the new FlyCameraKeyboardMoveInput().
  108083. */
  108084. addKeyboard(): FlyCameraInputsManager;
  108085. /**
  108086. * Add mouse input support to the input manager.
  108087. * @param touchEnabled Enable touch screen support.
  108088. * @returns the new FlyCameraMouseInput().
  108089. */
  108090. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  108091. }
  108092. }
  108093. declare module BABYLON {
  108094. /**
  108095. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108096. * such as in a 3D Space Shooter or a Flight Simulator.
  108097. */
  108098. export class FlyCamera extends TargetCamera {
  108099. /**
  108100. * Define the collision ellipsoid of the camera.
  108101. * This is helpful for simulating a camera body, like a player's body.
  108102. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  108103. */
  108104. ellipsoid: Vector3;
  108105. /**
  108106. * Define an offset for the position of the ellipsoid around the camera.
  108107. * This can be helpful if the camera is attached away from the player's body center,
  108108. * such as at its head.
  108109. */
  108110. ellipsoidOffset: Vector3;
  108111. /**
  108112. * Enable or disable collisions of the camera with the rest of the scene objects.
  108113. */
  108114. checkCollisions: boolean;
  108115. /**
  108116. * Enable or disable gravity on the camera.
  108117. */
  108118. applyGravity: boolean;
  108119. /**
  108120. * Define the current direction the camera is moving to.
  108121. */
  108122. cameraDirection: Vector3;
  108123. /**
  108124. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  108125. * This overrides and empties cameraRotation.
  108126. */
  108127. rotationQuaternion: Quaternion;
  108128. /**
  108129. * Track Roll to maintain the wanted Rolling when looking around.
  108130. */
  108131. _trackRoll: number;
  108132. /**
  108133. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  108134. */
  108135. rollCorrect: number;
  108136. /**
  108137. * Mimic a banked turn, Rolling the camera when Yawing.
  108138. * It's recommended to use rollCorrect = 10 for faster banking correction.
  108139. */
  108140. bankedTurn: boolean;
  108141. /**
  108142. * Limit in radians for how much Roll banking will add. (Default: 90°)
  108143. */
  108144. bankedTurnLimit: number;
  108145. /**
  108146. * Value of 0 disables the banked Roll.
  108147. * Value of 1 is equal to the Yaw angle in radians.
  108148. */
  108149. bankedTurnMultiplier: number;
  108150. /**
  108151. * The inputs manager loads all the input sources, such as keyboard and mouse.
  108152. */
  108153. inputs: FlyCameraInputsManager;
  108154. /**
  108155. * Gets the input sensibility for mouse input.
  108156. * Higher values reduce sensitivity.
  108157. */
  108158. /**
  108159. * Sets the input sensibility for a mouse input.
  108160. * Higher values reduce sensitivity.
  108161. */
  108162. angularSensibility: number;
  108163. /**
  108164. * Get the keys for camera movement forward.
  108165. */
  108166. /**
  108167. * Set the keys for camera movement forward.
  108168. */
  108169. keysForward: number[];
  108170. /**
  108171. * Get the keys for camera movement backward.
  108172. */
  108173. keysBackward: number[];
  108174. /**
  108175. * Get the keys for camera movement up.
  108176. */
  108177. /**
  108178. * Set the keys for camera movement up.
  108179. */
  108180. keysUp: number[];
  108181. /**
  108182. * Get the keys for camera movement down.
  108183. */
  108184. /**
  108185. * Set the keys for camera movement down.
  108186. */
  108187. keysDown: number[];
  108188. /**
  108189. * Get the keys for camera movement left.
  108190. */
  108191. /**
  108192. * Set the keys for camera movement left.
  108193. */
  108194. keysLeft: number[];
  108195. /**
  108196. * Set the keys for camera movement right.
  108197. */
  108198. /**
  108199. * Set the keys for camera movement right.
  108200. */
  108201. keysRight: number[];
  108202. /**
  108203. * Event raised when the camera collides with a mesh in the scene.
  108204. */
  108205. onCollide: (collidedMesh: AbstractMesh) => void;
  108206. private _collider;
  108207. private _needMoveForGravity;
  108208. private _oldPosition;
  108209. private _diffPosition;
  108210. private _newPosition;
  108211. /** @hidden */
  108212. _localDirection: Vector3;
  108213. /** @hidden */
  108214. _transformedDirection: Vector3;
  108215. /**
  108216. * Instantiates a FlyCamera.
  108217. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108218. * such as in a 3D Space Shooter or a Flight Simulator.
  108219. * @param name Define the name of the camera in the scene.
  108220. * @param position Define the starting position of the camera in the scene.
  108221. * @param scene Define the scene the camera belongs to.
  108222. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  108223. */
  108224. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108225. /**
  108226. * Attach a control to the HTML DOM element.
  108227. * @param element Defines the element that listens to the input events.
  108228. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  108229. */
  108230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108231. /**
  108232. * Detach a control from the HTML DOM element.
  108233. * The camera will stop reacting to that input.
  108234. * @param element Defines the element that listens to the input events.
  108235. */
  108236. detachControl(element: HTMLElement): void;
  108237. private _collisionMask;
  108238. /**
  108239. * Get the mask that the camera ignores in collision events.
  108240. */
  108241. /**
  108242. * Set the mask that the camera ignores in collision events.
  108243. */
  108244. collisionMask: number;
  108245. /** @hidden */
  108246. _collideWithWorld(displacement: Vector3): void;
  108247. /** @hidden */
  108248. private _onCollisionPositionChange;
  108249. /** @hidden */
  108250. _checkInputs(): void;
  108251. /** @hidden */
  108252. _decideIfNeedsToMove(): boolean;
  108253. /** @hidden */
  108254. _updatePosition(): void;
  108255. /**
  108256. * Restore the Roll to its target value at the rate specified.
  108257. * @param rate - Higher means slower restoring.
  108258. * @hidden
  108259. */
  108260. restoreRoll(rate: number): void;
  108261. /**
  108262. * Destroy the camera and release the current resources held by it.
  108263. */
  108264. dispose(): void;
  108265. /**
  108266. * Get the current object class name.
  108267. * @returns the class name.
  108268. */
  108269. getClassName(): string;
  108270. }
  108271. }
  108272. declare module BABYLON {
  108273. /**
  108274. * Listen to keyboard events to control the camera.
  108275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108276. */
  108277. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  108278. /**
  108279. * Defines the camera the input is attached to.
  108280. */
  108281. camera: FlyCamera;
  108282. /**
  108283. * The list of keyboard keys used to control the forward move of the camera.
  108284. */
  108285. keysForward: number[];
  108286. /**
  108287. * The list of keyboard keys used to control the backward move of the camera.
  108288. */
  108289. keysBackward: number[];
  108290. /**
  108291. * The list of keyboard keys used to control the forward move of the camera.
  108292. */
  108293. keysUp: number[];
  108294. /**
  108295. * The list of keyboard keys used to control the backward move of the camera.
  108296. */
  108297. keysDown: number[];
  108298. /**
  108299. * The list of keyboard keys used to control the right strafe move of the camera.
  108300. */
  108301. keysRight: number[];
  108302. /**
  108303. * The list of keyboard keys used to control the left strafe move of the camera.
  108304. */
  108305. keysLeft: number[];
  108306. private _keys;
  108307. private _onCanvasBlurObserver;
  108308. private _onKeyboardObserver;
  108309. private _engine;
  108310. private _scene;
  108311. /**
  108312. * Attach the input controls to a specific dom element to get the input from.
  108313. * @param element Defines the element the controls should be listened from
  108314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108315. */
  108316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108317. /**
  108318. * Detach the current controls from the specified dom element.
  108319. * @param element Defines the element to stop listening the inputs from
  108320. */
  108321. detachControl(element: Nullable<HTMLElement>): void;
  108322. /**
  108323. * Gets the class name of the current intput.
  108324. * @returns the class name
  108325. */
  108326. getClassName(): string;
  108327. /** @hidden */
  108328. _onLostFocus(e: FocusEvent): void;
  108329. /**
  108330. * Get the friendly name associated with the input class.
  108331. * @returns the input friendly name
  108332. */
  108333. getSimpleName(): string;
  108334. /**
  108335. * Update the current camera state depending on the inputs that have been used this frame.
  108336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108337. */
  108338. checkInputs(): void;
  108339. }
  108340. }
  108341. declare module BABYLON {
  108342. /**
  108343. * Manage the mouse wheel inputs to control a follow camera.
  108344. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108345. */
  108346. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  108347. /**
  108348. * Defines the camera the input is attached to.
  108349. */
  108350. camera: FollowCamera;
  108351. /**
  108352. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  108353. */
  108354. axisControlRadius: boolean;
  108355. /**
  108356. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  108357. */
  108358. axisControlHeight: boolean;
  108359. /**
  108360. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  108361. */
  108362. axisControlRotation: boolean;
  108363. /**
  108364. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  108365. * relation to mouseWheel events.
  108366. */
  108367. wheelPrecision: number;
  108368. /**
  108369. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108370. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108371. */
  108372. wheelDeltaPercentage: number;
  108373. private _wheel;
  108374. private _observer;
  108375. /**
  108376. * Attach the input controls to a specific dom element to get the input from.
  108377. * @param element Defines the element the controls should be listened from
  108378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108379. */
  108380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108381. /**
  108382. * Detach the current controls from the specified dom element.
  108383. * @param element Defines the element to stop listening the inputs from
  108384. */
  108385. detachControl(element: Nullable<HTMLElement>): void;
  108386. /**
  108387. * Gets the class name of the current intput.
  108388. * @returns the class name
  108389. */
  108390. getClassName(): string;
  108391. /**
  108392. * Get the friendly name associated with the input class.
  108393. * @returns the input friendly name
  108394. */
  108395. getSimpleName(): string;
  108396. }
  108397. }
  108398. declare module BABYLON {
  108399. /**
  108400. * Manage the pointers inputs to control an follow camera.
  108401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108402. */
  108403. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  108404. /**
  108405. * Defines the camera the input is attached to.
  108406. */
  108407. camera: FollowCamera;
  108408. /**
  108409. * Gets the class name of the current input.
  108410. * @returns the class name
  108411. */
  108412. getClassName(): string;
  108413. /**
  108414. * Defines the pointer angular sensibility along the X axis or how fast is
  108415. * the camera rotating.
  108416. * A negative number will reverse the axis direction.
  108417. */
  108418. angularSensibilityX: number;
  108419. /**
  108420. * Defines the pointer angular sensibility along the Y axis or how fast is
  108421. * the camera rotating.
  108422. * A negative number will reverse the axis direction.
  108423. */
  108424. angularSensibilityY: number;
  108425. /**
  108426. * Defines the pointer pinch precision or how fast is the camera zooming.
  108427. * A negative number will reverse the axis direction.
  108428. */
  108429. pinchPrecision: number;
  108430. /**
  108431. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108432. * from 0.
  108433. * It defines the percentage of current camera.radius to use as delta when
  108434. * pinch zoom is used.
  108435. */
  108436. pinchDeltaPercentage: number;
  108437. /**
  108438. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  108439. */
  108440. axisXControlRadius: boolean;
  108441. /**
  108442. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  108443. */
  108444. axisXControlHeight: boolean;
  108445. /**
  108446. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  108447. */
  108448. axisXControlRotation: boolean;
  108449. /**
  108450. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  108451. */
  108452. axisYControlRadius: boolean;
  108453. /**
  108454. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  108455. */
  108456. axisYControlHeight: boolean;
  108457. /**
  108458. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  108459. */
  108460. axisYControlRotation: boolean;
  108461. /**
  108462. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  108463. */
  108464. axisPinchControlRadius: boolean;
  108465. /**
  108466. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  108467. */
  108468. axisPinchControlHeight: boolean;
  108469. /**
  108470. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  108471. */
  108472. axisPinchControlRotation: boolean;
  108473. /**
  108474. * Log error messages if basic misconfiguration has occurred.
  108475. */
  108476. warningEnable: boolean;
  108477. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108478. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108479. private _warningCounter;
  108480. private _warning;
  108481. }
  108482. }
  108483. declare module BABYLON {
  108484. /**
  108485. * Default Inputs manager for the FollowCamera.
  108486. * It groups all the default supported inputs for ease of use.
  108487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108488. */
  108489. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  108490. /**
  108491. * Instantiates a new FollowCameraInputsManager.
  108492. * @param camera Defines the camera the inputs belong to
  108493. */
  108494. constructor(camera: FollowCamera);
  108495. /**
  108496. * Add keyboard input support to the input manager.
  108497. * @returns the current input manager
  108498. */
  108499. addKeyboard(): FollowCameraInputsManager;
  108500. /**
  108501. * Add mouse wheel input support to the input manager.
  108502. * @returns the current input manager
  108503. */
  108504. addMouseWheel(): FollowCameraInputsManager;
  108505. /**
  108506. * Add pointers input support to the input manager.
  108507. * @returns the current input manager
  108508. */
  108509. addPointers(): FollowCameraInputsManager;
  108510. /**
  108511. * Add orientation input support to the input manager.
  108512. * @returns the current input manager
  108513. */
  108514. addVRDeviceOrientation(): FollowCameraInputsManager;
  108515. }
  108516. }
  108517. declare module BABYLON {
  108518. /**
  108519. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  108520. * an arc rotate version arcFollowCamera are available.
  108521. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108522. */
  108523. export class FollowCamera extends TargetCamera {
  108524. /**
  108525. * Distance the follow camera should follow an object at
  108526. */
  108527. radius: number;
  108528. /**
  108529. * Minimum allowed distance of the camera to the axis of rotation
  108530. * (The camera can not get closer).
  108531. * This can help limiting how the Camera is able to move in the scene.
  108532. */
  108533. lowerRadiusLimit: Nullable<number>;
  108534. /**
  108535. * Maximum allowed distance of the camera to the axis of rotation
  108536. * (The camera can not get further).
  108537. * This can help limiting how the Camera is able to move in the scene.
  108538. */
  108539. upperRadiusLimit: Nullable<number>;
  108540. /**
  108541. * Define a rotation offset between the camera and the object it follows
  108542. */
  108543. rotationOffset: number;
  108544. /**
  108545. * Minimum allowed angle to camera position relative to target object.
  108546. * This can help limiting how the Camera is able to move in the scene.
  108547. */
  108548. lowerRotationOffsetLimit: Nullable<number>;
  108549. /**
  108550. * Maximum allowed angle to camera position relative to target object.
  108551. * This can help limiting how the Camera is able to move in the scene.
  108552. */
  108553. upperRotationOffsetLimit: Nullable<number>;
  108554. /**
  108555. * Define a height offset between the camera and the object it follows.
  108556. * It can help following an object from the top (like a car chaing a plane)
  108557. */
  108558. heightOffset: number;
  108559. /**
  108560. * Minimum allowed height of camera position relative to target object.
  108561. * This can help limiting how the Camera is able to move in the scene.
  108562. */
  108563. lowerHeightOffsetLimit: Nullable<number>;
  108564. /**
  108565. * Maximum allowed height of camera position relative to target object.
  108566. * This can help limiting how the Camera is able to move in the scene.
  108567. */
  108568. upperHeightOffsetLimit: Nullable<number>;
  108569. /**
  108570. * Define how fast the camera can accelerate to follow it s target.
  108571. */
  108572. cameraAcceleration: number;
  108573. /**
  108574. * Define the speed limit of the camera following an object.
  108575. */
  108576. maxCameraSpeed: number;
  108577. /**
  108578. * Define the target of the camera.
  108579. */
  108580. lockedTarget: Nullable<AbstractMesh>;
  108581. /**
  108582. * Defines the input associated with the camera.
  108583. */
  108584. inputs: FollowCameraInputsManager;
  108585. /**
  108586. * Instantiates the follow camera.
  108587. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108588. * @param name Define the name of the camera in the scene
  108589. * @param position Define the position of the camera
  108590. * @param scene Define the scene the camera belong to
  108591. * @param lockedTarget Define the target of the camera
  108592. */
  108593. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  108594. private _follow;
  108595. /**
  108596. * Attached controls to the current camera.
  108597. * @param element Defines the element the controls should be listened from
  108598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108599. */
  108600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108601. /**
  108602. * Detach the current controls from the camera.
  108603. * The camera will stop reacting to inputs.
  108604. * @param element Defines the element to stop listening the inputs from
  108605. */
  108606. detachControl(element: HTMLElement): void;
  108607. /** @hidden */
  108608. _checkInputs(): void;
  108609. private _checkLimits;
  108610. /**
  108611. * Gets the camera class name.
  108612. * @returns the class name
  108613. */
  108614. getClassName(): string;
  108615. }
  108616. /**
  108617. * Arc Rotate version of the follow camera.
  108618. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  108619. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108620. */
  108621. export class ArcFollowCamera extends TargetCamera {
  108622. /** The longitudinal angle of the camera */
  108623. alpha: number;
  108624. /** The latitudinal angle of the camera */
  108625. beta: number;
  108626. /** The radius of the camera from its target */
  108627. radius: number;
  108628. /** Define the camera target (the messh it should follow) */
  108629. target: Nullable<AbstractMesh>;
  108630. private _cartesianCoordinates;
  108631. /**
  108632. * Instantiates a new ArcFollowCamera
  108633. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108634. * @param name Define the name of the camera
  108635. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  108636. * @param beta Define the rotation angle of the camera around the elevation axis
  108637. * @param radius Define the radius of the camera from its target point
  108638. * @param target Define the target of the camera
  108639. * @param scene Define the scene the camera belongs to
  108640. */
  108641. constructor(name: string,
  108642. /** The longitudinal angle of the camera */
  108643. alpha: number,
  108644. /** The latitudinal angle of the camera */
  108645. beta: number,
  108646. /** The radius of the camera from its target */
  108647. radius: number,
  108648. /** Define the camera target (the messh it should follow) */
  108649. target: Nullable<AbstractMesh>, scene: Scene);
  108650. private _follow;
  108651. /** @hidden */
  108652. _checkInputs(): void;
  108653. /**
  108654. * Returns the class name of the object.
  108655. * It is mostly used internally for serialization purposes.
  108656. */
  108657. getClassName(): string;
  108658. }
  108659. }
  108660. declare module BABYLON {
  108661. /**
  108662. * Manage the keyboard inputs to control the movement of a follow camera.
  108663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108664. */
  108665. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  108666. /**
  108667. * Defines the camera the input is attached to.
  108668. */
  108669. camera: FollowCamera;
  108670. /**
  108671. * Defines the list of key codes associated with the up action (increase heightOffset)
  108672. */
  108673. keysHeightOffsetIncr: number[];
  108674. /**
  108675. * Defines the list of key codes associated with the down action (decrease heightOffset)
  108676. */
  108677. keysHeightOffsetDecr: number[];
  108678. /**
  108679. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  108680. */
  108681. keysHeightOffsetModifierAlt: boolean;
  108682. /**
  108683. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  108684. */
  108685. keysHeightOffsetModifierCtrl: boolean;
  108686. /**
  108687. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  108688. */
  108689. keysHeightOffsetModifierShift: boolean;
  108690. /**
  108691. * Defines the list of key codes associated with the left action (increase rotationOffset)
  108692. */
  108693. keysRotationOffsetIncr: number[];
  108694. /**
  108695. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  108696. */
  108697. keysRotationOffsetDecr: number[];
  108698. /**
  108699. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  108700. */
  108701. keysRotationOffsetModifierAlt: boolean;
  108702. /**
  108703. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  108704. */
  108705. keysRotationOffsetModifierCtrl: boolean;
  108706. /**
  108707. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  108708. */
  108709. keysRotationOffsetModifierShift: boolean;
  108710. /**
  108711. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  108712. */
  108713. keysRadiusIncr: number[];
  108714. /**
  108715. * Defines the list of key codes associated with the zoom-out action (increase radius)
  108716. */
  108717. keysRadiusDecr: number[];
  108718. /**
  108719. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  108720. */
  108721. keysRadiusModifierAlt: boolean;
  108722. /**
  108723. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  108724. */
  108725. keysRadiusModifierCtrl: boolean;
  108726. /**
  108727. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  108728. */
  108729. keysRadiusModifierShift: boolean;
  108730. /**
  108731. * Defines the rate of change of heightOffset.
  108732. */
  108733. heightSensibility: number;
  108734. /**
  108735. * Defines the rate of change of rotationOffset.
  108736. */
  108737. rotationSensibility: number;
  108738. /**
  108739. * Defines the rate of change of radius.
  108740. */
  108741. radiusSensibility: number;
  108742. private _keys;
  108743. private _ctrlPressed;
  108744. private _altPressed;
  108745. private _shiftPressed;
  108746. private _onCanvasBlurObserver;
  108747. private _onKeyboardObserver;
  108748. private _engine;
  108749. private _scene;
  108750. /**
  108751. * Attach the input controls to a specific dom element to get the input from.
  108752. * @param element Defines the element the controls should be listened from
  108753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108754. */
  108755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108756. /**
  108757. * Detach the current controls from the specified dom element.
  108758. * @param element Defines the element to stop listening the inputs from
  108759. */
  108760. detachControl(element: Nullable<HTMLElement>): void;
  108761. /**
  108762. * Update the current camera state depending on the inputs that have been used this frame.
  108763. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108764. */
  108765. checkInputs(): void;
  108766. /**
  108767. * Gets the class name of the current input.
  108768. * @returns the class name
  108769. */
  108770. getClassName(): string;
  108771. /**
  108772. * Get the friendly name associated with the input class.
  108773. * @returns the input friendly name
  108774. */
  108775. getSimpleName(): string;
  108776. /**
  108777. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108778. * allow modification of the heightOffset value.
  108779. */
  108780. private _modifierHeightOffset;
  108781. /**
  108782. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108783. * allow modification of the rotationOffset value.
  108784. */
  108785. private _modifierRotationOffset;
  108786. /**
  108787. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108788. * allow modification of the radius value.
  108789. */
  108790. private _modifierRadius;
  108791. }
  108792. }
  108793. declare module BABYLON {
  108794. interface FreeCameraInputsManager {
  108795. /**
  108796. * @hidden
  108797. */
  108798. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  108799. /**
  108800. * Add orientation input support to the input manager.
  108801. * @returns the current input manager
  108802. */
  108803. addDeviceOrientation(): FreeCameraInputsManager;
  108804. }
  108805. /**
  108806. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  108807. * Screen rotation is taken into account.
  108808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108809. */
  108810. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  108811. private _camera;
  108812. private _screenOrientationAngle;
  108813. private _constantTranform;
  108814. private _screenQuaternion;
  108815. private _alpha;
  108816. private _beta;
  108817. private _gamma;
  108818. /**
  108819. * Can be used to detect if a device orientation sensor is available on a device
  108820. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  108821. * @returns a promise that will resolve on orientation change
  108822. */
  108823. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  108824. /**
  108825. * @hidden
  108826. */
  108827. _onDeviceOrientationChangedObservable: Observable<void>;
  108828. /**
  108829. * Instantiates a new input
  108830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108831. */
  108832. constructor();
  108833. /**
  108834. * Define the camera controlled by the input.
  108835. */
  108836. camera: FreeCamera;
  108837. /**
  108838. * Attach the input controls to a specific dom element to get the input from.
  108839. * @param element Defines the element the controls should be listened from
  108840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108841. */
  108842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108843. private _orientationChanged;
  108844. private _deviceOrientation;
  108845. /**
  108846. * Detach the current controls from the specified dom element.
  108847. * @param element Defines the element to stop listening the inputs from
  108848. */
  108849. detachControl(element: Nullable<HTMLElement>): void;
  108850. /**
  108851. * Update the current camera state depending on the inputs that have been used this frame.
  108852. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108853. */
  108854. checkInputs(): void;
  108855. /**
  108856. * Gets the class name of the current intput.
  108857. * @returns the class name
  108858. */
  108859. getClassName(): string;
  108860. /**
  108861. * Get the friendly name associated with the input class.
  108862. * @returns the input friendly name
  108863. */
  108864. getSimpleName(): string;
  108865. }
  108866. }
  108867. declare module BABYLON {
  108868. /**
  108869. * Manage the gamepad inputs to control a free camera.
  108870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108871. */
  108872. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  108873. /**
  108874. * Define the camera the input is attached to.
  108875. */
  108876. camera: FreeCamera;
  108877. /**
  108878. * Define the Gamepad controlling the input
  108879. */
  108880. gamepad: Nullable<Gamepad>;
  108881. /**
  108882. * Defines the gamepad rotation sensiblity.
  108883. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108884. */
  108885. gamepadAngularSensibility: number;
  108886. /**
  108887. * Defines the gamepad move sensiblity.
  108888. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108889. */
  108890. gamepadMoveSensibility: number;
  108891. private _yAxisScale;
  108892. /**
  108893. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  108894. */
  108895. invertYAxis: boolean;
  108896. private _onGamepadConnectedObserver;
  108897. private _onGamepadDisconnectedObserver;
  108898. private _cameraTransform;
  108899. private _deltaTransform;
  108900. private _vector3;
  108901. private _vector2;
  108902. /**
  108903. * Attach the input controls to a specific dom element to get the input from.
  108904. * @param element Defines the element the controls should be listened from
  108905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108906. */
  108907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108908. /**
  108909. * Detach the current controls from the specified dom element.
  108910. * @param element Defines the element to stop listening the inputs from
  108911. */
  108912. detachControl(element: Nullable<HTMLElement>): void;
  108913. /**
  108914. * Update the current camera state depending on the inputs that have been used this frame.
  108915. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108916. */
  108917. checkInputs(): void;
  108918. /**
  108919. * Gets the class name of the current intput.
  108920. * @returns the class name
  108921. */
  108922. getClassName(): string;
  108923. /**
  108924. * Get the friendly name associated with the input class.
  108925. * @returns the input friendly name
  108926. */
  108927. getSimpleName(): string;
  108928. }
  108929. }
  108930. declare module BABYLON {
  108931. /**
  108932. * Defines the potential axis of a Joystick
  108933. */
  108934. export enum JoystickAxis {
  108935. /** X axis */
  108936. X = 0,
  108937. /** Y axis */
  108938. Y = 1,
  108939. /** Z axis */
  108940. Z = 2
  108941. }
  108942. /**
  108943. * Class used to define virtual joystick (used in touch mode)
  108944. */
  108945. export class VirtualJoystick {
  108946. /**
  108947. * Gets or sets a boolean indicating that left and right values must be inverted
  108948. */
  108949. reverseLeftRight: boolean;
  108950. /**
  108951. * Gets or sets a boolean indicating that up and down values must be inverted
  108952. */
  108953. reverseUpDown: boolean;
  108954. /**
  108955. * Gets the offset value for the position (ie. the change of the position value)
  108956. */
  108957. deltaPosition: Vector3;
  108958. /**
  108959. * Gets a boolean indicating if the virtual joystick was pressed
  108960. */
  108961. pressed: boolean;
  108962. /**
  108963. * Canvas the virtual joystick will render onto, default z-index of this is 5
  108964. */
  108965. static Canvas: Nullable<HTMLCanvasElement>;
  108966. private static _globalJoystickIndex;
  108967. private static vjCanvasContext;
  108968. private static vjCanvasWidth;
  108969. private static vjCanvasHeight;
  108970. private static halfWidth;
  108971. private _action;
  108972. private _axisTargetedByLeftAndRight;
  108973. private _axisTargetedByUpAndDown;
  108974. private _joystickSensibility;
  108975. private _inversedSensibility;
  108976. private _joystickPointerID;
  108977. private _joystickColor;
  108978. private _joystickPointerPos;
  108979. private _joystickPreviousPointerPos;
  108980. private _joystickPointerStartPos;
  108981. private _deltaJoystickVector;
  108982. private _leftJoystick;
  108983. private _touches;
  108984. private _onPointerDownHandlerRef;
  108985. private _onPointerMoveHandlerRef;
  108986. private _onPointerUpHandlerRef;
  108987. private _onResize;
  108988. /**
  108989. * Creates a new virtual joystick
  108990. * @param leftJoystick defines that the joystick is for left hand (false by default)
  108991. */
  108992. constructor(leftJoystick?: boolean);
  108993. /**
  108994. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  108995. * @param newJoystickSensibility defines the new sensibility
  108996. */
  108997. setJoystickSensibility(newJoystickSensibility: number): void;
  108998. private _onPointerDown;
  108999. private _onPointerMove;
  109000. private _onPointerUp;
  109001. /**
  109002. * Change the color of the virtual joystick
  109003. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  109004. */
  109005. setJoystickColor(newColor: string): void;
  109006. /**
  109007. * Defines a callback to call when the joystick is touched
  109008. * @param action defines the callback
  109009. */
  109010. setActionOnTouch(action: () => any): void;
  109011. /**
  109012. * Defines which axis you'd like to control for left & right
  109013. * @param axis defines the axis to use
  109014. */
  109015. setAxisForLeftRight(axis: JoystickAxis): void;
  109016. /**
  109017. * Defines which axis you'd like to control for up & down
  109018. * @param axis defines the axis to use
  109019. */
  109020. setAxisForUpDown(axis: JoystickAxis): void;
  109021. private _drawVirtualJoystick;
  109022. /**
  109023. * Release internal HTML canvas
  109024. */
  109025. releaseCanvas(): void;
  109026. }
  109027. }
  109028. declare module BABYLON {
  109029. interface FreeCameraInputsManager {
  109030. /**
  109031. * Add virtual joystick input support to the input manager.
  109032. * @returns the current input manager
  109033. */
  109034. addVirtualJoystick(): FreeCameraInputsManager;
  109035. }
  109036. /**
  109037. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  109038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109039. */
  109040. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  109041. /**
  109042. * Defines the camera the input is attached to.
  109043. */
  109044. camera: FreeCamera;
  109045. private _leftjoystick;
  109046. private _rightjoystick;
  109047. /**
  109048. * Gets the left stick of the virtual joystick.
  109049. * @returns The virtual Joystick
  109050. */
  109051. getLeftJoystick(): VirtualJoystick;
  109052. /**
  109053. * Gets the right stick of the virtual joystick.
  109054. * @returns The virtual Joystick
  109055. */
  109056. getRightJoystick(): VirtualJoystick;
  109057. /**
  109058. * Update the current camera state depending on the inputs that have been used this frame.
  109059. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109060. */
  109061. checkInputs(): void;
  109062. /**
  109063. * Attach the input controls to a specific dom element to get the input from.
  109064. * @param element Defines the element the controls should be listened from
  109065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109066. */
  109067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109068. /**
  109069. * Detach the current controls from the specified dom element.
  109070. * @param element Defines the element to stop listening the inputs from
  109071. */
  109072. detachControl(element: Nullable<HTMLElement>): void;
  109073. /**
  109074. * Gets the class name of the current intput.
  109075. * @returns the class name
  109076. */
  109077. getClassName(): string;
  109078. /**
  109079. * Get the friendly name associated with the input class.
  109080. * @returns the input friendly name
  109081. */
  109082. getSimpleName(): string;
  109083. }
  109084. }
  109085. declare module BABYLON {
  109086. /**
  109087. * This represents a FPS type of camera controlled by touch.
  109088. * This is like a universal camera minus the Gamepad controls.
  109089. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109090. */
  109091. export class TouchCamera extends FreeCamera {
  109092. /**
  109093. * Defines the touch sensibility for rotation.
  109094. * The higher the faster.
  109095. */
  109096. touchAngularSensibility: number;
  109097. /**
  109098. * Defines the touch sensibility for move.
  109099. * The higher the faster.
  109100. */
  109101. touchMoveSensibility: number;
  109102. /**
  109103. * Instantiates a new touch camera.
  109104. * This represents a FPS type of camera controlled by touch.
  109105. * This is like a universal camera minus the Gamepad controls.
  109106. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109107. * @param name Define the name of the camera in the scene
  109108. * @param position Define the start position of the camera in the scene
  109109. * @param scene Define the scene the camera belongs to
  109110. */
  109111. constructor(name: string, position: Vector3, scene: Scene);
  109112. /**
  109113. * Gets the current object class name.
  109114. * @return the class name
  109115. */
  109116. getClassName(): string;
  109117. /** @hidden */
  109118. _setupInputs(): void;
  109119. }
  109120. }
  109121. declare module BABYLON {
  109122. /**
  109123. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  109124. * being tilted forward or back and left or right.
  109125. */
  109126. export class DeviceOrientationCamera extends FreeCamera {
  109127. private _initialQuaternion;
  109128. private _quaternionCache;
  109129. private _tmpDragQuaternion;
  109130. private _disablePointerInputWhenUsingDeviceOrientation;
  109131. /**
  109132. * Creates a new device orientation camera
  109133. * @param name The name of the camera
  109134. * @param position The start position camera
  109135. * @param scene The scene the camera belongs to
  109136. */
  109137. constructor(name: string, position: Vector3, scene: Scene);
  109138. /**
  109139. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  109140. */
  109141. disablePointerInputWhenUsingDeviceOrientation: boolean;
  109142. private _dragFactor;
  109143. /**
  109144. * Enabled turning on the y axis when the orientation sensor is active
  109145. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  109146. */
  109147. enableHorizontalDragging(dragFactor?: number): void;
  109148. /**
  109149. * Gets the current instance class name ("DeviceOrientationCamera").
  109150. * This helps avoiding instanceof at run time.
  109151. * @returns the class name
  109152. */
  109153. getClassName(): string;
  109154. /**
  109155. * @hidden
  109156. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  109157. */
  109158. _checkInputs(): void;
  109159. /**
  109160. * Reset the camera to its default orientation on the specified axis only.
  109161. * @param axis The axis to reset
  109162. */
  109163. resetToCurrentRotation(axis?: Axis): void;
  109164. }
  109165. }
  109166. declare module BABYLON {
  109167. /**
  109168. * Defines supported buttons for XBox360 compatible gamepads
  109169. */
  109170. export enum Xbox360Button {
  109171. /** A */
  109172. A = 0,
  109173. /** B */
  109174. B = 1,
  109175. /** X */
  109176. X = 2,
  109177. /** Y */
  109178. Y = 3,
  109179. /** Start */
  109180. Start = 4,
  109181. /** Back */
  109182. Back = 5,
  109183. /** Left button */
  109184. LB = 6,
  109185. /** Right button */
  109186. RB = 7,
  109187. /** Left stick */
  109188. LeftStick = 8,
  109189. /** Right stick */
  109190. RightStick = 9
  109191. }
  109192. /** Defines values for XBox360 DPad */
  109193. export enum Xbox360Dpad {
  109194. /** Up */
  109195. Up = 0,
  109196. /** Down */
  109197. Down = 1,
  109198. /** Left */
  109199. Left = 2,
  109200. /** Right */
  109201. Right = 3
  109202. }
  109203. /**
  109204. * Defines a XBox360 gamepad
  109205. */
  109206. export class Xbox360Pad extends Gamepad {
  109207. private _leftTrigger;
  109208. private _rightTrigger;
  109209. private _onlefttriggerchanged;
  109210. private _onrighttriggerchanged;
  109211. private _onbuttondown;
  109212. private _onbuttonup;
  109213. private _ondpaddown;
  109214. private _ondpadup;
  109215. /** Observable raised when a button is pressed */
  109216. onButtonDownObservable: Observable<Xbox360Button>;
  109217. /** Observable raised when a button is released */
  109218. onButtonUpObservable: Observable<Xbox360Button>;
  109219. /** Observable raised when a pad is pressed */
  109220. onPadDownObservable: Observable<Xbox360Dpad>;
  109221. /** Observable raised when a pad is released */
  109222. onPadUpObservable: Observable<Xbox360Dpad>;
  109223. private _buttonA;
  109224. private _buttonB;
  109225. private _buttonX;
  109226. private _buttonY;
  109227. private _buttonBack;
  109228. private _buttonStart;
  109229. private _buttonLB;
  109230. private _buttonRB;
  109231. private _buttonLeftStick;
  109232. private _buttonRightStick;
  109233. private _dPadUp;
  109234. private _dPadDown;
  109235. private _dPadLeft;
  109236. private _dPadRight;
  109237. private _isXboxOnePad;
  109238. /**
  109239. * Creates a new XBox360 gamepad object
  109240. * @param id defines the id of this gamepad
  109241. * @param index defines its index
  109242. * @param gamepad defines the internal HTML gamepad object
  109243. * @param xboxOne defines if it is a XBox One gamepad
  109244. */
  109245. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  109246. /**
  109247. * Defines the callback to call when left trigger is pressed
  109248. * @param callback defines the callback to use
  109249. */
  109250. onlefttriggerchanged(callback: (value: number) => void): void;
  109251. /**
  109252. * Defines the callback to call when right trigger is pressed
  109253. * @param callback defines the callback to use
  109254. */
  109255. onrighttriggerchanged(callback: (value: number) => void): void;
  109256. /**
  109257. * Gets the left trigger value
  109258. */
  109259. /**
  109260. * Sets the left trigger value
  109261. */
  109262. leftTrigger: number;
  109263. /**
  109264. * Gets the right trigger value
  109265. */
  109266. /**
  109267. * Sets the right trigger value
  109268. */
  109269. rightTrigger: number;
  109270. /**
  109271. * Defines the callback to call when a button is pressed
  109272. * @param callback defines the callback to use
  109273. */
  109274. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  109275. /**
  109276. * Defines the callback to call when a button is released
  109277. * @param callback defines the callback to use
  109278. */
  109279. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  109280. /**
  109281. * Defines the callback to call when a pad is pressed
  109282. * @param callback defines the callback to use
  109283. */
  109284. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  109285. /**
  109286. * Defines the callback to call when a pad is released
  109287. * @param callback defines the callback to use
  109288. */
  109289. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  109290. private _setButtonValue;
  109291. private _setDPadValue;
  109292. /**
  109293. * Gets the value of the `A` button
  109294. */
  109295. /**
  109296. * Sets the value of the `A` button
  109297. */
  109298. buttonA: number;
  109299. /**
  109300. * Gets the value of the `B` button
  109301. */
  109302. /**
  109303. * Sets the value of the `B` button
  109304. */
  109305. buttonB: number;
  109306. /**
  109307. * Gets the value of the `X` button
  109308. */
  109309. /**
  109310. * Sets the value of the `X` button
  109311. */
  109312. buttonX: number;
  109313. /**
  109314. * Gets the value of the `Y` button
  109315. */
  109316. /**
  109317. * Sets the value of the `Y` button
  109318. */
  109319. buttonY: number;
  109320. /**
  109321. * Gets the value of the `Start` button
  109322. */
  109323. /**
  109324. * Sets the value of the `Start` button
  109325. */
  109326. buttonStart: number;
  109327. /**
  109328. * Gets the value of the `Back` button
  109329. */
  109330. /**
  109331. * Sets the value of the `Back` button
  109332. */
  109333. buttonBack: number;
  109334. /**
  109335. * Gets the value of the `Left` button
  109336. */
  109337. /**
  109338. * Sets the value of the `Left` button
  109339. */
  109340. buttonLB: number;
  109341. /**
  109342. * Gets the value of the `Right` button
  109343. */
  109344. /**
  109345. * Sets the value of the `Right` button
  109346. */
  109347. buttonRB: number;
  109348. /**
  109349. * Gets the value of the Left joystick
  109350. */
  109351. /**
  109352. * Sets the value of the Left joystick
  109353. */
  109354. buttonLeftStick: number;
  109355. /**
  109356. * Gets the value of the Right joystick
  109357. */
  109358. /**
  109359. * Sets the value of the Right joystick
  109360. */
  109361. buttonRightStick: number;
  109362. /**
  109363. * Gets the value of D-pad up
  109364. */
  109365. /**
  109366. * Sets the value of D-pad up
  109367. */
  109368. dPadUp: number;
  109369. /**
  109370. * Gets the value of D-pad down
  109371. */
  109372. /**
  109373. * Sets the value of D-pad down
  109374. */
  109375. dPadDown: number;
  109376. /**
  109377. * Gets the value of D-pad left
  109378. */
  109379. /**
  109380. * Sets the value of D-pad left
  109381. */
  109382. dPadLeft: number;
  109383. /**
  109384. * Gets the value of D-pad right
  109385. */
  109386. /**
  109387. * Sets the value of D-pad right
  109388. */
  109389. dPadRight: number;
  109390. /**
  109391. * Force the gamepad to synchronize with device values
  109392. */
  109393. update(): void;
  109394. /**
  109395. * Disposes the gamepad
  109396. */
  109397. dispose(): void;
  109398. }
  109399. }
  109400. declare module BABYLON {
  109401. /**
  109402. * Defines supported buttons for DualShock compatible gamepads
  109403. */
  109404. export enum DualShockButton {
  109405. /** Cross */
  109406. Cross = 0,
  109407. /** Circle */
  109408. Circle = 1,
  109409. /** Square */
  109410. Square = 2,
  109411. /** Triangle */
  109412. Triangle = 3,
  109413. /** Options */
  109414. Options = 4,
  109415. /** Share */
  109416. Share = 5,
  109417. /** L1 */
  109418. L1 = 6,
  109419. /** R1 */
  109420. R1 = 7,
  109421. /** Left stick */
  109422. LeftStick = 8,
  109423. /** Right stick */
  109424. RightStick = 9
  109425. }
  109426. /** Defines values for DualShock DPad */
  109427. export enum DualShockDpad {
  109428. /** Up */
  109429. Up = 0,
  109430. /** Down */
  109431. Down = 1,
  109432. /** Left */
  109433. Left = 2,
  109434. /** Right */
  109435. Right = 3
  109436. }
  109437. /**
  109438. * Defines a DualShock gamepad
  109439. */
  109440. export class DualShockPad extends Gamepad {
  109441. private _leftTrigger;
  109442. private _rightTrigger;
  109443. private _onlefttriggerchanged;
  109444. private _onrighttriggerchanged;
  109445. private _onbuttondown;
  109446. private _onbuttonup;
  109447. private _ondpaddown;
  109448. private _ondpadup;
  109449. /** Observable raised when a button is pressed */
  109450. onButtonDownObservable: Observable<DualShockButton>;
  109451. /** Observable raised when a button is released */
  109452. onButtonUpObservable: Observable<DualShockButton>;
  109453. /** Observable raised when a pad is pressed */
  109454. onPadDownObservable: Observable<DualShockDpad>;
  109455. /** Observable raised when a pad is released */
  109456. onPadUpObservable: Observable<DualShockDpad>;
  109457. private _buttonCross;
  109458. private _buttonCircle;
  109459. private _buttonSquare;
  109460. private _buttonTriangle;
  109461. private _buttonShare;
  109462. private _buttonOptions;
  109463. private _buttonL1;
  109464. private _buttonR1;
  109465. private _buttonLeftStick;
  109466. private _buttonRightStick;
  109467. private _dPadUp;
  109468. private _dPadDown;
  109469. private _dPadLeft;
  109470. private _dPadRight;
  109471. /**
  109472. * Creates a new DualShock gamepad object
  109473. * @param id defines the id of this gamepad
  109474. * @param index defines its index
  109475. * @param gamepad defines the internal HTML gamepad object
  109476. */
  109477. constructor(id: string, index: number, gamepad: any);
  109478. /**
  109479. * Defines the callback to call when left trigger is pressed
  109480. * @param callback defines the callback to use
  109481. */
  109482. onlefttriggerchanged(callback: (value: number) => void): void;
  109483. /**
  109484. * Defines the callback to call when right trigger is pressed
  109485. * @param callback defines the callback to use
  109486. */
  109487. onrighttriggerchanged(callback: (value: number) => void): void;
  109488. /**
  109489. * Gets the left trigger value
  109490. */
  109491. /**
  109492. * Sets the left trigger value
  109493. */
  109494. leftTrigger: number;
  109495. /**
  109496. * Gets the right trigger value
  109497. */
  109498. /**
  109499. * Sets the right trigger value
  109500. */
  109501. rightTrigger: number;
  109502. /**
  109503. * Defines the callback to call when a button is pressed
  109504. * @param callback defines the callback to use
  109505. */
  109506. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  109507. /**
  109508. * Defines the callback to call when a button is released
  109509. * @param callback defines the callback to use
  109510. */
  109511. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  109512. /**
  109513. * Defines the callback to call when a pad is pressed
  109514. * @param callback defines the callback to use
  109515. */
  109516. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  109517. /**
  109518. * Defines the callback to call when a pad is released
  109519. * @param callback defines the callback to use
  109520. */
  109521. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  109522. private _setButtonValue;
  109523. private _setDPadValue;
  109524. /**
  109525. * Gets the value of the `Cross` button
  109526. */
  109527. /**
  109528. * Sets the value of the `Cross` button
  109529. */
  109530. buttonCross: number;
  109531. /**
  109532. * Gets the value of the `Circle` button
  109533. */
  109534. /**
  109535. * Sets the value of the `Circle` button
  109536. */
  109537. buttonCircle: number;
  109538. /**
  109539. * Gets the value of the `Square` button
  109540. */
  109541. /**
  109542. * Sets the value of the `Square` button
  109543. */
  109544. buttonSquare: number;
  109545. /**
  109546. * Gets the value of the `Triangle` button
  109547. */
  109548. /**
  109549. * Sets the value of the `Triangle` button
  109550. */
  109551. buttonTriangle: number;
  109552. /**
  109553. * Gets the value of the `Options` button
  109554. */
  109555. /**
  109556. * Sets the value of the `Options` button
  109557. */
  109558. buttonOptions: number;
  109559. /**
  109560. * Gets the value of the `Share` button
  109561. */
  109562. /**
  109563. * Sets the value of the `Share` button
  109564. */
  109565. buttonShare: number;
  109566. /**
  109567. * Gets the value of the `L1` button
  109568. */
  109569. /**
  109570. * Sets the value of the `L1` button
  109571. */
  109572. buttonL1: number;
  109573. /**
  109574. * Gets the value of the `R1` button
  109575. */
  109576. /**
  109577. * Sets the value of the `R1` button
  109578. */
  109579. buttonR1: number;
  109580. /**
  109581. * Gets the value of the Left joystick
  109582. */
  109583. /**
  109584. * Sets the value of the Left joystick
  109585. */
  109586. buttonLeftStick: number;
  109587. /**
  109588. * Gets the value of the Right joystick
  109589. */
  109590. /**
  109591. * Sets the value of the Right joystick
  109592. */
  109593. buttonRightStick: number;
  109594. /**
  109595. * Gets the value of D-pad up
  109596. */
  109597. /**
  109598. * Sets the value of D-pad up
  109599. */
  109600. dPadUp: number;
  109601. /**
  109602. * Gets the value of D-pad down
  109603. */
  109604. /**
  109605. * Sets the value of D-pad down
  109606. */
  109607. dPadDown: number;
  109608. /**
  109609. * Gets the value of D-pad left
  109610. */
  109611. /**
  109612. * Sets the value of D-pad left
  109613. */
  109614. dPadLeft: number;
  109615. /**
  109616. * Gets the value of D-pad right
  109617. */
  109618. /**
  109619. * Sets the value of D-pad right
  109620. */
  109621. dPadRight: number;
  109622. /**
  109623. * Force the gamepad to synchronize with device values
  109624. */
  109625. update(): void;
  109626. /**
  109627. * Disposes the gamepad
  109628. */
  109629. dispose(): void;
  109630. }
  109631. }
  109632. declare module BABYLON {
  109633. /**
  109634. * Manager for handling gamepads
  109635. */
  109636. export class GamepadManager {
  109637. private _scene?;
  109638. private _babylonGamepads;
  109639. private _oneGamepadConnected;
  109640. /** @hidden */
  109641. _isMonitoring: boolean;
  109642. private _gamepadEventSupported;
  109643. private _gamepadSupport;
  109644. /**
  109645. * observable to be triggered when the gamepad controller has been connected
  109646. */
  109647. onGamepadConnectedObservable: Observable<Gamepad>;
  109648. /**
  109649. * observable to be triggered when the gamepad controller has been disconnected
  109650. */
  109651. onGamepadDisconnectedObservable: Observable<Gamepad>;
  109652. private _onGamepadConnectedEvent;
  109653. private _onGamepadDisconnectedEvent;
  109654. /**
  109655. * Initializes the gamepad manager
  109656. * @param _scene BabylonJS scene
  109657. */
  109658. constructor(_scene?: Scene | undefined);
  109659. /**
  109660. * The gamepads in the game pad manager
  109661. */
  109662. readonly gamepads: Gamepad[];
  109663. /**
  109664. * Get the gamepad controllers based on type
  109665. * @param type The type of gamepad controller
  109666. * @returns Nullable gamepad
  109667. */
  109668. getGamepadByType(type?: number): Nullable<Gamepad>;
  109669. /**
  109670. * Disposes the gamepad manager
  109671. */
  109672. dispose(): void;
  109673. private _addNewGamepad;
  109674. private _startMonitoringGamepads;
  109675. private _stopMonitoringGamepads;
  109676. /** @hidden */
  109677. _checkGamepadsStatus(): void;
  109678. private _updateGamepadObjects;
  109679. }
  109680. }
  109681. declare module BABYLON {
  109682. interface Scene {
  109683. /** @hidden */
  109684. _gamepadManager: Nullable<GamepadManager>;
  109685. /**
  109686. * Gets the gamepad manager associated with the scene
  109687. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  109688. */
  109689. gamepadManager: GamepadManager;
  109690. }
  109691. /**
  109692. * Interface representing a free camera inputs manager
  109693. */
  109694. interface FreeCameraInputsManager {
  109695. /**
  109696. * Adds gamepad input support to the FreeCameraInputsManager.
  109697. * @returns the FreeCameraInputsManager
  109698. */
  109699. addGamepad(): FreeCameraInputsManager;
  109700. }
  109701. /**
  109702. * Interface representing an arc rotate camera inputs manager
  109703. */
  109704. interface ArcRotateCameraInputsManager {
  109705. /**
  109706. * Adds gamepad input support to the ArcRotateCamera InputManager.
  109707. * @returns the camera inputs manager
  109708. */
  109709. addGamepad(): ArcRotateCameraInputsManager;
  109710. }
  109711. /**
  109712. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  109713. */
  109714. export class GamepadSystemSceneComponent implements ISceneComponent {
  109715. /**
  109716. * The component name helpfull to identify the component in the list of scene components.
  109717. */
  109718. readonly name: string;
  109719. /**
  109720. * The scene the component belongs to.
  109721. */
  109722. scene: Scene;
  109723. /**
  109724. * Creates a new instance of the component for the given scene
  109725. * @param scene Defines the scene to register the component in
  109726. */
  109727. constructor(scene: Scene);
  109728. /**
  109729. * Registers the component in a given scene
  109730. */
  109731. register(): void;
  109732. /**
  109733. * Rebuilds the elements related to this component in case of
  109734. * context lost for instance.
  109735. */
  109736. rebuild(): void;
  109737. /**
  109738. * Disposes the component and the associated ressources
  109739. */
  109740. dispose(): void;
  109741. private _beforeCameraUpdate;
  109742. }
  109743. }
  109744. declare module BABYLON {
  109745. /**
  109746. * 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,
  109747. * which still works and will still be found in many Playgrounds.
  109748. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109749. */
  109750. export class UniversalCamera extends TouchCamera {
  109751. /**
  109752. * Defines the gamepad rotation sensiblity.
  109753. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109754. */
  109755. gamepadAngularSensibility: number;
  109756. /**
  109757. * Defines the gamepad move sensiblity.
  109758. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109759. */
  109760. gamepadMoveSensibility: number;
  109761. /**
  109762. * 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,
  109763. * which still works and will still be found in many Playgrounds.
  109764. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109765. * @param name Define the name of the camera in the scene
  109766. * @param position Define the start position of the camera in the scene
  109767. * @param scene Define the scene the camera belongs to
  109768. */
  109769. constructor(name: string, position: Vector3, scene: Scene);
  109770. /**
  109771. * Gets the current object class name.
  109772. * @return the class name
  109773. */
  109774. getClassName(): string;
  109775. }
  109776. }
  109777. declare module BABYLON {
  109778. /**
  109779. * This represents a FPS type of camera. This is only here for back compat purpose.
  109780. * Please use the UniversalCamera instead as both are identical.
  109781. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109782. */
  109783. export class GamepadCamera extends UniversalCamera {
  109784. /**
  109785. * Instantiates a new Gamepad Camera
  109786. * This represents a FPS type of camera. This is only here for back compat purpose.
  109787. * Please use the UniversalCamera instead as both are identical.
  109788. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109789. * @param name Define the name of the camera in the scene
  109790. * @param position Define the start position of the camera in the scene
  109791. * @param scene Define the scene the camera belongs to
  109792. */
  109793. constructor(name: string, position: Vector3, scene: Scene);
  109794. /**
  109795. * Gets the current object class name.
  109796. * @return the class name
  109797. */
  109798. getClassName(): string;
  109799. }
  109800. }
  109801. declare module BABYLON {
  109802. /** @hidden */
  109803. export var passPixelShader: {
  109804. name: string;
  109805. shader: string;
  109806. };
  109807. }
  109808. declare module BABYLON {
  109809. /** @hidden */
  109810. export var passCubePixelShader: {
  109811. name: string;
  109812. shader: string;
  109813. };
  109814. }
  109815. declare module BABYLON {
  109816. /**
  109817. * PassPostProcess which produces an output the same as it's input
  109818. */
  109819. export class PassPostProcess extends PostProcess {
  109820. /**
  109821. * Creates the PassPostProcess
  109822. * @param name The name of the effect.
  109823. * @param options The required width/height ratio to downsize to before computing the render pass.
  109824. * @param camera The camera to apply the render pass to.
  109825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109826. * @param engine The engine which the post process will be applied. (default: current engine)
  109827. * @param reusable If the post process can be reused on the same frame. (default: false)
  109828. * @param textureType The type of texture to be used when performing the post processing.
  109829. * @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)
  109830. */
  109831. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109832. }
  109833. /**
  109834. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  109835. */
  109836. export class PassCubePostProcess extends PostProcess {
  109837. private _face;
  109838. /**
  109839. * Gets or sets the cube face to display.
  109840. * * 0 is +X
  109841. * * 1 is -X
  109842. * * 2 is +Y
  109843. * * 3 is -Y
  109844. * * 4 is +Z
  109845. * * 5 is -Z
  109846. */
  109847. face: number;
  109848. /**
  109849. * Creates the PassCubePostProcess
  109850. * @param name The name of the effect.
  109851. * @param options The required width/height ratio to downsize to before computing the render pass.
  109852. * @param camera The camera to apply the render pass to.
  109853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109854. * @param engine The engine which the post process will be applied. (default: current engine)
  109855. * @param reusable If the post process can be reused on the same frame. (default: false)
  109856. * @param textureType The type of texture to be used when performing the post processing.
  109857. * @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)
  109858. */
  109859. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109860. }
  109861. }
  109862. declare module BABYLON {
  109863. /** @hidden */
  109864. export var anaglyphPixelShader: {
  109865. name: string;
  109866. shader: string;
  109867. };
  109868. }
  109869. declare module BABYLON {
  109870. /**
  109871. * Postprocess used to generate anaglyphic rendering
  109872. */
  109873. export class AnaglyphPostProcess extends PostProcess {
  109874. private _passedProcess;
  109875. /**
  109876. * Creates a new AnaglyphPostProcess
  109877. * @param name defines postprocess name
  109878. * @param options defines creation options or target ratio scale
  109879. * @param rigCameras defines cameras using this postprocess
  109880. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  109881. * @param engine defines hosting engine
  109882. * @param reusable defines if the postprocess will be reused multiple times per frame
  109883. */
  109884. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  109885. }
  109886. }
  109887. declare module BABYLON {
  109888. /**
  109889. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  109890. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109891. */
  109892. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  109893. /**
  109894. * Creates a new AnaglyphArcRotateCamera
  109895. * @param name defines camera name
  109896. * @param alpha defines alpha angle (in radians)
  109897. * @param beta defines beta angle (in radians)
  109898. * @param radius defines radius
  109899. * @param target defines camera target
  109900. * @param interaxialDistance defines distance between each color axis
  109901. * @param scene defines the hosting scene
  109902. */
  109903. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  109904. /**
  109905. * Gets camera class name
  109906. * @returns AnaglyphArcRotateCamera
  109907. */
  109908. getClassName(): string;
  109909. }
  109910. }
  109911. declare module BABYLON {
  109912. /**
  109913. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  109914. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109915. */
  109916. export class AnaglyphFreeCamera extends FreeCamera {
  109917. /**
  109918. * Creates a new AnaglyphFreeCamera
  109919. * @param name defines camera name
  109920. * @param position defines initial position
  109921. * @param interaxialDistance defines distance between each color axis
  109922. * @param scene defines the hosting scene
  109923. */
  109924. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109925. /**
  109926. * Gets camera class name
  109927. * @returns AnaglyphFreeCamera
  109928. */
  109929. getClassName(): string;
  109930. }
  109931. }
  109932. declare module BABYLON {
  109933. /**
  109934. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  109935. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109936. */
  109937. export class AnaglyphGamepadCamera extends GamepadCamera {
  109938. /**
  109939. * Creates a new AnaglyphGamepadCamera
  109940. * @param name defines camera name
  109941. * @param position defines initial position
  109942. * @param interaxialDistance defines distance between each color axis
  109943. * @param scene defines the hosting scene
  109944. */
  109945. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109946. /**
  109947. * Gets camera class name
  109948. * @returns AnaglyphGamepadCamera
  109949. */
  109950. getClassName(): string;
  109951. }
  109952. }
  109953. declare module BABYLON {
  109954. /**
  109955. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  109956. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109957. */
  109958. export class AnaglyphUniversalCamera extends UniversalCamera {
  109959. /**
  109960. * Creates a new AnaglyphUniversalCamera
  109961. * @param name defines camera name
  109962. * @param position defines initial position
  109963. * @param interaxialDistance defines distance between each color axis
  109964. * @param scene defines the hosting scene
  109965. */
  109966. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109967. /**
  109968. * Gets camera class name
  109969. * @returns AnaglyphUniversalCamera
  109970. */
  109971. getClassName(): string;
  109972. }
  109973. }
  109974. declare module BABYLON {
  109975. /** @hidden */
  109976. export var stereoscopicInterlacePixelShader: {
  109977. name: string;
  109978. shader: string;
  109979. };
  109980. }
  109981. declare module BABYLON {
  109982. /**
  109983. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  109984. */
  109985. export class StereoscopicInterlacePostProcess extends PostProcess {
  109986. private _stepSize;
  109987. private _passedProcess;
  109988. /**
  109989. * Initializes a StereoscopicInterlacePostProcess
  109990. * @param name The name of the effect.
  109991. * @param rigCameras The rig cameras to be appled to the post process
  109992. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  109993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109994. * @param engine The engine which the post process will be applied. (default: current engine)
  109995. * @param reusable If the post process can be reused on the same frame. (default: false)
  109996. */
  109997. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109998. }
  109999. }
  110000. declare module BABYLON {
  110001. /**
  110002. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  110003. * @see http://doc.babylonjs.com/features/cameras
  110004. */
  110005. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  110006. /**
  110007. * Creates a new StereoscopicArcRotateCamera
  110008. * @param name defines camera name
  110009. * @param alpha defines alpha angle (in radians)
  110010. * @param beta defines beta angle (in radians)
  110011. * @param radius defines radius
  110012. * @param target defines camera target
  110013. * @param interaxialDistance defines distance between each color axis
  110014. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110015. * @param scene defines the hosting scene
  110016. */
  110017. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110018. /**
  110019. * Gets camera class name
  110020. * @returns StereoscopicArcRotateCamera
  110021. */
  110022. getClassName(): string;
  110023. }
  110024. }
  110025. declare module BABYLON {
  110026. /**
  110027. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  110028. * @see http://doc.babylonjs.com/features/cameras
  110029. */
  110030. export class StereoscopicFreeCamera extends FreeCamera {
  110031. /**
  110032. * Creates a new StereoscopicFreeCamera
  110033. * @param name defines camera name
  110034. * @param position defines initial position
  110035. * @param interaxialDistance defines distance between each color axis
  110036. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110037. * @param scene defines the hosting scene
  110038. */
  110039. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110040. /**
  110041. * Gets camera class name
  110042. * @returns StereoscopicFreeCamera
  110043. */
  110044. getClassName(): string;
  110045. }
  110046. }
  110047. declare module BABYLON {
  110048. /**
  110049. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  110050. * @see http://doc.babylonjs.com/features/cameras
  110051. */
  110052. export class StereoscopicGamepadCamera extends GamepadCamera {
  110053. /**
  110054. * Creates a new StereoscopicGamepadCamera
  110055. * @param name defines camera name
  110056. * @param position defines initial position
  110057. * @param interaxialDistance defines distance between each color axis
  110058. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110059. * @param scene defines the hosting scene
  110060. */
  110061. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110062. /**
  110063. * Gets camera class name
  110064. * @returns StereoscopicGamepadCamera
  110065. */
  110066. getClassName(): string;
  110067. }
  110068. }
  110069. declare module BABYLON {
  110070. /**
  110071. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  110072. * @see http://doc.babylonjs.com/features/cameras
  110073. */
  110074. export class StereoscopicUniversalCamera extends UniversalCamera {
  110075. /**
  110076. * Creates a new StereoscopicUniversalCamera
  110077. * @param name defines camera name
  110078. * @param position defines initial position
  110079. * @param interaxialDistance defines distance between each color axis
  110080. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110081. * @param scene defines the hosting scene
  110082. */
  110083. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110084. /**
  110085. * Gets camera class name
  110086. * @returns StereoscopicUniversalCamera
  110087. */
  110088. getClassName(): string;
  110089. }
  110090. }
  110091. declare module BABYLON {
  110092. /**
  110093. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  110094. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110095. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110096. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110097. */
  110098. export class VirtualJoysticksCamera extends FreeCamera {
  110099. /**
  110100. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  110101. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110102. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110103. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110104. * @param name Define the name of the camera in the scene
  110105. * @param position Define the start position of the camera in the scene
  110106. * @param scene Define the scene the camera belongs to
  110107. */
  110108. constructor(name: string, position: Vector3, scene: Scene);
  110109. /**
  110110. * Gets the current object class name.
  110111. * @return the class name
  110112. */
  110113. getClassName(): string;
  110114. }
  110115. }
  110116. declare module BABYLON {
  110117. /**
  110118. * This represents all the required metrics to create a VR camera.
  110119. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  110120. */
  110121. export class VRCameraMetrics {
  110122. /**
  110123. * Define the horizontal resolution off the screen.
  110124. */
  110125. hResolution: number;
  110126. /**
  110127. * Define the vertical resolution off the screen.
  110128. */
  110129. vResolution: number;
  110130. /**
  110131. * Define the horizontal screen size.
  110132. */
  110133. hScreenSize: number;
  110134. /**
  110135. * Define the vertical screen size.
  110136. */
  110137. vScreenSize: number;
  110138. /**
  110139. * Define the vertical screen center position.
  110140. */
  110141. vScreenCenter: number;
  110142. /**
  110143. * Define the distance of the eyes to the screen.
  110144. */
  110145. eyeToScreenDistance: number;
  110146. /**
  110147. * Define the distance between both lenses
  110148. */
  110149. lensSeparationDistance: number;
  110150. /**
  110151. * Define the distance between both viewer's eyes.
  110152. */
  110153. interpupillaryDistance: number;
  110154. /**
  110155. * Define the distortion factor of the VR postprocess.
  110156. * Please, touch with care.
  110157. */
  110158. distortionK: number[];
  110159. /**
  110160. * Define the chromatic aberration correction factors for the VR post process.
  110161. */
  110162. chromaAbCorrection: number[];
  110163. /**
  110164. * Define the scale factor of the post process.
  110165. * The smaller the better but the slower.
  110166. */
  110167. postProcessScaleFactor: number;
  110168. /**
  110169. * Define an offset for the lens center.
  110170. */
  110171. lensCenterOffset: number;
  110172. /**
  110173. * Define if the current vr camera should compensate the distortion of the lense or not.
  110174. */
  110175. compensateDistortion: boolean;
  110176. /**
  110177. * Defines if multiview should be enabled when rendering (Default: false)
  110178. */
  110179. multiviewEnabled: boolean;
  110180. /**
  110181. * Gets the rendering aspect ratio based on the provided resolutions.
  110182. */
  110183. readonly aspectRatio: number;
  110184. /**
  110185. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  110186. */
  110187. readonly aspectRatioFov: number;
  110188. /**
  110189. * @hidden
  110190. */
  110191. readonly leftHMatrix: Matrix;
  110192. /**
  110193. * @hidden
  110194. */
  110195. readonly rightHMatrix: Matrix;
  110196. /**
  110197. * @hidden
  110198. */
  110199. readonly leftPreViewMatrix: Matrix;
  110200. /**
  110201. * @hidden
  110202. */
  110203. readonly rightPreViewMatrix: Matrix;
  110204. /**
  110205. * Get the default VRMetrics based on the most generic setup.
  110206. * @returns the default vr metrics
  110207. */
  110208. static GetDefault(): VRCameraMetrics;
  110209. }
  110210. }
  110211. declare module BABYLON {
  110212. /** @hidden */
  110213. export var vrDistortionCorrectionPixelShader: {
  110214. name: string;
  110215. shader: string;
  110216. };
  110217. }
  110218. declare module BABYLON {
  110219. /**
  110220. * VRDistortionCorrectionPostProcess used for mobile VR
  110221. */
  110222. export class VRDistortionCorrectionPostProcess extends PostProcess {
  110223. private _isRightEye;
  110224. private _distortionFactors;
  110225. private _postProcessScaleFactor;
  110226. private _lensCenterOffset;
  110227. private _scaleIn;
  110228. private _scaleFactor;
  110229. private _lensCenter;
  110230. /**
  110231. * Initializes the VRDistortionCorrectionPostProcess
  110232. * @param name The name of the effect.
  110233. * @param camera The camera to apply the render pass to.
  110234. * @param isRightEye If this is for the right eye distortion
  110235. * @param vrMetrics All the required metrics for the VR camera
  110236. */
  110237. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  110238. }
  110239. }
  110240. declare module BABYLON {
  110241. /**
  110242. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  110243. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110244. */
  110245. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  110246. /**
  110247. * Creates a new VRDeviceOrientationArcRotateCamera
  110248. * @param name defines camera name
  110249. * @param alpha defines the camera rotation along the logitudinal axis
  110250. * @param beta defines the camera rotation along the latitudinal axis
  110251. * @param radius defines the camera distance from its target
  110252. * @param target defines the camera target
  110253. * @param scene defines the scene the camera belongs to
  110254. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110255. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110256. */
  110257. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110258. /**
  110259. * Gets camera class name
  110260. * @returns VRDeviceOrientationArcRotateCamera
  110261. */
  110262. getClassName(): string;
  110263. }
  110264. }
  110265. declare module BABYLON {
  110266. /**
  110267. * Camera used to simulate VR rendering (based on FreeCamera)
  110268. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110269. */
  110270. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  110271. /**
  110272. * Creates a new VRDeviceOrientationFreeCamera
  110273. * @param name defines camera name
  110274. * @param position defines the start position of the camera
  110275. * @param scene defines the scene the camera belongs to
  110276. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110277. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110278. */
  110279. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110280. /**
  110281. * Gets camera class name
  110282. * @returns VRDeviceOrientationFreeCamera
  110283. */
  110284. getClassName(): string;
  110285. }
  110286. }
  110287. declare module BABYLON {
  110288. /**
  110289. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  110290. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110291. */
  110292. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  110293. /**
  110294. * Creates a new VRDeviceOrientationGamepadCamera
  110295. * @param name defines camera name
  110296. * @param position defines the start position of the camera
  110297. * @param scene defines the scene the camera belongs to
  110298. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110299. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110300. */
  110301. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110302. /**
  110303. * Gets camera class name
  110304. * @returns VRDeviceOrientationGamepadCamera
  110305. */
  110306. getClassName(): string;
  110307. }
  110308. }
  110309. declare module BABYLON {
  110310. /** @hidden */
  110311. export var imageProcessingPixelShader: {
  110312. name: string;
  110313. shader: string;
  110314. };
  110315. }
  110316. declare module BABYLON {
  110317. /**
  110318. * ImageProcessingPostProcess
  110319. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  110320. */
  110321. export class ImageProcessingPostProcess extends PostProcess {
  110322. /**
  110323. * Default configuration related to image processing available in the PBR Material.
  110324. */
  110325. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110326. /**
  110327. * Gets the image processing configuration used either in this material.
  110328. */
  110329. /**
  110330. * Sets the Default image processing configuration used either in the this material.
  110331. *
  110332. * If sets to null, the scene one is in use.
  110333. */
  110334. imageProcessingConfiguration: ImageProcessingConfiguration;
  110335. /**
  110336. * Keep track of the image processing observer to allow dispose and replace.
  110337. */
  110338. private _imageProcessingObserver;
  110339. /**
  110340. * Attaches a new image processing configuration to the PBR Material.
  110341. * @param configuration
  110342. */
  110343. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  110344. /**
  110345. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110346. */
  110347. /**
  110348. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110349. */
  110350. colorCurves: Nullable<ColorCurves>;
  110351. /**
  110352. * Gets wether the color curves effect is enabled.
  110353. */
  110354. /**
  110355. * Sets wether the color curves effect is enabled.
  110356. */
  110357. colorCurvesEnabled: boolean;
  110358. /**
  110359. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110360. */
  110361. /**
  110362. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110363. */
  110364. colorGradingTexture: Nullable<BaseTexture>;
  110365. /**
  110366. * Gets wether the color grading effect is enabled.
  110367. */
  110368. /**
  110369. * Gets wether the color grading effect is enabled.
  110370. */
  110371. colorGradingEnabled: boolean;
  110372. /**
  110373. * Gets exposure used in the effect.
  110374. */
  110375. /**
  110376. * Sets exposure used in the effect.
  110377. */
  110378. exposure: number;
  110379. /**
  110380. * Gets wether tonemapping is enabled or not.
  110381. */
  110382. /**
  110383. * Sets wether tonemapping is enabled or not
  110384. */
  110385. toneMappingEnabled: boolean;
  110386. /**
  110387. * Gets the type of tone mapping effect.
  110388. */
  110389. /**
  110390. * Sets the type of tone mapping effect.
  110391. */
  110392. toneMappingType: number;
  110393. /**
  110394. * Gets contrast used in the effect.
  110395. */
  110396. /**
  110397. * Sets contrast used in the effect.
  110398. */
  110399. contrast: number;
  110400. /**
  110401. * Gets Vignette stretch size.
  110402. */
  110403. /**
  110404. * Sets Vignette stretch size.
  110405. */
  110406. vignetteStretch: number;
  110407. /**
  110408. * Gets Vignette centre X Offset.
  110409. */
  110410. /**
  110411. * Sets Vignette centre X Offset.
  110412. */
  110413. vignetteCentreX: number;
  110414. /**
  110415. * Gets Vignette centre Y Offset.
  110416. */
  110417. /**
  110418. * Sets Vignette centre Y Offset.
  110419. */
  110420. vignetteCentreY: number;
  110421. /**
  110422. * Gets Vignette weight or intensity of the vignette effect.
  110423. */
  110424. /**
  110425. * Sets Vignette weight or intensity of the vignette effect.
  110426. */
  110427. vignetteWeight: number;
  110428. /**
  110429. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110430. * if vignetteEnabled is set to true.
  110431. */
  110432. /**
  110433. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110434. * if vignetteEnabled is set to true.
  110435. */
  110436. vignetteColor: Color4;
  110437. /**
  110438. * Gets Camera field of view used by the Vignette effect.
  110439. */
  110440. /**
  110441. * Sets Camera field of view used by the Vignette effect.
  110442. */
  110443. vignetteCameraFov: number;
  110444. /**
  110445. * Gets the vignette blend mode allowing different kind of effect.
  110446. */
  110447. /**
  110448. * Sets the vignette blend mode allowing different kind of effect.
  110449. */
  110450. vignetteBlendMode: number;
  110451. /**
  110452. * Gets wether the vignette effect is enabled.
  110453. */
  110454. /**
  110455. * Sets wether the vignette effect is enabled.
  110456. */
  110457. vignetteEnabled: boolean;
  110458. private _fromLinearSpace;
  110459. /**
  110460. * Gets wether the input of the processing is in Gamma or Linear Space.
  110461. */
  110462. /**
  110463. * Sets wether the input of the processing is in Gamma or Linear Space.
  110464. */
  110465. fromLinearSpace: boolean;
  110466. /**
  110467. * Defines cache preventing GC.
  110468. */
  110469. private _defines;
  110470. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  110471. /**
  110472. * "ImageProcessingPostProcess"
  110473. * @returns "ImageProcessingPostProcess"
  110474. */
  110475. getClassName(): string;
  110476. protected _updateParameters(): void;
  110477. dispose(camera?: Camera): void;
  110478. }
  110479. }
  110480. declare module BABYLON {
  110481. /**
  110482. * Class containing static functions to help procedurally build meshes
  110483. */
  110484. export class GroundBuilder {
  110485. /**
  110486. * Creates a ground mesh
  110487. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110488. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110490. * @param name defines the name of the mesh
  110491. * @param options defines the options used to create the mesh
  110492. * @param scene defines the hosting scene
  110493. * @returns the ground mesh
  110494. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110495. */
  110496. static CreateGround(name: string, options: {
  110497. width?: number;
  110498. height?: number;
  110499. subdivisions?: number;
  110500. subdivisionsX?: number;
  110501. subdivisionsY?: number;
  110502. updatable?: boolean;
  110503. }, scene: any): Mesh;
  110504. /**
  110505. * Creates a tiled ground mesh
  110506. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110507. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110508. * * 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
  110509. * * 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
  110510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110511. * @param name defines the name of the mesh
  110512. * @param options defines the options used to create the mesh
  110513. * @param scene defines the hosting scene
  110514. * @returns the tiled ground mesh
  110515. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110516. */
  110517. static CreateTiledGround(name: string, options: {
  110518. xmin: number;
  110519. zmin: number;
  110520. xmax: number;
  110521. zmax: number;
  110522. subdivisions?: {
  110523. w: number;
  110524. h: number;
  110525. };
  110526. precision?: {
  110527. w: number;
  110528. h: number;
  110529. };
  110530. updatable?: boolean;
  110531. }, scene?: Nullable<Scene>): Mesh;
  110532. /**
  110533. * Creates a ground mesh from a height map
  110534. * * The parameter `url` sets the URL of the height map image resource.
  110535. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110536. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110537. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110538. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110539. * * 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.
  110540. * * 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).
  110541. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110543. * @param name defines the name of the mesh
  110544. * @param url defines the url to the height map
  110545. * @param options defines the options used to create the mesh
  110546. * @param scene defines the hosting scene
  110547. * @returns the ground mesh
  110548. * @see https://doc.babylonjs.com/babylon101/height_map
  110549. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110550. */
  110551. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110552. width?: number;
  110553. height?: number;
  110554. subdivisions?: number;
  110555. minHeight?: number;
  110556. maxHeight?: number;
  110557. colorFilter?: Color3;
  110558. alphaFilter?: number;
  110559. updatable?: boolean;
  110560. onReady?: (mesh: GroundMesh) => void;
  110561. }, scene?: Nullable<Scene>): GroundMesh;
  110562. }
  110563. }
  110564. declare module BABYLON {
  110565. /**
  110566. * Class containing static functions to help procedurally build meshes
  110567. */
  110568. export class TorusBuilder {
  110569. /**
  110570. * Creates a torus mesh
  110571. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110572. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110573. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110577. * @param name defines the name of the mesh
  110578. * @param options defines the options used to create the mesh
  110579. * @param scene defines the hosting scene
  110580. * @returns the torus mesh
  110581. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110582. */
  110583. static CreateTorus(name: string, options: {
  110584. diameter?: number;
  110585. thickness?: number;
  110586. tessellation?: number;
  110587. updatable?: boolean;
  110588. sideOrientation?: number;
  110589. frontUVs?: Vector4;
  110590. backUVs?: Vector4;
  110591. }, scene: any): Mesh;
  110592. }
  110593. }
  110594. declare module BABYLON {
  110595. /**
  110596. * Class containing static functions to help procedurally build meshes
  110597. */
  110598. export class CylinderBuilder {
  110599. /**
  110600. * Creates a cylinder or a cone mesh
  110601. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110602. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110603. * * 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.
  110604. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110605. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110606. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110607. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110608. * * 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).
  110609. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110610. * * 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).
  110611. * * 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
  110612. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110613. * * 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
  110614. * * 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.
  110615. * * If `enclose` is false, a ring surface is one element.
  110616. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110617. * * 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
  110618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110621. * @param name defines the name of the mesh
  110622. * @param options defines the options used to create the mesh
  110623. * @param scene defines the hosting scene
  110624. * @returns the cylinder mesh
  110625. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110626. */
  110627. static CreateCylinder(name: string, options: {
  110628. height?: number;
  110629. diameterTop?: number;
  110630. diameterBottom?: number;
  110631. diameter?: number;
  110632. tessellation?: number;
  110633. subdivisions?: number;
  110634. arc?: number;
  110635. faceColors?: Color4[];
  110636. faceUV?: Vector4[];
  110637. updatable?: boolean;
  110638. hasRings?: boolean;
  110639. enclose?: boolean;
  110640. cap?: number;
  110641. sideOrientation?: number;
  110642. frontUVs?: Vector4;
  110643. backUVs?: Vector4;
  110644. }, scene: any): Mesh;
  110645. }
  110646. }
  110647. declare module BABYLON {
  110648. /**
  110649. * States of the webXR experience
  110650. */
  110651. export enum WebXRState {
  110652. /**
  110653. * Transitioning to being in XR mode
  110654. */
  110655. ENTERING_XR = 0,
  110656. /**
  110657. * Transitioning to non XR mode
  110658. */
  110659. EXITING_XR = 1,
  110660. /**
  110661. * In XR mode and presenting
  110662. */
  110663. IN_XR = 2,
  110664. /**
  110665. * Not entered XR mode
  110666. */
  110667. NOT_IN_XR = 3
  110668. }
  110669. /**
  110670. * Abstraction of the XR render target
  110671. */
  110672. export interface WebXRRenderTarget extends IDisposable {
  110673. /**
  110674. * xrpresent context of the canvas which can be used to display/mirror xr content
  110675. */
  110676. canvasContext: WebGLRenderingContext;
  110677. /**
  110678. * xr layer for the canvas
  110679. */
  110680. xrLayer: Nullable<XRWebGLLayer>;
  110681. /**
  110682. * Initializes the xr layer for the session
  110683. * @param xrSession xr session
  110684. * @returns a promise that will resolve once the XR Layer has been created
  110685. */
  110686. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110687. }
  110688. }
  110689. declare module BABYLON {
  110690. /**
  110691. * COnfiguration object for WebXR output canvas
  110692. */
  110693. export class WebXRManagedOutputCanvasOptions {
  110694. /**
  110695. * Options for this XR Layer output
  110696. */
  110697. canvasOptions: XRWebGLLayerOptions;
  110698. /**
  110699. * CSS styling for a newly created canvas (if not provided)
  110700. */
  110701. newCanvasCssStyle?: string;
  110702. /**
  110703. * Get the default values of the configuration object
  110704. * @returns default values of this configuration object
  110705. */
  110706. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  110707. }
  110708. /**
  110709. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110710. */
  110711. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110712. private configuration;
  110713. private _engine;
  110714. private _canvas;
  110715. /**
  110716. * xrpresent context of the canvas which can be used to display/mirror xr content
  110717. */
  110718. canvasContext: WebGLRenderingContext;
  110719. /**
  110720. * xr layer for the canvas
  110721. */
  110722. xrLayer: Nullable<XRWebGLLayer>;
  110723. /**
  110724. * Initializes the xr layer for the session
  110725. * @param xrSession xr session
  110726. * @returns a promise that will resolve once the XR Layer has been created
  110727. */
  110728. initializeXRLayerAsync(xrSession: any): any;
  110729. /**
  110730. * Initializes the canvas to be added/removed upon entering/exiting xr
  110731. * @param engine the Babylon engine
  110732. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110733. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110734. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  110735. */
  110736. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  110737. /**
  110738. * Disposes of the object
  110739. */
  110740. dispose(): void;
  110741. private _setManagedOutputCanvas;
  110742. private _addCanvas;
  110743. private _removeCanvas;
  110744. }
  110745. }
  110746. declare module BABYLON {
  110747. /**
  110748. * Manages an XRSession to work with Babylon's engine
  110749. * @see https://doc.babylonjs.com/how_to/webxr
  110750. */
  110751. export class WebXRSessionManager implements IDisposable {
  110752. private scene;
  110753. /**
  110754. * Fires every time a new xrFrame arrives which can be used to update the camera
  110755. */
  110756. onXRFrameObservable: Observable<any>;
  110757. /**
  110758. * Fires when the xr session is ended either by the device or manually done
  110759. */
  110760. onXRSessionEnded: Observable<any>;
  110761. /**
  110762. * Underlying xr session
  110763. */
  110764. session: XRSession;
  110765. /**
  110766. * Type of reference space used when creating the session
  110767. */
  110768. referenceSpace: XRReferenceSpace;
  110769. /**
  110770. * Current XR frame
  110771. */
  110772. currentFrame: Nullable<XRFrame>;
  110773. private _xrNavigator;
  110774. private baseLayer;
  110775. private _rttProvider;
  110776. private _sessionEnded;
  110777. /**
  110778. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110779. * @param scene The scene which the session should be created for
  110780. */
  110781. constructor(scene: Scene);
  110782. /**
  110783. * Initializes the manager
  110784. * After initialization enterXR can be called to start an XR session
  110785. * @returns Promise which resolves after it is initialized
  110786. */
  110787. initializeAsync(): Promise<void>;
  110788. /**
  110789. * Initializes an xr session
  110790. * @param xrSessionMode mode to initialize
  110791. * @param optionalFeatures defines optional values to pass to the session builder
  110792. * @returns a promise which will resolve once the session has been initialized
  110793. */
  110794. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  110795. /**
  110796. * Sets the reference space on the xr session
  110797. * @param referenceSpace space to set
  110798. * @returns a promise that will resolve once the reference space has been set
  110799. */
  110800. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110801. /**
  110802. * Updates the render state of the session
  110803. * @param state state to set
  110804. * @returns a promise that resolves once the render state has been updated
  110805. */
  110806. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110807. /**
  110808. * Starts rendering to the xr layer
  110809. * @returns a promise that will resolve once rendering has started
  110810. */
  110811. startRenderingToXRAsync(): Promise<void>;
  110812. /**
  110813. * Gets the correct render target texture to be rendered this frame for this eye
  110814. * @param eye the eye for which to get the render target
  110815. * @returns the render target for the specified eye
  110816. */
  110817. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110818. /**
  110819. * Stops the xrSession and restores the renderloop
  110820. * @returns Promise which resolves after it exits XR
  110821. */
  110822. exitXRAsync(): Promise<void>;
  110823. /**
  110824. * Checks if a session would be supported for the creation options specified
  110825. * @param sessionMode session mode to check if supported eg. immersive-vr
  110826. * @returns true if supported
  110827. */
  110828. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110829. /**
  110830. * Creates a WebXRRenderTarget object for the XR session
  110831. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110832. * @param options optional options to provide when creating a new render target
  110833. * @returns a WebXR render target to which the session can render
  110834. */
  110835. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  110836. /**
  110837. * @hidden
  110838. * Converts the render layer of xrSession to a render target
  110839. * @param session session to create render target for
  110840. * @param scene scene the new render target should be created for
  110841. */
  110842. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110843. /**
  110844. * Disposes of the session manager
  110845. */
  110846. dispose(): void;
  110847. /**
  110848. * Gets a promise returning true when fullfiled if the given session mode is supported
  110849. * @param sessionMode defines the session to test
  110850. * @returns a promise
  110851. */
  110852. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110853. }
  110854. }
  110855. declare module BABYLON {
  110856. /**
  110857. * WebXR Camera which holds the views for the xrSession
  110858. * @see https://doc.babylonjs.com/how_to/webxr
  110859. */
  110860. export class WebXRCamera extends FreeCamera {
  110861. /**
  110862. * Is the camera in debug mode. Used when using an emulator
  110863. */
  110864. debugMode: boolean;
  110865. /**
  110866. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110867. * @param name the name of the camera
  110868. * @param scene the scene to add the camera to
  110869. */
  110870. constructor(name: string, scene: Scene);
  110871. private _updateNumberOfRigCameras;
  110872. /** @hidden */
  110873. _updateForDualEyeDebugging(): void;
  110874. /**
  110875. * Updates the cameras position from the current pose information of the XR session
  110876. * @param xrSessionManager the session containing pose information
  110877. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110878. */
  110879. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110880. }
  110881. }
  110882. declare module BABYLON {
  110883. /**
  110884. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110885. * @see https://doc.babylonjs.com/how_to/webxr
  110886. */
  110887. export class WebXRExperienceHelper implements IDisposable {
  110888. private scene;
  110889. /**
  110890. * 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
  110891. */
  110892. container: AbstractMesh;
  110893. /**
  110894. * Camera used to render xr content
  110895. */
  110896. camera: WebXRCamera;
  110897. /**
  110898. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110899. */
  110900. state: WebXRState;
  110901. private _setState;
  110902. private static _TmpVector;
  110903. /**
  110904. * Fires when the state of the experience helper has changed
  110905. */
  110906. onStateChangedObservable: Observable<WebXRState>;
  110907. /** Session manager used to keep track of xr session */
  110908. sessionManager: WebXRSessionManager;
  110909. private _nonVRCamera;
  110910. private _originalSceneAutoClear;
  110911. private _supported;
  110912. /**
  110913. * Creates the experience helper
  110914. * @param scene the scene to attach the experience helper to
  110915. * @returns a promise for the experience helper
  110916. */
  110917. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110918. /**
  110919. * Creates a WebXRExperienceHelper
  110920. * @param scene The scene the helper should be created in
  110921. */
  110922. private constructor();
  110923. /**
  110924. * Exits XR mode and returns the scene to its original state
  110925. * @returns promise that resolves after xr mode has exited
  110926. */
  110927. exitXRAsync(): Promise<void>;
  110928. /**
  110929. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110930. * @param sessionMode options for the XR session
  110931. * @param referenceSpaceType frame of reference of the XR session
  110932. * @param renderTarget the output canvas that will be used to enter XR mode
  110933. * @returns promise that resolves after xr mode has entered
  110934. */
  110935. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  110936. /**
  110937. * Updates the global position of the camera by moving the camera's container
  110938. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110939. * @param position The desired global position of the camera
  110940. */
  110941. setPositionOfCameraUsingContainer(position: Vector3): void;
  110942. /**
  110943. * Rotates the xr camera by rotating the camera's container around the camera's position
  110944. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110945. * @param rotation the desired quaternion rotation to apply to the camera
  110946. */
  110947. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110948. /**
  110949. * Disposes of the experience helper
  110950. */
  110951. dispose(): void;
  110952. }
  110953. }
  110954. declare module BABYLON {
  110955. /**
  110956. * Represents an XR input
  110957. */
  110958. export class WebXRController {
  110959. private scene;
  110960. /** The underlying input source for the controller */
  110961. inputSource: XRInputSource;
  110962. private parentContainer;
  110963. /**
  110964. * 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
  110965. */
  110966. grip?: AbstractMesh;
  110967. /**
  110968. * Pointer which can be used to select objects or attach a visible laser to
  110969. */
  110970. pointer: AbstractMesh;
  110971. private _gamepadMode;
  110972. /**
  110973. * If available, this is the gamepad object related to this controller.
  110974. * Using this object it is possible to get click events and trackpad changes of the
  110975. * webxr controller that is currently being used.
  110976. */
  110977. gamepadController?: WebVRController;
  110978. /**
  110979. * Event that fires when the controller is removed/disposed
  110980. */
  110981. onDisposeObservable: Observable<{}>;
  110982. private _tmpQuaternion;
  110983. private _tmpVector;
  110984. /**
  110985. * Creates the controller
  110986. * @see https://doc.babylonjs.com/how_to/webxr
  110987. * @param scene the scene which the controller should be associated to
  110988. * @param inputSource the underlying input source for the controller
  110989. * @param parentContainer parent that the controller meshes should be children of
  110990. */
  110991. constructor(scene: Scene,
  110992. /** The underlying input source for the controller */
  110993. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110994. /**
  110995. * Updates the controller pose based on the given XRFrame
  110996. * @param xrFrame xr frame to update the pose with
  110997. * @param referenceSpace reference space to use
  110998. */
  110999. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  111000. /**
  111001. * Gets a world space ray coming from the controller
  111002. * @param result the resulting ray
  111003. */
  111004. getWorldPointerRayToRef(result: Ray): void;
  111005. /**
  111006. * Get the scene associated with this controller
  111007. * @returns the scene object
  111008. */
  111009. getScene(): Scene;
  111010. /**
  111011. * Disposes of the object
  111012. */
  111013. dispose(): void;
  111014. }
  111015. }
  111016. declare module BABYLON {
  111017. /**
  111018. * XR input used to track XR inputs such as controllers/rays
  111019. */
  111020. export class WebXRInput implements IDisposable {
  111021. /**
  111022. * Base experience the input listens to
  111023. */
  111024. baseExperience: WebXRExperienceHelper;
  111025. /**
  111026. * XR controllers being tracked
  111027. */
  111028. controllers: Array<WebXRController>;
  111029. private _frameObserver;
  111030. private _stateObserver;
  111031. /**
  111032. * Event when a controller has been connected/added
  111033. */
  111034. onControllerAddedObservable: Observable<WebXRController>;
  111035. /**
  111036. * Event when a controller has been removed/disconnected
  111037. */
  111038. onControllerRemovedObservable: Observable<WebXRController>;
  111039. /**
  111040. * Initializes the WebXRInput
  111041. * @param baseExperience experience helper which the input should be created for
  111042. */
  111043. constructor(
  111044. /**
  111045. * Base experience the input listens to
  111046. */
  111047. baseExperience: WebXRExperienceHelper);
  111048. private _onInputSourcesChange;
  111049. private _addAndRemoveControllers;
  111050. /**
  111051. * Disposes of the object
  111052. */
  111053. dispose(): void;
  111054. }
  111055. }
  111056. declare module BABYLON {
  111057. /**
  111058. * Class used to represent data loading progression
  111059. */
  111060. export class SceneLoaderProgressEvent {
  111061. /** defines if data length to load can be evaluated */
  111062. readonly lengthComputable: boolean;
  111063. /** defines the loaded data length */
  111064. readonly loaded: number;
  111065. /** defines the data length to load */
  111066. readonly total: number;
  111067. /**
  111068. * Create a new progress event
  111069. * @param lengthComputable defines if data length to load can be evaluated
  111070. * @param loaded defines the loaded data length
  111071. * @param total defines the data length to load
  111072. */
  111073. constructor(
  111074. /** defines if data length to load can be evaluated */
  111075. lengthComputable: boolean,
  111076. /** defines the loaded data length */
  111077. loaded: number,
  111078. /** defines the data length to load */
  111079. total: number);
  111080. /**
  111081. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  111082. * @param event defines the source event
  111083. * @returns a new SceneLoaderProgressEvent
  111084. */
  111085. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  111086. }
  111087. /**
  111088. * Interface used by SceneLoader plugins to define supported file extensions
  111089. */
  111090. export interface ISceneLoaderPluginExtensions {
  111091. /**
  111092. * Defines the list of supported extensions
  111093. */
  111094. [extension: string]: {
  111095. isBinary: boolean;
  111096. };
  111097. }
  111098. /**
  111099. * Interface used by SceneLoader plugin factory
  111100. */
  111101. export interface ISceneLoaderPluginFactory {
  111102. /**
  111103. * Defines the name of the factory
  111104. */
  111105. name: string;
  111106. /**
  111107. * Function called to create a new plugin
  111108. * @return the new plugin
  111109. */
  111110. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  111111. /**
  111112. * The callback that returns true if the data can be directly loaded.
  111113. * @param data string containing the file data
  111114. * @returns if the data can be loaded directly
  111115. */
  111116. canDirectLoad?(data: string): boolean;
  111117. }
  111118. /**
  111119. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  111120. */
  111121. export interface ISceneLoaderPluginBase {
  111122. /**
  111123. * The friendly name of this plugin.
  111124. */
  111125. name: string;
  111126. /**
  111127. * The file extensions supported by this plugin.
  111128. */
  111129. extensions: string | ISceneLoaderPluginExtensions;
  111130. /**
  111131. * The callback called when loading from a url.
  111132. * @param scene scene loading this url
  111133. * @param url url to load
  111134. * @param onSuccess callback called when the file successfully loads
  111135. * @param onProgress callback called while file is loading (if the server supports this mode)
  111136. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  111137. * @param onError callback called when the file fails to load
  111138. * @returns a file request object
  111139. */
  111140. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111141. /**
  111142. * The callback called when loading from a file object.
  111143. * @param scene scene loading this file
  111144. * @param file defines the file to load
  111145. * @param onSuccess defines the callback to call when data is loaded
  111146. * @param onProgress defines the callback to call during loading process
  111147. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  111148. * @param onError defines the callback to call when an error occurs
  111149. * @returns a file request object
  111150. */
  111151. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111152. /**
  111153. * The callback that returns true if the data can be directly loaded.
  111154. * @param data string containing the file data
  111155. * @returns if the data can be loaded directly
  111156. */
  111157. canDirectLoad?(data: string): boolean;
  111158. /**
  111159. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  111160. * @param scene scene loading this data
  111161. * @param data string containing the data
  111162. * @returns data to pass to the plugin
  111163. */
  111164. directLoad?(scene: Scene, data: string): any;
  111165. /**
  111166. * The callback that allows custom handling of the root url based on the response url.
  111167. * @param rootUrl the original root url
  111168. * @param responseURL the response url if available
  111169. * @returns the new root url
  111170. */
  111171. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  111172. }
  111173. /**
  111174. * Interface used to define a SceneLoader plugin
  111175. */
  111176. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  111177. /**
  111178. * Import meshes into a scene.
  111179. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111180. * @param scene The scene to import into
  111181. * @param data The data to import
  111182. * @param rootUrl The root url for scene and resources
  111183. * @param meshes The meshes array to import into
  111184. * @param particleSystems The particle systems array to import into
  111185. * @param skeletons The skeletons array to import into
  111186. * @param onError The callback when import fails
  111187. * @returns True if successful or false otherwise
  111188. */
  111189. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  111190. /**
  111191. * Load into a scene.
  111192. * @param scene The scene to load into
  111193. * @param data The data to import
  111194. * @param rootUrl The root url for scene and resources
  111195. * @param onError The callback when import fails
  111196. * @returns True if successful or false otherwise
  111197. */
  111198. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  111199. /**
  111200. * Load into an asset container.
  111201. * @param scene The scene to load into
  111202. * @param data The data to import
  111203. * @param rootUrl The root url for scene and resources
  111204. * @param onError The callback when import fails
  111205. * @returns The loaded asset container
  111206. */
  111207. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  111208. }
  111209. /**
  111210. * Interface used to define an async SceneLoader plugin
  111211. */
  111212. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  111213. /**
  111214. * Import meshes into a scene.
  111215. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111216. * @param scene The scene to import into
  111217. * @param data The data to import
  111218. * @param rootUrl The root url for scene and resources
  111219. * @param onProgress The callback when the load progresses
  111220. * @param fileName Defines the name of the file to load
  111221. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  111222. */
  111223. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  111224. meshes: AbstractMesh[];
  111225. particleSystems: IParticleSystem[];
  111226. skeletons: Skeleton[];
  111227. animationGroups: AnimationGroup[];
  111228. }>;
  111229. /**
  111230. * Load into a scene.
  111231. * @param scene The scene to load into
  111232. * @param data The data to import
  111233. * @param rootUrl The root url for scene and resources
  111234. * @param onProgress The callback when the load progresses
  111235. * @param fileName Defines the name of the file to load
  111236. * @returns Nothing
  111237. */
  111238. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  111239. /**
  111240. * Load into an asset container.
  111241. * @param scene The scene to load into
  111242. * @param data The data to import
  111243. * @param rootUrl The root url for scene and resources
  111244. * @param onProgress The callback when the load progresses
  111245. * @param fileName Defines the name of the file to load
  111246. * @returns The loaded asset container
  111247. */
  111248. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  111249. }
  111250. /**
  111251. * Class used to load scene from various file formats using registered plugins
  111252. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  111253. */
  111254. export class SceneLoader {
  111255. /**
  111256. * No logging while loading
  111257. */
  111258. static readonly NO_LOGGING: number;
  111259. /**
  111260. * Minimal logging while loading
  111261. */
  111262. static readonly MINIMAL_LOGGING: number;
  111263. /**
  111264. * Summary logging while loading
  111265. */
  111266. static readonly SUMMARY_LOGGING: number;
  111267. /**
  111268. * Detailled logging while loading
  111269. */
  111270. static readonly DETAILED_LOGGING: number;
  111271. /**
  111272. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111273. */
  111274. static ForceFullSceneLoadingForIncremental: boolean;
  111275. /**
  111276. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111277. */
  111278. static ShowLoadingScreen: boolean;
  111279. /**
  111280. * Defines the current logging level (while loading the scene)
  111281. * @ignorenaming
  111282. */
  111283. static loggingLevel: number;
  111284. /**
  111285. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111286. */
  111287. static CleanBoneMatrixWeights: boolean;
  111288. /**
  111289. * Event raised when a plugin is used to load a scene
  111290. */
  111291. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  111292. private static _registeredPlugins;
  111293. private static _getDefaultPlugin;
  111294. private static _getPluginForExtension;
  111295. private static _getPluginForDirectLoad;
  111296. private static _getPluginForFilename;
  111297. private static _getDirectLoad;
  111298. private static _loadData;
  111299. private static _getFileInfo;
  111300. /**
  111301. * Gets a plugin that can load the given extension
  111302. * @param extension defines the extension to load
  111303. * @returns a plugin or null if none works
  111304. */
  111305. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  111306. /**
  111307. * Gets a boolean indicating that the given extension can be loaded
  111308. * @param extension defines the extension to load
  111309. * @returns true if the extension is supported
  111310. */
  111311. static IsPluginForExtensionAvailable(extension: string): boolean;
  111312. /**
  111313. * Adds a new plugin to the list of registered plugins
  111314. * @param plugin defines the plugin to add
  111315. */
  111316. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  111317. /**
  111318. * Import meshes into a scene
  111319. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 the instance of BABYLON.Scene to append to
  111323. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons 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 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>;
  111330. /**
  111331. * Import meshes into a scene
  111332. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111333. * @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)
  111334. * @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)
  111335. * @param scene the instance of BABYLON.Scene to append to
  111336. * @param onProgress a callback with a progress event for each file being loaded
  111337. * @param pluginExtension the extension used to determine the plugin
  111338. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  111339. */
  111340. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  111341. meshes: AbstractMesh[];
  111342. particleSystems: IParticleSystem[];
  111343. skeletons: Skeleton[];
  111344. animationGroups: AnimationGroup[];
  111345. }>;
  111346. /**
  111347. * Load a scene
  111348. * @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)
  111349. * @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)
  111350. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111351. * @param onSuccess a callback with the scene when import succeeds
  111352. * @param onProgress a callback with a progress event for each file being loaded
  111353. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111354. * @param pluginExtension the extension used to determine the plugin
  111355. * @returns The loaded plugin
  111356. */
  111357. 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>;
  111358. /**
  111359. * Load a scene
  111360. * @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)
  111361. * @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)
  111362. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111363. * @param onProgress a callback with a progress event for each file being loaded
  111364. * @param pluginExtension the extension used to determine the plugin
  111365. * @returns The loaded scene
  111366. */
  111367. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111368. /**
  111369. * Append a scene
  111370. * @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)
  111371. * @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)
  111372. * @param scene is the instance of BABYLON.Scene to append to
  111373. * @param onSuccess a callback with the scene when import succeeds
  111374. * @param onProgress a callback with a progress event for each file being loaded
  111375. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111376. * @param pluginExtension the extension used to determine the plugin
  111377. * @returns The loaded plugin
  111378. */
  111379. 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>;
  111380. /**
  111381. * Append a scene
  111382. * @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)
  111383. * @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)
  111384. * @param scene is the instance of BABYLON.Scene to append to
  111385. * @param onProgress a callback with a progress event for each file being loaded
  111386. * @param pluginExtension the extension used to determine the plugin
  111387. * @returns The given scene
  111388. */
  111389. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111390. /**
  111391. * Load a scene into an asset container
  111392. * @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)
  111393. * @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)
  111394. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111395. * @param onSuccess a callback with the scene when import succeeds
  111396. * @param onProgress a callback with a progress event for each file being loaded
  111397. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111398. * @param pluginExtension the extension used to determine the plugin
  111399. * @returns The loaded plugin
  111400. */
  111401. 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>;
  111402. /**
  111403. * Load a scene into an asset container
  111404. * @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)
  111405. * @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)
  111406. * @param scene is the instance of Scene to append to
  111407. * @param onProgress a callback with a progress event for each file being loaded
  111408. * @param pluginExtension the extension used to determine the plugin
  111409. * @returns The loaded asset container
  111410. */
  111411. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  111412. }
  111413. }
  111414. declare module BABYLON {
  111415. /**
  111416. * Generic Controller
  111417. */
  111418. export class GenericController extends WebVRController {
  111419. /**
  111420. * Base Url for the controller model.
  111421. */
  111422. static readonly MODEL_BASE_URL: string;
  111423. /**
  111424. * File name for the controller model.
  111425. */
  111426. static readonly MODEL_FILENAME: string;
  111427. /**
  111428. * Creates a new GenericController from a gamepad
  111429. * @param vrGamepad the gamepad that the controller should be created from
  111430. */
  111431. constructor(vrGamepad: any);
  111432. /**
  111433. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111434. * @param scene scene in which to add meshes
  111435. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111436. */
  111437. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111438. /**
  111439. * Called once for each button that changed state since the last frame
  111440. * @param buttonIdx Which button index changed
  111441. * @param state New state of the button
  111442. * @param changes Which properties on the state changed since last frame
  111443. */
  111444. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111445. }
  111446. }
  111447. declare module BABYLON {
  111448. /**
  111449. * Defines the WindowsMotionController object that the state of the windows motion controller
  111450. */
  111451. export class WindowsMotionController extends WebVRController {
  111452. /**
  111453. * The base url used to load the left and right controller models
  111454. */
  111455. static MODEL_BASE_URL: string;
  111456. /**
  111457. * The name of the left controller model file
  111458. */
  111459. static MODEL_LEFT_FILENAME: string;
  111460. /**
  111461. * The name of the right controller model file
  111462. */
  111463. static MODEL_RIGHT_FILENAME: string;
  111464. /**
  111465. * The controller name prefix for this controller type
  111466. */
  111467. static readonly GAMEPAD_ID_PREFIX: string;
  111468. /**
  111469. * The controller id pattern for this controller type
  111470. */
  111471. private static readonly GAMEPAD_ID_PATTERN;
  111472. private _loadedMeshInfo;
  111473. protected readonly _mapping: {
  111474. buttons: string[];
  111475. buttonMeshNames: {
  111476. 'trigger': string;
  111477. 'menu': string;
  111478. 'grip': string;
  111479. 'thumbstick': string;
  111480. 'trackpad': string;
  111481. };
  111482. buttonObservableNames: {
  111483. 'trigger': string;
  111484. 'menu': string;
  111485. 'grip': string;
  111486. 'thumbstick': string;
  111487. 'trackpad': string;
  111488. };
  111489. axisMeshNames: string[];
  111490. pointingPoseMeshName: string;
  111491. };
  111492. /**
  111493. * Fired when the trackpad on this controller is clicked
  111494. */
  111495. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111496. /**
  111497. * Fired when the trackpad on this controller is modified
  111498. */
  111499. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111500. /**
  111501. * The current x and y values of this controller's trackpad
  111502. */
  111503. trackpad: StickValues;
  111504. /**
  111505. * Creates a new WindowsMotionController from a gamepad
  111506. * @param vrGamepad the gamepad that the controller should be created from
  111507. */
  111508. constructor(vrGamepad: any);
  111509. /**
  111510. * Fired when the trigger on this controller is modified
  111511. */
  111512. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111513. /**
  111514. * Fired when the menu button on this controller is modified
  111515. */
  111516. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111517. /**
  111518. * Fired when the grip button on this controller is modified
  111519. */
  111520. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111521. /**
  111522. * Fired when the thumbstick button on this controller is modified
  111523. */
  111524. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111525. /**
  111526. * Fired when the touchpad button on this controller is modified
  111527. */
  111528. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111529. /**
  111530. * Fired when the touchpad values on this controller are modified
  111531. */
  111532. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  111533. protected _updateTrackpad(): void;
  111534. /**
  111535. * Called once per frame by the engine.
  111536. */
  111537. update(): void;
  111538. /**
  111539. * Called once for each button that changed state since the last frame
  111540. * @param buttonIdx Which button index changed
  111541. * @param state New state of the button
  111542. * @param changes Which properties on the state changed since last frame
  111543. */
  111544. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111545. /**
  111546. * Moves the buttons on the controller mesh based on their current state
  111547. * @param buttonName the name of the button to move
  111548. * @param buttonValue the value of the button which determines the buttons new position
  111549. */
  111550. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111551. /**
  111552. * Moves the axis on the controller mesh based on its current state
  111553. * @param axis the index of the axis
  111554. * @param axisValue the value of the axis which determines the meshes new position
  111555. * @hidden
  111556. */
  111557. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  111558. /**
  111559. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111560. * @param scene scene in which to add meshes
  111561. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111562. */
  111563. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  111564. /**
  111565. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111566. * can be transformed by button presses and axes values, based on this._mapping.
  111567. *
  111568. * @param scene scene in which the meshes exist
  111569. * @param meshes list of meshes that make up the controller model to process
  111570. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111571. */
  111572. private processModel;
  111573. private createMeshInfo;
  111574. /**
  111575. * Gets the ray of the controller in the direction the controller is pointing
  111576. * @param length the length the resulting ray should be
  111577. * @returns a ray in the direction the controller is pointing
  111578. */
  111579. getForwardRay(length?: number): Ray;
  111580. /**
  111581. * Disposes of the controller
  111582. */
  111583. dispose(): void;
  111584. }
  111585. /**
  111586. * This class represents a new windows motion controller in XR.
  111587. */
  111588. export class XRWindowsMotionController extends WindowsMotionController {
  111589. /**
  111590. * Changing the original WIndowsMotionController mapping to fir the new mapping
  111591. */
  111592. protected readonly _mapping: {
  111593. buttons: string[];
  111594. buttonMeshNames: {
  111595. 'trigger': string;
  111596. 'menu': string;
  111597. 'grip': string;
  111598. 'thumbstick': string;
  111599. 'trackpad': string;
  111600. };
  111601. buttonObservableNames: {
  111602. 'trigger': string;
  111603. 'menu': string;
  111604. 'grip': string;
  111605. 'thumbstick': string;
  111606. 'trackpad': string;
  111607. };
  111608. axisMeshNames: string[];
  111609. pointingPoseMeshName: string;
  111610. };
  111611. /**
  111612. * Construct a new XR-Based windows motion controller
  111613. *
  111614. * @param gamepadInfo the gamepad object from the browser
  111615. */
  111616. constructor(gamepadInfo: any);
  111617. /**
  111618. * holds the thumbstick values (X,Y)
  111619. */
  111620. thumbstickValues: StickValues;
  111621. /**
  111622. * Fired when the thumbstick on this controller is clicked
  111623. */
  111624. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  111625. /**
  111626. * Fired when the thumbstick on this controller is modified
  111627. */
  111628. onThumbstickValuesChangedObservable: Observable<StickValues>;
  111629. /**
  111630. * Fired when the touchpad button on this controller is modified
  111631. */
  111632. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111633. /**
  111634. * Fired when the touchpad values on this controller are modified
  111635. */
  111636. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111637. /**
  111638. * Fired when the thumbstick button on this controller is modified
  111639. * here to prevent breaking changes
  111640. */
  111641. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111642. /**
  111643. * updating the thumbstick(!) and not the trackpad.
  111644. * This is named this way due to the difference between WebVR and XR and to avoid
  111645. * changing the parent class.
  111646. */
  111647. protected _updateTrackpad(): void;
  111648. /**
  111649. * Disposes the class with joy
  111650. */
  111651. dispose(): void;
  111652. }
  111653. }
  111654. declare module BABYLON {
  111655. /**
  111656. * Oculus Touch Controller
  111657. */
  111658. export class OculusTouchController extends WebVRController {
  111659. /**
  111660. * Base Url for the controller model.
  111661. */
  111662. static MODEL_BASE_URL: string;
  111663. /**
  111664. * File name for the left controller model.
  111665. */
  111666. static MODEL_LEFT_FILENAME: string;
  111667. /**
  111668. * File name for the right controller model.
  111669. */
  111670. static MODEL_RIGHT_FILENAME: string;
  111671. /**
  111672. * Base Url for the Quest controller model.
  111673. */
  111674. static QUEST_MODEL_BASE_URL: string;
  111675. /**
  111676. * @hidden
  111677. * If the controllers are running on a device that needs the updated Quest controller models
  111678. */
  111679. static _IsQuest: boolean;
  111680. /**
  111681. * Fired when the secondary trigger on this controller is modified
  111682. */
  111683. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111684. /**
  111685. * Fired when the thumb rest on this controller is modified
  111686. */
  111687. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111688. /**
  111689. * Creates a new OculusTouchController from a gamepad
  111690. * @param vrGamepad the gamepad that the controller should be created from
  111691. */
  111692. constructor(vrGamepad: any);
  111693. /**
  111694. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111695. * @param scene scene in which to add meshes
  111696. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111697. */
  111698. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111699. /**
  111700. * Fired when the A button on this controller is modified
  111701. */
  111702. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111703. /**
  111704. * Fired when the B button on this controller is modified
  111705. */
  111706. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111707. /**
  111708. * Fired when the X button on this controller is modified
  111709. */
  111710. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111711. /**
  111712. * Fired when the Y button on this controller is modified
  111713. */
  111714. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111715. /**
  111716. * Called once for each button that changed state since the last frame
  111717. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111718. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111719. * 2) secondary trigger (same)
  111720. * 3) A (right) X (left), touch, pressed = value
  111721. * 4) B / Y
  111722. * 5) thumb rest
  111723. * @param buttonIdx Which button index changed
  111724. * @param state New state of the button
  111725. * @param changes Which properties on the state changed since last frame
  111726. */
  111727. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111728. }
  111729. }
  111730. declare module BABYLON {
  111731. /**
  111732. * Vive Controller
  111733. */
  111734. export class ViveController extends WebVRController {
  111735. /**
  111736. * Base Url for the controller model.
  111737. */
  111738. static MODEL_BASE_URL: string;
  111739. /**
  111740. * File name for the controller model.
  111741. */
  111742. static MODEL_FILENAME: string;
  111743. /**
  111744. * Creates a new ViveController from a gamepad
  111745. * @param vrGamepad the gamepad that the controller should be created from
  111746. */
  111747. constructor(vrGamepad: any);
  111748. /**
  111749. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111750. * @param scene scene in which to add meshes
  111751. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111752. */
  111753. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111754. /**
  111755. * Fired when the left button on this controller is modified
  111756. */
  111757. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111758. /**
  111759. * Fired when the right button on this controller is modified
  111760. */
  111761. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111762. /**
  111763. * Fired when the menu button on this controller is modified
  111764. */
  111765. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111766. /**
  111767. * Called once for each button that changed state since the last frame
  111768. * Vive mapping:
  111769. * 0: touchpad
  111770. * 1: trigger
  111771. * 2: left AND right buttons
  111772. * 3: menu button
  111773. * @param buttonIdx Which button index changed
  111774. * @param state New state of the button
  111775. * @param changes Which properties on the state changed since last frame
  111776. */
  111777. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111778. }
  111779. }
  111780. declare module BABYLON {
  111781. /**
  111782. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111783. */
  111784. export class WebXRControllerModelLoader {
  111785. /**
  111786. * an observable that triggers when a new model (the mesh itself) was initialized.
  111787. * To know when the mesh was loaded use the controller's own modelLoaded() method
  111788. */
  111789. onControllerModelLoaded: Observable<WebXRController>;
  111790. /**
  111791. * Creates the WebXRControllerModelLoader
  111792. * @param input xr input that creates the controllers
  111793. */
  111794. constructor(input: WebXRInput);
  111795. }
  111796. }
  111797. declare module BABYLON {
  111798. /**
  111799. * Handles pointer input automatically for the pointer of XR controllers
  111800. */
  111801. export class WebXRControllerPointerSelection {
  111802. private static _idCounter;
  111803. private _tmpRay;
  111804. /**
  111805. * Creates a WebXRControllerPointerSelection
  111806. * @param input input manager to setup pointer selection
  111807. */
  111808. constructor(input: WebXRInput);
  111809. private _convertNormalToDirectionOfRay;
  111810. private _updatePointerDistance;
  111811. }
  111812. }
  111813. declare module BABYLON {
  111814. /**
  111815. * Enables teleportation
  111816. */
  111817. export class WebXRControllerTeleportation {
  111818. private _teleportationFillColor;
  111819. private _teleportationBorderColor;
  111820. private _tmpRay;
  111821. private _tmpVector;
  111822. /**
  111823. * Creates a WebXRControllerTeleportation
  111824. * @param input input manager to add teleportation to
  111825. * @param floorMeshes floormeshes which can be teleported to
  111826. */
  111827. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  111828. }
  111829. }
  111830. declare module BABYLON {
  111831. /**
  111832. * Button which can be used to enter a different mode of XR
  111833. */
  111834. export class WebXREnterExitUIButton {
  111835. /** button element */
  111836. element: HTMLElement;
  111837. /** XR initialization options for the button */
  111838. sessionMode: XRSessionMode;
  111839. /** Reference space type */
  111840. referenceSpaceType: XRReferenceSpaceType;
  111841. /**
  111842. * Creates a WebXREnterExitUIButton
  111843. * @param element button element
  111844. * @param sessionMode XR initialization session mode
  111845. * @param referenceSpaceType the type of reference space to be used
  111846. */
  111847. constructor(
  111848. /** button element */
  111849. element: HTMLElement,
  111850. /** XR initialization options for the button */
  111851. sessionMode: XRSessionMode,
  111852. /** Reference space type */
  111853. referenceSpaceType: XRReferenceSpaceType);
  111854. /**
  111855. * Overwritable function which can be used to update the button's visuals when the state changes
  111856. * @param activeButton the current active button in the UI
  111857. */
  111858. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  111859. }
  111860. /**
  111861. * Options to create the webXR UI
  111862. */
  111863. export class WebXREnterExitUIOptions {
  111864. /**
  111865. * Context to enter xr with
  111866. */
  111867. renderTarget?: Nullable<WebXRRenderTarget>;
  111868. /**
  111869. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  111870. */
  111871. customButtons?: Array<WebXREnterExitUIButton>;
  111872. /**
  111873. * A session mode to use when creating the default button.
  111874. * Default is immersive-vr
  111875. */
  111876. sessionMode?: XRSessionMode;
  111877. /**
  111878. * A reference space type to use when creating the default button.
  111879. * Default is local-floor
  111880. */
  111881. referenceSpaceType?: XRReferenceSpaceType;
  111882. }
  111883. /**
  111884. * UI to allow the user to enter/exit XR mode
  111885. */
  111886. export class WebXREnterExitUI implements IDisposable {
  111887. private scene;
  111888. private _overlay;
  111889. private _buttons;
  111890. private _activeButton;
  111891. /**
  111892. * Fired every time the active button is changed.
  111893. *
  111894. * When xr is entered via a button that launches xr that button will be the callback parameter
  111895. *
  111896. * When exiting xr the callback parameter will be null)
  111897. */
  111898. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  111899. /**
  111900. * Creates UI to allow the user to enter/exit XR mode
  111901. * @param scene the scene to add the ui to
  111902. * @param helper the xr experience helper to enter/exit xr with
  111903. * @param options options to configure the UI
  111904. * @returns the created ui
  111905. */
  111906. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  111907. private constructor();
  111908. private _updateButtons;
  111909. /**
  111910. * Disposes of the object
  111911. */
  111912. dispose(): void;
  111913. }
  111914. }
  111915. declare module BABYLON {
  111916. /**
  111917. * Options for the default xr helper
  111918. */
  111919. export class WebXRDefaultExperienceOptions {
  111920. /**
  111921. * Floor meshes that should be used for teleporting
  111922. */
  111923. floorMeshes: Array<AbstractMesh>;
  111924. /**
  111925. * Enable or disable default UI to enter XR
  111926. */
  111927. disableDefaultUI?: boolean;
  111928. /**
  111929. * optional configuration for the output canvas
  111930. */
  111931. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  111932. }
  111933. /**
  111934. * Default experience which provides a similar setup to the previous webVRExperience
  111935. */
  111936. export class WebXRDefaultExperience {
  111937. /**
  111938. * Base experience
  111939. */
  111940. baseExperience: WebXRExperienceHelper;
  111941. /**
  111942. * Input experience extension
  111943. */
  111944. input: WebXRInput;
  111945. /**
  111946. * Loads the controller models
  111947. */
  111948. controllerModelLoader: WebXRControllerModelLoader;
  111949. /**
  111950. * Enables laser pointer and selection
  111951. */
  111952. pointerSelection: WebXRControllerPointerSelection;
  111953. /**
  111954. * Enables teleportation
  111955. */
  111956. teleportation: WebXRControllerTeleportation;
  111957. /**
  111958. * Enables ui for enetering/exiting xr
  111959. */
  111960. enterExitUI: WebXREnterExitUI;
  111961. /**
  111962. * Default target xr should render to
  111963. */
  111964. renderTarget: WebXRRenderTarget;
  111965. /**
  111966. * Creates the default xr experience
  111967. * @param scene scene
  111968. * @param options options for basic configuration
  111969. * @returns resulting WebXRDefaultExperience
  111970. */
  111971. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111972. private constructor();
  111973. /**
  111974. * DIsposes of the experience helper
  111975. */
  111976. dispose(): void;
  111977. }
  111978. }
  111979. declare module BABYLON {
  111980. /**
  111981. * Options to modify the vr teleportation behavior.
  111982. */
  111983. export interface VRTeleportationOptions {
  111984. /**
  111985. * The name of the mesh which should be used as the teleportation floor. (default: null)
  111986. */
  111987. floorMeshName?: string;
  111988. /**
  111989. * A list of meshes to be used as the teleportation floor. (default: empty)
  111990. */
  111991. floorMeshes?: Mesh[];
  111992. /**
  111993. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  111994. */
  111995. teleportationMode?: number;
  111996. /**
  111997. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  111998. */
  111999. teleportationTime?: number;
  112000. /**
  112001. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  112002. */
  112003. teleportationSpeed?: number;
  112004. /**
  112005. * The easing function used in the animation or null for Linear. (default CircleEase)
  112006. */
  112007. easingFunction?: EasingFunction;
  112008. }
  112009. /**
  112010. * Options to modify the vr experience helper's behavior.
  112011. */
  112012. export interface VRExperienceHelperOptions extends WebVROptions {
  112013. /**
  112014. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  112015. */
  112016. createDeviceOrientationCamera?: boolean;
  112017. /**
  112018. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  112019. */
  112020. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  112021. /**
  112022. * Uses the main button on the controller to toggle the laser casted. (default: true)
  112023. */
  112024. laserToggle?: boolean;
  112025. /**
  112026. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  112027. */
  112028. floorMeshes?: Mesh[];
  112029. /**
  112030. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  112031. */
  112032. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  112033. /**
  112034. * Defines if WebXR should be used instead of WebVR (if available)
  112035. */
  112036. useXR?: boolean;
  112037. }
  112038. /**
  112039. * Event containing information after VR has been entered
  112040. */
  112041. export class OnAfterEnteringVRObservableEvent {
  112042. /**
  112043. * If entering vr was successful
  112044. */
  112045. success: boolean;
  112046. }
  112047. /**
  112048. * Helps to quickly add VR support to an existing scene.
  112049. * See http://doc.babylonjs.com/how_to/webvr_helper
  112050. */
  112051. export class VRExperienceHelper {
  112052. /** Options to modify the vr experience helper's behavior. */
  112053. webVROptions: VRExperienceHelperOptions;
  112054. private _scene;
  112055. private _position;
  112056. private _btnVR;
  112057. private _btnVRDisplayed;
  112058. private _webVRsupported;
  112059. private _webVRready;
  112060. private _webVRrequesting;
  112061. private _webVRpresenting;
  112062. private _hasEnteredVR;
  112063. private _fullscreenVRpresenting;
  112064. private _inputElement;
  112065. private _webVRCamera;
  112066. private _vrDeviceOrientationCamera;
  112067. private _deviceOrientationCamera;
  112068. private _existingCamera;
  112069. private _onKeyDown;
  112070. private _onVrDisplayPresentChange;
  112071. private _onVRDisplayChanged;
  112072. private _onVRRequestPresentStart;
  112073. private _onVRRequestPresentComplete;
  112074. /**
  112075. * 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)
  112076. */
  112077. enableGazeEvenWhenNoPointerLock: boolean;
  112078. /**
  112079. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  112080. */
  112081. exitVROnDoubleTap: boolean;
  112082. /**
  112083. * Observable raised right before entering VR.
  112084. */
  112085. onEnteringVRObservable: Observable<VRExperienceHelper>;
  112086. /**
  112087. * Observable raised when entering VR has completed.
  112088. */
  112089. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  112090. /**
  112091. * Observable raised when exiting VR.
  112092. */
  112093. onExitingVRObservable: Observable<VRExperienceHelper>;
  112094. /**
  112095. * Observable raised when controller mesh is loaded.
  112096. */
  112097. onControllerMeshLoadedObservable: Observable<WebVRController>;
  112098. /** Return this.onEnteringVRObservable
  112099. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  112100. */
  112101. readonly onEnteringVR: Observable<VRExperienceHelper>;
  112102. /** Return this.onExitingVRObservable
  112103. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  112104. */
  112105. readonly onExitingVR: Observable<VRExperienceHelper>;
  112106. /** Return this.onControllerMeshLoadedObservable
  112107. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  112108. */
  112109. readonly onControllerMeshLoaded: Observable<WebVRController>;
  112110. private _rayLength;
  112111. private _useCustomVRButton;
  112112. private _teleportationRequested;
  112113. private _teleportActive;
  112114. private _floorMeshName;
  112115. private _floorMeshesCollection;
  112116. private _teleportationMode;
  112117. private _teleportationTime;
  112118. private _teleportationSpeed;
  112119. private _teleportationEasing;
  112120. private _rotationAllowed;
  112121. private _teleportBackwardsVector;
  112122. private _teleportationTarget;
  112123. private _isDefaultTeleportationTarget;
  112124. private _postProcessMove;
  112125. private _teleportationFillColor;
  112126. private _teleportationBorderColor;
  112127. private _rotationAngle;
  112128. private _haloCenter;
  112129. private _cameraGazer;
  112130. private _padSensibilityUp;
  112131. private _padSensibilityDown;
  112132. private _leftController;
  112133. private _rightController;
  112134. /**
  112135. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  112136. */
  112137. onNewMeshSelected: Observable<AbstractMesh>;
  112138. /**
  112139. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  112140. * This observable will provide the mesh and the controller used to select the mesh
  112141. */
  112142. onMeshSelectedWithController: Observable<{
  112143. mesh: AbstractMesh;
  112144. controller: WebVRController;
  112145. }>;
  112146. /**
  112147. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  112148. */
  112149. onNewMeshPicked: Observable<PickingInfo>;
  112150. private _circleEase;
  112151. /**
  112152. * Observable raised before camera teleportation
  112153. */
  112154. onBeforeCameraTeleport: Observable<Vector3>;
  112155. /**
  112156. * Observable raised after camera teleportation
  112157. */
  112158. onAfterCameraTeleport: Observable<Vector3>;
  112159. /**
  112160. * Observable raised when current selected mesh gets unselected
  112161. */
  112162. onSelectedMeshUnselected: Observable<AbstractMesh>;
  112163. private _raySelectionPredicate;
  112164. /**
  112165. * To be optionaly changed by user to define custom ray selection
  112166. */
  112167. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  112168. /**
  112169. * To be optionaly changed by user to define custom selection logic (after ray selection)
  112170. */
  112171. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112172. /**
  112173. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  112174. */
  112175. teleportationEnabled: boolean;
  112176. private _defaultHeight;
  112177. private _teleportationInitialized;
  112178. private _interactionsEnabled;
  112179. private _interactionsRequested;
  112180. private _displayGaze;
  112181. private _displayLaserPointer;
  112182. /**
  112183. * The mesh used to display where the user is going to teleport.
  112184. */
  112185. /**
  112186. * Sets the mesh to be used to display where the user is going to teleport.
  112187. */
  112188. teleportationTarget: Mesh;
  112189. /**
  112190. * 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
  112191. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  112192. * See http://doc.babylonjs.com/resources/baking_transformations
  112193. */
  112194. gazeTrackerMesh: Mesh;
  112195. /**
  112196. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  112197. */
  112198. updateGazeTrackerScale: boolean;
  112199. /**
  112200. * If the gaze trackers color should be updated when selecting meshes
  112201. */
  112202. updateGazeTrackerColor: boolean;
  112203. /**
  112204. * If the controller laser color should be updated when selecting meshes
  112205. */
  112206. updateControllerLaserColor: boolean;
  112207. /**
  112208. * The gaze tracking mesh corresponding to the left controller
  112209. */
  112210. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  112211. /**
  112212. * The gaze tracking mesh corresponding to the right controller
  112213. */
  112214. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  112215. /**
  112216. * If the ray of the gaze should be displayed.
  112217. */
  112218. /**
  112219. * Sets if the ray of the gaze should be displayed.
  112220. */
  112221. displayGaze: boolean;
  112222. /**
  112223. * If the ray of the LaserPointer should be displayed.
  112224. */
  112225. /**
  112226. * Sets if the ray of the LaserPointer should be displayed.
  112227. */
  112228. displayLaserPointer: boolean;
  112229. /**
  112230. * The deviceOrientationCamera used as the camera when not in VR.
  112231. */
  112232. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  112233. /**
  112234. * Based on the current WebVR support, returns the current VR camera used.
  112235. */
  112236. readonly currentVRCamera: Nullable<Camera>;
  112237. /**
  112238. * The webVRCamera which is used when in VR.
  112239. */
  112240. readonly webVRCamera: WebVRFreeCamera;
  112241. /**
  112242. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  112243. */
  112244. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  112245. /**
  112246. * The html button that is used to trigger entering into VR.
  112247. */
  112248. readonly vrButton: Nullable<HTMLButtonElement>;
  112249. private readonly _teleportationRequestInitiated;
  112250. /**
  112251. * Defines wether or not Pointer lock should be requested when switching to
  112252. * full screen.
  112253. */
  112254. requestPointerLockOnFullScreen: boolean;
  112255. /**
  112256. * If asking to force XR, this will be populated with the default xr experience
  112257. */
  112258. xr: WebXRDefaultExperience;
  112259. /**
  112260. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  112261. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  112262. */
  112263. xrTestDone: boolean;
  112264. /**
  112265. * Instantiates a VRExperienceHelper.
  112266. * Helps to quickly add VR support to an existing scene.
  112267. * @param scene The scene the VRExperienceHelper belongs to.
  112268. * @param webVROptions Options to modify the vr experience helper's behavior.
  112269. */
  112270. constructor(scene: Scene,
  112271. /** Options to modify the vr experience helper's behavior. */
  112272. webVROptions?: VRExperienceHelperOptions);
  112273. private completeVRInit;
  112274. private _onDefaultMeshLoaded;
  112275. private _onResize;
  112276. private _onFullscreenChange;
  112277. /**
  112278. * Gets a value indicating if we are currently in VR mode.
  112279. */
  112280. readonly isInVRMode: boolean;
  112281. private onVrDisplayPresentChange;
  112282. private onVRDisplayChanged;
  112283. private moveButtonToBottomRight;
  112284. private displayVRButton;
  112285. private updateButtonVisibility;
  112286. private _cachedAngularSensibility;
  112287. /**
  112288. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  112289. * Otherwise, will use the fullscreen API.
  112290. */
  112291. enterVR(): void;
  112292. /**
  112293. * Attempt to exit VR, or fullscreen.
  112294. */
  112295. exitVR(): void;
  112296. /**
  112297. * The position of the vr experience helper.
  112298. */
  112299. /**
  112300. * Sets the position of the vr experience helper.
  112301. */
  112302. position: Vector3;
  112303. /**
  112304. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  112305. */
  112306. enableInteractions(): void;
  112307. private readonly _noControllerIsActive;
  112308. private beforeRender;
  112309. private _isTeleportationFloor;
  112310. /**
  112311. * Adds a floor mesh to be used for teleportation.
  112312. * @param floorMesh the mesh to be used for teleportation.
  112313. */
  112314. addFloorMesh(floorMesh: Mesh): void;
  112315. /**
  112316. * Removes a floor mesh from being used for teleportation.
  112317. * @param floorMesh the mesh to be removed.
  112318. */
  112319. removeFloorMesh(floorMesh: Mesh): void;
  112320. /**
  112321. * Enables interactions and teleportation using the VR controllers and gaze.
  112322. * @param vrTeleportationOptions options to modify teleportation behavior.
  112323. */
  112324. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  112325. private _onNewGamepadConnected;
  112326. private _tryEnableInteractionOnController;
  112327. private _onNewGamepadDisconnected;
  112328. private _enableInteractionOnController;
  112329. private _checkTeleportWithRay;
  112330. private _checkRotate;
  112331. private _checkTeleportBackwards;
  112332. private _enableTeleportationOnController;
  112333. private _createTeleportationCircles;
  112334. private _displayTeleportationTarget;
  112335. private _hideTeleportationTarget;
  112336. private _rotateCamera;
  112337. private _moveTeleportationSelectorTo;
  112338. private _workingVector;
  112339. private _workingQuaternion;
  112340. private _workingMatrix;
  112341. /**
  112342. * Time Constant Teleportation Mode
  112343. */
  112344. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  112345. /**
  112346. * Speed Constant Teleportation Mode
  112347. */
  112348. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  112349. /**
  112350. * Teleports the users feet to the desired location
  112351. * @param location The location where the user's feet should be placed
  112352. */
  112353. teleportCamera(location: Vector3): void;
  112354. private _convertNormalToDirectionOfRay;
  112355. private _castRayAndSelectObject;
  112356. private _notifySelectedMeshUnselected;
  112357. /**
  112358. * Sets the color of the laser ray from the vr controllers.
  112359. * @param color new color for the ray.
  112360. */
  112361. changeLaserColor(color: Color3): void;
  112362. /**
  112363. * Sets the color of the ray from the vr headsets gaze.
  112364. * @param color new color for the ray.
  112365. */
  112366. changeGazeColor(color: Color3): void;
  112367. /**
  112368. * Exits VR and disposes of the vr experience helper
  112369. */
  112370. dispose(): void;
  112371. /**
  112372. * Gets the name of the VRExperienceHelper class
  112373. * @returns "VRExperienceHelper"
  112374. */
  112375. getClassName(): string;
  112376. }
  112377. }
  112378. declare module BABYLON {
  112379. /**
  112380. * Contains an array of blocks representing the octree
  112381. */
  112382. export interface IOctreeContainer<T> {
  112383. /**
  112384. * Blocks within the octree
  112385. */
  112386. blocks: Array<OctreeBlock<T>>;
  112387. }
  112388. /**
  112389. * Class used to store a cell in an octree
  112390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112391. */
  112392. export class OctreeBlock<T> {
  112393. /**
  112394. * Gets the content of the current block
  112395. */
  112396. entries: T[];
  112397. /**
  112398. * Gets the list of block children
  112399. */
  112400. blocks: Array<OctreeBlock<T>>;
  112401. private _depth;
  112402. private _maxDepth;
  112403. private _capacity;
  112404. private _minPoint;
  112405. private _maxPoint;
  112406. private _boundingVectors;
  112407. private _creationFunc;
  112408. /**
  112409. * Creates a new block
  112410. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  112411. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  112412. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112413. * @param depth defines the current depth of this block in the octree
  112414. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  112415. * @param creationFunc defines a callback to call when an element is added to the block
  112416. */
  112417. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  112418. /**
  112419. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112420. */
  112421. readonly capacity: number;
  112422. /**
  112423. * Gets the minimum vector (in world space) of the block's bounding box
  112424. */
  112425. readonly minPoint: Vector3;
  112426. /**
  112427. * Gets the maximum vector (in world space) of the block's bounding box
  112428. */
  112429. readonly maxPoint: Vector3;
  112430. /**
  112431. * Add a new element to this block
  112432. * @param entry defines the element to add
  112433. */
  112434. addEntry(entry: T): void;
  112435. /**
  112436. * Remove an element from this block
  112437. * @param entry defines the element to remove
  112438. */
  112439. removeEntry(entry: T): void;
  112440. /**
  112441. * Add an array of elements to this block
  112442. * @param entries defines the array of elements to add
  112443. */
  112444. addEntries(entries: T[]): void;
  112445. /**
  112446. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  112447. * @param frustumPlanes defines the frustum planes to test
  112448. * @param selection defines the array to store current content if selection is positive
  112449. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112450. */
  112451. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112452. /**
  112453. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  112454. * @param sphereCenter defines the bounding sphere center
  112455. * @param sphereRadius defines the bounding sphere radius
  112456. * @param selection defines the array to store current content if selection is positive
  112457. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112458. */
  112459. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112460. /**
  112461. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  112462. * @param ray defines the ray to test with
  112463. * @param selection defines the array to store current content if selection is positive
  112464. */
  112465. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  112466. /**
  112467. * Subdivide the content into child blocks (this block will then be empty)
  112468. */
  112469. createInnerBlocks(): void;
  112470. /**
  112471. * @hidden
  112472. */
  112473. 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;
  112474. }
  112475. }
  112476. declare module BABYLON {
  112477. /**
  112478. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  112479. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112480. */
  112481. export class Octree<T> {
  112482. /** 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.) */
  112483. maxDepth: number;
  112484. /**
  112485. * Blocks within the octree containing objects
  112486. */
  112487. blocks: Array<OctreeBlock<T>>;
  112488. /**
  112489. * Content stored in the octree
  112490. */
  112491. dynamicContent: T[];
  112492. private _maxBlockCapacity;
  112493. private _selectionContent;
  112494. private _creationFunc;
  112495. /**
  112496. * Creates a octree
  112497. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112498. * @param creationFunc function to be used to instatiate the octree
  112499. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  112500. * @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.)
  112501. */
  112502. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  112503. /** 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.) */
  112504. maxDepth?: number);
  112505. /**
  112506. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  112507. * @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);
  112508. * @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);
  112509. * @param entries meshes to be added to the octree blocks
  112510. */
  112511. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  112512. /**
  112513. * Adds a mesh to the octree
  112514. * @param entry Mesh to add to the octree
  112515. */
  112516. addMesh(entry: T): void;
  112517. /**
  112518. * Remove an element from the octree
  112519. * @param entry defines the element to remove
  112520. */
  112521. removeMesh(entry: T): void;
  112522. /**
  112523. * Selects an array of meshes within the frustum
  112524. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  112525. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  112526. * @returns array of meshes within the frustum
  112527. */
  112528. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  112529. /**
  112530. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  112531. * @param sphereCenter defines the bounding sphere center
  112532. * @param sphereRadius defines the bounding sphere radius
  112533. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112534. * @returns an array of objects that intersect the sphere
  112535. */
  112536. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  112537. /**
  112538. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  112539. * @param ray defines the ray to test with
  112540. * @returns array of intersected objects
  112541. */
  112542. intersectsRay(ray: Ray): SmartArray<T>;
  112543. /**
  112544. * Adds a mesh into the octree block if it intersects the block
  112545. */
  112546. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  112547. /**
  112548. * Adds a submesh into the octree block if it intersects the block
  112549. */
  112550. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  112551. }
  112552. }
  112553. declare module BABYLON {
  112554. interface Scene {
  112555. /**
  112556. * @hidden
  112557. * Backing Filed
  112558. */
  112559. _selectionOctree: Octree<AbstractMesh>;
  112560. /**
  112561. * Gets the octree used to boost mesh selection (picking)
  112562. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112563. */
  112564. selectionOctree: Octree<AbstractMesh>;
  112565. /**
  112566. * Creates or updates the octree used to boost selection (picking)
  112567. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112568. * @param maxCapacity defines the maximum capacity per leaf
  112569. * @param maxDepth defines the maximum depth of the octree
  112570. * @returns an octree of AbstractMesh
  112571. */
  112572. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  112573. }
  112574. interface AbstractMesh {
  112575. /**
  112576. * @hidden
  112577. * Backing Field
  112578. */
  112579. _submeshesOctree: Octree<SubMesh>;
  112580. /**
  112581. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  112582. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112583. * @param maxCapacity defines the maximum size of each block (64 by default)
  112584. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  112585. * @returns the new octree
  112586. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  112587. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112588. */
  112589. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  112590. }
  112591. /**
  112592. * Defines the octree scene component responsible to manage any octrees
  112593. * in a given scene.
  112594. */
  112595. export class OctreeSceneComponent {
  112596. /**
  112597. * The component name help to identify the component in the list of scene components.
  112598. */
  112599. readonly name: string;
  112600. /**
  112601. * The scene the component belongs to.
  112602. */
  112603. scene: Scene;
  112604. /**
  112605. * Indicates if the meshes have been checked to make sure they are isEnabled()
  112606. */
  112607. readonly checksIsEnabled: boolean;
  112608. /**
  112609. * Creates a new instance of the component for the given scene
  112610. * @param scene Defines the scene to register the component in
  112611. */
  112612. constructor(scene: Scene);
  112613. /**
  112614. * Registers the component in a given scene
  112615. */
  112616. register(): void;
  112617. /**
  112618. * Return the list of active meshes
  112619. * @returns the list of active meshes
  112620. */
  112621. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112622. /**
  112623. * Return the list of active sub meshes
  112624. * @param mesh The mesh to get the candidates sub meshes from
  112625. * @returns the list of active sub meshes
  112626. */
  112627. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112628. private _tempRay;
  112629. /**
  112630. * Return the list of sub meshes intersecting with a given local ray
  112631. * @param mesh defines the mesh to find the submesh for
  112632. * @param localRay defines the ray in local space
  112633. * @returns the list of intersecting sub meshes
  112634. */
  112635. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  112636. /**
  112637. * Return the list of sub meshes colliding with a collider
  112638. * @param mesh defines the mesh to find the submesh for
  112639. * @param collider defines the collider to evaluate the collision against
  112640. * @returns the list of colliding sub meshes
  112641. */
  112642. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  112643. /**
  112644. * Rebuilds the elements related to this component in case of
  112645. * context lost for instance.
  112646. */
  112647. rebuild(): void;
  112648. /**
  112649. * Disposes the component and the associated ressources.
  112650. */
  112651. dispose(): void;
  112652. }
  112653. }
  112654. declare module BABYLON {
  112655. /**
  112656. * Renders a layer on top of an existing scene
  112657. */
  112658. export class UtilityLayerRenderer implements IDisposable {
  112659. /** the original scene that will be rendered on top of */
  112660. originalScene: Scene;
  112661. private _pointerCaptures;
  112662. private _lastPointerEvents;
  112663. private static _DefaultUtilityLayer;
  112664. private static _DefaultKeepDepthUtilityLayer;
  112665. private _sharedGizmoLight;
  112666. private _renderCamera;
  112667. /**
  112668. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  112669. * @returns the camera that is used when rendering the utility layer
  112670. */
  112671. getRenderCamera(): Nullable<Camera>;
  112672. /**
  112673. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  112674. * @param cam the camera that should be used when rendering the utility layer
  112675. */
  112676. setRenderCamera(cam: Nullable<Camera>): void;
  112677. /**
  112678. * @hidden
  112679. * Light which used by gizmos to get light shading
  112680. */
  112681. _getSharedGizmoLight(): HemisphericLight;
  112682. /**
  112683. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  112684. */
  112685. pickUtilitySceneFirst: boolean;
  112686. /**
  112687. * 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)
  112688. */
  112689. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  112690. /**
  112691. * 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)
  112692. */
  112693. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  112694. /**
  112695. * The scene that is rendered on top of the original scene
  112696. */
  112697. utilityLayerScene: Scene;
  112698. /**
  112699. * If the utility layer should automatically be rendered on top of existing scene
  112700. */
  112701. shouldRender: boolean;
  112702. /**
  112703. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  112704. */
  112705. onlyCheckPointerDownEvents: boolean;
  112706. /**
  112707. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  112708. */
  112709. processAllEvents: boolean;
  112710. /**
  112711. * Observable raised when the pointer move from the utility layer scene to the main scene
  112712. */
  112713. onPointerOutObservable: Observable<number>;
  112714. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  112715. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  112716. private _afterRenderObserver;
  112717. private _sceneDisposeObserver;
  112718. private _originalPointerObserver;
  112719. /**
  112720. * Instantiates a UtilityLayerRenderer
  112721. * @param originalScene the original scene that will be rendered on top of
  112722. * @param handleEvents boolean indicating if the utility layer should handle events
  112723. */
  112724. constructor(
  112725. /** the original scene that will be rendered on top of */
  112726. originalScene: Scene, handleEvents?: boolean);
  112727. private _notifyObservers;
  112728. /**
  112729. * Renders the utility layers scene on top of the original scene
  112730. */
  112731. render(): void;
  112732. /**
  112733. * Disposes of the renderer
  112734. */
  112735. dispose(): void;
  112736. private _updateCamera;
  112737. }
  112738. }
  112739. declare module BABYLON {
  112740. /**
  112741. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  112742. */
  112743. export class Gizmo implements IDisposable {
  112744. /** The utility layer the gizmo will be added to */
  112745. gizmoLayer: UtilityLayerRenderer;
  112746. /**
  112747. * The root mesh of the gizmo
  112748. */
  112749. _rootMesh: Mesh;
  112750. private _attachedMesh;
  112751. /**
  112752. * Ratio for the scale of the gizmo (Default: 1)
  112753. */
  112754. scaleRatio: number;
  112755. /**
  112756. * If a custom mesh has been set (Default: false)
  112757. */
  112758. protected _customMeshSet: boolean;
  112759. /**
  112760. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  112761. * * When set, interactions will be enabled
  112762. */
  112763. attachedMesh: Nullable<AbstractMesh>;
  112764. /**
  112765. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112766. * @param mesh The mesh to replace the default mesh of the gizmo
  112767. */
  112768. setCustomMesh(mesh: Mesh): void;
  112769. /**
  112770. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  112771. */
  112772. updateGizmoRotationToMatchAttachedMesh: boolean;
  112773. /**
  112774. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  112775. */
  112776. updateGizmoPositionToMatchAttachedMesh: boolean;
  112777. /**
  112778. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  112779. */
  112780. updateScale: boolean;
  112781. protected _interactionsEnabled: boolean;
  112782. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112783. private _beforeRenderObserver;
  112784. private _tempVector;
  112785. /**
  112786. * Creates a gizmo
  112787. * @param gizmoLayer The utility layer the gizmo will be added to
  112788. */
  112789. constructor(
  112790. /** The utility layer the gizmo will be added to */
  112791. gizmoLayer?: UtilityLayerRenderer);
  112792. /**
  112793. * Updates the gizmo to match the attached mesh's position/rotation
  112794. */
  112795. protected _update(): void;
  112796. /**
  112797. * Disposes of the gizmo
  112798. */
  112799. dispose(): void;
  112800. }
  112801. }
  112802. declare module BABYLON {
  112803. /**
  112804. * Single plane drag gizmo
  112805. */
  112806. export class PlaneDragGizmo extends Gizmo {
  112807. /**
  112808. * Drag behavior responsible for the gizmos dragging interactions
  112809. */
  112810. dragBehavior: PointerDragBehavior;
  112811. private _pointerObserver;
  112812. /**
  112813. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112814. */
  112815. snapDistance: number;
  112816. /**
  112817. * Event that fires each time the gizmo snaps to a new location.
  112818. * * snapDistance is the the change in distance
  112819. */
  112820. onSnapObservable: Observable<{
  112821. snapDistance: number;
  112822. }>;
  112823. private _plane;
  112824. private _coloredMaterial;
  112825. private _hoverMaterial;
  112826. private _isEnabled;
  112827. private _parent;
  112828. /** @hidden */
  112829. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  112830. /** @hidden */
  112831. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112832. /**
  112833. * Creates a PlaneDragGizmo
  112834. * @param gizmoLayer The utility layer the gizmo will be added to
  112835. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  112836. * @param color The color of the gizmo
  112837. */
  112838. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112839. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112840. /**
  112841. * If the gizmo is enabled
  112842. */
  112843. isEnabled: boolean;
  112844. /**
  112845. * Disposes of the gizmo
  112846. */
  112847. dispose(): void;
  112848. }
  112849. }
  112850. declare module BABYLON {
  112851. /**
  112852. * Gizmo that enables dragging a mesh along 3 axis
  112853. */
  112854. export class PositionGizmo extends Gizmo {
  112855. /**
  112856. * Internal gizmo used for interactions on the x axis
  112857. */
  112858. xGizmo: AxisDragGizmo;
  112859. /**
  112860. * Internal gizmo used for interactions on the y axis
  112861. */
  112862. yGizmo: AxisDragGizmo;
  112863. /**
  112864. * Internal gizmo used for interactions on the z axis
  112865. */
  112866. zGizmo: AxisDragGizmo;
  112867. /**
  112868. * Internal gizmo used for interactions on the yz plane
  112869. */
  112870. xPlaneGizmo: PlaneDragGizmo;
  112871. /**
  112872. * Internal gizmo used for interactions on the xz plane
  112873. */
  112874. yPlaneGizmo: PlaneDragGizmo;
  112875. /**
  112876. * Internal gizmo used for interactions on the xy plane
  112877. */
  112878. zPlaneGizmo: PlaneDragGizmo;
  112879. /**
  112880. * private variables
  112881. */
  112882. private _meshAttached;
  112883. private _updateGizmoRotationToMatchAttachedMesh;
  112884. private _snapDistance;
  112885. private _scaleRatio;
  112886. /** Fires an event when any of it's sub gizmos are dragged */
  112887. onDragStartObservable: Observable<unknown>;
  112888. /** Fires an event when any of it's sub gizmos are released from dragging */
  112889. onDragEndObservable: Observable<unknown>;
  112890. /**
  112891. * If set to true, planar drag is enabled
  112892. */
  112893. private _planarGizmoEnabled;
  112894. attachedMesh: Nullable<AbstractMesh>;
  112895. /**
  112896. * Creates a PositionGizmo
  112897. * @param gizmoLayer The utility layer the gizmo will be added to
  112898. */
  112899. constructor(gizmoLayer?: UtilityLayerRenderer);
  112900. /**
  112901. * If the planar drag gizmo is enabled
  112902. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  112903. */
  112904. planarGizmoEnabled: boolean;
  112905. updateGizmoRotationToMatchAttachedMesh: boolean;
  112906. /**
  112907. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112908. */
  112909. snapDistance: number;
  112910. /**
  112911. * Ratio for the scale of the gizmo (Default: 1)
  112912. */
  112913. scaleRatio: number;
  112914. /**
  112915. * Disposes of the gizmo
  112916. */
  112917. dispose(): void;
  112918. /**
  112919. * CustomMeshes are not supported by this gizmo
  112920. * @param mesh The mesh to replace the default mesh of the gizmo
  112921. */
  112922. setCustomMesh(mesh: Mesh): void;
  112923. }
  112924. }
  112925. declare module BABYLON {
  112926. /**
  112927. * Single axis drag gizmo
  112928. */
  112929. export class AxisDragGizmo extends Gizmo {
  112930. /**
  112931. * Drag behavior responsible for the gizmos dragging interactions
  112932. */
  112933. dragBehavior: PointerDragBehavior;
  112934. private _pointerObserver;
  112935. /**
  112936. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112937. */
  112938. snapDistance: number;
  112939. /**
  112940. * Event that fires each time the gizmo snaps to a new location.
  112941. * * snapDistance is the the change in distance
  112942. */
  112943. onSnapObservable: Observable<{
  112944. snapDistance: number;
  112945. }>;
  112946. private _isEnabled;
  112947. private _parent;
  112948. private _arrow;
  112949. private _coloredMaterial;
  112950. private _hoverMaterial;
  112951. /** @hidden */
  112952. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  112953. /** @hidden */
  112954. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112955. /**
  112956. * Creates an AxisDragGizmo
  112957. * @param gizmoLayer The utility layer the gizmo will be added to
  112958. * @param dragAxis The axis which the gizmo will be able to drag on
  112959. * @param color The color of the gizmo
  112960. */
  112961. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112962. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112963. /**
  112964. * If the gizmo is enabled
  112965. */
  112966. isEnabled: boolean;
  112967. /**
  112968. * Disposes of the gizmo
  112969. */
  112970. dispose(): void;
  112971. }
  112972. }
  112973. declare module BABYLON.Debug {
  112974. /**
  112975. * The Axes viewer will show 3 axes in a specific point in space
  112976. */
  112977. export class AxesViewer {
  112978. private _xAxis;
  112979. private _yAxis;
  112980. private _zAxis;
  112981. private _scaleLinesFactor;
  112982. private _instanced;
  112983. /**
  112984. * Gets the hosting scene
  112985. */
  112986. scene: Scene;
  112987. /**
  112988. * Gets or sets a number used to scale line length
  112989. */
  112990. scaleLines: number;
  112991. /** Gets the node hierarchy used to render x-axis */
  112992. readonly xAxis: TransformNode;
  112993. /** Gets the node hierarchy used to render y-axis */
  112994. readonly yAxis: TransformNode;
  112995. /** Gets the node hierarchy used to render z-axis */
  112996. readonly zAxis: TransformNode;
  112997. /**
  112998. * Creates a new AxesViewer
  112999. * @param scene defines the hosting scene
  113000. * @param scaleLines defines a number used to scale line length (1 by default)
  113001. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  113002. * @param xAxis defines the node hierarchy used to render the x-axis
  113003. * @param yAxis defines the node hierarchy used to render the y-axis
  113004. * @param zAxis defines the node hierarchy used to render the z-axis
  113005. */
  113006. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  113007. /**
  113008. * Force the viewer to update
  113009. * @param position defines the position of the viewer
  113010. * @param xaxis defines the x axis of the viewer
  113011. * @param yaxis defines the y axis of the viewer
  113012. * @param zaxis defines the z axis of the viewer
  113013. */
  113014. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  113015. /**
  113016. * Creates an instance of this axes viewer.
  113017. * @returns a new axes viewer with instanced meshes
  113018. */
  113019. createInstance(): AxesViewer;
  113020. /** Releases resources */
  113021. dispose(): void;
  113022. private static _SetRenderingGroupId;
  113023. }
  113024. }
  113025. declare module BABYLON.Debug {
  113026. /**
  113027. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  113028. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  113029. */
  113030. export class BoneAxesViewer extends AxesViewer {
  113031. /**
  113032. * Gets or sets the target mesh where to display the axes viewer
  113033. */
  113034. mesh: Nullable<Mesh>;
  113035. /**
  113036. * Gets or sets the target bone where to display the axes viewer
  113037. */
  113038. bone: Nullable<Bone>;
  113039. /** Gets current position */
  113040. pos: Vector3;
  113041. /** Gets direction of X axis */
  113042. xaxis: Vector3;
  113043. /** Gets direction of Y axis */
  113044. yaxis: Vector3;
  113045. /** Gets direction of Z axis */
  113046. zaxis: Vector3;
  113047. /**
  113048. * Creates a new BoneAxesViewer
  113049. * @param scene defines the hosting scene
  113050. * @param bone defines the target bone
  113051. * @param mesh defines the target mesh
  113052. * @param scaleLines defines a scaling factor for line length (1 by default)
  113053. */
  113054. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  113055. /**
  113056. * Force the viewer to update
  113057. */
  113058. update(): void;
  113059. /** Releases resources */
  113060. dispose(): void;
  113061. }
  113062. }
  113063. declare module BABYLON {
  113064. /**
  113065. * Interface used to define scene explorer extensibility option
  113066. */
  113067. export interface IExplorerExtensibilityOption {
  113068. /**
  113069. * Define the option label
  113070. */
  113071. label: string;
  113072. /**
  113073. * Defines the action to execute on click
  113074. */
  113075. action: (entity: any) => void;
  113076. }
  113077. /**
  113078. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  113079. */
  113080. export interface IExplorerExtensibilityGroup {
  113081. /**
  113082. * Defines a predicate to test if a given type mut be extended
  113083. */
  113084. predicate: (entity: any) => boolean;
  113085. /**
  113086. * Gets the list of options added to a type
  113087. */
  113088. entries: IExplorerExtensibilityOption[];
  113089. }
  113090. /**
  113091. * Interface used to define the options to use to create the Inspector
  113092. */
  113093. export interface IInspectorOptions {
  113094. /**
  113095. * Display in overlay mode (default: false)
  113096. */
  113097. overlay?: boolean;
  113098. /**
  113099. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  113100. */
  113101. globalRoot?: HTMLElement;
  113102. /**
  113103. * Display the Scene explorer
  113104. */
  113105. showExplorer?: boolean;
  113106. /**
  113107. * Display the property inspector
  113108. */
  113109. showInspector?: boolean;
  113110. /**
  113111. * Display in embed mode (both panes on the right)
  113112. */
  113113. embedMode?: boolean;
  113114. /**
  113115. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  113116. */
  113117. handleResize?: boolean;
  113118. /**
  113119. * Allow the panes to popup (default: true)
  113120. */
  113121. enablePopup?: boolean;
  113122. /**
  113123. * Allow the panes to be closed by users (default: true)
  113124. */
  113125. enableClose?: boolean;
  113126. /**
  113127. * Optional list of extensibility entries
  113128. */
  113129. explorerExtensibility?: IExplorerExtensibilityGroup[];
  113130. /**
  113131. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  113132. */
  113133. inspectorURL?: string;
  113134. /**
  113135. * Optional initial tab (default to DebugLayerTab.Properties)
  113136. */
  113137. initialTab?: DebugLayerTab.Properties;
  113138. }
  113139. interface Scene {
  113140. /**
  113141. * @hidden
  113142. * Backing field
  113143. */
  113144. _debugLayer: DebugLayer;
  113145. /**
  113146. * Gets the debug layer (aka Inspector) associated with the scene
  113147. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113148. */
  113149. debugLayer: DebugLayer;
  113150. }
  113151. /**
  113152. * Enum of inspector action tab
  113153. */
  113154. export enum DebugLayerTab {
  113155. /**
  113156. * Properties tag (default)
  113157. */
  113158. Properties = 0,
  113159. /**
  113160. * Debug tab
  113161. */
  113162. Debug = 1,
  113163. /**
  113164. * Statistics tab
  113165. */
  113166. Statistics = 2,
  113167. /**
  113168. * Tools tab
  113169. */
  113170. Tools = 3,
  113171. /**
  113172. * Settings tab
  113173. */
  113174. Settings = 4
  113175. }
  113176. /**
  113177. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113178. * what is happening in your scene
  113179. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113180. */
  113181. export class DebugLayer {
  113182. /**
  113183. * Define the url to get the inspector script from.
  113184. * By default it uses the babylonjs CDN.
  113185. * @ignoreNaming
  113186. */
  113187. static InspectorURL: string;
  113188. private _scene;
  113189. private BJSINSPECTOR;
  113190. private _onPropertyChangedObservable?;
  113191. /**
  113192. * Observable triggered when a property is changed through the inspector.
  113193. */
  113194. readonly onPropertyChangedObservable: any;
  113195. /**
  113196. * Instantiates a new debug layer.
  113197. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113198. * what is happening in your scene
  113199. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113200. * @param scene Defines the scene to inspect
  113201. */
  113202. constructor(scene: Scene);
  113203. /** Creates the inspector window. */
  113204. private _createInspector;
  113205. /**
  113206. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  113207. * @param entity defines the entity to select
  113208. * @param lineContainerTitle defines the specific block to highlight
  113209. */
  113210. select(entity: any, lineContainerTitle?: string): void;
  113211. /** Get the inspector from bundle or global */
  113212. private _getGlobalInspector;
  113213. /**
  113214. * Get if the inspector is visible or not.
  113215. * @returns true if visible otherwise, false
  113216. */
  113217. isVisible(): boolean;
  113218. /**
  113219. * Hide the inspector and close its window.
  113220. */
  113221. hide(): void;
  113222. /**
  113223. * Launch the debugLayer.
  113224. * @param config Define the configuration of the inspector
  113225. * @return a promise fulfilled when the debug layer is visible
  113226. */
  113227. show(config?: IInspectorOptions): Promise<DebugLayer>;
  113228. }
  113229. }
  113230. declare module BABYLON {
  113231. /**
  113232. * Class containing static functions to help procedurally build meshes
  113233. */
  113234. export class BoxBuilder {
  113235. /**
  113236. * Creates a box mesh
  113237. * * The parameter `size` sets the size (float) of each box side (default 1)
  113238. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  113239. * * 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)
  113240. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  113241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113244. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  113245. * @param name defines the name of the mesh
  113246. * @param options defines the options used to create the mesh
  113247. * @param scene defines the hosting scene
  113248. * @returns the box mesh
  113249. */
  113250. static CreateBox(name: string, options: {
  113251. size?: number;
  113252. width?: number;
  113253. height?: number;
  113254. depth?: number;
  113255. faceUV?: Vector4[];
  113256. faceColors?: Color4[];
  113257. sideOrientation?: number;
  113258. frontUVs?: Vector4;
  113259. backUVs?: Vector4;
  113260. wrap?: boolean;
  113261. topBaseAt?: number;
  113262. bottomBaseAt?: number;
  113263. updatable?: boolean;
  113264. }, scene?: Nullable<Scene>): Mesh;
  113265. }
  113266. }
  113267. declare module BABYLON {
  113268. /**
  113269. * Class containing static functions to help procedurally build meshes
  113270. */
  113271. export class SphereBuilder {
  113272. /**
  113273. * Creates a sphere mesh
  113274. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  113275. * * 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`)
  113276. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  113277. * * 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
  113278. * * 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)
  113279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113282. * @param name defines the name of the mesh
  113283. * @param options defines the options used to create the mesh
  113284. * @param scene defines the hosting scene
  113285. * @returns the sphere mesh
  113286. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  113287. */
  113288. static CreateSphere(name: string, options: {
  113289. segments?: number;
  113290. diameter?: number;
  113291. diameterX?: number;
  113292. diameterY?: number;
  113293. diameterZ?: number;
  113294. arc?: number;
  113295. slice?: number;
  113296. sideOrientation?: number;
  113297. frontUVs?: Vector4;
  113298. backUVs?: Vector4;
  113299. updatable?: boolean;
  113300. }, scene?: Nullable<Scene>): Mesh;
  113301. }
  113302. }
  113303. declare module BABYLON.Debug {
  113304. /**
  113305. * Used to show the physics impostor around the specific mesh
  113306. */
  113307. export class PhysicsViewer {
  113308. /** @hidden */
  113309. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  113310. /** @hidden */
  113311. protected _meshes: Array<Nullable<AbstractMesh>>;
  113312. /** @hidden */
  113313. protected _scene: Nullable<Scene>;
  113314. /** @hidden */
  113315. protected _numMeshes: number;
  113316. /** @hidden */
  113317. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  113318. private _renderFunction;
  113319. private _utilityLayer;
  113320. private _debugBoxMesh;
  113321. private _debugSphereMesh;
  113322. private _debugCylinderMesh;
  113323. private _debugMaterial;
  113324. private _debugMeshMeshes;
  113325. /**
  113326. * Creates a new PhysicsViewer
  113327. * @param scene defines the hosting scene
  113328. */
  113329. constructor(scene: Scene);
  113330. /** @hidden */
  113331. protected _updateDebugMeshes(): void;
  113332. /**
  113333. * Renders a specified physic impostor
  113334. * @param impostor defines the impostor to render
  113335. * @param targetMesh defines the mesh represented by the impostor
  113336. * @returns the new debug mesh used to render the impostor
  113337. */
  113338. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  113339. /**
  113340. * Hides a specified physic impostor
  113341. * @param impostor defines the impostor to hide
  113342. */
  113343. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  113344. private _getDebugMaterial;
  113345. private _getDebugBoxMesh;
  113346. private _getDebugSphereMesh;
  113347. private _getDebugCylinderMesh;
  113348. private _getDebugMeshMesh;
  113349. private _getDebugMesh;
  113350. /** Releases all resources */
  113351. dispose(): void;
  113352. }
  113353. }
  113354. declare module BABYLON {
  113355. /**
  113356. * Class containing static functions to help procedurally build meshes
  113357. */
  113358. export class LinesBuilder {
  113359. /**
  113360. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  113361. * * 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
  113362. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  113363. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  113364. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  113365. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  113366. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  113367. * * 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
  113368. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  113369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  113371. * @param name defines the name of the new line system
  113372. * @param options defines the options used to create the line system
  113373. * @param scene defines the hosting scene
  113374. * @returns a new line system mesh
  113375. */
  113376. static CreateLineSystem(name: string, options: {
  113377. lines: Vector3[][];
  113378. updatable?: boolean;
  113379. instance?: Nullable<LinesMesh>;
  113380. colors?: Nullable<Color4[][]>;
  113381. useVertexAlpha?: boolean;
  113382. }, scene: Nullable<Scene>): LinesMesh;
  113383. /**
  113384. * Creates a line mesh
  113385. * 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
  113386. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113387. * * The parameter `points` is an array successive Vector3
  113388. * * 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
  113389. * * The optional parameter `colors` is an array of successive Color4, one per line point
  113390. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  113391. * * When updating an instance, remember that only point positions can change, not the number of points
  113392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  113394. * @param name defines the name of the new line system
  113395. * @param options defines the options used to create the line system
  113396. * @param scene defines the hosting scene
  113397. * @returns a new line mesh
  113398. */
  113399. static CreateLines(name: string, options: {
  113400. points: Vector3[];
  113401. updatable?: boolean;
  113402. instance?: Nullable<LinesMesh>;
  113403. colors?: Color4[];
  113404. useVertexAlpha?: boolean;
  113405. }, scene?: Nullable<Scene>): LinesMesh;
  113406. /**
  113407. * Creates a dashed line mesh
  113408. * * 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
  113409. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113410. * * The parameter `points` is an array successive Vector3
  113411. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  113412. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  113413. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  113414. * * 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
  113415. * * When updating an instance, remember that only point positions can change, not the number of points
  113416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113417. * @param name defines the name of the mesh
  113418. * @param options defines the options used to create the mesh
  113419. * @param scene defines the hosting scene
  113420. * @returns the dashed line mesh
  113421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  113422. */
  113423. static CreateDashedLines(name: string, options: {
  113424. points: Vector3[];
  113425. dashSize?: number;
  113426. gapSize?: number;
  113427. dashNb?: number;
  113428. updatable?: boolean;
  113429. instance?: LinesMesh;
  113430. }, scene?: Nullable<Scene>): LinesMesh;
  113431. }
  113432. }
  113433. declare module BABYLON {
  113434. /**
  113435. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113436. * in order to better appreciate the issue one might have.
  113437. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113438. */
  113439. export class RayHelper {
  113440. /**
  113441. * Defines the ray we are currently tryin to visualize.
  113442. */
  113443. ray: Nullable<Ray>;
  113444. private _renderPoints;
  113445. private _renderLine;
  113446. private _renderFunction;
  113447. private _scene;
  113448. private _updateToMeshFunction;
  113449. private _attachedToMesh;
  113450. private _meshSpaceDirection;
  113451. private _meshSpaceOrigin;
  113452. /**
  113453. * Helper function to create a colored helper in a scene in one line.
  113454. * @param ray Defines the ray we are currently tryin to visualize
  113455. * @param scene Defines the scene the ray is used in
  113456. * @param color Defines the color we want to see the ray in
  113457. * @returns The newly created ray helper.
  113458. */
  113459. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  113460. /**
  113461. * Instantiate a new ray helper.
  113462. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113463. * in order to better appreciate the issue one might have.
  113464. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113465. * @param ray Defines the ray we are currently tryin to visualize
  113466. */
  113467. constructor(ray: Ray);
  113468. /**
  113469. * Shows the ray we are willing to debug.
  113470. * @param scene Defines the scene the ray needs to be rendered in
  113471. * @param color Defines the color the ray needs to be rendered in
  113472. */
  113473. show(scene: Scene, color?: Color3): void;
  113474. /**
  113475. * Hides the ray we are debugging.
  113476. */
  113477. hide(): void;
  113478. private _render;
  113479. /**
  113480. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  113481. * @param mesh Defines the mesh we want the helper attached to
  113482. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  113483. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  113484. * @param length Defines the length of the ray
  113485. */
  113486. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  113487. /**
  113488. * Detach the ray helper from the mesh it has previously been attached to.
  113489. */
  113490. detachFromMesh(): void;
  113491. private _updateToMesh;
  113492. /**
  113493. * Dispose the helper and release its associated resources.
  113494. */
  113495. dispose(): void;
  113496. }
  113497. }
  113498. declare module BABYLON.Debug {
  113499. /**
  113500. * Class used to render a debug view of a given skeleton
  113501. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  113502. */
  113503. export class SkeletonViewer {
  113504. /** defines the skeleton to render */
  113505. skeleton: Skeleton;
  113506. /** defines the mesh attached to the skeleton */
  113507. mesh: AbstractMesh;
  113508. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113509. autoUpdateBonesMatrices: boolean;
  113510. /** defines the rendering group id to use with the viewer */
  113511. renderingGroupId: number;
  113512. /** Gets or sets the color used to render the skeleton */
  113513. color: Color3;
  113514. private _scene;
  113515. private _debugLines;
  113516. private _debugMesh;
  113517. private _isEnabled;
  113518. private _renderFunction;
  113519. private _utilityLayer;
  113520. /**
  113521. * Returns the mesh used to render the bones
  113522. */
  113523. readonly debugMesh: Nullable<LinesMesh>;
  113524. /**
  113525. * Creates a new SkeletonViewer
  113526. * @param skeleton defines the skeleton to render
  113527. * @param mesh defines the mesh attached to the skeleton
  113528. * @param scene defines the hosting scene
  113529. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  113530. * @param renderingGroupId defines the rendering group id to use with the viewer
  113531. */
  113532. constructor(
  113533. /** defines the skeleton to render */
  113534. skeleton: Skeleton,
  113535. /** defines the mesh attached to the skeleton */
  113536. mesh: AbstractMesh, scene: Scene,
  113537. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113538. autoUpdateBonesMatrices?: boolean,
  113539. /** defines the rendering group id to use with the viewer */
  113540. renderingGroupId?: number);
  113541. /** Gets or sets a boolean indicating if the viewer is enabled */
  113542. isEnabled: boolean;
  113543. private _getBonePosition;
  113544. private _getLinesForBonesWithLength;
  113545. private _getLinesForBonesNoLength;
  113546. /** Update the viewer to sync with current skeleton state */
  113547. update(): void;
  113548. /** Release associated resources */
  113549. dispose(): void;
  113550. }
  113551. }
  113552. declare module BABYLON {
  113553. /**
  113554. * Options to create the null engine
  113555. */
  113556. export class NullEngineOptions {
  113557. /**
  113558. * Render width (Default: 512)
  113559. */
  113560. renderWidth: number;
  113561. /**
  113562. * Render height (Default: 256)
  113563. */
  113564. renderHeight: number;
  113565. /**
  113566. * Texture size (Default: 512)
  113567. */
  113568. textureSize: number;
  113569. /**
  113570. * If delta time between frames should be constant
  113571. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113572. */
  113573. deterministicLockstep: boolean;
  113574. /**
  113575. * Maximum about of steps between frames (Default: 4)
  113576. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113577. */
  113578. lockstepMaxSteps: number;
  113579. }
  113580. /**
  113581. * The null engine class provides support for headless version of babylon.js.
  113582. * This can be used in server side scenario or for testing purposes
  113583. */
  113584. export class NullEngine extends Engine {
  113585. private _options;
  113586. /**
  113587. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113588. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113589. * @returns true if engine is in deterministic lock step mode
  113590. */
  113591. isDeterministicLockStep(): boolean;
  113592. /**
  113593. * Gets the max steps when engine is running in deterministic lock step
  113594. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113595. * @returns the max steps
  113596. */
  113597. getLockstepMaxSteps(): number;
  113598. /**
  113599. * Gets the current hardware scaling level.
  113600. * By default the hardware scaling level is computed from the window device ratio.
  113601. * 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.
  113602. * @returns a number indicating the current hardware scaling level
  113603. */
  113604. getHardwareScalingLevel(): number;
  113605. constructor(options?: NullEngineOptions);
  113606. /**
  113607. * Creates a vertex buffer
  113608. * @param vertices the data for the vertex buffer
  113609. * @returns the new WebGL static buffer
  113610. */
  113611. createVertexBuffer(vertices: FloatArray): DataBuffer;
  113612. /**
  113613. * Creates a new index buffer
  113614. * @param indices defines the content of the index buffer
  113615. * @param updatable defines if the index buffer must be updatable
  113616. * @returns a new webGL buffer
  113617. */
  113618. createIndexBuffer(indices: IndicesArray): DataBuffer;
  113619. /**
  113620. * Clear the current render buffer or the current render target (if any is set up)
  113621. * @param color defines the color to use
  113622. * @param backBuffer defines if the back buffer must be cleared
  113623. * @param depth defines if the depth buffer must be cleared
  113624. * @param stencil defines if the stencil buffer must be cleared
  113625. */
  113626. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113627. /**
  113628. * Gets the current render width
  113629. * @param useScreen defines if screen size must be used (or the current render target if any)
  113630. * @returns a number defining the current render width
  113631. */
  113632. getRenderWidth(useScreen?: boolean): number;
  113633. /**
  113634. * Gets the current render height
  113635. * @param useScreen defines if screen size must be used (or the current render target if any)
  113636. * @returns a number defining the current render height
  113637. */
  113638. getRenderHeight(useScreen?: boolean): number;
  113639. /**
  113640. * Set the WebGL's viewport
  113641. * @param viewport defines the viewport element to be used
  113642. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  113643. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  113644. */
  113645. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  113646. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  113647. /**
  113648. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113649. * @param pipelineContext defines the pipeline context to use
  113650. * @param uniformsNames defines the list of uniform names
  113651. * @returns an array of webGL uniform locations
  113652. */
  113653. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113654. /**
  113655. * Gets the lsit of active attributes for a given webGL program
  113656. * @param pipelineContext defines the pipeline context to use
  113657. * @param attributesNames defines the list of attribute names to get
  113658. * @returns an array of indices indicating the offset of each attribute
  113659. */
  113660. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113661. /**
  113662. * Binds an effect to the webGL context
  113663. * @param effect defines the effect to bind
  113664. */
  113665. bindSamplers(effect: Effect): void;
  113666. /**
  113667. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113668. * @param effect defines the effect to activate
  113669. */
  113670. enableEffect(effect: Effect): void;
  113671. /**
  113672. * Set various states to the webGL context
  113673. * @param culling defines backface culling state
  113674. * @param zOffset defines the value to apply to zOffset (0 by default)
  113675. * @param force defines if states must be applied even if cache is up to date
  113676. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113677. */
  113678. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113679. /**
  113680. * Set the value of an uniform to an array of int32
  113681. * @param uniform defines the webGL uniform location where to store the value
  113682. * @param array defines the array of int32 to store
  113683. */
  113684. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113685. /**
  113686. * Set the value of an uniform to an array of int32 (stored as vec2)
  113687. * @param uniform defines the webGL uniform location where to store the value
  113688. * @param array defines the array of int32 to store
  113689. */
  113690. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113691. /**
  113692. * Set the value of an uniform to an array of int32 (stored as vec3)
  113693. * @param uniform defines the webGL uniform location where to store the value
  113694. * @param array defines the array of int32 to store
  113695. */
  113696. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113697. /**
  113698. * Set the value of an uniform to an array of int32 (stored as vec4)
  113699. * @param uniform defines the webGL uniform location where to store the value
  113700. * @param array defines the array of int32 to store
  113701. */
  113702. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113703. /**
  113704. * Set the value of an uniform to an array of float32
  113705. * @param uniform defines the webGL uniform location where to store the value
  113706. * @param array defines the array of float32 to store
  113707. */
  113708. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113709. /**
  113710. * Set the value of an uniform to an array of float32 (stored as vec2)
  113711. * @param uniform defines the webGL uniform location where to store the value
  113712. * @param array defines the array of float32 to store
  113713. */
  113714. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113715. /**
  113716. * Set the value of an uniform to an array of float32 (stored as vec3)
  113717. * @param uniform defines the webGL uniform location where to store the value
  113718. * @param array defines the array of float32 to store
  113719. */
  113720. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113721. /**
  113722. * Set the value of an uniform to an array of float32 (stored as vec4)
  113723. * @param uniform defines the webGL uniform location where to store the value
  113724. * @param array defines the array of float32 to store
  113725. */
  113726. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113727. /**
  113728. * Set the value of an uniform to an array of number
  113729. * @param uniform defines the webGL uniform location where to store the value
  113730. * @param array defines the array of number to store
  113731. */
  113732. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113733. /**
  113734. * Set the value of an uniform to an array of number (stored as vec2)
  113735. * @param uniform defines the webGL uniform location where to store the value
  113736. * @param array defines the array of number to store
  113737. */
  113738. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113739. /**
  113740. * Set the value of an uniform to an array of number (stored as vec3)
  113741. * @param uniform defines the webGL uniform location where to store the value
  113742. * @param array defines the array of number to store
  113743. */
  113744. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113745. /**
  113746. * Set the value of an uniform to an array of number (stored as vec4)
  113747. * @param uniform defines the webGL uniform location where to store the value
  113748. * @param array defines the array of number to store
  113749. */
  113750. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113751. /**
  113752. * Set the value of an uniform to an array of float32 (stored as matrices)
  113753. * @param uniform defines the webGL uniform location where to store the value
  113754. * @param matrices defines the array of float32 to store
  113755. */
  113756. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113757. /**
  113758. * Set the value of an uniform to a matrix (3x3)
  113759. * @param uniform defines the webGL uniform location where to store the value
  113760. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113761. */
  113762. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113763. /**
  113764. * Set the value of an uniform to a matrix (2x2)
  113765. * @param uniform defines the webGL uniform location where to store the value
  113766. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113767. */
  113768. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113769. /**
  113770. * Set the value of an uniform to a number (float)
  113771. * @param uniform defines the webGL uniform location where to store the value
  113772. * @param value defines the float number to store
  113773. */
  113774. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113775. /**
  113776. * Set the value of an uniform to a vec2
  113777. * @param uniform defines the webGL uniform location where to store the value
  113778. * @param x defines the 1st component of the value
  113779. * @param y defines the 2nd component of the value
  113780. */
  113781. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113782. /**
  113783. * Set the value of an uniform to a vec3
  113784. * @param uniform defines the webGL uniform location where to store the value
  113785. * @param x defines the 1st component of the value
  113786. * @param y defines the 2nd component of the value
  113787. * @param z defines the 3rd component of the value
  113788. */
  113789. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113790. /**
  113791. * Set the value of an uniform to a boolean
  113792. * @param uniform defines the webGL uniform location where to store the value
  113793. * @param bool defines the boolean to store
  113794. */
  113795. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113796. /**
  113797. * Set the value of an uniform to a vec4
  113798. * @param uniform defines the webGL uniform location where to store the value
  113799. * @param x defines the 1st component of the value
  113800. * @param y defines the 2nd component of the value
  113801. * @param z defines the 3rd component of the value
  113802. * @param w defines the 4th component of the value
  113803. */
  113804. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113805. /**
  113806. * Sets the current alpha mode
  113807. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113808. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113809. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113810. */
  113811. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113812. /**
  113813. * Bind webGl buffers directly to the webGL context
  113814. * @param vertexBuffers defines the vertex buffer to bind
  113815. * @param indexBuffer defines the index buffer to bind
  113816. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  113817. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  113818. * @param effect defines the effect associated with the vertex buffer
  113819. */
  113820. bindBuffers(vertexBuffers: {
  113821. [key: string]: VertexBuffer;
  113822. }, indexBuffer: DataBuffer, effect: Effect): void;
  113823. /**
  113824. * Force the entire cache to be cleared
  113825. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113826. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113827. */
  113828. wipeCaches(bruteForce?: boolean): void;
  113829. /**
  113830. * Send a draw order
  113831. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113832. * @param indexStart defines the starting index
  113833. * @param indexCount defines the number of index to draw
  113834. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113835. */
  113836. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113837. /**
  113838. * Draw a list of indexed primitives
  113839. * @param fillMode defines the primitive to use
  113840. * @param indexStart defines the starting index
  113841. * @param indexCount defines the number of index to draw
  113842. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113843. */
  113844. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113845. /**
  113846. * Draw a list of unindexed primitives
  113847. * @param fillMode defines the primitive to use
  113848. * @param verticesStart defines the index of first vertex to draw
  113849. * @param verticesCount defines the count of vertices to draw
  113850. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113851. */
  113852. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113853. /** @hidden */
  113854. _createTexture(): WebGLTexture;
  113855. /** @hidden */
  113856. _releaseTexture(texture: InternalTexture): void;
  113857. /**
  113858. * Usually called from Texture.ts.
  113859. * Passed information to create a WebGLTexture
  113860. * @param urlArg defines a value which contains one of the following:
  113861. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113862. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113863. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113864. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113865. * @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)
  113866. * @param scene needed for loading to the correct scene
  113867. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113868. * @param onLoad optional callback to be called upon successful completion
  113869. * @param onError optional callback to be called upon failure
  113870. * @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
  113871. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113872. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113873. * @param forcedExtension defines the extension to use to pick the right loader
  113874. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  113875. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113876. */
  113877. 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;
  113878. /**
  113879. * Creates a new render target texture
  113880. * @param size defines the size of the texture
  113881. * @param options defines the options used to create the texture
  113882. * @returns a new render target texture stored in an InternalTexture
  113883. */
  113884. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  113885. /**
  113886. * Update the sampling mode of a given texture
  113887. * @param samplingMode defines the required sampling mode
  113888. * @param texture defines the texture to update
  113889. */
  113890. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113891. /**
  113892. * Binds the frame buffer to the specified texture.
  113893. * @param texture The texture to render to or null for the default canvas
  113894. * @param faceIndex The face of the texture to render to in case of cube texture
  113895. * @param requiredWidth The width of the target to render to
  113896. * @param requiredHeight The height of the target to render to
  113897. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  113898. * @param depthStencilTexture The depth stencil texture to use to render
  113899. * @param lodLevel defines le lod level to bind to the frame buffer
  113900. */
  113901. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113902. /**
  113903. * Unbind the current render target texture from the webGL context
  113904. * @param texture defines the render target texture to unbind
  113905. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113906. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113907. */
  113908. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113909. /**
  113910. * Creates a dynamic vertex buffer
  113911. * @param vertices the data for the dynamic vertex buffer
  113912. * @returns the new WebGL dynamic buffer
  113913. */
  113914. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  113915. /**
  113916. * Update the content of a dynamic texture
  113917. * @param texture defines the texture to update
  113918. * @param canvas defines the canvas containing the source
  113919. * @param invertY defines if data must be stored with Y axis inverted
  113920. * @param premulAlpha defines if alpha is stored as premultiplied
  113921. * @param format defines the format of the data
  113922. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113923. */
  113924. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  113925. /**
  113926. * Gets a boolean indicating if all created effects are ready
  113927. * @returns true if all effects are ready
  113928. */
  113929. areAllEffectsReady(): boolean;
  113930. /**
  113931. * @hidden
  113932. * Get the current error code of the webGL context
  113933. * @returns the error code
  113934. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113935. */
  113936. getError(): number;
  113937. /** @hidden */
  113938. _getUnpackAlignement(): number;
  113939. /** @hidden */
  113940. _unpackFlipY(value: boolean): void;
  113941. /**
  113942. * Update a dynamic index buffer
  113943. * @param indexBuffer defines the target index buffer
  113944. * @param indices defines the data to update
  113945. * @param offset defines the offset in the target index buffer where update should start
  113946. */
  113947. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  113948. /**
  113949. * Updates a dynamic vertex buffer.
  113950. * @param vertexBuffer the vertex buffer to update
  113951. * @param vertices the data used to update the vertex buffer
  113952. * @param byteOffset the byte offset of the data (optional)
  113953. * @param byteLength the byte length of the data (optional)
  113954. */
  113955. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  113956. /** @hidden */
  113957. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  113958. /** @hidden */
  113959. _bindTexture(channel: number, texture: InternalTexture): void;
  113960. protected _deleteBuffer(buffer: WebGLBuffer): void;
  113961. /**
  113962. * 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
  113963. */
  113964. releaseEffects(): void;
  113965. displayLoadingUI(): void;
  113966. hideLoadingUI(): void;
  113967. /** @hidden */
  113968. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113969. /** @hidden */
  113970. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113971. /** @hidden */
  113972. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113973. /** @hidden */
  113974. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113975. }
  113976. }
  113977. declare module BABYLON {
  113978. /** @hidden */
  113979. export class _OcclusionDataStorage {
  113980. /** @hidden */
  113981. occlusionInternalRetryCounter: number;
  113982. /** @hidden */
  113983. isOcclusionQueryInProgress: boolean;
  113984. /** @hidden */
  113985. isOccluded: boolean;
  113986. /** @hidden */
  113987. occlusionRetryCount: number;
  113988. /** @hidden */
  113989. occlusionType: number;
  113990. /** @hidden */
  113991. occlusionQueryAlgorithmType: number;
  113992. }
  113993. interface Engine {
  113994. /**
  113995. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  113996. * @return the new query
  113997. */
  113998. createQuery(): WebGLQuery;
  113999. /**
  114000. * Delete and release a webGL query
  114001. * @param query defines the query to delete
  114002. * @return the current engine
  114003. */
  114004. deleteQuery(query: WebGLQuery): Engine;
  114005. /**
  114006. * Check if a given query has resolved and got its value
  114007. * @param query defines the query to check
  114008. * @returns true if the query got its value
  114009. */
  114010. isQueryResultAvailable(query: WebGLQuery): boolean;
  114011. /**
  114012. * Gets the value of a given query
  114013. * @param query defines the query to check
  114014. * @returns the value of the query
  114015. */
  114016. getQueryResult(query: WebGLQuery): number;
  114017. /**
  114018. * Initiates an occlusion query
  114019. * @param algorithmType defines the algorithm to use
  114020. * @param query defines the query to use
  114021. * @returns the current engine
  114022. * @see http://doc.babylonjs.com/features/occlusionquery
  114023. */
  114024. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  114025. /**
  114026. * Ends an occlusion query
  114027. * @see http://doc.babylonjs.com/features/occlusionquery
  114028. * @param algorithmType defines the algorithm to use
  114029. * @returns the current engine
  114030. */
  114031. endOcclusionQuery(algorithmType: number): Engine;
  114032. /**
  114033. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  114034. * Please note that only one query can be issued at a time
  114035. * @returns a time token used to track the time span
  114036. */
  114037. startTimeQuery(): Nullable<_TimeToken>;
  114038. /**
  114039. * Ends a time query
  114040. * @param token defines the token used to measure the time span
  114041. * @returns the time spent (in ns)
  114042. */
  114043. endTimeQuery(token: _TimeToken): int;
  114044. /** @hidden */
  114045. _currentNonTimestampToken: Nullable<_TimeToken>;
  114046. /** @hidden */
  114047. _createTimeQuery(): WebGLQuery;
  114048. /** @hidden */
  114049. _deleteTimeQuery(query: WebGLQuery): void;
  114050. /** @hidden */
  114051. _getGlAlgorithmType(algorithmType: number): number;
  114052. /** @hidden */
  114053. _getTimeQueryResult(query: WebGLQuery): any;
  114054. /** @hidden */
  114055. _getTimeQueryAvailability(query: WebGLQuery): any;
  114056. }
  114057. interface AbstractMesh {
  114058. /**
  114059. * Backing filed
  114060. * @hidden
  114061. */
  114062. __occlusionDataStorage: _OcclusionDataStorage;
  114063. /**
  114064. * Access property
  114065. * @hidden
  114066. */
  114067. _occlusionDataStorage: _OcclusionDataStorage;
  114068. /**
  114069. * 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.
  114070. * The default value is -1 which means don't break the query and wait till the result
  114071. * @see http://doc.babylonjs.com/features/occlusionquery
  114072. */
  114073. occlusionRetryCount: number;
  114074. /**
  114075. * 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:
  114076. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  114077. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  114078. * * 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.
  114079. * @see http://doc.babylonjs.com/features/occlusionquery
  114080. */
  114081. occlusionType: number;
  114082. /**
  114083. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  114084. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  114085. * * 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.
  114086. * @see http://doc.babylonjs.com/features/occlusionquery
  114087. */
  114088. occlusionQueryAlgorithmType: number;
  114089. /**
  114090. * 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
  114091. * @see http://doc.babylonjs.com/features/occlusionquery
  114092. */
  114093. isOccluded: boolean;
  114094. /**
  114095. * Flag to check the progress status of the query
  114096. * @see http://doc.babylonjs.com/features/occlusionquery
  114097. */
  114098. isOcclusionQueryInProgress: boolean;
  114099. }
  114100. }
  114101. declare module BABYLON {
  114102. /** @hidden */
  114103. export var _forceTransformFeedbackToBundle: boolean;
  114104. interface Engine {
  114105. /**
  114106. * Creates a webGL transform feedback object
  114107. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  114108. * @returns the webGL transform feedback object
  114109. */
  114110. createTransformFeedback(): WebGLTransformFeedback;
  114111. /**
  114112. * Delete a webGL transform feedback object
  114113. * @param value defines the webGL transform feedback object to delete
  114114. */
  114115. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  114116. /**
  114117. * Bind a webGL transform feedback object to the webgl context
  114118. * @param value defines the webGL transform feedback object to bind
  114119. */
  114120. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  114121. /**
  114122. * Begins a transform feedback operation
  114123. * @param usePoints defines if points or triangles must be used
  114124. */
  114125. beginTransformFeedback(usePoints: boolean): void;
  114126. /**
  114127. * Ends a transform feedback operation
  114128. */
  114129. endTransformFeedback(): void;
  114130. /**
  114131. * Specify the varyings to use with transform feedback
  114132. * @param program defines the associated webGL program
  114133. * @param value defines the list of strings representing the varying names
  114134. */
  114135. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  114136. /**
  114137. * Bind a webGL buffer for a transform feedback operation
  114138. * @param value defines the webGL buffer to bind
  114139. */
  114140. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  114141. }
  114142. }
  114143. declare module BABYLON {
  114144. /**
  114145. * Creation options of the multi render target texture.
  114146. */
  114147. export interface IMultiRenderTargetOptions {
  114148. /**
  114149. * Define if the texture needs to create mip maps after render.
  114150. */
  114151. generateMipMaps?: boolean;
  114152. /**
  114153. * Define the types of all the draw buffers we want to create
  114154. */
  114155. types?: number[];
  114156. /**
  114157. * Define the sampling modes of all the draw buffers we want to create
  114158. */
  114159. samplingModes?: number[];
  114160. /**
  114161. * Define if a depth buffer is required
  114162. */
  114163. generateDepthBuffer?: boolean;
  114164. /**
  114165. * Define if a stencil buffer is required
  114166. */
  114167. generateStencilBuffer?: boolean;
  114168. /**
  114169. * Define if a depth texture is required instead of a depth buffer
  114170. */
  114171. generateDepthTexture?: boolean;
  114172. /**
  114173. * Define the number of desired draw buffers
  114174. */
  114175. textureCount?: number;
  114176. /**
  114177. * Define if aspect ratio should be adapted to the texture or stay the scene one
  114178. */
  114179. doNotChangeAspectRatio?: boolean;
  114180. /**
  114181. * Define the default type of the buffers we are creating
  114182. */
  114183. defaultType?: number;
  114184. }
  114185. /**
  114186. * A multi render target, like a render target provides the ability to render to a texture.
  114187. * Unlike the render target, it can render to several draw buffers in one draw.
  114188. * This is specially interesting in deferred rendering or for any effects requiring more than
  114189. * just one color from a single pass.
  114190. */
  114191. export class MultiRenderTarget extends RenderTargetTexture {
  114192. private _internalTextures;
  114193. private _textures;
  114194. private _multiRenderTargetOptions;
  114195. /**
  114196. * Get if draw buffers are currently supported by the used hardware and browser.
  114197. */
  114198. readonly isSupported: boolean;
  114199. /**
  114200. * Get the list of textures generated by the multi render target.
  114201. */
  114202. readonly textures: Texture[];
  114203. /**
  114204. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  114205. */
  114206. readonly depthTexture: Texture;
  114207. /**
  114208. * Set the wrapping mode on U of all the textures we are rendering to.
  114209. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114210. */
  114211. wrapU: number;
  114212. /**
  114213. * Set the wrapping mode on V of all the textures we are rendering to.
  114214. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114215. */
  114216. wrapV: number;
  114217. /**
  114218. * Instantiate a new multi render target texture.
  114219. * A multi render target, like a render target provides the ability to render to a texture.
  114220. * Unlike the render target, it can render to several draw buffers in one draw.
  114221. * This is specially interesting in deferred rendering or for any effects requiring more than
  114222. * just one color from a single pass.
  114223. * @param name Define the name of the texture
  114224. * @param size Define the size of the buffers to render to
  114225. * @param count Define the number of target we are rendering into
  114226. * @param scene Define the scene the texture belongs to
  114227. * @param options Define the options used to create the multi render target
  114228. */
  114229. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  114230. /** @hidden */
  114231. _rebuild(): void;
  114232. private _createInternalTextures;
  114233. private _createTextures;
  114234. /**
  114235. * Define the number of samples used if MSAA is enabled.
  114236. */
  114237. samples: number;
  114238. /**
  114239. * Resize all the textures in the multi render target.
  114240. * Be carrefull as it will recreate all the data in the new texture.
  114241. * @param size Define the new size
  114242. */
  114243. resize(size: any): void;
  114244. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  114245. /**
  114246. * Dispose the render targets and their associated resources
  114247. */
  114248. dispose(): void;
  114249. /**
  114250. * Release all the underlying texture used as draw buffers.
  114251. */
  114252. releaseInternalTextures(): void;
  114253. }
  114254. }
  114255. declare module BABYLON {
  114256. interface ThinEngine {
  114257. /**
  114258. * Unbind a list of render target textures from the webGL context
  114259. * This is used only when drawBuffer extension or webGL2 are active
  114260. * @param textures defines the render target textures to unbind
  114261. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114262. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114263. */
  114264. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  114265. /**
  114266. * Create a multi render target texture
  114267. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  114268. * @param size defines the size of the texture
  114269. * @param options defines the creation options
  114270. * @returns the cube texture as an InternalTexture
  114271. */
  114272. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  114273. /**
  114274. * Update the sample count for a given multiple render target texture
  114275. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114276. * @param textures defines the textures to update
  114277. * @param samples defines the sample count to set
  114278. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114279. */
  114280. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  114281. }
  114282. }
  114283. declare module BABYLON {
  114284. /**
  114285. * Class used to define an additional view for the engine
  114286. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114287. */
  114288. export class EngineView {
  114289. /** Defines the canvas where to render the view */
  114290. target: HTMLCanvasElement;
  114291. /** Defines an optional camera used to render the view (will use active camera else) */
  114292. camera?: Camera;
  114293. }
  114294. interface Engine {
  114295. /**
  114296. * Gets or sets the HTML element to use for attaching events
  114297. */
  114298. inputElement: Nullable<HTMLElement>;
  114299. /**
  114300. * Gets the current engine view
  114301. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114302. */
  114303. activeView: Nullable<EngineView>;
  114304. /** Gets or sets the list of views */
  114305. views: EngineView[];
  114306. /**
  114307. * Register a new child canvas
  114308. * @param canvas defines the canvas to register
  114309. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  114310. * @returns the associated view
  114311. */
  114312. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  114313. /**
  114314. * Remove a registered child canvas
  114315. * @param canvas defines the canvas to remove
  114316. * @returns the current engine
  114317. */
  114318. unRegisterView(canvas: HTMLCanvasElement): Engine;
  114319. }
  114320. }
  114321. declare module BABYLON {
  114322. /**
  114323. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  114324. */
  114325. export interface CubeMapInfo {
  114326. /**
  114327. * The pixel array for the front face.
  114328. * This is stored in format, left to right, up to down format.
  114329. */
  114330. front: Nullable<ArrayBufferView>;
  114331. /**
  114332. * The pixel array for the back face.
  114333. * This is stored in format, left to right, up to down format.
  114334. */
  114335. back: Nullable<ArrayBufferView>;
  114336. /**
  114337. * The pixel array for the left face.
  114338. * This is stored in format, left to right, up to down format.
  114339. */
  114340. left: Nullable<ArrayBufferView>;
  114341. /**
  114342. * The pixel array for the right face.
  114343. * This is stored in format, left to right, up to down format.
  114344. */
  114345. right: Nullable<ArrayBufferView>;
  114346. /**
  114347. * The pixel array for the up face.
  114348. * This is stored in format, left to right, up to down format.
  114349. */
  114350. up: Nullable<ArrayBufferView>;
  114351. /**
  114352. * The pixel array for the down face.
  114353. * This is stored in format, left to right, up to down format.
  114354. */
  114355. down: Nullable<ArrayBufferView>;
  114356. /**
  114357. * The size of the cubemap stored.
  114358. *
  114359. * Each faces will be size * size pixels.
  114360. */
  114361. size: number;
  114362. /**
  114363. * The format of the texture.
  114364. *
  114365. * RGBA, RGB.
  114366. */
  114367. format: number;
  114368. /**
  114369. * The type of the texture data.
  114370. *
  114371. * UNSIGNED_INT, FLOAT.
  114372. */
  114373. type: number;
  114374. /**
  114375. * Specifies whether the texture is in gamma space.
  114376. */
  114377. gammaSpace: boolean;
  114378. }
  114379. /**
  114380. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  114381. */
  114382. export class PanoramaToCubeMapTools {
  114383. private static FACE_FRONT;
  114384. private static FACE_BACK;
  114385. private static FACE_RIGHT;
  114386. private static FACE_LEFT;
  114387. private static FACE_DOWN;
  114388. private static FACE_UP;
  114389. /**
  114390. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  114391. *
  114392. * @param float32Array The source data.
  114393. * @param inputWidth The width of the input panorama.
  114394. * @param inputHeight The height of the input panorama.
  114395. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  114396. * @return The cubemap data
  114397. */
  114398. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  114399. private static CreateCubemapTexture;
  114400. private static CalcProjectionSpherical;
  114401. }
  114402. }
  114403. declare module BABYLON {
  114404. /**
  114405. * Helper class dealing with the extraction of spherical polynomial dataArray
  114406. * from a cube map.
  114407. */
  114408. export class CubeMapToSphericalPolynomialTools {
  114409. private static FileFaces;
  114410. /**
  114411. * Converts a texture to the according Spherical Polynomial data.
  114412. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114413. *
  114414. * @param texture The texture to extract the information from.
  114415. * @return The Spherical Polynomial data.
  114416. */
  114417. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  114418. /**
  114419. * Converts a cubemap to the according Spherical Polynomial data.
  114420. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114421. *
  114422. * @param cubeInfo The Cube map to extract the information from.
  114423. * @return The Spherical Polynomial data.
  114424. */
  114425. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  114426. }
  114427. }
  114428. declare module BABYLON {
  114429. interface BaseTexture {
  114430. /**
  114431. * Get the polynomial representation of the texture data.
  114432. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  114433. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  114434. */
  114435. sphericalPolynomial: Nullable<SphericalPolynomial>;
  114436. }
  114437. }
  114438. declare module BABYLON {
  114439. /** @hidden */
  114440. export var rgbdEncodePixelShader: {
  114441. name: string;
  114442. shader: string;
  114443. };
  114444. }
  114445. declare module BABYLON {
  114446. /** @hidden */
  114447. export var rgbdDecodePixelShader: {
  114448. name: string;
  114449. shader: string;
  114450. };
  114451. }
  114452. declare module BABYLON {
  114453. /**
  114454. * Raw texture data and descriptor sufficient for WebGL texture upload
  114455. */
  114456. export interface EnvironmentTextureInfo {
  114457. /**
  114458. * Version of the environment map
  114459. */
  114460. version: number;
  114461. /**
  114462. * Width of image
  114463. */
  114464. width: number;
  114465. /**
  114466. * Irradiance information stored in the file.
  114467. */
  114468. irradiance: any;
  114469. /**
  114470. * Specular information stored in the file.
  114471. */
  114472. specular: any;
  114473. }
  114474. /**
  114475. * Defines One Image in the file. It requires only the position in the file
  114476. * as well as the length.
  114477. */
  114478. interface BufferImageData {
  114479. /**
  114480. * Length of the image data.
  114481. */
  114482. length: number;
  114483. /**
  114484. * Position of the data from the null terminator delimiting the end of the JSON.
  114485. */
  114486. position: number;
  114487. }
  114488. /**
  114489. * Defines the specular data enclosed in the file.
  114490. * This corresponds to the version 1 of the data.
  114491. */
  114492. export interface EnvironmentTextureSpecularInfoV1 {
  114493. /**
  114494. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  114495. */
  114496. specularDataPosition?: number;
  114497. /**
  114498. * This contains all the images data needed to reconstruct the cubemap.
  114499. */
  114500. mipmaps: Array<BufferImageData>;
  114501. /**
  114502. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  114503. */
  114504. lodGenerationScale: number;
  114505. }
  114506. /**
  114507. * Sets of helpers addressing the serialization and deserialization of environment texture
  114508. * stored in a BabylonJS env file.
  114509. * Those files are usually stored as .env files.
  114510. */
  114511. export class EnvironmentTextureTools {
  114512. /**
  114513. * Magic number identifying the env file.
  114514. */
  114515. private static _MagicBytes;
  114516. /**
  114517. * Gets the environment info from an env file.
  114518. * @param data The array buffer containing the .env bytes.
  114519. * @returns the environment file info (the json header) if successfully parsed.
  114520. */
  114521. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  114522. /**
  114523. * Creates an environment texture from a loaded cube texture.
  114524. * @param texture defines the cube texture to convert in env file
  114525. * @return a promise containing the environment data if succesfull.
  114526. */
  114527. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  114528. /**
  114529. * Creates a JSON representation of the spherical data.
  114530. * @param texture defines the texture containing the polynomials
  114531. * @return the JSON representation of the spherical info
  114532. */
  114533. private static _CreateEnvTextureIrradiance;
  114534. /**
  114535. * Creates the ArrayBufferViews used for initializing environment texture image data.
  114536. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  114537. * @param info parameters that determine what views will be created for accessing the underlying buffer
  114538. * @return the views described by info providing access to the underlying buffer
  114539. */
  114540. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  114541. /**
  114542. * Uploads the texture info contained in the env file to the GPU.
  114543. * @param texture defines the internal texture to upload to
  114544. * @param arrayBuffer defines the buffer cotaining the data to load
  114545. * @param info defines the texture info retrieved through the GetEnvInfo method
  114546. * @returns a promise
  114547. */
  114548. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  114549. private static _OnImageReadyAsync;
  114550. /**
  114551. * Uploads the levels of image data to the GPU.
  114552. * @param texture defines the internal texture to upload to
  114553. * @param imageData defines the array buffer views of image data [mipmap][face]
  114554. * @returns a promise
  114555. */
  114556. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  114557. /**
  114558. * Uploads spherical polynomials information to the texture.
  114559. * @param texture defines the texture we are trying to upload the information to
  114560. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  114561. */
  114562. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  114563. /** @hidden */
  114564. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114565. }
  114566. }
  114567. declare module BABYLON {
  114568. /**
  114569. * Contains position and normal vectors for a vertex
  114570. */
  114571. export class PositionNormalVertex {
  114572. /** the position of the vertex (defaut: 0,0,0) */
  114573. position: Vector3;
  114574. /** the normal of the vertex (defaut: 0,1,0) */
  114575. normal: Vector3;
  114576. /**
  114577. * Creates a PositionNormalVertex
  114578. * @param position the position of the vertex (defaut: 0,0,0)
  114579. * @param normal the normal of the vertex (defaut: 0,1,0)
  114580. */
  114581. constructor(
  114582. /** the position of the vertex (defaut: 0,0,0) */
  114583. position?: Vector3,
  114584. /** the normal of the vertex (defaut: 0,1,0) */
  114585. normal?: Vector3);
  114586. /**
  114587. * Clones the PositionNormalVertex
  114588. * @returns the cloned PositionNormalVertex
  114589. */
  114590. clone(): PositionNormalVertex;
  114591. }
  114592. /**
  114593. * Contains position, normal and uv vectors for a vertex
  114594. */
  114595. export class PositionNormalTextureVertex {
  114596. /** the position of the vertex (defaut: 0,0,0) */
  114597. position: Vector3;
  114598. /** the normal of the vertex (defaut: 0,1,0) */
  114599. normal: Vector3;
  114600. /** the uv of the vertex (default: 0,0) */
  114601. uv: Vector2;
  114602. /**
  114603. * Creates a PositionNormalTextureVertex
  114604. * @param position the position of the vertex (defaut: 0,0,0)
  114605. * @param normal the normal of the vertex (defaut: 0,1,0)
  114606. * @param uv the uv of the vertex (default: 0,0)
  114607. */
  114608. constructor(
  114609. /** the position of the vertex (defaut: 0,0,0) */
  114610. position?: Vector3,
  114611. /** the normal of the vertex (defaut: 0,1,0) */
  114612. normal?: Vector3,
  114613. /** the uv of the vertex (default: 0,0) */
  114614. uv?: Vector2);
  114615. /**
  114616. * Clones the PositionNormalTextureVertex
  114617. * @returns the cloned PositionNormalTextureVertex
  114618. */
  114619. clone(): PositionNormalTextureVertex;
  114620. }
  114621. }
  114622. declare module BABYLON {
  114623. /** @hidden */
  114624. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  114625. private _genericAttributeLocation;
  114626. private _varyingLocationCount;
  114627. private _varyingLocationMap;
  114628. private _replacements;
  114629. private _textureCount;
  114630. private _uniforms;
  114631. lineProcessor(line: string): string;
  114632. attributeProcessor(attribute: string): string;
  114633. varyingProcessor(varying: string, isFragment: boolean): string;
  114634. uniformProcessor(uniform: string): string;
  114635. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  114636. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114637. }
  114638. }
  114639. declare module BABYLON {
  114640. /**
  114641. * Container for accessors for natively-stored mesh data buffers.
  114642. */
  114643. class NativeDataBuffer extends DataBuffer {
  114644. /**
  114645. * Accessor value used to identify/retrieve a natively-stored index buffer.
  114646. */
  114647. nativeIndexBuffer?: any;
  114648. /**
  114649. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  114650. */
  114651. nativeVertexBuffer?: any;
  114652. }
  114653. /** @hidden */
  114654. class NativeTexture extends InternalTexture {
  114655. getInternalTexture(): InternalTexture;
  114656. getViewCount(): number;
  114657. }
  114658. /** @hidden */
  114659. export class NativeEngine extends Engine {
  114660. private readonly _native;
  114661. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  114662. private readonly INVALID_HANDLE;
  114663. getHardwareScalingLevel(): number;
  114664. constructor();
  114665. /**
  114666. * Can be used to override the current requestAnimationFrame requester.
  114667. * @hidden
  114668. */
  114669. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114670. /**
  114671. * Override default engine behavior.
  114672. * @param color
  114673. * @param backBuffer
  114674. * @param depth
  114675. * @param stencil
  114676. */
  114677. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114678. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114679. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  114680. createVertexBuffer(data: DataArray): NativeDataBuffer;
  114681. recordVertexArrayObject(vertexBuffers: {
  114682. [key: string]: VertexBuffer;
  114683. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114684. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114685. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114686. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114687. /**
  114688. * Draw a list of indexed primitives
  114689. * @param fillMode defines the primitive to use
  114690. * @param indexStart defines the starting index
  114691. * @param indexCount defines the number of index to draw
  114692. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114693. */
  114694. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114695. /**
  114696. * Draw a list of unindexed primitives
  114697. * @param fillMode defines the primitive to use
  114698. * @param verticesStart defines the index of first vertex to draw
  114699. * @param verticesCount defines the count of vertices to draw
  114700. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114701. */
  114702. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114703. createPipelineContext(): IPipelineContext;
  114704. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114705. /** @hidden */
  114706. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114707. /** @hidden */
  114708. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114709. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114710. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114711. protected _setProgram(program: WebGLProgram): void;
  114712. _releaseEffect(effect: Effect): void;
  114713. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114714. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  114715. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  114716. bindSamplers(effect: Effect): void;
  114717. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  114718. getRenderWidth(useScreen?: boolean): number;
  114719. getRenderHeight(useScreen?: boolean): number;
  114720. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  114721. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114722. /**
  114723. * Set the z offset to apply to current rendering
  114724. * @param value defines the offset to apply
  114725. */
  114726. setZOffset(value: number): void;
  114727. /**
  114728. * Gets the current value of the zOffset
  114729. * @returns the current zOffset state
  114730. */
  114731. getZOffset(): number;
  114732. /**
  114733. * Enable or disable depth buffering
  114734. * @param enable defines the state to set
  114735. */
  114736. setDepthBuffer(enable: boolean): void;
  114737. /**
  114738. * Gets a boolean indicating if depth writing is enabled
  114739. * @returns the current depth writing state
  114740. */
  114741. getDepthWrite(): boolean;
  114742. /**
  114743. * Enable or disable depth writing
  114744. * @param enable defines the state to set
  114745. */
  114746. setDepthWrite(enable: boolean): void;
  114747. /**
  114748. * Enable or disable color writing
  114749. * @param enable defines the state to set
  114750. */
  114751. setColorWrite(enable: boolean): void;
  114752. /**
  114753. * Gets a boolean indicating if color writing is enabled
  114754. * @returns the current color writing state
  114755. */
  114756. getColorWrite(): boolean;
  114757. /**
  114758. * Sets alpha constants used by some alpha blending modes
  114759. * @param r defines the red component
  114760. * @param g defines the green component
  114761. * @param b defines the blue component
  114762. * @param a defines the alpha component
  114763. */
  114764. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114765. /**
  114766. * Sets the current alpha mode
  114767. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  114768. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114769. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114770. */
  114771. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114772. /**
  114773. * Gets the current alpha mode
  114774. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114775. * @returns the current alpha mode
  114776. */
  114777. getAlphaMode(): number;
  114778. setInt(uniform: WebGLUniformLocation, int: number): void;
  114779. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  114780. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  114781. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  114782. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  114783. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  114784. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  114785. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  114786. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  114787. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  114788. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  114789. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  114790. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  114791. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  114792. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114793. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114794. setFloat(uniform: WebGLUniformLocation, value: number): void;
  114795. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  114796. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  114797. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  114798. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  114799. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  114800. wipeCaches(bruteForce?: boolean): void;
  114801. _createTexture(): WebGLTexture;
  114802. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114803. /**
  114804. * Usually called from BABYLON.Texture.ts.
  114805. * Passed information to create a WebGLTexture
  114806. * @param urlArg defines a value which contains one of the following:
  114807. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114808. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114809. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114810. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114811. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  114812. * @param scene needed for loading to the correct scene
  114813. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  114814. * @param onLoad optional callback to be called upon successful completion
  114815. * @param onError optional callback to be called upon failure
  114816. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  114817. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114818. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114819. * @param forcedExtension defines the extension to use to pick the right loader
  114820. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114821. */
  114822. 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;
  114823. /**
  114824. * Creates a cube texture
  114825. * @param rootUrl defines the url where the files to load is located
  114826. * @param scene defines the current scene
  114827. * @param files defines the list of files to load (1 per face)
  114828. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  114829. * @param onLoad defines an optional callback raised when the texture is loaded
  114830. * @param onError defines an optional callback raised if there is an issue to load the texture
  114831. * @param format defines the format of the data
  114832. * @param forcedExtension defines the extension to use to pick the right loader
  114833. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  114834. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114835. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114836. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  114837. * @returns the cube texture as an InternalTexture
  114838. */
  114839. 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;
  114840. private _getSamplingFilter;
  114841. private static _GetNativeTextureFormat;
  114842. createRenderTargetTexture(size: number | {
  114843. width: number;
  114844. height: number;
  114845. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  114846. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  114847. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  114848. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114849. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114850. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114851. /**
  114852. * Updates a dynamic vertex buffer.
  114853. * @param vertexBuffer the vertex buffer to update
  114854. * @param data the data used to update the vertex buffer
  114855. * @param byteOffset the byte offset of the data (optional)
  114856. * @param byteLength the byte length of the data (optional)
  114857. */
  114858. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114859. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114860. private _updateAnisotropicLevel;
  114861. private _getAddressMode;
  114862. /** @hidden */
  114863. _bindTexture(channel: number, texture: InternalTexture): void;
  114864. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  114865. releaseEffects(): void;
  114866. /** @hidden */
  114867. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114868. /** @hidden */
  114869. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114870. /** @hidden */
  114871. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114872. /** @hidden */
  114873. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  114874. }
  114875. }
  114876. declare module BABYLON {
  114877. /**
  114878. * Gather the list of clipboard event types as constants.
  114879. */
  114880. export class ClipboardEventTypes {
  114881. /**
  114882. * The clipboard event is fired when a copy command is active (pressed).
  114883. */
  114884. static readonly COPY: number;
  114885. /**
  114886. * The clipboard event is fired when a cut command is active (pressed).
  114887. */
  114888. static readonly CUT: number;
  114889. /**
  114890. * The clipboard event is fired when a paste command is active (pressed).
  114891. */
  114892. static readonly PASTE: number;
  114893. }
  114894. /**
  114895. * This class is used to store clipboard related info for the onClipboardObservable event.
  114896. */
  114897. export class ClipboardInfo {
  114898. /**
  114899. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114900. */
  114901. type: number;
  114902. /**
  114903. * Defines the related dom event
  114904. */
  114905. event: ClipboardEvent;
  114906. /**
  114907. *Creates an instance of ClipboardInfo.
  114908. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  114909. * @param event Defines the related dom event
  114910. */
  114911. constructor(
  114912. /**
  114913. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114914. */
  114915. type: number,
  114916. /**
  114917. * Defines the related dom event
  114918. */
  114919. event: ClipboardEvent);
  114920. /**
  114921. * Get the clipboard event's type from the keycode.
  114922. * @param keyCode Defines the keyCode for the current keyboard event.
  114923. * @return {number}
  114924. */
  114925. static GetTypeFromCharacter(keyCode: number): number;
  114926. }
  114927. }
  114928. declare module BABYLON {
  114929. /**
  114930. * Google Daydream controller
  114931. */
  114932. export class DaydreamController extends WebVRController {
  114933. /**
  114934. * Base Url for the controller model.
  114935. */
  114936. static MODEL_BASE_URL: string;
  114937. /**
  114938. * File name for the controller model.
  114939. */
  114940. static MODEL_FILENAME: string;
  114941. /**
  114942. * Gamepad Id prefix used to identify Daydream Controller.
  114943. */
  114944. static readonly GAMEPAD_ID_PREFIX: string;
  114945. /**
  114946. * Creates a new DaydreamController from a gamepad
  114947. * @param vrGamepad the gamepad that the controller should be created from
  114948. */
  114949. constructor(vrGamepad: any);
  114950. /**
  114951. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114952. * @param scene scene in which to add meshes
  114953. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114954. */
  114955. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114956. /**
  114957. * Called once for each button that changed state since the last frame
  114958. * @param buttonIdx Which button index changed
  114959. * @param state New state of the button
  114960. * @param changes Which properties on the state changed since last frame
  114961. */
  114962. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114963. }
  114964. }
  114965. declare module BABYLON {
  114966. /**
  114967. * Gear VR Controller
  114968. */
  114969. export class GearVRController extends WebVRController {
  114970. /**
  114971. * Base Url for the controller model.
  114972. */
  114973. static MODEL_BASE_URL: string;
  114974. /**
  114975. * File name for the controller model.
  114976. */
  114977. static MODEL_FILENAME: string;
  114978. /**
  114979. * Gamepad Id prefix used to identify this controller.
  114980. */
  114981. static readonly GAMEPAD_ID_PREFIX: string;
  114982. private readonly _buttonIndexToObservableNameMap;
  114983. /**
  114984. * Creates a new GearVRController from a gamepad
  114985. * @param vrGamepad the gamepad that the controller should be created from
  114986. */
  114987. constructor(vrGamepad: any);
  114988. /**
  114989. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114990. * @param scene scene in which to add meshes
  114991. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114992. */
  114993. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114994. /**
  114995. * Called once for each button that changed state since the last frame
  114996. * @param buttonIdx Which button index changed
  114997. * @param state New state of the button
  114998. * @param changes Which properties on the state changed since last frame
  114999. */
  115000. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  115001. }
  115002. }
  115003. declare module BABYLON {
  115004. /**
  115005. * Class containing static functions to help procedurally build meshes
  115006. */
  115007. export class PolyhedronBuilder {
  115008. /**
  115009. * Creates a polyhedron mesh
  115010. * * 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
  115011. * * The parameter `size` (positive float, default 1) sets the polygon size
  115012. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115013. * * 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`
  115014. * * 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
  115015. * * 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)`)
  115016. * * 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
  115017. * * 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
  115018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115021. * @param name defines the name of the mesh
  115022. * @param options defines the options used to create the mesh
  115023. * @param scene defines the hosting scene
  115024. * @returns the polyhedron mesh
  115025. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115026. */
  115027. static CreatePolyhedron(name: string, options: {
  115028. type?: number;
  115029. size?: number;
  115030. sizeX?: number;
  115031. sizeY?: number;
  115032. sizeZ?: number;
  115033. custom?: any;
  115034. faceUV?: Vector4[];
  115035. faceColors?: Color4[];
  115036. flat?: boolean;
  115037. updatable?: boolean;
  115038. sideOrientation?: number;
  115039. frontUVs?: Vector4;
  115040. backUVs?: Vector4;
  115041. }, scene?: Nullable<Scene>): Mesh;
  115042. }
  115043. }
  115044. declare module BABYLON {
  115045. /**
  115046. * Gizmo that enables scaling a mesh along 3 axis
  115047. */
  115048. export class ScaleGizmo extends Gizmo {
  115049. /**
  115050. * Internal gizmo used for interactions on the x axis
  115051. */
  115052. xGizmo: AxisScaleGizmo;
  115053. /**
  115054. * Internal gizmo used for interactions on the y axis
  115055. */
  115056. yGizmo: AxisScaleGizmo;
  115057. /**
  115058. * Internal gizmo used for interactions on the z axis
  115059. */
  115060. zGizmo: AxisScaleGizmo;
  115061. /**
  115062. * Internal gizmo used to scale all axis equally
  115063. */
  115064. uniformScaleGizmo: AxisScaleGizmo;
  115065. private _meshAttached;
  115066. private _updateGizmoRotationToMatchAttachedMesh;
  115067. private _snapDistance;
  115068. private _scaleRatio;
  115069. private _uniformScalingMesh;
  115070. private _octahedron;
  115071. private _sensitivity;
  115072. /** Fires an event when any of it's sub gizmos are dragged */
  115073. onDragStartObservable: Observable<unknown>;
  115074. /** Fires an event when any of it's sub gizmos are released from dragging */
  115075. onDragEndObservable: Observable<unknown>;
  115076. attachedMesh: Nullable<AbstractMesh>;
  115077. /**
  115078. * Creates a ScaleGizmo
  115079. * @param gizmoLayer The utility layer the gizmo will be added to
  115080. */
  115081. constructor(gizmoLayer?: UtilityLayerRenderer);
  115082. updateGizmoRotationToMatchAttachedMesh: boolean;
  115083. /**
  115084. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115085. */
  115086. snapDistance: number;
  115087. /**
  115088. * Ratio for the scale of the gizmo (Default: 1)
  115089. */
  115090. scaleRatio: number;
  115091. /**
  115092. * Sensitivity factor for dragging (Default: 1)
  115093. */
  115094. sensitivity: number;
  115095. /**
  115096. * Disposes of the gizmo
  115097. */
  115098. dispose(): void;
  115099. }
  115100. }
  115101. declare module BABYLON {
  115102. /**
  115103. * Single axis scale gizmo
  115104. */
  115105. export class AxisScaleGizmo extends Gizmo {
  115106. /**
  115107. * Drag behavior responsible for the gizmos dragging interactions
  115108. */
  115109. dragBehavior: PointerDragBehavior;
  115110. private _pointerObserver;
  115111. /**
  115112. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115113. */
  115114. snapDistance: number;
  115115. /**
  115116. * Event that fires each time the gizmo snaps to a new location.
  115117. * * snapDistance is the the change in distance
  115118. */
  115119. onSnapObservable: Observable<{
  115120. snapDistance: number;
  115121. }>;
  115122. /**
  115123. * If the scaling operation should be done on all axis (default: false)
  115124. */
  115125. uniformScaling: boolean;
  115126. /**
  115127. * Custom sensitivity value for the drag strength
  115128. */
  115129. sensitivity: number;
  115130. private _isEnabled;
  115131. private _parent;
  115132. private _arrow;
  115133. private _coloredMaterial;
  115134. private _hoverMaterial;
  115135. /**
  115136. * Creates an AxisScaleGizmo
  115137. * @param gizmoLayer The utility layer the gizmo will be added to
  115138. * @param dragAxis The axis which the gizmo will be able to scale on
  115139. * @param color The color of the gizmo
  115140. */
  115141. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  115142. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115143. /**
  115144. * If the gizmo is enabled
  115145. */
  115146. isEnabled: boolean;
  115147. /**
  115148. * Disposes of the gizmo
  115149. */
  115150. dispose(): void;
  115151. /**
  115152. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115153. * @param mesh The mesh to replace the default mesh of the gizmo
  115154. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  115155. */
  115156. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  115157. }
  115158. }
  115159. declare module BABYLON {
  115160. /**
  115161. * Bounding box gizmo
  115162. */
  115163. export class BoundingBoxGizmo extends Gizmo {
  115164. private _lineBoundingBox;
  115165. private _rotateSpheresParent;
  115166. private _scaleBoxesParent;
  115167. private _boundingDimensions;
  115168. private _renderObserver;
  115169. private _pointerObserver;
  115170. private _scaleDragSpeed;
  115171. private _tmpQuaternion;
  115172. private _tmpVector;
  115173. private _tmpRotationMatrix;
  115174. /**
  115175. * 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)
  115176. */
  115177. ignoreChildren: boolean;
  115178. /**
  115179. * 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)
  115180. */
  115181. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  115182. /**
  115183. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  115184. */
  115185. rotationSphereSize: number;
  115186. /**
  115187. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  115188. */
  115189. scaleBoxSize: number;
  115190. /**
  115191. * 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)
  115192. */
  115193. fixedDragMeshScreenSize: boolean;
  115194. /**
  115195. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  115196. */
  115197. fixedDragMeshScreenSizeDistanceFactor: number;
  115198. /**
  115199. * Fired when a rotation sphere or scale box is dragged
  115200. */
  115201. onDragStartObservable: Observable<{}>;
  115202. /**
  115203. * Fired when a scale box is dragged
  115204. */
  115205. onScaleBoxDragObservable: Observable<{}>;
  115206. /**
  115207. * Fired when a scale box drag is ended
  115208. */
  115209. onScaleBoxDragEndObservable: Observable<{}>;
  115210. /**
  115211. * Fired when a rotation sphere is dragged
  115212. */
  115213. onRotationSphereDragObservable: Observable<{}>;
  115214. /**
  115215. * Fired when a rotation sphere drag is ended
  115216. */
  115217. onRotationSphereDragEndObservable: Observable<{}>;
  115218. /**
  115219. * 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)
  115220. */
  115221. scalePivot: Nullable<Vector3>;
  115222. /**
  115223. * Mesh used as a pivot to rotate the attached mesh
  115224. */
  115225. private _anchorMesh;
  115226. private _existingMeshScale;
  115227. private _dragMesh;
  115228. private pointerDragBehavior;
  115229. private coloredMaterial;
  115230. private hoverColoredMaterial;
  115231. /**
  115232. * Sets the color of the bounding box gizmo
  115233. * @param color the color to set
  115234. */
  115235. setColor(color: Color3): void;
  115236. /**
  115237. * Creates an BoundingBoxGizmo
  115238. * @param gizmoLayer The utility layer the gizmo will be added to
  115239. * @param color The color of the gizmo
  115240. */
  115241. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  115242. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115243. private _selectNode;
  115244. /**
  115245. * Updates the bounding box information for the Gizmo
  115246. */
  115247. updateBoundingBox(): void;
  115248. private _updateRotationSpheres;
  115249. private _updateScaleBoxes;
  115250. /**
  115251. * Enables rotation on the specified axis and disables rotation on the others
  115252. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  115253. */
  115254. setEnabledRotationAxis(axis: string): void;
  115255. /**
  115256. * Enables/disables scaling
  115257. * @param enable if scaling should be enabled
  115258. */
  115259. setEnabledScaling(enable: boolean): void;
  115260. private _updateDummy;
  115261. /**
  115262. * Enables a pointer drag behavior on the bounding box of the gizmo
  115263. */
  115264. enableDragBehavior(): void;
  115265. /**
  115266. * Disposes of the gizmo
  115267. */
  115268. dispose(): void;
  115269. /**
  115270. * 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)
  115271. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  115272. * @returns the bounding box mesh with the passed in mesh as a child
  115273. */
  115274. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  115275. /**
  115276. * CustomMeshes are not supported by this gizmo
  115277. * @param mesh The mesh to replace the default mesh of the gizmo
  115278. */
  115279. setCustomMesh(mesh: Mesh): void;
  115280. }
  115281. }
  115282. declare module BABYLON {
  115283. /**
  115284. * Single plane rotation gizmo
  115285. */
  115286. export class PlaneRotationGizmo extends Gizmo {
  115287. /**
  115288. * Drag behavior responsible for the gizmos dragging interactions
  115289. */
  115290. dragBehavior: PointerDragBehavior;
  115291. private _pointerObserver;
  115292. /**
  115293. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  115294. */
  115295. snapDistance: number;
  115296. /**
  115297. * Event that fires each time the gizmo snaps to a new location.
  115298. * * snapDistance is the the change in distance
  115299. */
  115300. onSnapObservable: Observable<{
  115301. snapDistance: number;
  115302. }>;
  115303. private _isEnabled;
  115304. private _parent;
  115305. /**
  115306. * Creates a PlaneRotationGizmo
  115307. * @param gizmoLayer The utility layer the gizmo will be added to
  115308. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  115309. * @param color The color of the gizmo
  115310. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115311. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115312. */
  115313. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  115314. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115315. /**
  115316. * If the gizmo is enabled
  115317. */
  115318. isEnabled: boolean;
  115319. /**
  115320. * Disposes of the gizmo
  115321. */
  115322. dispose(): void;
  115323. }
  115324. }
  115325. declare module BABYLON {
  115326. /**
  115327. * Gizmo that enables rotating a mesh along 3 axis
  115328. */
  115329. export class RotationGizmo extends Gizmo {
  115330. /**
  115331. * Internal gizmo used for interactions on the x axis
  115332. */
  115333. xGizmo: PlaneRotationGizmo;
  115334. /**
  115335. * Internal gizmo used for interactions on the y axis
  115336. */
  115337. yGizmo: PlaneRotationGizmo;
  115338. /**
  115339. * Internal gizmo used for interactions on the z axis
  115340. */
  115341. zGizmo: PlaneRotationGizmo;
  115342. /** Fires an event when any of it's sub gizmos are dragged */
  115343. onDragStartObservable: Observable<unknown>;
  115344. /** Fires an event when any of it's sub gizmos are released from dragging */
  115345. onDragEndObservable: Observable<unknown>;
  115346. private _meshAttached;
  115347. attachedMesh: Nullable<AbstractMesh>;
  115348. /**
  115349. * Creates a RotationGizmo
  115350. * @param gizmoLayer The utility layer the gizmo will be added to
  115351. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115352. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115353. */
  115354. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  115355. updateGizmoRotationToMatchAttachedMesh: boolean;
  115356. /**
  115357. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115358. */
  115359. snapDistance: number;
  115360. /**
  115361. * Ratio for the scale of the gizmo (Default: 1)
  115362. */
  115363. scaleRatio: number;
  115364. /**
  115365. * Disposes of the gizmo
  115366. */
  115367. dispose(): void;
  115368. /**
  115369. * CustomMeshes are not supported by this gizmo
  115370. * @param mesh The mesh to replace the default mesh of the gizmo
  115371. */
  115372. setCustomMesh(mesh: Mesh): void;
  115373. }
  115374. }
  115375. declare module BABYLON {
  115376. /**
  115377. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  115378. */
  115379. export class GizmoManager implements IDisposable {
  115380. private scene;
  115381. /**
  115382. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  115383. */
  115384. gizmos: {
  115385. positionGizmo: Nullable<PositionGizmo>;
  115386. rotationGizmo: Nullable<RotationGizmo>;
  115387. scaleGizmo: Nullable<ScaleGizmo>;
  115388. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  115389. };
  115390. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  115391. clearGizmoOnEmptyPointerEvent: boolean;
  115392. /** Fires an event when the manager is attached to a mesh */
  115393. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  115394. private _gizmosEnabled;
  115395. private _pointerObserver;
  115396. private _attachedMesh;
  115397. private _boundingBoxColor;
  115398. private _defaultUtilityLayer;
  115399. private _defaultKeepDepthUtilityLayer;
  115400. /**
  115401. * When bounding box gizmo is enabled, this can be used to track drag/end events
  115402. */
  115403. boundingBoxDragBehavior: SixDofDragBehavior;
  115404. /**
  115405. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  115406. */
  115407. attachableMeshes: Nullable<Array<AbstractMesh>>;
  115408. /**
  115409. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  115410. */
  115411. usePointerToAttachGizmos: boolean;
  115412. /**
  115413. * Utility layer that the bounding box gizmo belongs to
  115414. */
  115415. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  115416. /**
  115417. * Utility layer that all gizmos besides bounding box belong to
  115418. */
  115419. readonly utilityLayer: UtilityLayerRenderer;
  115420. /**
  115421. * Instatiates a gizmo manager
  115422. * @param scene the scene to overlay the gizmos on top of
  115423. */
  115424. constructor(scene: Scene);
  115425. /**
  115426. * Attaches a set of gizmos to the specified mesh
  115427. * @param mesh The mesh the gizmo's should be attached to
  115428. */
  115429. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115430. /**
  115431. * If the position gizmo is enabled
  115432. */
  115433. positionGizmoEnabled: boolean;
  115434. /**
  115435. * If the rotation gizmo is enabled
  115436. */
  115437. rotationGizmoEnabled: boolean;
  115438. /**
  115439. * If the scale gizmo is enabled
  115440. */
  115441. scaleGizmoEnabled: boolean;
  115442. /**
  115443. * If the boundingBox gizmo is enabled
  115444. */
  115445. boundingBoxGizmoEnabled: boolean;
  115446. /**
  115447. * Disposes of the gizmo manager
  115448. */
  115449. dispose(): void;
  115450. }
  115451. }
  115452. declare module BABYLON {
  115453. /**
  115454. * A directional light is defined by a direction (what a surprise!).
  115455. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  115456. * 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.
  115457. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115458. */
  115459. export class DirectionalLight extends ShadowLight {
  115460. private _shadowFrustumSize;
  115461. /**
  115462. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  115463. */
  115464. /**
  115465. * Specifies a fix frustum size for the shadow generation.
  115466. */
  115467. shadowFrustumSize: number;
  115468. private _shadowOrthoScale;
  115469. /**
  115470. * Gets the shadow projection scale against the optimal computed one.
  115471. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115472. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115473. */
  115474. /**
  115475. * Sets the shadow projection scale against the optimal computed one.
  115476. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115477. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115478. */
  115479. shadowOrthoScale: number;
  115480. /**
  115481. * Automatically compute the projection matrix to best fit (including all the casters)
  115482. * on each frame.
  115483. */
  115484. autoUpdateExtends: boolean;
  115485. private _orthoLeft;
  115486. private _orthoRight;
  115487. private _orthoTop;
  115488. private _orthoBottom;
  115489. /**
  115490. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  115491. * The directional light is emitted from everywhere in the given direction.
  115492. * It can cast shadows.
  115493. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115494. * @param name The friendly name of the light
  115495. * @param direction The direction of the light
  115496. * @param scene The scene the light belongs to
  115497. */
  115498. constructor(name: string, direction: Vector3, scene: Scene);
  115499. /**
  115500. * Returns the string "DirectionalLight".
  115501. * @return The class name
  115502. */
  115503. getClassName(): string;
  115504. /**
  115505. * Returns the integer 1.
  115506. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115507. */
  115508. getTypeID(): number;
  115509. /**
  115510. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  115511. * Returns the DirectionalLight Shadow projection matrix.
  115512. */
  115513. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115514. /**
  115515. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  115516. * Returns the DirectionalLight Shadow projection matrix.
  115517. */
  115518. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  115519. /**
  115520. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  115521. * Returns the DirectionalLight Shadow projection matrix.
  115522. */
  115523. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115524. protected _buildUniformLayout(): void;
  115525. /**
  115526. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  115527. * @param effect The effect to update
  115528. * @param lightIndex The index of the light in the effect to update
  115529. * @returns The directional light
  115530. */
  115531. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  115532. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  115533. /**
  115534. * Gets the minZ used for shadow according to both the scene and the light.
  115535. *
  115536. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115537. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115538. * @param activeCamera The camera we are returning the min for
  115539. * @returns the depth min z
  115540. */
  115541. getDepthMinZ(activeCamera: Camera): number;
  115542. /**
  115543. * Gets the maxZ used for shadow according to both the scene and the light.
  115544. *
  115545. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115546. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115547. * @param activeCamera The camera we are returning the max for
  115548. * @returns the depth max z
  115549. */
  115550. getDepthMaxZ(activeCamera: Camera): number;
  115551. /**
  115552. * Prepares the list of defines specific to the light type.
  115553. * @param defines the list of defines
  115554. * @param lightIndex defines the index of the light for the effect
  115555. */
  115556. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115557. }
  115558. }
  115559. declare module BABYLON {
  115560. /**
  115561. * Class containing static functions to help procedurally build meshes
  115562. */
  115563. export class HemisphereBuilder {
  115564. /**
  115565. * Creates a hemisphere mesh
  115566. * @param name defines the name of the mesh
  115567. * @param options defines the options used to create the mesh
  115568. * @param scene defines the hosting scene
  115569. * @returns the hemisphere mesh
  115570. */
  115571. static CreateHemisphere(name: string, options: {
  115572. segments?: number;
  115573. diameter?: number;
  115574. sideOrientation?: number;
  115575. }, scene: any): Mesh;
  115576. }
  115577. }
  115578. declare module BABYLON {
  115579. /**
  115580. * A spot light is defined by a position, a direction, an angle, and an exponent.
  115581. * These values define a cone of light starting from the position, emitting toward the direction.
  115582. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  115583. * and the exponent defines the speed of the decay of the light with distance (reach).
  115584. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115585. */
  115586. export class SpotLight extends ShadowLight {
  115587. private _angle;
  115588. private _innerAngle;
  115589. private _cosHalfAngle;
  115590. private _lightAngleScale;
  115591. private _lightAngleOffset;
  115592. /**
  115593. * Gets the cone angle of the spot light in Radians.
  115594. */
  115595. /**
  115596. * Sets the cone angle of the spot light in Radians.
  115597. */
  115598. angle: number;
  115599. /**
  115600. * Only used in gltf falloff mode, this defines the angle where
  115601. * the directional falloff will start before cutting at angle which could be seen
  115602. * as outer angle.
  115603. */
  115604. /**
  115605. * Only used in gltf falloff mode, this defines the angle where
  115606. * the directional falloff will start before cutting at angle which could be seen
  115607. * as outer angle.
  115608. */
  115609. innerAngle: number;
  115610. private _shadowAngleScale;
  115611. /**
  115612. * Allows scaling the angle of the light for shadow generation only.
  115613. */
  115614. /**
  115615. * Allows scaling the angle of the light for shadow generation only.
  115616. */
  115617. shadowAngleScale: number;
  115618. /**
  115619. * The light decay speed with the distance from the emission spot.
  115620. */
  115621. exponent: number;
  115622. private _projectionTextureMatrix;
  115623. /**
  115624. * Allows reading the projecton texture
  115625. */
  115626. readonly projectionTextureMatrix: Matrix;
  115627. protected _projectionTextureLightNear: number;
  115628. /**
  115629. * Gets the near clip of the Spotlight for texture projection.
  115630. */
  115631. /**
  115632. * Sets the near clip of the Spotlight for texture projection.
  115633. */
  115634. projectionTextureLightNear: number;
  115635. protected _projectionTextureLightFar: number;
  115636. /**
  115637. * Gets the far clip of the Spotlight for texture projection.
  115638. */
  115639. /**
  115640. * Sets the far clip of the Spotlight for texture projection.
  115641. */
  115642. projectionTextureLightFar: number;
  115643. protected _projectionTextureUpDirection: Vector3;
  115644. /**
  115645. * Gets the Up vector of the Spotlight for texture projection.
  115646. */
  115647. /**
  115648. * Sets the Up vector of the Spotlight for texture projection.
  115649. */
  115650. projectionTextureUpDirection: Vector3;
  115651. private _projectionTexture;
  115652. /**
  115653. * Gets the projection texture of the light.
  115654. */
  115655. /**
  115656. * Sets the projection texture of the light.
  115657. */
  115658. projectionTexture: Nullable<BaseTexture>;
  115659. private _projectionTextureViewLightDirty;
  115660. private _projectionTextureProjectionLightDirty;
  115661. private _projectionTextureDirty;
  115662. private _projectionTextureViewTargetVector;
  115663. private _projectionTextureViewLightMatrix;
  115664. private _projectionTextureProjectionLightMatrix;
  115665. private _projectionTextureScalingMatrix;
  115666. /**
  115667. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  115668. * It can cast shadows.
  115669. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115670. * @param name The light friendly name
  115671. * @param position The position of the spot light in the scene
  115672. * @param direction The direction of the light in the scene
  115673. * @param angle The cone angle of the light in Radians
  115674. * @param exponent The light decay speed with the distance from the emission spot
  115675. * @param scene The scene the lights belongs to
  115676. */
  115677. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  115678. /**
  115679. * Returns the string "SpotLight".
  115680. * @returns the class name
  115681. */
  115682. getClassName(): string;
  115683. /**
  115684. * Returns the integer 2.
  115685. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115686. */
  115687. getTypeID(): number;
  115688. /**
  115689. * Overrides the direction setter to recompute the projection texture view light Matrix.
  115690. */
  115691. protected _setDirection(value: Vector3): void;
  115692. /**
  115693. * Overrides the position setter to recompute the projection texture view light Matrix.
  115694. */
  115695. protected _setPosition(value: Vector3): void;
  115696. /**
  115697. * 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.
  115698. * Returns the SpotLight.
  115699. */
  115700. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115701. protected _computeProjectionTextureViewLightMatrix(): void;
  115702. protected _computeProjectionTextureProjectionLightMatrix(): void;
  115703. /**
  115704. * Main function for light texture projection matrix computing.
  115705. */
  115706. protected _computeProjectionTextureMatrix(): void;
  115707. protected _buildUniformLayout(): void;
  115708. private _computeAngleValues;
  115709. /**
  115710. * Sets the passed Effect "effect" with the Light textures.
  115711. * @param effect The effect to update
  115712. * @param lightIndex The index of the light in the effect to update
  115713. * @returns The light
  115714. */
  115715. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  115716. /**
  115717. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  115718. * @param effect The effect to update
  115719. * @param lightIndex The index of the light in the effect to update
  115720. * @returns The spot light
  115721. */
  115722. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  115723. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115724. /**
  115725. * Disposes the light and the associated resources.
  115726. */
  115727. dispose(): void;
  115728. /**
  115729. * Prepares the list of defines specific to the light type.
  115730. * @param defines the list of defines
  115731. * @param lightIndex defines the index of the light for the effect
  115732. */
  115733. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115734. }
  115735. }
  115736. declare module BABYLON {
  115737. /**
  115738. * Gizmo that enables viewing a light
  115739. */
  115740. export class LightGizmo extends Gizmo {
  115741. private _lightMesh;
  115742. private _material;
  115743. private _cachedPosition;
  115744. private _cachedForward;
  115745. private _attachedMeshParent;
  115746. /**
  115747. * Creates a LightGizmo
  115748. * @param gizmoLayer The utility layer the gizmo will be added to
  115749. */
  115750. constructor(gizmoLayer?: UtilityLayerRenderer);
  115751. private _light;
  115752. /**
  115753. * The light that the gizmo is attached to
  115754. */
  115755. light: Nullable<Light>;
  115756. /**
  115757. * Gets the material used to render the light gizmo
  115758. */
  115759. readonly material: StandardMaterial;
  115760. /**
  115761. * @hidden
  115762. * Updates the gizmo to match the attached mesh's position/rotation
  115763. */
  115764. protected _update(): void;
  115765. private static _Scale;
  115766. /**
  115767. * Creates the lines for a light mesh
  115768. */
  115769. private static _CreateLightLines;
  115770. /**
  115771. * Disposes of the light gizmo
  115772. */
  115773. dispose(): void;
  115774. private static _CreateHemisphericLightMesh;
  115775. private static _CreatePointLightMesh;
  115776. private static _CreateSpotLightMesh;
  115777. private static _CreateDirectionalLightMesh;
  115778. }
  115779. }
  115780. declare module BABYLON {
  115781. /** @hidden */
  115782. export var backgroundFragmentDeclaration: {
  115783. name: string;
  115784. shader: string;
  115785. };
  115786. }
  115787. declare module BABYLON {
  115788. /** @hidden */
  115789. export var backgroundUboDeclaration: {
  115790. name: string;
  115791. shader: string;
  115792. };
  115793. }
  115794. declare module BABYLON {
  115795. /** @hidden */
  115796. export var backgroundPixelShader: {
  115797. name: string;
  115798. shader: string;
  115799. };
  115800. }
  115801. declare module BABYLON {
  115802. /** @hidden */
  115803. export var backgroundVertexDeclaration: {
  115804. name: string;
  115805. shader: string;
  115806. };
  115807. }
  115808. declare module BABYLON {
  115809. /** @hidden */
  115810. export var backgroundVertexShader: {
  115811. name: string;
  115812. shader: string;
  115813. };
  115814. }
  115815. declare module BABYLON {
  115816. /**
  115817. * Background material used to create an efficient environement around your scene.
  115818. */
  115819. export class BackgroundMaterial extends PushMaterial {
  115820. /**
  115821. * Standard reflectance value at parallel view angle.
  115822. */
  115823. static StandardReflectance0: number;
  115824. /**
  115825. * Standard reflectance value at grazing angle.
  115826. */
  115827. static StandardReflectance90: number;
  115828. protected _primaryColor: Color3;
  115829. /**
  115830. * Key light Color (multiply against the environement texture)
  115831. */
  115832. primaryColor: Color3;
  115833. protected __perceptualColor: Nullable<Color3>;
  115834. /**
  115835. * Experimental Internal Use Only.
  115836. *
  115837. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  115838. * This acts as a helper to set the primary color to a more "human friendly" value.
  115839. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  115840. * output color as close as possible from the chosen value.
  115841. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  115842. * part of lighting setup.)
  115843. */
  115844. _perceptualColor: Nullable<Color3>;
  115845. protected _primaryColorShadowLevel: float;
  115846. /**
  115847. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  115848. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  115849. */
  115850. primaryColorShadowLevel: float;
  115851. protected _primaryColorHighlightLevel: float;
  115852. /**
  115853. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  115854. * The primary color is used at the level chosen to define what the white area would look.
  115855. */
  115856. primaryColorHighlightLevel: float;
  115857. protected _reflectionTexture: Nullable<BaseTexture>;
  115858. /**
  115859. * Reflection Texture used in the material.
  115860. * Should be author in a specific way for the best result (refer to the documentation).
  115861. */
  115862. reflectionTexture: Nullable<BaseTexture>;
  115863. protected _reflectionBlur: float;
  115864. /**
  115865. * Reflection Texture level of blur.
  115866. *
  115867. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  115868. * texture twice.
  115869. */
  115870. reflectionBlur: float;
  115871. protected _diffuseTexture: Nullable<BaseTexture>;
  115872. /**
  115873. * Diffuse Texture used in the material.
  115874. * Should be author in a specific way for the best result (refer to the documentation).
  115875. */
  115876. diffuseTexture: Nullable<BaseTexture>;
  115877. protected _shadowLights: Nullable<IShadowLight[]>;
  115878. /**
  115879. * Specify the list of lights casting shadow on the material.
  115880. * All scene shadow lights will be included if null.
  115881. */
  115882. shadowLights: Nullable<IShadowLight[]>;
  115883. protected _shadowLevel: float;
  115884. /**
  115885. * Helps adjusting the shadow to a softer level if required.
  115886. * 0 means black shadows and 1 means no shadows.
  115887. */
  115888. shadowLevel: float;
  115889. protected _sceneCenter: Vector3;
  115890. /**
  115891. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  115892. * It is usually zero but might be interesting to modify according to your setup.
  115893. */
  115894. sceneCenter: Vector3;
  115895. protected _opacityFresnel: boolean;
  115896. /**
  115897. * This helps specifying that the material is falling off to the sky box at grazing angle.
  115898. * This helps ensuring a nice transition when the camera goes under the ground.
  115899. */
  115900. opacityFresnel: boolean;
  115901. protected _reflectionFresnel: boolean;
  115902. /**
  115903. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  115904. * This helps adding a mirror texture on the ground.
  115905. */
  115906. reflectionFresnel: boolean;
  115907. protected _reflectionFalloffDistance: number;
  115908. /**
  115909. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  115910. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  115911. */
  115912. reflectionFalloffDistance: number;
  115913. protected _reflectionAmount: number;
  115914. /**
  115915. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  115916. */
  115917. reflectionAmount: number;
  115918. protected _reflectionReflectance0: number;
  115919. /**
  115920. * This specifies the weight of the reflection at grazing angle.
  115921. */
  115922. reflectionReflectance0: number;
  115923. protected _reflectionReflectance90: number;
  115924. /**
  115925. * This specifies the weight of the reflection at a perpendicular point of view.
  115926. */
  115927. reflectionReflectance90: number;
  115928. /**
  115929. * Sets the reflection reflectance fresnel values according to the default standard
  115930. * empirically know to work well :-)
  115931. */
  115932. reflectionStandardFresnelWeight: number;
  115933. protected _useRGBColor: boolean;
  115934. /**
  115935. * Helps to directly use the maps channels instead of their level.
  115936. */
  115937. useRGBColor: boolean;
  115938. protected _enableNoise: boolean;
  115939. /**
  115940. * This helps reducing the banding effect that could occur on the background.
  115941. */
  115942. enableNoise: boolean;
  115943. /**
  115944. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115945. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  115946. * Recommended to be keep at 1.0 except for special cases.
  115947. */
  115948. fovMultiplier: number;
  115949. private _fovMultiplier;
  115950. /**
  115951. * Enable the FOV adjustment feature controlled by fovMultiplier.
  115952. */
  115953. useEquirectangularFOV: boolean;
  115954. private _maxSimultaneousLights;
  115955. /**
  115956. * Number of Simultaneous lights allowed on the material.
  115957. */
  115958. maxSimultaneousLights: int;
  115959. /**
  115960. * Default configuration related to image processing available in the Background Material.
  115961. */
  115962. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115963. /**
  115964. * Keep track of the image processing observer to allow dispose and replace.
  115965. */
  115966. private _imageProcessingObserver;
  115967. /**
  115968. * Attaches a new image processing configuration to the PBR Material.
  115969. * @param configuration (if null the scene configuration will be use)
  115970. */
  115971. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115972. /**
  115973. * Gets the image processing configuration used either in this material.
  115974. */
  115975. /**
  115976. * Sets the Default image processing configuration used either in the this material.
  115977. *
  115978. * If sets to null, the scene one is in use.
  115979. */
  115980. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  115981. /**
  115982. * Gets wether the color curves effect is enabled.
  115983. */
  115984. /**
  115985. * Sets wether the color curves effect is enabled.
  115986. */
  115987. cameraColorCurvesEnabled: boolean;
  115988. /**
  115989. * Gets wether the color grading effect is enabled.
  115990. */
  115991. /**
  115992. * Gets wether the color grading effect is enabled.
  115993. */
  115994. cameraColorGradingEnabled: boolean;
  115995. /**
  115996. * Gets wether tonemapping is enabled or not.
  115997. */
  115998. /**
  115999. * Sets wether tonemapping is enabled or not
  116000. */
  116001. cameraToneMappingEnabled: boolean;
  116002. /**
  116003. * The camera exposure used on this material.
  116004. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116005. * This corresponds to a photographic exposure.
  116006. */
  116007. /**
  116008. * The camera exposure used on this material.
  116009. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116010. * This corresponds to a photographic exposure.
  116011. */
  116012. cameraExposure: float;
  116013. /**
  116014. * Gets The camera contrast used on this material.
  116015. */
  116016. /**
  116017. * Sets The camera contrast used on this material.
  116018. */
  116019. cameraContrast: float;
  116020. /**
  116021. * Gets the Color Grading 2D Lookup Texture.
  116022. */
  116023. /**
  116024. * Sets the Color Grading 2D Lookup Texture.
  116025. */
  116026. cameraColorGradingTexture: Nullable<BaseTexture>;
  116027. /**
  116028. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116029. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116030. * 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;
  116031. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116032. */
  116033. /**
  116034. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116035. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116036. * 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;
  116037. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116038. */
  116039. cameraColorCurves: Nullable<ColorCurves>;
  116040. /**
  116041. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  116042. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  116043. */
  116044. switchToBGR: boolean;
  116045. private _renderTargets;
  116046. private _reflectionControls;
  116047. private _white;
  116048. private _primaryShadowColor;
  116049. private _primaryHighlightColor;
  116050. /**
  116051. * Instantiates a Background Material in the given scene
  116052. * @param name The friendly name of the material
  116053. * @param scene The scene to add the material to
  116054. */
  116055. constructor(name: string, scene: Scene);
  116056. /**
  116057. * Gets a boolean indicating that current material needs to register RTT
  116058. */
  116059. readonly hasRenderTargetTextures: boolean;
  116060. /**
  116061. * The entire material has been created in order to prevent overdraw.
  116062. * @returns false
  116063. */
  116064. needAlphaTesting(): boolean;
  116065. /**
  116066. * The entire material has been created in order to prevent overdraw.
  116067. * @returns true if blending is enable
  116068. */
  116069. needAlphaBlending(): boolean;
  116070. /**
  116071. * Checks wether the material is ready to be rendered for a given mesh.
  116072. * @param mesh The mesh to render
  116073. * @param subMesh The submesh to check against
  116074. * @param useInstances Specify wether or not the material is used with instances
  116075. * @returns true if all the dependencies are ready (Textures, Effects...)
  116076. */
  116077. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116078. /**
  116079. * Compute the primary color according to the chosen perceptual color.
  116080. */
  116081. private _computePrimaryColorFromPerceptualColor;
  116082. /**
  116083. * Compute the highlights and shadow colors according to their chosen levels.
  116084. */
  116085. private _computePrimaryColors;
  116086. /**
  116087. * Build the uniform buffer used in the material.
  116088. */
  116089. buildUniformLayout(): void;
  116090. /**
  116091. * Unbind the material.
  116092. */
  116093. unbind(): void;
  116094. /**
  116095. * Bind only the world matrix to the material.
  116096. * @param world The world matrix to bind.
  116097. */
  116098. bindOnlyWorldMatrix(world: Matrix): void;
  116099. /**
  116100. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  116101. * @param world The world matrix to bind.
  116102. * @param subMesh The submesh to bind for.
  116103. */
  116104. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116105. /**
  116106. * Checks to see if a texture is used in the material.
  116107. * @param texture - Base texture to use.
  116108. * @returns - Boolean specifying if a texture is used in the material.
  116109. */
  116110. hasTexture(texture: BaseTexture): boolean;
  116111. /**
  116112. * Dispose the material.
  116113. * @param forceDisposeEffect Force disposal of the associated effect.
  116114. * @param forceDisposeTextures Force disposal of the associated textures.
  116115. */
  116116. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116117. /**
  116118. * Clones the material.
  116119. * @param name The cloned name.
  116120. * @returns The cloned material.
  116121. */
  116122. clone(name: string): BackgroundMaterial;
  116123. /**
  116124. * Serializes the current material to its JSON representation.
  116125. * @returns The JSON representation.
  116126. */
  116127. serialize(): any;
  116128. /**
  116129. * Gets the class name of the material
  116130. * @returns "BackgroundMaterial"
  116131. */
  116132. getClassName(): string;
  116133. /**
  116134. * Parse a JSON input to create back a background material.
  116135. * @param source The JSON data to parse
  116136. * @param scene The scene to create the parsed material in
  116137. * @param rootUrl The root url of the assets the material depends upon
  116138. * @returns the instantiated BackgroundMaterial.
  116139. */
  116140. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  116141. }
  116142. }
  116143. declare module BABYLON {
  116144. /**
  116145. * Represents the different options available during the creation of
  116146. * a Environment helper.
  116147. *
  116148. * This can control the default ground, skybox and image processing setup of your scene.
  116149. */
  116150. export interface IEnvironmentHelperOptions {
  116151. /**
  116152. * Specifies wether or not to create a ground.
  116153. * True by default.
  116154. */
  116155. createGround: boolean;
  116156. /**
  116157. * Specifies the ground size.
  116158. * 15 by default.
  116159. */
  116160. groundSize: number;
  116161. /**
  116162. * The texture used on the ground for the main color.
  116163. * Comes from the BabylonJS CDN by default.
  116164. *
  116165. * Remarks: Can be either a texture or a url.
  116166. */
  116167. groundTexture: string | BaseTexture;
  116168. /**
  116169. * The color mixed in the ground texture by default.
  116170. * BabylonJS clearColor by default.
  116171. */
  116172. groundColor: Color3;
  116173. /**
  116174. * Specifies the ground opacity.
  116175. * 1 by default.
  116176. */
  116177. groundOpacity: number;
  116178. /**
  116179. * Enables the ground to receive shadows.
  116180. * True by default.
  116181. */
  116182. enableGroundShadow: boolean;
  116183. /**
  116184. * Helps preventing the shadow to be fully black on the ground.
  116185. * 0.5 by default.
  116186. */
  116187. groundShadowLevel: number;
  116188. /**
  116189. * Creates a mirror texture attach to the ground.
  116190. * false by default.
  116191. */
  116192. enableGroundMirror: boolean;
  116193. /**
  116194. * Specifies the ground mirror size ratio.
  116195. * 0.3 by default as the default kernel is 64.
  116196. */
  116197. groundMirrorSizeRatio: number;
  116198. /**
  116199. * Specifies the ground mirror blur kernel size.
  116200. * 64 by default.
  116201. */
  116202. groundMirrorBlurKernel: number;
  116203. /**
  116204. * Specifies the ground mirror visibility amount.
  116205. * 1 by default
  116206. */
  116207. groundMirrorAmount: number;
  116208. /**
  116209. * Specifies the ground mirror reflectance weight.
  116210. * This uses the standard weight of the background material to setup the fresnel effect
  116211. * of the mirror.
  116212. * 1 by default.
  116213. */
  116214. groundMirrorFresnelWeight: number;
  116215. /**
  116216. * Specifies the ground mirror Falloff distance.
  116217. * This can helps reducing the size of the reflection.
  116218. * 0 by Default.
  116219. */
  116220. groundMirrorFallOffDistance: number;
  116221. /**
  116222. * Specifies the ground mirror texture type.
  116223. * Unsigned Int by Default.
  116224. */
  116225. groundMirrorTextureType: number;
  116226. /**
  116227. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  116228. * the shown objects.
  116229. */
  116230. groundYBias: number;
  116231. /**
  116232. * Specifies wether or not to create a skybox.
  116233. * True by default.
  116234. */
  116235. createSkybox: boolean;
  116236. /**
  116237. * Specifies the skybox size.
  116238. * 20 by default.
  116239. */
  116240. skyboxSize: number;
  116241. /**
  116242. * The texture used on the skybox for the main color.
  116243. * Comes from the BabylonJS CDN by default.
  116244. *
  116245. * Remarks: Can be either a texture or a url.
  116246. */
  116247. skyboxTexture: string | BaseTexture;
  116248. /**
  116249. * The color mixed in the skybox texture by default.
  116250. * BabylonJS clearColor by default.
  116251. */
  116252. skyboxColor: Color3;
  116253. /**
  116254. * The background rotation around the Y axis of the scene.
  116255. * This helps aligning the key lights of your scene with the background.
  116256. * 0 by default.
  116257. */
  116258. backgroundYRotation: number;
  116259. /**
  116260. * Compute automatically the size of the elements to best fit with the scene.
  116261. */
  116262. sizeAuto: boolean;
  116263. /**
  116264. * Default position of the rootMesh if autoSize is not true.
  116265. */
  116266. rootPosition: Vector3;
  116267. /**
  116268. * Sets up the image processing in the scene.
  116269. * true by default.
  116270. */
  116271. setupImageProcessing: boolean;
  116272. /**
  116273. * The texture used as your environment texture in the scene.
  116274. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  116275. *
  116276. * Remarks: Can be either a texture or a url.
  116277. */
  116278. environmentTexture: string | BaseTexture;
  116279. /**
  116280. * The value of the exposure to apply to the scene.
  116281. * 0.6 by default if setupImageProcessing is true.
  116282. */
  116283. cameraExposure: number;
  116284. /**
  116285. * The value of the contrast to apply to the scene.
  116286. * 1.6 by default if setupImageProcessing is true.
  116287. */
  116288. cameraContrast: number;
  116289. /**
  116290. * Specifies wether or not tonemapping should be enabled in the scene.
  116291. * true by default if setupImageProcessing is true.
  116292. */
  116293. toneMappingEnabled: boolean;
  116294. }
  116295. /**
  116296. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  116297. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  116298. * It also helps with the default setup of your imageProcessing configuration.
  116299. */
  116300. export class EnvironmentHelper {
  116301. /**
  116302. * Default ground texture URL.
  116303. */
  116304. private static _groundTextureCDNUrl;
  116305. /**
  116306. * Default skybox texture URL.
  116307. */
  116308. private static _skyboxTextureCDNUrl;
  116309. /**
  116310. * Default environment texture URL.
  116311. */
  116312. private static _environmentTextureCDNUrl;
  116313. /**
  116314. * Creates the default options for the helper.
  116315. */
  116316. private static _getDefaultOptions;
  116317. private _rootMesh;
  116318. /**
  116319. * Gets the root mesh created by the helper.
  116320. */
  116321. readonly rootMesh: Mesh;
  116322. private _skybox;
  116323. /**
  116324. * Gets the skybox created by the helper.
  116325. */
  116326. readonly skybox: Nullable<Mesh>;
  116327. private _skyboxTexture;
  116328. /**
  116329. * Gets the skybox texture created by the helper.
  116330. */
  116331. readonly skyboxTexture: Nullable<BaseTexture>;
  116332. private _skyboxMaterial;
  116333. /**
  116334. * Gets the skybox material created by the helper.
  116335. */
  116336. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  116337. private _ground;
  116338. /**
  116339. * Gets the ground mesh created by the helper.
  116340. */
  116341. readonly ground: Nullable<Mesh>;
  116342. private _groundTexture;
  116343. /**
  116344. * Gets the ground texture created by the helper.
  116345. */
  116346. readonly groundTexture: Nullable<BaseTexture>;
  116347. private _groundMirror;
  116348. /**
  116349. * Gets the ground mirror created by the helper.
  116350. */
  116351. readonly groundMirror: Nullable<MirrorTexture>;
  116352. /**
  116353. * Gets the ground mirror render list to helps pushing the meshes
  116354. * you wish in the ground reflection.
  116355. */
  116356. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  116357. private _groundMaterial;
  116358. /**
  116359. * Gets the ground material created by the helper.
  116360. */
  116361. readonly groundMaterial: Nullable<BackgroundMaterial>;
  116362. /**
  116363. * Stores the creation options.
  116364. */
  116365. private readonly _scene;
  116366. private _options;
  116367. /**
  116368. * This observable will be notified with any error during the creation of the environment,
  116369. * mainly texture creation errors.
  116370. */
  116371. onErrorObservable: Observable<{
  116372. message?: string;
  116373. exception?: any;
  116374. }>;
  116375. /**
  116376. * constructor
  116377. * @param options Defines the options we want to customize the helper
  116378. * @param scene The scene to add the material to
  116379. */
  116380. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  116381. /**
  116382. * Updates the background according to the new options
  116383. * @param options
  116384. */
  116385. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  116386. /**
  116387. * Sets the primary color of all the available elements.
  116388. * @param color the main color to affect to the ground and the background
  116389. */
  116390. setMainColor(color: Color3): void;
  116391. /**
  116392. * Setup the image processing according to the specified options.
  116393. */
  116394. private _setupImageProcessing;
  116395. /**
  116396. * Setup the environment texture according to the specified options.
  116397. */
  116398. private _setupEnvironmentTexture;
  116399. /**
  116400. * Setup the background according to the specified options.
  116401. */
  116402. private _setupBackground;
  116403. /**
  116404. * Get the scene sizes according to the setup.
  116405. */
  116406. private _getSceneSize;
  116407. /**
  116408. * Setup the ground according to the specified options.
  116409. */
  116410. private _setupGround;
  116411. /**
  116412. * Setup the ground material according to the specified options.
  116413. */
  116414. private _setupGroundMaterial;
  116415. /**
  116416. * Setup the ground diffuse texture according to the specified options.
  116417. */
  116418. private _setupGroundDiffuseTexture;
  116419. /**
  116420. * Setup the ground mirror texture according to the specified options.
  116421. */
  116422. private _setupGroundMirrorTexture;
  116423. /**
  116424. * Setup the ground to receive the mirror texture.
  116425. */
  116426. private _setupMirrorInGroundMaterial;
  116427. /**
  116428. * Setup the skybox according to the specified options.
  116429. */
  116430. private _setupSkybox;
  116431. /**
  116432. * Setup the skybox material according to the specified options.
  116433. */
  116434. private _setupSkyboxMaterial;
  116435. /**
  116436. * Setup the skybox reflection texture according to the specified options.
  116437. */
  116438. private _setupSkyboxReflectionTexture;
  116439. private _errorHandler;
  116440. /**
  116441. * Dispose all the elements created by the Helper.
  116442. */
  116443. dispose(): void;
  116444. }
  116445. }
  116446. declare module BABYLON {
  116447. /**
  116448. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  116449. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  116450. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  116451. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116452. */
  116453. export class PhotoDome extends TransformNode {
  116454. /**
  116455. * Define the image as a Monoscopic panoramic 360 image.
  116456. */
  116457. static readonly MODE_MONOSCOPIC: number;
  116458. /**
  116459. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116460. */
  116461. static readonly MODE_TOPBOTTOM: number;
  116462. /**
  116463. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116464. */
  116465. static readonly MODE_SIDEBYSIDE: number;
  116466. private _useDirectMapping;
  116467. /**
  116468. * The texture being displayed on the sphere
  116469. */
  116470. protected _photoTexture: Texture;
  116471. /**
  116472. * Gets or sets the texture being displayed on the sphere
  116473. */
  116474. photoTexture: Texture;
  116475. /**
  116476. * Observable raised when an error occured while loading the 360 image
  116477. */
  116478. onLoadErrorObservable: Observable<string>;
  116479. /**
  116480. * The skybox material
  116481. */
  116482. protected _material: BackgroundMaterial;
  116483. /**
  116484. * The surface used for the skybox
  116485. */
  116486. protected _mesh: Mesh;
  116487. /**
  116488. * Gets the mesh used for the skybox.
  116489. */
  116490. readonly mesh: Mesh;
  116491. /**
  116492. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116493. * Also see the options.resolution property.
  116494. */
  116495. fovMultiplier: number;
  116496. private _imageMode;
  116497. /**
  116498. * Gets or set the current video mode for the video. It can be:
  116499. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  116500. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116501. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116502. */
  116503. imageMode: number;
  116504. /**
  116505. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  116506. * @param name Element's name, child elements will append suffixes for their own names.
  116507. * @param urlsOfPhoto defines the url of the photo to display
  116508. * @param options defines an object containing optional or exposed sub element properties
  116509. * @param onError defines a callback called when an error occured while loading the texture
  116510. */
  116511. constructor(name: string, urlOfPhoto: string, options: {
  116512. resolution?: number;
  116513. size?: number;
  116514. useDirectMapping?: boolean;
  116515. faceForward?: boolean;
  116516. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  116517. private _onBeforeCameraRenderObserver;
  116518. private _changeImageMode;
  116519. /**
  116520. * Releases resources associated with this node.
  116521. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116522. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116523. */
  116524. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116525. }
  116526. }
  116527. declare module BABYLON {
  116528. /**
  116529. * Class used to host RGBD texture specific utilities
  116530. */
  116531. export class RGBDTextureTools {
  116532. /**
  116533. * Expand the RGBD Texture from RGBD to Half Float if possible.
  116534. * @param texture the texture to expand.
  116535. */
  116536. static ExpandRGBDTexture(texture: Texture): void;
  116537. }
  116538. }
  116539. declare module BABYLON {
  116540. /**
  116541. * Class used to host texture specific utilities
  116542. */
  116543. export class BRDFTextureTools {
  116544. /**
  116545. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  116546. * @param scene defines the hosting scene
  116547. * @returns the environment BRDF texture
  116548. */
  116549. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  116550. private static _environmentBRDFBase64Texture;
  116551. }
  116552. }
  116553. declare module BABYLON {
  116554. /**
  116555. * @hidden
  116556. */
  116557. export interface IMaterialClearCoatDefines {
  116558. CLEARCOAT: boolean;
  116559. CLEARCOAT_DEFAULTIOR: boolean;
  116560. CLEARCOAT_TEXTURE: boolean;
  116561. CLEARCOAT_TEXTUREDIRECTUV: number;
  116562. CLEARCOAT_BUMP: boolean;
  116563. CLEARCOAT_BUMPDIRECTUV: number;
  116564. CLEARCOAT_TINT: boolean;
  116565. CLEARCOAT_TINT_TEXTURE: boolean;
  116566. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116567. /** @hidden */
  116568. _areTexturesDirty: boolean;
  116569. }
  116570. /**
  116571. * Define the code related to the clear coat parameters of the pbr material.
  116572. */
  116573. export class PBRClearCoatConfiguration {
  116574. /**
  116575. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116576. * The default fits with a polyurethane material.
  116577. */
  116578. private static readonly _DefaultIndexOfRefraction;
  116579. private _isEnabled;
  116580. /**
  116581. * Defines if the clear coat is enabled in the material.
  116582. */
  116583. isEnabled: boolean;
  116584. /**
  116585. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  116586. */
  116587. intensity: number;
  116588. /**
  116589. * Defines the clear coat layer roughness.
  116590. */
  116591. roughness: number;
  116592. private _indexOfRefraction;
  116593. /**
  116594. * Defines the index of refraction of the clear coat.
  116595. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116596. * The default fits with a polyurethane material.
  116597. * Changing the default value is more performance intensive.
  116598. */
  116599. indexOfRefraction: number;
  116600. private _texture;
  116601. /**
  116602. * Stores the clear coat values in a texture.
  116603. */
  116604. texture: Nullable<BaseTexture>;
  116605. private _bumpTexture;
  116606. /**
  116607. * Define the clear coat specific bump texture.
  116608. */
  116609. bumpTexture: Nullable<BaseTexture>;
  116610. private _isTintEnabled;
  116611. /**
  116612. * Defines if the clear coat tint is enabled in the material.
  116613. */
  116614. isTintEnabled: boolean;
  116615. /**
  116616. * Defines the clear coat tint of the material.
  116617. * This is only use if tint is enabled
  116618. */
  116619. tintColor: Color3;
  116620. /**
  116621. * Defines the distance at which the tint color should be found in the
  116622. * clear coat media.
  116623. * This is only use if tint is enabled
  116624. */
  116625. tintColorAtDistance: number;
  116626. /**
  116627. * Defines the clear coat layer thickness.
  116628. * This is only use if tint is enabled
  116629. */
  116630. tintThickness: number;
  116631. private _tintTexture;
  116632. /**
  116633. * Stores the clear tint values in a texture.
  116634. * rgb is tint
  116635. * a is a thickness factor
  116636. */
  116637. tintTexture: Nullable<BaseTexture>;
  116638. /** @hidden */
  116639. private _internalMarkAllSubMeshesAsTexturesDirty;
  116640. /** @hidden */
  116641. _markAllSubMeshesAsTexturesDirty(): void;
  116642. /**
  116643. * Instantiate a new istance of clear coat configuration.
  116644. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116645. */
  116646. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116647. /**
  116648. * Gets wehter the submesh is ready to be used or not.
  116649. * @param defines the list of "defines" to update.
  116650. * @param scene defines the scene the material belongs to.
  116651. * @param engine defines the engine the material belongs to.
  116652. * @param disableBumpMap defines wether the material disables bump or not.
  116653. * @returns - boolean indicating that the submesh is ready or not.
  116654. */
  116655. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  116656. /**
  116657. * Checks to see if a texture is used in the material.
  116658. * @param defines the list of "defines" to update.
  116659. * @param scene defines the scene to the material belongs to.
  116660. */
  116661. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  116662. /**
  116663. * Binds the material data.
  116664. * @param uniformBuffer defines the Uniform buffer to fill in.
  116665. * @param scene defines the scene the material belongs to.
  116666. * @param engine defines the engine the material belongs to.
  116667. * @param disableBumpMap defines wether the material disables bump or not.
  116668. * @param isFrozen defines wether the material is frozen or not.
  116669. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116670. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116671. */
  116672. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  116673. /**
  116674. * Checks to see if a texture is used in the material.
  116675. * @param texture - Base texture to use.
  116676. * @returns - Boolean specifying if a texture is used in the material.
  116677. */
  116678. hasTexture(texture: BaseTexture): boolean;
  116679. /**
  116680. * Returns an array of the actively used textures.
  116681. * @param activeTextures Array of BaseTextures
  116682. */
  116683. getActiveTextures(activeTextures: BaseTexture[]): void;
  116684. /**
  116685. * Returns the animatable textures.
  116686. * @param animatables Array of animatable textures.
  116687. */
  116688. getAnimatables(animatables: IAnimatable[]): void;
  116689. /**
  116690. * Disposes the resources of the material.
  116691. * @param forceDisposeTextures - Forces the disposal of all textures.
  116692. */
  116693. dispose(forceDisposeTextures?: boolean): void;
  116694. /**
  116695. * Get the current class name of the texture useful for serialization or dynamic coding.
  116696. * @returns "PBRClearCoatConfiguration"
  116697. */
  116698. getClassName(): string;
  116699. /**
  116700. * Add fallbacks to the effect fallbacks list.
  116701. * @param defines defines the Base texture to use.
  116702. * @param fallbacks defines the current fallback list.
  116703. * @param currentRank defines the current fallback rank.
  116704. * @returns the new fallback rank.
  116705. */
  116706. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116707. /**
  116708. * Add the required uniforms to the current list.
  116709. * @param uniforms defines the current uniform list.
  116710. */
  116711. static AddUniforms(uniforms: string[]): void;
  116712. /**
  116713. * Add the required samplers to the current list.
  116714. * @param samplers defines the current sampler list.
  116715. */
  116716. static AddSamplers(samplers: string[]): void;
  116717. /**
  116718. * Add the required uniforms to the current buffer.
  116719. * @param uniformBuffer defines the current uniform buffer.
  116720. */
  116721. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116722. /**
  116723. * Makes a duplicate of the current configuration into another one.
  116724. * @param clearCoatConfiguration define the config where to copy the info
  116725. */
  116726. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  116727. /**
  116728. * Serializes this clear coat configuration.
  116729. * @returns - An object with the serialized config.
  116730. */
  116731. serialize(): any;
  116732. /**
  116733. * Parses a anisotropy Configuration from a serialized object.
  116734. * @param source - Serialized object.
  116735. * @param scene Defines the scene we are parsing for
  116736. * @param rootUrl Defines the rootUrl to load from
  116737. */
  116738. parse(source: any, scene: Scene, rootUrl: string): void;
  116739. }
  116740. }
  116741. declare module BABYLON {
  116742. /**
  116743. * @hidden
  116744. */
  116745. export interface IMaterialAnisotropicDefines {
  116746. ANISOTROPIC: boolean;
  116747. ANISOTROPIC_TEXTURE: boolean;
  116748. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116749. MAINUV1: boolean;
  116750. _areTexturesDirty: boolean;
  116751. _needUVs: boolean;
  116752. }
  116753. /**
  116754. * Define the code related to the anisotropic parameters of the pbr material.
  116755. */
  116756. export class PBRAnisotropicConfiguration {
  116757. private _isEnabled;
  116758. /**
  116759. * Defines if the anisotropy is enabled in the material.
  116760. */
  116761. isEnabled: boolean;
  116762. /**
  116763. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  116764. */
  116765. intensity: number;
  116766. /**
  116767. * Defines if the effect is along the tangents, bitangents or in between.
  116768. * By default, the effect is "strectching" the highlights along the tangents.
  116769. */
  116770. direction: Vector2;
  116771. private _texture;
  116772. /**
  116773. * Stores the anisotropy values in a texture.
  116774. * rg is direction (like normal from -1 to 1)
  116775. * b is a intensity
  116776. */
  116777. texture: Nullable<BaseTexture>;
  116778. /** @hidden */
  116779. private _internalMarkAllSubMeshesAsTexturesDirty;
  116780. /** @hidden */
  116781. _markAllSubMeshesAsTexturesDirty(): void;
  116782. /**
  116783. * Instantiate a new istance of anisotropy configuration.
  116784. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116785. */
  116786. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116787. /**
  116788. * Specifies that the submesh is ready to be used.
  116789. * @param defines the list of "defines" to update.
  116790. * @param scene defines the scene the material belongs to.
  116791. * @returns - boolean indicating that the submesh is ready or not.
  116792. */
  116793. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  116794. /**
  116795. * Checks to see if a texture is used in the material.
  116796. * @param defines the list of "defines" to update.
  116797. * @param mesh the mesh we are preparing the defines for.
  116798. * @param scene defines the scene the material belongs to.
  116799. */
  116800. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  116801. /**
  116802. * Binds the material data.
  116803. * @param uniformBuffer defines the Uniform buffer to fill in.
  116804. * @param scene defines the scene the material belongs to.
  116805. * @param isFrozen defines wether the material is frozen or not.
  116806. */
  116807. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116808. /**
  116809. * Checks to see if a texture is used in the material.
  116810. * @param texture - Base texture to use.
  116811. * @returns - Boolean specifying if a texture is used in the material.
  116812. */
  116813. hasTexture(texture: BaseTexture): boolean;
  116814. /**
  116815. * Returns an array of the actively used textures.
  116816. * @param activeTextures Array of BaseTextures
  116817. */
  116818. getActiveTextures(activeTextures: BaseTexture[]): void;
  116819. /**
  116820. * Returns the animatable textures.
  116821. * @param animatables Array of animatable textures.
  116822. */
  116823. getAnimatables(animatables: IAnimatable[]): void;
  116824. /**
  116825. * Disposes the resources of the material.
  116826. * @param forceDisposeTextures - Forces the disposal of all textures.
  116827. */
  116828. dispose(forceDisposeTextures?: boolean): void;
  116829. /**
  116830. * Get the current class name of the texture useful for serialization or dynamic coding.
  116831. * @returns "PBRAnisotropicConfiguration"
  116832. */
  116833. getClassName(): string;
  116834. /**
  116835. * Add fallbacks to the effect fallbacks list.
  116836. * @param defines defines the Base texture to use.
  116837. * @param fallbacks defines the current fallback list.
  116838. * @param currentRank defines the current fallback rank.
  116839. * @returns the new fallback rank.
  116840. */
  116841. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116842. /**
  116843. * Add the required uniforms to the current list.
  116844. * @param uniforms defines the current uniform list.
  116845. */
  116846. static AddUniforms(uniforms: string[]): void;
  116847. /**
  116848. * Add the required uniforms to the current buffer.
  116849. * @param uniformBuffer defines the current uniform buffer.
  116850. */
  116851. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116852. /**
  116853. * Add the required samplers to the current list.
  116854. * @param samplers defines the current sampler list.
  116855. */
  116856. static AddSamplers(samplers: string[]): void;
  116857. /**
  116858. * Makes a duplicate of the current configuration into another one.
  116859. * @param anisotropicConfiguration define the config where to copy the info
  116860. */
  116861. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  116862. /**
  116863. * Serializes this anisotropy configuration.
  116864. * @returns - An object with the serialized config.
  116865. */
  116866. serialize(): any;
  116867. /**
  116868. * Parses a anisotropy Configuration from a serialized object.
  116869. * @param source - Serialized object.
  116870. * @param scene Defines the scene we are parsing for
  116871. * @param rootUrl Defines the rootUrl to load from
  116872. */
  116873. parse(source: any, scene: Scene, rootUrl: string): void;
  116874. }
  116875. }
  116876. declare module BABYLON {
  116877. /**
  116878. * @hidden
  116879. */
  116880. export interface IMaterialBRDFDefines {
  116881. BRDF_V_HEIGHT_CORRELATED: boolean;
  116882. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116883. SPHERICAL_HARMONICS: boolean;
  116884. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116885. /** @hidden */
  116886. _areMiscDirty: boolean;
  116887. }
  116888. /**
  116889. * Define the code related to the BRDF parameters of the pbr material.
  116890. */
  116891. export class PBRBRDFConfiguration {
  116892. /**
  116893. * Default value used for the energy conservation.
  116894. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116895. */
  116896. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  116897. /**
  116898. * Default value used for the Smith Visibility Height Correlated mode.
  116899. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116900. */
  116901. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  116902. /**
  116903. * Default value used for the IBL diffuse part.
  116904. * This can help switching back to the polynomials mode globally which is a tiny bit
  116905. * less GPU intensive at the drawback of a lower quality.
  116906. */
  116907. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  116908. /**
  116909. * Default value used for activating energy conservation for the specular workflow.
  116910. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116911. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116912. */
  116913. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  116914. private _useEnergyConservation;
  116915. /**
  116916. * Defines if the material uses energy conservation.
  116917. */
  116918. useEnergyConservation: boolean;
  116919. private _useSmithVisibilityHeightCorrelated;
  116920. /**
  116921. * LEGACY Mode set to false
  116922. * Defines if the material uses height smith correlated visibility term.
  116923. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  116924. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  116925. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  116926. * Not relying on height correlated will also disable energy conservation.
  116927. */
  116928. useSmithVisibilityHeightCorrelated: boolean;
  116929. private _useSphericalHarmonics;
  116930. /**
  116931. * LEGACY Mode set to false
  116932. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  116933. * diffuse part of the IBL.
  116934. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  116935. * to the ground truth.
  116936. */
  116937. useSphericalHarmonics: boolean;
  116938. private _useSpecularGlossinessInputEnergyConservation;
  116939. /**
  116940. * Defines if the material uses energy conservation, when the specular workflow is active.
  116941. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116942. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116943. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  116944. */
  116945. useSpecularGlossinessInputEnergyConservation: boolean;
  116946. /** @hidden */
  116947. private _internalMarkAllSubMeshesAsMiscDirty;
  116948. /** @hidden */
  116949. _markAllSubMeshesAsMiscDirty(): void;
  116950. /**
  116951. * Instantiate a new istance of clear coat configuration.
  116952. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  116953. */
  116954. constructor(markAllSubMeshesAsMiscDirty: () => void);
  116955. /**
  116956. * Checks to see if a texture is used in the material.
  116957. * @param defines the list of "defines" to update.
  116958. */
  116959. prepareDefines(defines: IMaterialBRDFDefines): void;
  116960. /**
  116961. * Get the current class name of the texture useful for serialization or dynamic coding.
  116962. * @returns "PBRClearCoatConfiguration"
  116963. */
  116964. getClassName(): string;
  116965. /**
  116966. * Makes a duplicate of the current configuration into another one.
  116967. * @param brdfConfiguration define the config where to copy the info
  116968. */
  116969. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  116970. /**
  116971. * Serializes this BRDF configuration.
  116972. * @returns - An object with the serialized config.
  116973. */
  116974. serialize(): any;
  116975. /**
  116976. * Parses a anisotropy Configuration from a serialized object.
  116977. * @param source - Serialized object.
  116978. * @param scene Defines the scene we are parsing for
  116979. * @param rootUrl Defines the rootUrl to load from
  116980. */
  116981. parse(source: any, scene: Scene, rootUrl: string): void;
  116982. }
  116983. }
  116984. declare module BABYLON {
  116985. /**
  116986. * @hidden
  116987. */
  116988. export interface IMaterialSheenDefines {
  116989. SHEEN: boolean;
  116990. SHEEN_TEXTURE: boolean;
  116991. SHEEN_TEXTUREDIRECTUV: number;
  116992. SHEEN_LINKWITHALBEDO: boolean;
  116993. /** @hidden */
  116994. _areTexturesDirty: boolean;
  116995. }
  116996. /**
  116997. * Define the code related to the Sheen parameters of the pbr material.
  116998. */
  116999. export class PBRSheenConfiguration {
  117000. private _isEnabled;
  117001. /**
  117002. * Defines if the material uses sheen.
  117003. */
  117004. isEnabled: boolean;
  117005. private _linkSheenWithAlbedo;
  117006. /**
  117007. * Defines if the sheen is linked to the sheen color.
  117008. */
  117009. linkSheenWithAlbedo: boolean;
  117010. /**
  117011. * Defines the sheen intensity.
  117012. */
  117013. intensity: number;
  117014. /**
  117015. * Defines the sheen color.
  117016. */
  117017. color: Color3;
  117018. private _texture;
  117019. /**
  117020. * Stores the sheen tint values in a texture.
  117021. * rgb is tint
  117022. * a is a intensity
  117023. */
  117024. texture: Nullable<BaseTexture>;
  117025. /** @hidden */
  117026. private _internalMarkAllSubMeshesAsTexturesDirty;
  117027. /** @hidden */
  117028. _markAllSubMeshesAsTexturesDirty(): void;
  117029. /**
  117030. * Instantiate a new istance of clear coat configuration.
  117031. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117032. */
  117033. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117034. /**
  117035. * Specifies that the submesh is ready to be used.
  117036. * @param defines the list of "defines" to update.
  117037. * @param scene defines the scene the material belongs to.
  117038. * @returns - boolean indicating that the submesh is ready or not.
  117039. */
  117040. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  117041. /**
  117042. * Checks to see if a texture is used in the material.
  117043. * @param defines the list of "defines" to update.
  117044. * @param scene defines the scene the material belongs to.
  117045. */
  117046. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  117047. /**
  117048. * Binds the material data.
  117049. * @param uniformBuffer defines the Uniform buffer to fill in.
  117050. * @param scene defines the scene the material belongs to.
  117051. * @param isFrozen defines wether the material is frozen or not.
  117052. */
  117053. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  117054. /**
  117055. * Checks to see if a texture is used in the material.
  117056. * @param texture - Base texture to use.
  117057. * @returns - Boolean specifying if a texture is used in the material.
  117058. */
  117059. hasTexture(texture: BaseTexture): boolean;
  117060. /**
  117061. * Returns an array of the actively used textures.
  117062. * @param activeTextures Array of BaseTextures
  117063. */
  117064. getActiveTextures(activeTextures: BaseTexture[]): void;
  117065. /**
  117066. * Returns the animatable textures.
  117067. * @param animatables Array of animatable textures.
  117068. */
  117069. getAnimatables(animatables: IAnimatable[]): void;
  117070. /**
  117071. * Disposes the resources of the material.
  117072. * @param forceDisposeTextures - Forces the disposal of all textures.
  117073. */
  117074. dispose(forceDisposeTextures?: boolean): void;
  117075. /**
  117076. * Get the current class name of the texture useful for serialization or dynamic coding.
  117077. * @returns "PBRSheenConfiguration"
  117078. */
  117079. getClassName(): string;
  117080. /**
  117081. * Add fallbacks to the effect fallbacks list.
  117082. * @param defines defines the Base texture to use.
  117083. * @param fallbacks defines the current fallback list.
  117084. * @param currentRank defines the current fallback rank.
  117085. * @returns the new fallback rank.
  117086. */
  117087. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117088. /**
  117089. * Add the required uniforms to the current list.
  117090. * @param uniforms defines the current uniform list.
  117091. */
  117092. static AddUniforms(uniforms: string[]): void;
  117093. /**
  117094. * Add the required uniforms to the current buffer.
  117095. * @param uniformBuffer defines the current uniform buffer.
  117096. */
  117097. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117098. /**
  117099. * Add the required samplers to the current list.
  117100. * @param samplers defines the current sampler list.
  117101. */
  117102. static AddSamplers(samplers: string[]): void;
  117103. /**
  117104. * Makes a duplicate of the current configuration into another one.
  117105. * @param sheenConfiguration define the config where to copy the info
  117106. */
  117107. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  117108. /**
  117109. * Serializes this BRDF configuration.
  117110. * @returns - An object with the serialized config.
  117111. */
  117112. serialize(): any;
  117113. /**
  117114. * Parses a anisotropy Configuration from a serialized object.
  117115. * @param source - Serialized object.
  117116. * @param scene Defines the scene we are parsing for
  117117. * @param rootUrl Defines the rootUrl to load from
  117118. */
  117119. parse(source: any, scene: Scene, rootUrl: string): void;
  117120. }
  117121. }
  117122. declare module BABYLON {
  117123. /**
  117124. * @hidden
  117125. */
  117126. export interface IMaterialSubSurfaceDefines {
  117127. SUBSURFACE: boolean;
  117128. SS_REFRACTION: boolean;
  117129. SS_TRANSLUCENCY: boolean;
  117130. SS_SCATERRING: boolean;
  117131. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117132. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117133. SS_REFRACTIONMAP_3D: boolean;
  117134. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117135. SS_LODINREFRACTIONALPHA: boolean;
  117136. SS_GAMMAREFRACTION: boolean;
  117137. SS_RGBDREFRACTION: boolean;
  117138. SS_LINEARSPECULARREFRACTION: boolean;
  117139. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117140. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117141. /** @hidden */
  117142. _areTexturesDirty: boolean;
  117143. }
  117144. /**
  117145. * Define the code related to the sub surface parameters of the pbr material.
  117146. */
  117147. export class PBRSubSurfaceConfiguration {
  117148. private _isRefractionEnabled;
  117149. /**
  117150. * Defines if the refraction is enabled in the material.
  117151. */
  117152. isRefractionEnabled: boolean;
  117153. private _isTranslucencyEnabled;
  117154. /**
  117155. * Defines if the translucency is enabled in the material.
  117156. */
  117157. isTranslucencyEnabled: boolean;
  117158. private _isScatteringEnabled;
  117159. /**
  117160. * Defines the refraction intensity of the material.
  117161. * The refraction when enabled replaces the Diffuse part of the material.
  117162. * The intensity helps transitionning between diffuse and refraction.
  117163. */
  117164. refractionIntensity: number;
  117165. /**
  117166. * Defines the translucency intensity of the material.
  117167. * When translucency has been enabled, this defines how much of the "translucency"
  117168. * is addded to the diffuse part of the material.
  117169. */
  117170. translucencyIntensity: number;
  117171. /**
  117172. * Defines the scattering intensity of the material.
  117173. * When scattering has been enabled, this defines how much of the "scattered light"
  117174. * is addded to the diffuse part of the material.
  117175. */
  117176. scatteringIntensity: number;
  117177. private _thicknessTexture;
  117178. /**
  117179. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  117180. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  117181. * 0 would mean minimumThickness
  117182. * 1 would mean maximumThickness
  117183. * The other channels might be use as a mask to vary the different effects intensity.
  117184. */
  117185. thicknessTexture: Nullable<BaseTexture>;
  117186. private _refractionTexture;
  117187. /**
  117188. * Defines the texture to use for refraction.
  117189. */
  117190. refractionTexture: Nullable<BaseTexture>;
  117191. private _indexOfRefraction;
  117192. /**
  117193. * Defines the index of refraction used in the material.
  117194. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  117195. */
  117196. indexOfRefraction: number;
  117197. private _invertRefractionY;
  117198. /**
  117199. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117200. */
  117201. invertRefractionY: boolean;
  117202. private _linkRefractionWithTransparency;
  117203. /**
  117204. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117205. * Materials half opaque for instance using refraction could benefit from this control.
  117206. */
  117207. linkRefractionWithTransparency: boolean;
  117208. /**
  117209. * Defines the minimum thickness stored in the thickness map.
  117210. * If no thickness map is defined, this value will be used to simulate thickness.
  117211. */
  117212. minimumThickness: number;
  117213. /**
  117214. * Defines the maximum thickness stored in the thickness map.
  117215. */
  117216. maximumThickness: number;
  117217. /**
  117218. * Defines the volume tint of the material.
  117219. * This is used for both translucency and scattering.
  117220. */
  117221. tintColor: Color3;
  117222. /**
  117223. * Defines the distance at which the tint color should be found in the media.
  117224. * This is used for refraction only.
  117225. */
  117226. tintColorAtDistance: number;
  117227. /**
  117228. * Defines how far each channel transmit through the media.
  117229. * It is defined as a color to simplify it selection.
  117230. */
  117231. diffusionDistance: Color3;
  117232. private _useMaskFromThicknessTexture;
  117233. /**
  117234. * Stores the intensity of the different subsurface effects in the thickness texture.
  117235. * * the green channel is the translucency intensity.
  117236. * * the blue channel is the scattering intensity.
  117237. * * the alpha channel is the refraction intensity.
  117238. */
  117239. useMaskFromThicknessTexture: boolean;
  117240. /** @hidden */
  117241. private _internalMarkAllSubMeshesAsTexturesDirty;
  117242. /** @hidden */
  117243. _markAllSubMeshesAsTexturesDirty(): void;
  117244. /**
  117245. * Instantiate a new istance of sub surface configuration.
  117246. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117247. */
  117248. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117249. /**
  117250. * Gets wehter the submesh is ready to be used or not.
  117251. * @param defines the list of "defines" to update.
  117252. * @param scene defines the scene the material belongs to.
  117253. * @returns - boolean indicating that the submesh is ready or not.
  117254. */
  117255. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  117256. /**
  117257. * Checks to see if a texture is used in the material.
  117258. * @param defines the list of "defines" to update.
  117259. * @param scene defines the scene to the material belongs to.
  117260. */
  117261. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  117262. /**
  117263. * Binds the material data.
  117264. * @param uniformBuffer defines the Uniform buffer to fill in.
  117265. * @param scene defines the scene the material belongs to.
  117266. * @param engine defines the engine the material belongs to.
  117267. * @param isFrozen defines wether the material is frozen or not.
  117268. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  117269. */
  117270. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  117271. /**
  117272. * Unbinds the material from the mesh.
  117273. * @param activeEffect defines the effect that should be unbound from.
  117274. * @returns true if unbound, otherwise false
  117275. */
  117276. unbind(activeEffect: Effect): boolean;
  117277. /**
  117278. * Returns the texture used for refraction or null if none is used.
  117279. * @param scene defines the scene the material belongs to.
  117280. * @returns - Refraction texture if present. If no refraction texture and refraction
  117281. * is linked with transparency, returns environment texture. Otherwise, returns null.
  117282. */
  117283. private _getRefractionTexture;
  117284. /**
  117285. * Returns true if alpha blending should be disabled.
  117286. */
  117287. readonly disableAlphaBlending: boolean;
  117288. /**
  117289. * Fills the list of render target textures.
  117290. * @param renderTargets the list of render targets to update
  117291. */
  117292. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  117293. /**
  117294. * Checks to see if a texture is used in the material.
  117295. * @param texture - Base texture to use.
  117296. * @returns - Boolean specifying if a texture is used in the material.
  117297. */
  117298. hasTexture(texture: BaseTexture): boolean;
  117299. /**
  117300. * Gets a boolean indicating that current material needs to register RTT
  117301. * @returns true if this uses a render target otherwise false.
  117302. */
  117303. hasRenderTargetTextures(): boolean;
  117304. /**
  117305. * Returns an array of the actively used textures.
  117306. * @param activeTextures Array of BaseTextures
  117307. */
  117308. getActiveTextures(activeTextures: BaseTexture[]): void;
  117309. /**
  117310. * Returns the animatable textures.
  117311. * @param animatables Array of animatable textures.
  117312. */
  117313. getAnimatables(animatables: IAnimatable[]): void;
  117314. /**
  117315. * Disposes the resources of the material.
  117316. * @param forceDisposeTextures - Forces the disposal of all textures.
  117317. */
  117318. dispose(forceDisposeTextures?: boolean): void;
  117319. /**
  117320. * Get the current class name of the texture useful for serialization or dynamic coding.
  117321. * @returns "PBRSubSurfaceConfiguration"
  117322. */
  117323. getClassName(): string;
  117324. /**
  117325. * Add fallbacks to the effect fallbacks list.
  117326. * @param defines defines the Base texture to use.
  117327. * @param fallbacks defines the current fallback list.
  117328. * @param currentRank defines the current fallback rank.
  117329. * @returns the new fallback rank.
  117330. */
  117331. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117332. /**
  117333. * Add the required uniforms to the current list.
  117334. * @param uniforms defines the current uniform list.
  117335. */
  117336. static AddUniforms(uniforms: string[]): void;
  117337. /**
  117338. * Add the required samplers to the current list.
  117339. * @param samplers defines the current sampler list.
  117340. */
  117341. static AddSamplers(samplers: string[]): void;
  117342. /**
  117343. * Add the required uniforms to the current buffer.
  117344. * @param uniformBuffer defines the current uniform buffer.
  117345. */
  117346. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117347. /**
  117348. * Makes a duplicate of the current configuration into another one.
  117349. * @param configuration define the config where to copy the info
  117350. */
  117351. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  117352. /**
  117353. * Serializes this Sub Surface configuration.
  117354. * @returns - An object with the serialized config.
  117355. */
  117356. serialize(): any;
  117357. /**
  117358. * Parses a anisotropy Configuration from a serialized object.
  117359. * @param source - Serialized object.
  117360. * @param scene Defines the scene we are parsing for
  117361. * @param rootUrl Defines the rootUrl to load from
  117362. */
  117363. parse(source: any, scene: Scene, rootUrl: string): void;
  117364. }
  117365. }
  117366. declare module BABYLON {
  117367. /** @hidden */
  117368. export var pbrFragmentDeclaration: {
  117369. name: string;
  117370. shader: string;
  117371. };
  117372. }
  117373. declare module BABYLON {
  117374. /** @hidden */
  117375. export var pbrUboDeclaration: {
  117376. name: string;
  117377. shader: string;
  117378. };
  117379. }
  117380. declare module BABYLON {
  117381. /** @hidden */
  117382. export var pbrFragmentExtraDeclaration: {
  117383. name: string;
  117384. shader: string;
  117385. };
  117386. }
  117387. declare module BABYLON {
  117388. /** @hidden */
  117389. export var pbrFragmentSamplersDeclaration: {
  117390. name: string;
  117391. shader: string;
  117392. };
  117393. }
  117394. declare module BABYLON {
  117395. /** @hidden */
  117396. export var pbrHelperFunctions: {
  117397. name: string;
  117398. shader: string;
  117399. };
  117400. }
  117401. declare module BABYLON {
  117402. /** @hidden */
  117403. export var harmonicsFunctions: {
  117404. name: string;
  117405. shader: string;
  117406. };
  117407. }
  117408. declare module BABYLON {
  117409. /** @hidden */
  117410. export var pbrDirectLightingSetupFunctions: {
  117411. name: string;
  117412. shader: string;
  117413. };
  117414. }
  117415. declare module BABYLON {
  117416. /** @hidden */
  117417. export var pbrDirectLightingFalloffFunctions: {
  117418. name: string;
  117419. shader: string;
  117420. };
  117421. }
  117422. declare module BABYLON {
  117423. /** @hidden */
  117424. export var pbrBRDFFunctions: {
  117425. name: string;
  117426. shader: string;
  117427. };
  117428. }
  117429. declare module BABYLON {
  117430. /** @hidden */
  117431. export var pbrDirectLightingFunctions: {
  117432. name: string;
  117433. shader: string;
  117434. };
  117435. }
  117436. declare module BABYLON {
  117437. /** @hidden */
  117438. export var pbrIBLFunctions: {
  117439. name: string;
  117440. shader: string;
  117441. };
  117442. }
  117443. declare module BABYLON {
  117444. /** @hidden */
  117445. export var pbrDebug: {
  117446. name: string;
  117447. shader: string;
  117448. };
  117449. }
  117450. declare module BABYLON {
  117451. /** @hidden */
  117452. export var pbrPixelShader: {
  117453. name: string;
  117454. shader: string;
  117455. };
  117456. }
  117457. declare module BABYLON {
  117458. /** @hidden */
  117459. export var pbrVertexDeclaration: {
  117460. name: string;
  117461. shader: string;
  117462. };
  117463. }
  117464. declare module BABYLON {
  117465. /** @hidden */
  117466. export var pbrVertexShader: {
  117467. name: string;
  117468. shader: string;
  117469. };
  117470. }
  117471. declare module BABYLON {
  117472. /**
  117473. * Manages the defines for the PBR Material.
  117474. * @hidden
  117475. */
  117476. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  117477. PBR: boolean;
  117478. MAINUV1: boolean;
  117479. MAINUV2: boolean;
  117480. UV1: boolean;
  117481. UV2: boolean;
  117482. ALBEDO: boolean;
  117483. ALBEDODIRECTUV: number;
  117484. VERTEXCOLOR: boolean;
  117485. AMBIENT: boolean;
  117486. AMBIENTDIRECTUV: number;
  117487. AMBIENTINGRAYSCALE: boolean;
  117488. OPACITY: boolean;
  117489. VERTEXALPHA: boolean;
  117490. OPACITYDIRECTUV: number;
  117491. OPACITYRGB: boolean;
  117492. ALPHATEST: boolean;
  117493. DEPTHPREPASS: boolean;
  117494. ALPHABLEND: boolean;
  117495. ALPHAFROMALBEDO: boolean;
  117496. ALPHATESTVALUE: string;
  117497. SPECULAROVERALPHA: boolean;
  117498. RADIANCEOVERALPHA: boolean;
  117499. ALPHAFRESNEL: boolean;
  117500. LINEARALPHAFRESNEL: boolean;
  117501. PREMULTIPLYALPHA: boolean;
  117502. EMISSIVE: boolean;
  117503. EMISSIVEDIRECTUV: number;
  117504. REFLECTIVITY: boolean;
  117505. REFLECTIVITYDIRECTUV: number;
  117506. SPECULARTERM: boolean;
  117507. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  117508. MICROSURFACEAUTOMATIC: boolean;
  117509. LODBASEDMICROSFURACE: boolean;
  117510. MICROSURFACEMAP: boolean;
  117511. MICROSURFACEMAPDIRECTUV: number;
  117512. METALLICWORKFLOW: boolean;
  117513. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  117514. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  117515. METALLNESSSTOREINMETALMAPBLUE: boolean;
  117516. AOSTOREINMETALMAPRED: boolean;
  117517. METALLICF0FACTORFROMMETALLICMAP: boolean;
  117518. ENVIRONMENTBRDF: boolean;
  117519. ENVIRONMENTBRDF_RGBD: boolean;
  117520. NORMAL: boolean;
  117521. TANGENT: boolean;
  117522. BUMP: boolean;
  117523. BUMPDIRECTUV: number;
  117524. OBJECTSPACE_NORMALMAP: boolean;
  117525. PARALLAX: boolean;
  117526. PARALLAXOCCLUSION: boolean;
  117527. NORMALXYSCALE: boolean;
  117528. LIGHTMAP: boolean;
  117529. LIGHTMAPDIRECTUV: number;
  117530. USELIGHTMAPASSHADOWMAP: boolean;
  117531. GAMMALIGHTMAP: boolean;
  117532. RGBDLIGHTMAP: boolean;
  117533. REFLECTION: boolean;
  117534. REFLECTIONMAP_3D: boolean;
  117535. REFLECTIONMAP_SPHERICAL: boolean;
  117536. REFLECTIONMAP_PLANAR: boolean;
  117537. REFLECTIONMAP_CUBIC: boolean;
  117538. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  117539. REFLECTIONMAP_PROJECTION: boolean;
  117540. REFLECTIONMAP_SKYBOX: boolean;
  117541. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  117542. REFLECTIONMAP_EXPLICIT: boolean;
  117543. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  117544. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  117545. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  117546. INVERTCUBICMAP: boolean;
  117547. USESPHERICALFROMREFLECTIONMAP: boolean;
  117548. USEIRRADIANCEMAP: boolean;
  117549. SPHERICAL_HARMONICS: boolean;
  117550. USESPHERICALINVERTEX: boolean;
  117551. REFLECTIONMAP_OPPOSITEZ: boolean;
  117552. LODINREFLECTIONALPHA: boolean;
  117553. GAMMAREFLECTION: boolean;
  117554. RGBDREFLECTION: boolean;
  117555. LINEARSPECULARREFLECTION: boolean;
  117556. RADIANCEOCCLUSION: boolean;
  117557. HORIZONOCCLUSION: boolean;
  117558. INSTANCES: boolean;
  117559. NUM_BONE_INFLUENCERS: number;
  117560. BonesPerMesh: number;
  117561. BONETEXTURE: boolean;
  117562. NONUNIFORMSCALING: boolean;
  117563. MORPHTARGETS: boolean;
  117564. MORPHTARGETS_NORMAL: boolean;
  117565. MORPHTARGETS_TANGENT: boolean;
  117566. MORPHTARGETS_UV: boolean;
  117567. NUM_MORPH_INFLUENCERS: number;
  117568. IMAGEPROCESSING: boolean;
  117569. VIGNETTE: boolean;
  117570. VIGNETTEBLENDMODEMULTIPLY: boolean;
  117571. VIGNETTEBLENDMODEOPAQUE: boolean;
  117572. TONEMAPPING: boolean;
  117573. TONEMAPPING_ACES: boolean;
  117574. CONTRAST: boolean;
  117575. COLORCURVES: boolean;
  117576. COLORGRADING: boolean;
  117577. COLORGRADING3D: boolean;
  117578. SAMPLER3DGREENDEPTH: boolean;
  117579. SAMPLER3DBGRMAP: boolean;
  117580. IMAGEPROCESSINGPOSTPROCESS: boolean;
  117581. EXPOSURE: boolean;
  117582. MULTIVIEW: boolean;
  117583. USEPHYSICALLIGHTFALLOFF: boolean;
  117584. USEGLTFLIGHTFALLOFF: boolean;
  117585. TWOSIDEDLIGHTING: boolean;
  117586. SHADOWFLOAT: boolean;
  117587. CLIPPLANE: boolean;
  117588. CLIPPLANE2: boolean;
  117589. CLIPPLANE3: boolean;
  117590. CLIPPLANE4: boolean;
  117591. POINTSIZE: boolean;
  117592. FOG: boolean;
  117593. LOGARITHMICDEPTH: boolean;
  117594. FORCENORMALFORWARD: boolean;
  117595. SPECULARAA: boolean;
  117596. CLEARCOAT: boolean;
  117597. CLEARCOAT_DEFAULTIOR: boolean;
  117598. CLEARCOAT_TEXTURE: boolean;
  117599. CLEARCOAT_TEXTUREDIRECTUV: number;
  117600. CLEARCOAT_BUMP: boolean;
  117601. CLEARCOAT_BUMPDIRECTUV: number;
  117602. CLEARCOAT_TINT: boolean;
  117603. CLEARCOAT_TINT_TEXTURE: boolean;
  117604. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  117605. ANISOTROPIC: boolean;
  117606. ANISOTROPIC_TEXTURE: boolean;
  117607. ANISOTROPIC_TEXTUREDIRECTUV: number;
  117608. BRDF_V_HEIGHT_CORRELATED: boolean;
  117609. MS_BRDF_ENERGY_CONSERVATION: boolean;
  117610. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  117611. SHEEN: boolean;
  117612. SHEEN_TEXTURE: boolean;
  117613. SHEEN_TEXTUREDIRECTUV: number;
  117614. SHEEN_LINKWITHALBEDO: boolean;
  117615. SUBSURFACE: boolean;
  117616. SS_REFRACTION: boolean;
  117617. SS_TRANSLUCENCY: boolean;
  117618. SS_SCATERRING: boolean;
  117619. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117620. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117621. SS_REFRACTIONMAP_3D: boolean;
  117622. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117623. SS_LODINREFRACTIONALPHA: boolean;
  117624. SS_GAMMAREFRACTION: boolean;
  117625. SS_RGBDREFRACTION: boolean;
  117626. SS_LINEARSPECULARREFRACTION: boolean;
  117627. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117628. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117629. UNLIT: boolean;
  117630. DEBUGMODE: number;
  117631. /**
  117632. * Initializes the PBR Material defines.
  117633. */
  117634. constructor();
  117635. /**
  117636. * Resets the PBR Material defines.
  117637. */
  117638. reset(): void;
  117639. }
  117640. /**
  117641. * The Physically based material base class of BJS.
  117642. *
  117643. * This offers the main features of a standard PBR material.
  117644. * For more information, please refer to the documentation :
  117645. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117646. */
  117647. export abstract class PBRBaseMaterial extends PushMaterial {
  117648. /**
  117649. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117650. */
  117651. static readonly PBRMATERIAL_OPAQUE: number;
  117652. /**
  117653. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117654. */
  117655. static readonly PBRMATERIAL_ALPHATEST: number;
  117656. /**
  117657. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117658. */
  117659. static readonly PBRMATERIAL_ALPHABLEND: number;
  117660. /**
  117661. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117662. * They are also discarded below the alpha cutoff threshold to improve performances.
  117663. */
  117664. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117665. /**
  117666. * Defines the default value of how much AO map is occluding the analytical lights
  117667. * (point spot...).
  117668. */
  117669. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117670. /**
  117671. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  117672. */
  117673. static readonly LIGHTFALLOFF_PHYSICAL: number;
  117674. /**
  117675. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  117676. * to enhance interoperability with other engines.
  117677. */
  117678. static readonly LIGHTFALLOFF_GLTF: number;
  117679. /**
  117680. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  117681. * to enhance interoperability with other materials.
  117682. */
  117683. static readonly LIGHTFALLOFF_STANDARD: number;
  117684. /**
  117685. * Intensity of the direct lights e.g. the four lights available in your scene.
  117686. * This impacts both the direct diffuse and specular highlights.
  117687. */
  117688. protected _directIntensity: number;
  117689. /**
  117690. * Intensity of the emissive part of the material.
  117691. * This helps controlling the emissive effect without modifying the emissive color.
  117692. */
  117693. protected _emissiveIntensity: number;
  117694. /**
  117695. * Intensity of the environment e.g. how much the environment will light the object
  117696. * either through harmonics for rough material or through the refelction for shiny ones.
  117697. */
  117698. protected _environmentIntensity: number;
  117699. /**
  117700. * This is a special control allowing the reduction of the specular highlights coming from the
  117701. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117702. */
  117703. protected _specularIntensity: number;
  117704. /**
  117705. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  117706. */
  117707. private _lightingInfos;
  117708. /**
  117709. * Debug Control allowing disabling the bump map on this material.
  117710. */
  117711. protected _disableBumpMap: boolean;
  117712. /**
  117713. * AKA Diffuse Texture in standard nomenclature.
  117714. */
  117715. protected _albedoTexture: Nullable<BaseTexture>;
  117716. /**
  117717. * AKA Occlusion Texture in other nomenclature.
  117718. */
  117719. protected _ambientTexture: Nullable<BaseTexture>;
  117720. /**
  117721. * AKA Occlusion Texture Intensity in other nomenclature.
  117722. */
  117723. protected _ambientTextureStrength: number;
  117724. /**
  117725. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117726. * 1 means it completely occludes it
  117727. * 0 mean it has no impact
  117728. */
  117729. protected _ambientTextureImpactOnAnalyticalLights: number;
  117730. /**
  117731. * Stores the alpha values in a texture.
  117732. */
  117733. protected _opacityTexture: Nullable<BaseTexture>;
  117734. /**
  117735. * Stores the reflection values in a texture.
  117736. */
  117737. protected _reflectionTexture: Nullable<BaseTexture>;
  117738. /**
  117739. * Stores the emissive values in a texture.
  117740. */
  117741. protected _emissiveTexture: Nullable<BaseTexture>;
  117742. /**
  117743. * AKA Specular texture in other nomenclature.
  117744. */
  117745. protected _reflectivityTexture: Nullable<BaseTexture>;
  117746. /**
  117747. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117748. */
  117749. protected _metallicTexture: Nullable<BaseTexture>;
  117750. /**
  117751. * Specifies the metallic scalar of the metallic/roughness workflow.
  117752. * Can also be used to scale the metalness values of the metallic texture.
  117753. */
  117754. protected _metallic: Nullable<number>;
  117755. /**
  117756. * Specifies the roughness scalar of the metallic/roughness workflow.
  117757. * Can also be used to scale the roughness values of the metallic texture.
  117758. */
  117759. protected _roughness: Nullable<number>;
  117760. /**
  117761. * Specifies the an F0 factor to help configuring the material F0.
  117762. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117763. * to 0.5 the previously hard coded value stays the same.
  117764. * Can also be used to scale the F0 values of the metallic texture.
  117765. */
  117766. protected _metallicF0Factor: number;
  117767. /**
  117768. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117769. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117770. * your expectation as it multiplies with the texture data.
  117771. */
  117772. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  117773. /**
  117774. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117775. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117776. */
  117777. protected _microSurfaceTexture: Nullable<BaseTexture>;
  117778. /**
  117779. * Stores surface normal data used to displace a mesh in a texture.
  117780. */
  117781. protected _bumpTexture: Nullable<BaseTexture>;
  117782. /**
  117783. * Stores the pre-calculated light information of a mesh in a texture.
  117784. */
  117785. protected _lightmapTexture: Nullable<BaseTexture>;
  117786. /**
  117787. * The color of a material in ambient lighting.
  117788. */
  117789. protected _ambientColor: Color3;
  117790. /**
  117791. * AKA Diffuse Color in other nomenclature.
  117792. */
  117793. protected _albedoColor: Color3;
  117794. /**
  117795. * AKA Specular Color in other nomenclature.
  117796. */
  117797. protected _reflectivityColor: Color3;
  117798. /**
  117799. * The color applied when light is reflected from a material.
  117800. */
  117801. protected _reflectionColor: Color3;
  117802. /**
  117803. * The color applied when light is emitted from a material.
  117804. */
  117805. protected _emissiveColor: Color3;
  117806. /**
  117807. * AKA Glossiness in other nomenclature.
  117808. */
  117809. protected _microSurface: number;
  117810. /**
  117811. * Specifies that the material will use the light map as a show map.
  117812. */
  117813. protected _useLightmapAsShadowmap: boolean;
  117814. /**
  117815. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117816. * makes the reflect vector face the model (under horizon).
  117817. */
  117818. protected _useHorizonOcclusion: boolean;
  117819. /**
  117820. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117821. * too much the area relying on ambient texture to define their ambient occlusion.
  117822. */
  117823. protected _useRadianceOcclusion: boolean;
  117824. /**
  117825. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117826. */
  117827. protected _useAlphaFromAlbedoTexture: boolean;
  117828. /**
  117829. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  117830. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117831. */
  117832. protected _useSpecularOverAlpha: boolean;
  117833. /**
  117834. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117835. */
  117836. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117837. /**
  117838. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117839. */
  117840. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  117841. /**
  117842. * Specifies if the metallic texture contains the roughness information in its green channel.
  117843. */
  117844. protected _useRoughnessFromMetallicTextureGreen: boolean;
  117845. /**
  117846. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117847. */
  117848. protected _useMetallnessFromMetallicTextureBlue: boolean;
  117849. /**
  117850. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117851. */
  117852. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  117853. /**
  117854. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117855. */
  117856. protected _useAmbientInGrayScale: boolean;
  117857. /**
  117858. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117859. * The material will try to infer what glossiness each pixel should be.
  117860. */
  117861. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  117862. /**
  117863. * Defines the falloff type used in this material.
  117864. * It by default is Physical.
  117865. */
  117866. protected _lightFalloff: number;
  117867. /**
  117868. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117869. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117870. */
  117871. protected _useRadianceOverAlpha: boolean;
  117872. /**
  117873. * Allows using an object space normal map (instead of tangent space).
  117874. */
  117875. protected _useObjectSpaceNormalMap: boolean;
  117876. /**
  117877. * Allows using the bump map in parallax mode.
  117878. */
  117879. protected _useParallax: boolean;
  117880. /**
  117881. * Allows using the bump map in parallax occlusion mode.
  117882. */
  117883. protected _useParallaxOcclusion: boolean;
  117884. /**
  117885. * Controls the scale bias of the parallax mode.
  117886. */
  117887. protected _parallaxScaleBias: number;
  117888. /**
  117889. * If sets to true, disables all the lights affecting the material.
  117890. */
  117891. protected _disableLighting: boolean;
  117892. /**
  117893. * Number of Simultaneous lights allowed on the material.
  117894. */
  117895. protected _maxSimultaneousLights: number;
  117896. /**
  117897. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  117898. */
  117899. protected _invertNormalMapX: boolean;
  117900. /**
  117901. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  117902. */
  117903. protected _invertNormalMapY: boolean;
  117904. /**
  117905. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117906. */
  117907. protected _twoSidedLighting: boolean;
  117908. /**
  117909. * Defines the alpha limits in alpha test mode.
  117910. */
  117911. protected _alphaCutOff: number;
  117912. /**
  117913. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117914. */
  117915. protected _forceAlphaTest: boolean;
  117916. /**
  117917. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117918. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117919. */
  117920. protected _useAlphaFresnel: boolean;
  117921. /**
  117922. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117923. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117924. */
  117925. protected _useLinearAlphaFresnel: boolean;
  117926. /**
  117927. * The transparency mode of the material.
  117928. */
  117929. protected _transparencyMode: Nullable<number>;
  117930. /**
  117931. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  117932. * from cos thetav and roughness:
  117933. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  117934. */
  117935. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  117936. /**
  117937. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117938. */
  117939. protected _forceIrradianceInFragment: boolean;
  117940. /**
  117941. * Force normal to face away from face.
  117942. */
  117943. protected _forceNormalForward: boolean;
  117944. /**
  117945. * Enables specular anti aliasing in the PBR shader.
  117946. * It will both interacts on the Geometry for analytical and IBL lighting.
  117947. * It also prefilter the roughness map based on the bump values.
  117948. */
  117949. protected _enableSpecularAntiAliasing: boolean;
  117950. /**
  117951. * Default configuration related to image processing available in the PBR Material.
  117952. */
  117953. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117954. /**
  117955. * Keep track of the image processing observer to allow dispose and replace.
  117956. */
  117957. private _imageProcessingObserver;
  117958. /**
  117959. * Attaches a new image processing configuration to the PBR Material.
  117960. * @param configuration
  117961. */
  117962. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117963. /**
  117964. * Stores the available render targets.
  117965. */
  117966. private _renderTargets;
  117967. /**
  117968. * Sets the global ambient color for the material used in lighting calculations.
  117969. */
  117970. private _globalAmbientColor;
  117971. /**
  117972. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  117973. */
  117974. private _useLogarithmicDepth;
  117975. /**
  117976. * If set to true, no lighting calculations will be applied.
  117977. */
  117978. private _unlit;
  117979. private _debugMode;
  117980. /**
  117981. * @hidden
  117982. * This is reserved for the inspector.
  117983. * Defines the material debug mode.
  117984. * It helps seeing only some components of the material while troubleshooting.
  117985. */
  117986. debugMode: number;
  117987. /**
  117988. * @hidden
  117989. * This is reserved for the inspector.
  117990. * Specify from where on screen the debug mode should start.
  117991. * The value goes from -1 (full screen) to 1 (not visible)
  117992. * It helps with side by side comparison against the final render
  117993. * This defaults to -1
  117994. */
  117995. private debugLimit;
  117996. /**
  117997. * @hidden
  117998. * This is reserved for the inspector.
  117999. * As the default viewing range might not be enough (if the ambient is really small for instance)
  118000. * You can use the factor to better multiply the final value.
  118001. */
  118002. private debugFactor;
  118003. /**
  118004. * Defines the clear coat layer parameters for the material.
  118005. */
  118006. readonly clearCoat: PBRClearCoatConfiguration;
  118007. /**
  118008. * Defines the anisotropic parameters for the material.
  118009. */
  118010. readonly anisotropy: PBRAnisotropicConfiguration;
  118011. /**
  118012. * Defines the BRDF parameters for the material.
  118013. */
  118014. readonly brdf: PBRBRDFConfiguration;
  118015. /**
  118016. * Defines the Sheen parameters for the material.
  118017. */
  118018. readonly sheen: PBRSheenConfiguration;
  118019. /**
  118020. * Defines the SubSurface parameters for the material.
  118021. */
  118022. readonly subSurface: PBRSubSurfaceConfiguration;
  118023. /**
  118024. * Custom callback helping to override the default shader used in the material.
  118025. */
  118026. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  118027. protected _rebuildInParallel: boolean;
  118028. /**
  118029. * Instantiates a new PBRMaterial instance.
  118030. *
  118031. * @param name The material name
  118032. * @param scene The scene the material will be use in.
  118033. */
  118034. constructor(name: string, scene: Scene);
  118035. /**
  118036. * Gets a boolean indicating that current material needs to register RTT
  118037. */
  118038. readonly hasRenderTargetTextures: boolean;
  118039. /**
  118040. * Gets the name of the material class.
  118041. */
  118042. getClassName(): string;
  118043. /**
  118044. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  118045. */
  118046. /**
  118047. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  118048. */
  118049. useLogarithmicDepth: boolean;
  118050. /**
  118051. * Gets the current transparency mode.
  118052. */
  118053. /**
  118054. * Sets the transparency mode of the material.
  118055. *
  118056. * | Value | Type | Description |
  118057. * | ----- | ----------------------------------- | ----------- |
  118058. * | 0 | OPAQUE | |
  118059. * | 1 | ALPHATEST | |
  118060. * | 2 | ALPHABLEND | |
  118061. * | 3 | ALPHATESTANDBLEND | |
  118062. *
  118063. */
  118064. transparencyMode: Nullable<number>;
  118065. /**
  118066. * Returns true if alpha blending should be disabled.
  118067. */
  118068. private readonly _disableAlphaBlending;
  118069. /**
  118070. * Specifies whether or not this material should be rendered in alpha blend mode.
  118071. */
  118072. needAlphaBlending(): boolean;
  118073. /**
  118074. * Specifies if the mesh will require alpha blending.
  118075. * @param mesh - BJS mesh.
  118076. */
  118077. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  118078. /**
  118079. * Specifies whether or not this material should be rendered in alpha test mode.
  118080. */
  118081. needAlphaTesting(): boolean;
  118082. /**
  118083. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  118084. */
  118085. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  118086. /**
  118087. * Gets the texture used for the alpha test.
  118088. */
  118089. getAlphaTestTexture(): Nullable<BaseTexture>;
  118090. /**
  118091. * Specifies that the submesh is ready to be used.
  118092. * @param mesh - BJS mesh.
  118093. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  118094. * @param useInstances - Specifies that instances should be used.
  118095. * @returns - boolean indicating that the submesh is ready or not.
  118096. */
  118097. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118098. /**
  118099. * Specifies if the material uses metallic roughness workflow.
  118100. * @returns boolean specifiying if the material uses metallic roughness workflow.
  118101. */
  118102. isMetallicWorkflow(): boolean;
  118103. private _prepareEffect;
  118104. private _prepareDefines;
  118105. /**
  118106. * Force shader compilation
  118107. */
  118108. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  118109. /**
  118110. * Initializes the uniform buffer layout for the shader.
  118111. */
  118112. buildUniformLayout(): void;
  118113. /**
  118114. * Unbinds the material from the mesh
  118115. */
  118116. unbind(): void;
  118117. /**
  118118. * Binds the submesh data.
  118119. * @param world - The world matrix.
  118120. * @param mesh - The BJS mesh.
  118121. * @param subMesh - A submesh of the BJS mesh.
  118122. */
  118123. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118124. /**
  118125. * Returns the animatable textures.
  118126. * @returns - Array of animatable textures.
  118127. */
  118128. getAnimatables(): IAnimatable[];
  118129. /**
  118130. * Returns the texture used for reflections.
  118131. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  118132. */
  118133. private _getReflectionTexture;
  118134. /**
  118135. * Returns an array of the actively used textures.
  118136. * @returns - Array of BaseTextures
  118137. */
  118138. getActiveTextures(): BaseTexture[];
  118139. /**
  118140. * Checks to see if a texture is used in the material.
  118141. * @param texture - Base texture to use.
  118142. * @returns - Boolean specifying if a texture is used in the material.
  118143. */
  118144. hasTexture(texture: BaseTexture): boolean;
  118145. /**
  118146. * Disposes the resources of the material.
  118147. * @param forceDisposeEffect - Forces the disposal of effects.
  118148. * @param forceDisposeTextures - Forces the disposal of all textures.
  118149. */
  118150. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  118151. }
  118152. }
  118153. declare module BABYLON {
  118154. /**
  118155. * The Physically based material of BJS.
  118156. *
  118157. * This offers the main features of a standard PBR material.
  118158. * For more information, please refer to the documentation :
  118159. * https://doc.babylonjs.com/how_to/physically_based_rendering
  118160. */
  118161. export class PBRMaterial extends PBRBaseMaterial {
  118162. /**
  118163. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  118164. */
  118165. static readonly PBRMATERIAL_OPAQUE: number;
  118166. /**
  118167. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  118168. */
  118169. static readonly PBRMATERIAL_ALPHATEST: number;
  118170. /**
  118171. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118172. */
  118173. static readonly PBRMATERIAL_ALPHABLEND: number;
  118174. /**
  118175. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118176. * They are also discarded below the alpha cutoff threshold to improve performances.
  118177. */
  118178. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  118179. /**
  118180. * Defines the default value of how much AO map is occluding the analytical lights
  118181. * (point spot...).
  118182. */
  118183. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  118184. /**
  118185. * Intensity of the direct lights e.g. the four lights available in your scene.
  118186. * This impacts both the direct diffuse and specular highlights.
  118187. */
  118188. directIntensity: number;
  118189. /**
  118190. * Intensity of the emissive part of the material.
  118191. * This helps controlling the emissive effect without modifying the emissive color.
  118192. */
  118193. emissiveIntensity: number;
  118194. /**
  118195. * Intensity of the environment e.g. how much the environment will light the object
  118196. * either through harmonics for rough material or through the refelction for shiny ones.
  118197. */
  118198. environmentIntensity: number;
  118199. /**
  118200. * This is a special control allowing the reduction of the specular highlights coming from the
  118201. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  118202. */
  118203. specularIntensity: number;
  118204. /**
  118205. * Debug Control allowing disabling the bump map on this material.
  118206. */
  118207. disableBumpMap: boolean;
  118208. /**
  118209. * AKA Diffuse Texture in standard nomenclature.
  118210. */
  118211. albedoTexture: BaseTexture;
  118212. /**
  118213. * AKA Occlusion Texture in other nomenclature.
  118214. */
  118215. ambientTexture: BaseTexture;
  118216. /**
  118217. * AKA Occlusion Texture Intensity in other nomenclature.
  118218. */
  118219. ambientTextureStrength: number;
  118220. /**
  118221. * Defines how much the AO map is occluding the analytical lights (point spot...).
  118222. * 1 means it completely occludes it
  118223. * 0 mean it has no impact
  118224. */
  118225. ambientTextureImpactOnAnalyticalLights: number;
  118226. /**
  118227. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  118228. */
  118229. opacityTexture: BaseTexture;
  118230. /**
  118231. * Stores the reflection values in a texture.
  118232. */
  118233. reflectionTexture: Nullable<BaseTexture>;
  118234. /**
  118235. * Stores the emissive values in a texture.
  118236. */
  118237. emissiveTexture: BaseTexture;
  118238. /**
  118239. * AKA Specular texture in other nomenclature.
  118240. */
  118241. reflectivityTexture: BaseTexture;
  118242. /**
  118243. * Used to switch from specular/glossiness to metallic/roughness workflow.
  118244. */
  118245. metallicTexture: BaseTexture;
  118246. /**
  118247. * Specifies the metallic scalar of the metallic/roughness workflow.
  118248. * Can also be used to scale the metalness values of the metallic texture.
  118249. */
  118250. metallic: Nullable<number>;
  118251. /**
  118252. * Specifies the roughness scalar of the metallic/roughness workflow.
  118253. * Can also be used to scale the roughness values of the metallic texture.
  118254. */
  118255. roughness: Nullable<number>;
  118256. /**
  118257. * Specifies the an F0 factor to help configuring the material F0.
  118258. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  118259. * to 0.5 the previously hard coded value stays the same.
  118260. * Can also be used to scale the F0 values of the metallic texture.
  118261. */
  118262. metallicF0Factor: number;
  118263. /**
  118264. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  118265. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  118266. * your expectation as it multiplies with the texture data.
  118267. */
  118268. useMetallicF0FactorFromMetallicTexture: boolean;
  118269. /**
  118270. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  118271. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  118272. */
  118273. microSurfaceTexture: BaseTexture;
  118274. /**
  118275. * Stores surface normal data used to displace a mesh in a texture.
  118276. */
  118277. bumpTexture: BaseTexture;
  118278. /**
  118279. * Stores the pre-calculated light information of a mesh in a texture.
  118280. */
  118281. lightmapTexture: BaseTexture;
  118282. /**
  118283. * Stores the refracted light information in a texture.
  118284. */
  118285. refractionTexture: Nullable<BaseTexture>;
  118286. /**
  118287. * The color of a material in ambient lighting.
  118288. */
  118289. ambientColor: Color3;
  118290. /**
  118291. * AKA Diffuse Color in other nomenclature.
  118292. */
  118293. albedoColor: Color3;
  118294. /**
  118295. * AKA Specular Color in other nomenclature.
  118296. */
  118297. reflectivityColor: Color3;
  118298. /**
  118299. * The color reflected from the material.
  118300. */
  118301. reflectionColor: Color3;
  118302. /**
  118303. * The color emitted from the material.
  118304. */
  118305. emissiveColor: Color3;
  118306. /**
  118307. * AKA Glossiness in other nomenclature.
  118308. */
  118309. microSurface: number;
  118310. /**
  118311. * source material index of refraction (IOR)' / 'destination material IOR.
  118312. */
  118313. indexOfRefraction: number;
  118314. /**
  118315. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  118316. */
  118317. invertRefractionY: boolean;
  118318. /**
  118319. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  118320. * Materials half opaque for instance using refraction could benefit from this control.
  118321. */
  118322. linkRefractionWithTransparency: boolean;
  118323. /**
  118324. * If true, the light map contains occlusion information instead of lighting info.
  118325. */
  118326. useLightmapAsShadowmap: boolean;
  118327. /**
  118328. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  118329. */
  118330. useAlphaFromAlbedoTexture: boolean;
  118331. /**
  118332. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  118333. */
  118334. forceAlphaTest: boolean;
  118335. /**
  118336. * Defines the alpha limits in alpha test mode.
  118337. */
  118338. alphaCutOff: number;
  118339. /**
  118340. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  118341. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  118342. */
  118343. useSpecularOverAlpha: boolean;
  118344. /**
  118345. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  118346. */
  118347. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  118348. /**
  118349. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  118350. */
  118351. useRoughnessFromMetallicTextureAlpha: boolean;
  118352. /**
  118353. * Specifies if the metallic texture contains the roughness information in its green channel.
  118354. */
  118355. useRoughnessFromMetallicTextureGreen: boolean;
  118356. /**
  118357. * Specifies if the metallic texture contains the metallness information in its blue channel.
  118358. */
  118359. useMetallnessFromMetallicTextureBlue: boolean;
  118360. /**
  118361. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  118362. */
  118363. useAmbientOcclusionFromMetallicTextureRed: boolean;
  118364. /**
  118365. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  118366. */
  118367. useAmbientInGrayScale: boolean;
  118368. /**
  118369. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  118370. * The material will try to infer what glossiness each pixel should be.
  118371. */
  118372. useAutoMicroSurfaceFromReflectivityMap: boolean;
  118373. /**
  118374. * BJS is using an harcoded light falloff based on a manually sets up range.
  118375. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118376. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118377. */
  118378. /**
  118379. * BJS is using an harcoded light falloff based on a manually sets up range.
  118380. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118381. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118382. */
  118383. usePhysicalLightFalloff: boolean;
  118384. /**
  118385. * In order to support the falloff compatibility with gltf, a special mode has been added
  118386. * to reproduce the gltf light falloff.
  118387. */
  118388. /**
  118389. * In order to support the falloff compatibility with gltf, a special mode has been added
  118390. * to reproduce the gltf light falloff.
  118391. */
  118392. useGLTFLightFalloff: boolean;
  118393. /**
  118394. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  118395. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  118396. */
  118397. useRadianceOverAlpha: boolean;
  118398. /**
  118399. * Allows using an object space normal map (instead of tangent space).
  118400. */
  118401. useObjectSpaceNormalMap: boolean;
  118402. /**
  118403. * Allows using the bump map in parallax mode.
  118404. */
  118405. useParallax: boolean;
  118406. /**
  118407. * Allows using the bump map in parallax occlusion mode.
  118408. */
  118409. useParallaxOcclusion: boolean;
  118410. /**
  118411. * Controls the scale bias of the parallax mode.
  118412. */
  118413. parallaxScaleBias: number;
  118414. /**
  118415. * If sets to true, disables all the lights affecting the material.
  118416. */
  118417. disableLighting: boolean;
  118418. /**
  118419. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  118420. */
  118421. forceIrradianceInFragment: boolean;
  118422. /**
  118423. * Number of Simultaneous lights allowed on the material.
  118424. */
  118425. maxSimultaneousLights: number;
  118426. /**
  118427. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118428. */
  118429. invertNormalMapX: boolean;
  118430. /**
  118431. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118432. */
  118433. invertNormalMapY: boolean;
  118434. /**
  118435. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118436. */
  118437. twoSidedLighting: boolean;
  118438. /**
  118439. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118440. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  118441. */
  118442. useAlphaFresnel: boolean;
  118443. /**
  118444. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118445. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  118446. */
  118447. useLinearAlphaFresnel: boolean;
  118448. /**
  118449. * Let user defines the brdf lookup texture used for IBL.
  118450. * A default 8bit version is embedded but you could point at :
  118451. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  118452. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118453. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  118454. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118455. */
  118456. environmentBRDFTexture: Nullable<BaseTexture>;
  118457. /**
  118458. * Force normal to face away from face.
  118459. */
  118460. forceNormalForward: boolean;
  118461. /**
  118462. * Enables specular anti aliasing in the PBR shader.
  118463. * It will both interacts on the Geometry for analytical and IBL lighting.
  118464. * It also prefilter the roughness map based on the bump values.
  118465. */
  118466. enableSpecularAntiAliasing: boolean;
  118467. /**
  118468. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  118469. * makes the reflect vector face the model (under horizon).
  118470. */
  118471. useHorizonOcclusion: boolean;
  118472. /**
  118473. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  118474. * too much the area relying on ambient texture to define their ambient occlusion.
  118475. */
  118476. useRadianceOcclusion: boolean;
  118477. /**
  118478. * If set to true, no lighting calculations will be applied.
  118479. */
  118480. unlit: boolean;
  118481. /**
  118482. * Gets the image processing configuration used either in this material.
  118483. */
  118484. /**
  118485. * Sets the Default image processing configuration used either in the this material.
  118486. *
  118487. * If sets to null, the scene one is in use.
  118488. */
  118489. imageProcessingConfiguration: ImageProcessingConfiguration;
  118490. /**
  118491. * Gets wether the color curves effect is enabled.
  118492. */
  118493. /**
  118494. * Sets wether the color curves effect is enabled.
  118495. */
  118496. cameraColorCurvesEnabled: boolean;
  118497. /**
  118498. * Gets wether the color grading effect is enabled.
  118499. */
  118500. /**
  118501. * Gets wether the color grading effect is enabled.
  118502. */
  118503. cameraColorGradingEnabled: boolean;
  118504. /**
  118505. * Gets wether tonemapping is enabled or not.
  118506. */
  118507. /**
  118508. * Sets wether tonemapping is enabled or not
  118509. */
  118510. cameraToneMappingEnabled: boolean;
  118511. /**
  118512. * The camera exposure used on this material.
  118513. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118514. * This corresponds to a photographic exposure.
  118515. */
  118516. /**
  118517. * The camera exposure used on this material.
  118518. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118519. * This corresponds to a photographic exposure.
  118520. */
  118521. cameraExposure: number;
  118522. /**
  118523. * Gets The camera contrast used on this material.
  118524. */
  118525. /**
  118526. * Sets The camera contrast used on this material.
  118527. */
  118528. cameraContrast: number;
  118529. /**
  118530. * Gets the Color Grading 2D Lookup Texture.
  118531. */
  118532. /**
  118533. * Sets the Color Grading 2D Lookup Texture.
  118534. */
  118535. cameraColorGradingTexture: Nullable<BaseTexture>;
  118536. /**
  118537. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118538. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118539. * 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;
  118540. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118541. */
  118542. /**
  118543. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118544. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118545. * 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;
  118546. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118547. */
  118548. cameraColorCurves: Nullable<ColorCurves>;
  118549. /**
  118550. * Instantiates a new PBRMaterial instance.
  118551. *
  118552. * @param name The material name
  118553. * @param scene The scene the material will be use in.
  118554. */
  118555. constructor(name: string, scene: Scene);
  118556. /**
  118557. * Returns the name of this material class.
  118558. */
  118559. getClassName(): string;
  118560. /**
  118561. * Makes a duplicate of the current material.
  118562. * @param name - name to use for the new material.
  118563. */
  118564. clone(name: string): PBRMaterial;
  118565. /**
  118566. * Serializes this PBR Material.
  118567. * @returns - An object with the serialized material.
  118568. */
  118569. serialize(): any;
  118570. /**
  118571. * Parses a PBR Material from a serialized object.
  118572. * @param source - Serialized object.
  118573. * @param scene - BJS scene instance.
  118574. * @param rootUrl - url for the scene object
  118575. * @returns - PBRMaterial
  118576. */
  118577. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  118578. }
  118579. }
  118580. declare module BABYLON {
  118581. /**
  118582. * Direct draw surface info
  118583. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  118584. */
  118585. export interface DDSInfo {
  118586. /**
  118587. * Width of the texture
  118588. */
  118589. width: number;
  118590. /**
  118591. * Width of the texture
  118592. */
  118593. height: number;
  118594. /**
  118595. * Number of Mipmaps for the texture
  118596. * @see https://en.wikipedia.org/wiki/Mipmap
  118597. */
  118598. mipmapCount: number;
  118599. /**
  118600. * If the textures format is a known fourCC format
  118601. * @see https://www.fourcc.org/
  118602. */
  118603. isFourCC: boolean;
  118604. /**
  118605. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  118606. */
  118607. isRGB: boolean;
  118608. /**
  118609. * If the texture is a lumincance format
  118610. */
  118611. isLuminance: boolean;
  118612. /**
  118613. * If this is a cube texture
  118614. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  118615. */
  118616. isCube: boolean;
  118617. /**
  118618. * If the texture is a compressed format eg. FOURCC_DXT1
  118619. */
  118620. isCompressed: boolean;
  118621. /**
  118622. * The dxgiFormat of the texture
  118623. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  118624. */
  118625. dxgiFormat: number;
  118626. /**
  118627. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  118628. */
  118629. textureType: number;
  118630. /**
  118631. * Sphericle polynomial created for the dds texture
  118632. */
  118633. sphericalPolynomial?: SphericalPolynomial;
  118634. }
  118635. /**
  118636. * Class used to provide DDS decompression tools
  118637. */
  118638. export class DDSTools {
  118639. /**
  118640. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  118641. */
  118642. static StoreLODInAlphaChannel: boolean;
  118643. /**
  118644. * Gets DDS information from an array buffer
  118645. * @param arrayBuffer defines the array buffer to read data from
  118646. * @returns the DDS information
  118647. */
  118648. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  118649. private static _FloatView;
  118650. private static _Int32View;
  118651. private static _ToHalfFloat;
  118652. private static _FromHalfFloat;
  118653. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  118654. private static _GetHalfFloatRGBAArrayBuffer;
  118655. private static _GetFloatRGBAArrayBuffer;
  118656. private static _GetFloatAsUIntRGBAArrayBuffer;
  118657. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  118658. private static _GetRGBAArrayBuffer;
  118659. private static _ExtractLongWordOrder;
  118660. private static _GetRGBArrayBuffer;
  118661. private static _GetLuminanceArrayBuffer;
  118662. /**
  118663. * Uploads DDS Levels to a Babylon Texture
  118664. * @hidden
  118665. */
  118666. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  118667. }
  118668. interface ThinEngine {
  118669. /**
  118670. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  118671. * @param rootUrl defines the url where the file to load is located
  118672. * @param scene defines the current scene
  118673. * @param lodScale defines scale to apply to the mip map selection
  118674. * @param lodOffset defines offset to apply to the mip map selection
  118675. * @param onLoad defines an optional callback raised when the texture is loaded
  118676. * @param onError defines an optional callback raised if there is an issue to load the texture
  118677. * @param format defines the format of the data
  118678. * @param forcedExtension defines the extension to use to pick the right loader
  118679. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  118680. * @returns the cube texture as an InternalTexture
  118681. */
  118682. 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;
  118683. }
  118684. }
  118685. declare module BABYLON {
  118686. /**
  118687. * Implementation of the DDS Texture Loader.
  118688. * @hidden
  118689. */
  118690. export class _DDSTextureLoader implements IInternalTextureLoader {
  118691. /**
  118692. * Defines wether the loader supports cascade loading the different faces.
  118693. */
  118694. readonly supportCascades: boolean;
  118695. /**
  118696. * This returns if the loader support the current file information.
  118697. * @param extension defines the file extension of the file being loaded
  118698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118699. * @param fallback defines the fallback internal texture if any
  118700. * @param isBase64 defines whether the texture is encoded as a base64
  118701. * @param isBuffer defines whether the texture data are stored as a buffer
  118702. * @returns true if the loader can load the specified file
  118703. */
  118704. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118705. /**
  118706. * Transform the url before loading if required.
  118707. * @param rootUrl the url of the texture
  118708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118709. * @returns the transformed texture
  118710. */
  118711. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118712. /**
  118713. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118714. * @param rootUrl the url of the texture
  118715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118716. * @returns the fallback texture
  118717. */
  118718. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118719. /**
  118720. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118721. * @param data contains the texture data
  118722. * @param texture defines the BabylonJS internal texture
  118723. * @param createPolynomials will be true if polynomials have been requested
  118724. * @param onLoad defines the callback to trigger once the texture is ready
  118725. * @param onError defines the callback to trigger in case of error
  118726. */
  118727. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118728. /**
  118729. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118730. * @param data contains the texture data
  118731. * @param texture defines the BabylonJS internal texture
  118732. * @param callback defines the method to call once ready to upload
  118733. */
  118734. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118735. }
  118736. }
  118737. declare module BABYLON {
  118738. /**
  118739. * Implementation of the ENV Texture Loader.
  118740. * @hidden
  118741. */
  118742. export class _ENVTextureLoader implements IInternalTextureLoader {
  118743. /**
  118744. * Defines wether the loader supports cascade loading the different faces.
  118745. */
  118746. readonly supportCascades: boolean;
  118747. /**
  118748. * This returns if the loader support the current file information.
  118749. * @param extension defines the file extension of the file being loaded
  118750. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118751. * @param fallback defines the fallback internal texture if any
  118752. * @param isBase64 defines whether the texture is encoded as a base64
  118753. * @param isBuffer defines whether the texture data are stored as a buffer
  118754. * @returns true if the loader can load the specified file
  118755. */
  118756. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118757. /**
  118758. * Transform the url before loading if required.
  118759. * @param rootUrl the url of the texture
  118760. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118761. * @returns the transformed texture
  118762. */
  118763. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118764. /**
  118765. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118766. * @param rootUrl the url of the texture
  118767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118768. * @returns the fallback texture
  118769. */
  118770. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118771. /**
  118772. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118773. * @param data contains the texture data
  118774. * @param texture defines the BabylonJS internal texture
  118775. * @param createPolynomials will be true if polynomials have been requested
  118776. * @param onLoad defines the callback to trigger once the texture is ready
  118777. * @param onError defines the callback to trigger in case of error
  118778. */
  118779. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118780. /**
  118781. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118782. * @param data contains the texture data
  118783. * @param texture defines the BabylonJS internal texture
  118784. * @param callback defines the method to call once ready to upload
  118785. */
  118786. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118787. }
  118788. }
  118789. declare module BABYLON {
  118790. /**
  118791. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  118792. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  118793. */
  118794. export class KhronosTextureContainer {
  118795. /** contents of the KTX container file */
  118796. arrayBuffer: any;
  118797. private static HEADER_LEN;
  118798. private static COMPRESSED_2D;
  118799. private static COMPRESSED_3D;
  118800. private static TEX_2D;
  118801. private static TEX_3D;
  118802. /**
  118803. * Gets the openGL type
  118804. */
  118805. glType: number;
  118806. /**
  118807. * Gets the openGL type size
  118808. */
  118809. glTypeSize: number;
  118810. /**
  118811. * Gets the openGL format
  118812. */
  118813. glFormat: number;
  118814. /**
  118815. * Gets the openGL internal format
  118816. */
  118817. glInternalFormat: number;
  118818. /**
  118819. * Gets the base internal format
  118820. */
  118821. glBaseInternalFormat: number;
  118822. /**
  118823. * Gets image width in pixel
  118824. */
  118825. pixelWidth: number;
  118826. /**
  118827. * Gets image height in pixel
  118828. */
  118829. pixelHeight: number;
  118830. /**
  118831. * Gets image depth in pixels
  118832. */
  118833. pixelDepth: number;
  118834. /**
  118835. * Gets the number of array elements
  118836. */
  118837. numberOfArrayElements: number;
  118838. /**
  118839. * Gets the number of faces
  118840. */
  118841. numberOfFaces: number;
  118842. /**
  118843. * Gets the number of mipmap levels
  118844. */
  118845. numberOfMipmapLevels: number;
  118846. /**
  118847. * Gets the bytes of key value data
  118848. */
  118849. bytesOfKeyValueData: number;
  118850. /**
  118851. * Gets the load type
  118852. */
  118853. loadType: number;
  118854. /**
  118855. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  118856. */
  118857. isInvalid: boolean;
  118858. /**
  118859. * Creates a new KhronosTextureContainer
  118860. * @param arrayBuffer contents of the KTX container file
  118861. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  118862. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  118863. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  118864. */
  118865. constructor(
  118866. /** contents of the KTX container file */
  118867. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  118868. /**
  118869. * Uploads KTX content to a Babylon Texture.
  118870. * It is assumed that the texture has already been created & is currently bound
  118871. * @hidden
  118872. */
  118873. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  118874. private _upload2DCompressedLevels;
  118875. }
  118876. }
  118877. declare module BABYLON {
  118878. /**
  118879. * Implementation of the KTX Texture Loader.
  118880. * @hidden
  118881. */
  118882. export class _KTXTextureLoader implements IInternalTextureLoader {
  118883. /**
  118884. * Defines wether the loader supports cascade loading the different faces.
  118885. */
  118886. readonly supportCascades: boolean;
  118887. /**
  118888. * This returns if the loader support the current file information.
  118889. * @param extension defines the file extension of the file being loaded
  118890. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118891. * @param fallback defines the fallback internal texture if any
  118892. * @param isBase64 defines whether the texture is encoded as a base64
  118893. * @param isBuffer defines whether the texture data are stored as a buffer
  118894. * @returns true if the loader can load the specified file
  118895. */
  118896. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118897. /**
  118898. * Transform the url before loading if required.
  118899. * @param rootUrl the url of the texture
  118900. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118901. * @returns the transformed texture
  118902. */
  118903. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118904. /**
  118905. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118906. * @param rootUrl the url of the texture
  118907. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118908. * @returns the fallback texture
  118909. */
  118910. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118911. /**
  118912. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118913. * @param data contains the texture data
  118914. * @param texture defines the BabylonJS internal texture
  118915. * @param createPolynomials will be true if polynomials have been requested
  118916. * @param onLoad defines the callback to trigger once the texture is ready
  118917. * @param onError defines the callback to trigger in case of error
  118918. */
  118919. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118920. /**
  118921. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118922. * @param data contains the texture data
  118923. * @param texture defines the BabylonJS internal texture
  118924. * @param callback defines the method to call once ready to upload
  118925. */
  118926. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  118927. }
  118928. }
  118929. declare module BABYLON {
  118930. /** @hidden */
  118931. export var _forceSceneHelpersToBundle: boolean;
  118932. interface Scene {
  118933. /**
  118934. * Creates a default light for the scene.
  118935. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  118936. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  118937. */
  118938. createDefaultLight(replace?: boolean): void;
  118939. /**
  118940. * Creates a default camera for the scene.
  118941. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  118942. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118943. * @param replace has default false, when true replaces the active camera in the scene
  118944. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  118945. */
  118946. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118947. /**
  118948. * Creates a default camera and a default light.
  118949. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  118950. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118951. * @param replace has the default false, when true replaces the active camera/light in the scene
  118952. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  118953. */
  118954. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118955. /**
  118956. * Creates a new sky box
  118957. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  118958. * @param environmentTexture defines the texture to use as environment texture
  118959. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  118960. * @param scale defines the overall scale of the skybox
  118961. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  118962. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  118963. * @returns a new mesh holding the sky box
  118964. */
  118965. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  118966. /**
  118967. * Creates a new environment
  118968. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  118969. * @param options defines the options you can use to configure the environment
  118970. * @returns the new EnvironmentHelper
  118971. */
  118972. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  118973. /**
  118974. * Creates a new VREXperienceHelper
  118975. * @see http://doc.babylonjs.com/how_to/webvr_helper
  118976. * @param webVROptions defines the options used to create the new VREXperienceHelper
  118977. * @returns a new VREXperienceHelper
  118978. */
  118979. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  118980. /**
  118981. * Creates a new WebXRDefaultExperience
  118982. * @see http://doc.babylonjs.com/how_to/webxr
  118983. * @param options experience options
  118984. * @returns a promise for a new WebXRDefaultExperience
  118985. */
  118986. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118987. }
  118988. }
  118989. declare module BABYLON {
  118990. /**
  118991. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  118992. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  118993. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  118994. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  118995. */
  118996. export class VideoDome extends TransformNode {
  118997. /**
  118998. * Define the video source as a Monoscopic panoramic 360 video.
  118999. */
  119000. static readonly MODE_MONOSCOPIC: number;
  119001. /**
  119002. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  119003. */
  119004. static readonly MODE_TOPBOTTOM: number;
  119005. /**
  119006. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  119007. */
  119008. static readonly MODE_SIDEBYSIDE: number;
  119009. private _halfDome;
  119010. private _useDirectMapping;
  119011. /**
  119012. * The video texture being displayed on the sphere
  119013. */
  119014. protected _videoTexture: VideoTexture;
  119015. /**
  119016. * Gets the video texture being displayed on the sphere
  119017. */
  119018. readonly videoTexture: VideoTexture;
  119019. /**
  119020. * The skybox material
  119021. */
  119022. protected _material: BackgroundMaterial;
  119023. /**
  119024. * The surface used for the skybox
  119025. */
  119026. protected _mesh: Mesh;
  119027. /**
  119028. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  119029. */
  119030. private _halfDomeMask;
  119031. /**
  119032. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119033. * Also see the options.resolution property.
  119034. */
  119035. fovMultiplier: number;
  119036. private _videoMode;
  119037. /**
  119038. * Gets or set the current video mode for the video. It can be:
  119039. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  119040. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  119041. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  119042. */
  119043. videoMode: number;
  119044. /**
  119045. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  119046. *
  119047. */
  119048. /**
  119049. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  119050. */
  119051. halfDome: boolean;
  119052. /**
  119053. * Oberserver used in Stereoscopic VR Mode.
  119054. */
  119055. private _onBeforeCameraRenderObserver;
  119056. /**
  119057. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  119058. * @param name Element's name, child elements will append suffixes for their own names.
  119059. * @param urlsOrVideo defines the url(s) or the video element to use
  119060. * @param options An object containing optional or exposed sub element properties
  119061. */
  119062. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  119063. resolution?: number;
  119064. clickToPlay?: boolean;
  119065. autoPlay?: boolean;
  119066. loop?: boolean;
  119067. size?: number;
  119068. poster?: string;
  119069. faceForward?: boolean;
  119070. useDirectMapping?: boolean;
  119071. halfDomeMode?: boolean;
  119072. }, scene: Scene);
  119073. private _changeVideoMode;
  119074. /**
  119075. * Releases resources associated with this node.
  119076. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119077. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119078. */
  119079. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119080. }
  119081. }
  119082. declare module BABYLON {
  119083. /**
  119084. * This class can be used to get instrumentation data from a Babylon engine
  119085. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119086. */
  119087. export class EngineInstrumentation implements IDisposable {
  119088. /**
  119089. * Define the instrumented engine.
  119090. */
  119091. engine: Engine;
  119092. private _captureGPUFrameTime;
  119093. private _gpuFrameTimeToken;
  119094. private _gpuFrameTime;
  119095. private _captureShaderCompilationTime;
  119096. private _shaderCompilationTime;
  119097. private _onBeginFrameObserver;
  119098. private _onEndFrameObserver;
  119099. private _onBeforeShaderCompilationObserver;
  119100. private _onAfterShaderCompilationObserver;
  119101. /**
  119102. * Gets the perf counter used for GPU frame time
  119103. */
  119104. readonly gpuFrameTimeCounter: PerfCounter;
  119105. /**
  119106. * Gets the GPU frame time capture status
  119107. */
  119108. /**
  119109. * Enable or disable the GPU frame time capture
  119110. */
  119111. captureGPUFrameTime: boolean;
  119112. /**
  119113. * Gets the perf counter used for shader compilation time
  119114. */
  119115. readonly shaderCompilationTimeCounter: PerfCounter;
  119116. /**
  119117. * Gets the shader compilation time capture status
  119118. */
  119119. /**
  119120. * Enable or disable the shader compilation time capture
  119121. */
  119122. captureShaderCompilationTime: boolean;
  119123. /**
  119124. * Instantiates a new engine instrumentation.
  119125. * This class can be used to get instrumentation data from a Babylon engine
  119126. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119127. * @param engine Defines the engine to instrument
  119128. */
  119129. constructor(
  119130. /**
  119131. * Define the instrumented engine.
  119132. */
  119133. engine: Engine);
  119134. /**
  119135. * Dispose and release associated resources.
  119136. */
  119137. dispose(): void;
  119138. }
  119139. }
  119140. declare module BABYLON {
  119141. /**
  119142. * This class can be used to get instrumentation data from a Babylon engine
  119143. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119144. */
  119145. export class SceneInstrumentation implements IDisposable {
  119146. /**
  119147. * Defines the scene to instrument
  119148. */
  119149. scene: Scene;
  119150. private _captureActiveMeshesEvaluationTime;
  119151. private _activeMeshesEvaluationTime;
  119152. private _captureRenderTargetsRenderTime;
  119153. private _renderTargetsRenderTime;
  119154. private _captureFrameTime;
  119155. private _frameTime;
  119156. private _captureRenderTime;
  119157. private _renderTime;
  119158. private _captureInterFrameTime;
  119159. private _interFrameTime;
  119160. private _captureParticlesRenderTime;
  119161. private _particlesRenderTime;
  119162. private _captureSpritesRenderTime;
  119163. private _spritesRenderTime;
  119164. private _capturePhysicsTime;
  119165. private _physicsTime;
  119166. private _captureAnimationsTime;
  119167. private _animationsTime;
  119168. private _captureCameraRenderTime;
  119169. private _cameraRenderTime;
  119170. private _onBeforeActiveMeshesEvaluationObserver;
  119171. private _onAfterActiveMeshesEvaluationObserver;
  119172. private _onBeforeRenderTargetsRenderObserver;
  119173. private _onAfterRenderTargetsRenderObserver;
  119174. private _onAfterRenderObserver;
  119175. private _onBeforeDrawPhaseObserver;
  119176. private _onAfterDrawPhaseObserver;
  119177. private _onBeforeAnimationsObserver;
  119178. private _onBeforeParticlesRenderingObserver;
  119179. private _onAfterParticlesRenderingObserver;
  119180. private _onBeforeSpritesRenderingObserver;
  119181. private _onAfterSpritesRenderingObserver;
  119182. private _onBeforePhysicsObserver;
  119183. private _onAfterPhysicsObserver;
  119184. private _onAfterAnimationsObserver;
  119185. private _onBeforeCameraRenderObserver;
  119186. private _onAfterCameraRenderObserver;
  119187. /**
  119188. * Gets the perf counter used for active meshes evaluation time
  119189. */
  119190. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  119191. /**
  119192. * Gets the active meshes evaluation time capture status
  119193. */
  119194. /**
  119195. * Enable or disable the active meshes evaluation time capture
  119196. */
  119197. captureActiveMeshesEvaluationTime: boolean;
  119198. /**
  119199. * Gets the perf counter used for render targets render time
  119200. */
  119201. readonly renderTargetsRenderTimeCounter: PerfCounter;
  119202. /**
  119203. * Gets the render targets render time capture status
  119204. */
  119205. /**
  119206. * Enable or disable the render targets render time capture
  119207. */
  119208. captureRenderTargetsRenderTime: boolean;
  119209. /**
  119210. * Gets the perf counter used for particles render time
  119211. */
  119212. readonly particlesRenderTimeCounter: PerfCounter;
  119213. /**
  119214. * Gets the particles render time capture status
  119215. */
  119216. /**
  119217. * Enable or disable the particles render time capture
  119218. */
  119219. captureParticlesRenderTime: boolean;
  119220. /**
  119221. * Gets the perf counter used for sprites render time
  119222. */
  119223. readonly spritesRenderTimeCounter: PerfCounter;
  119224. /**
  119225. * Gets the sprites render time capture status
  119226. */
  119227. /**
  119228. * Enable or disable the sprites render time capture
  119229. */
  119230. captureSpritesRenderTime: boolean;
  119231. /**
  119232. * Gets the perf counter used for physics time
  119233. */
  119234. readonly physicsTimeCounter: PerfCounter;
  119235. /**
  119236. * Gets the physics time capture status
  119237. */
  119238. /**
  119239. * Enable or disable the physics time capture
  119240. */
  119241. capturePhysicsTime: boolean;
  119242. /**
  119243. * Gets the perf counter used for animations time
  119244. */
  119245. readonly animationsTimeCounter: PerfCounter;
  119246. /**
  119247. * Gets the animations time capture status
  119248. */
  119249. /**
  119250. * Enable or disable the animations time capture
  119251. */
  119252. captureAnimationsTime: boolean;
  119253. /**
  119254. * Gets the perf counter used for frame time capture
  119255. */
  119256. readonly frameTimeCounter: PerfCounter;
  119257. /**
  119258. * Gets the frame time capture status
  119259. */
  119260. /**
  119261. * Enable or disable the frame time capture
  119262. */
  119263. captureFrameTime: boolean;
  119264. /**
  119265. * Gets the perf counter used for inter-frames time capture
  119266. */
  119267. readonly interFrameTimeCounter: PerfCounter;
  119268. /**
  119269. * Gets the inter-frames time capture status
  119270. */
  119271. /**
  119272. * Enable or disable the inter-frames time capture
  119273. */
  119274. captureInterFrameTime: boolean;
  119275. /**
  119276. * Gets the perf counter used for render time capture
  119277. */
  119278. readonly renderTimeCounter: PerfCounter;
  119279. /**
  119280. * Gets the render time capture status
  119281. */
  119282. /**
  119283. * Enable or disable the render time capture
  119284. */
  119285. captureRenderTime: boolean;
  119286. /**
  119287. * Gets the perf counter used for camera render time capture
  119288. */
  119289. readonly cameraRenderTimeCounter: PerfCounter;
  119290. /**
  119291. * Gets the camera render time capture status
  119292. */
  119293. /**
  119294. * Enable or disable the camera render time capture
  119295. */
  119296. captureCameraRenderTime: boolean;
  119297. /**
  119298. * Gets the perf counter used for draw calls
  119299. */
  119300. readonly drawCallsCounter: PerfCounter;
  119301. /**
  119302. * Instantiates a new scene instrumentation.
  119303. * This class can be used to get instrumentation data from a Babylon engine
  119304. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119305. * @param scene Defines the scene to instrument
  119306. */
  119307. constructor(
  119308. /**
  119309. * Defines the scene to instrument
  119310. */
  119311. scene: Scene);
  119312. /**
  119313. * Dispose and release associated resources.
  119314. */
  119315. dispose(): void;
  119316. }
  119317. }
  119318. declare module BABYLON {
  119319. /** @hidden */
  119320. export var glowMapGenerationPixelShader: {
  119321. name: string;
  119322. shader: string;
  119323. };
  119324. }
  119325. declare module BABYLON {
  119326. /** @hidden */
  119327. export var glowMapGenerationVertexShader: {
  119328. name: string;
  119329. shader: string;
  119330. };
  119331. }
  119332. declare module BABYLON {
  119333. /**
  119334. * Effect layer options. This helps customizing the behaviour
  119335. * of the effect layer.
  119336. */
  119337. export interface IEffectLayerOptions {
  119338. /**
  119339. * Multiplication factor apply to the canvas size to compute the render target size
  119340. * used to generated the objects (the smaller the faster).
  119341. */
  119342. mainTextureRatio: number;
  119343. /**
  119344. * Enforces a fixed size texture to ensure effect stability across devices.
  119345. */
  119346. mainTextureFixedSize?: number;
  119347. /**
  119348. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  119349. */
  119350. alphaBlendingMode: number;
  119351. /**
  119352. * The camera attached to the layer.
  119353. */
  119354. camera: Nullable<Camera>;
  119355. /**
  119356. * The rendering group to draw the layer in.
  119357. */
  119358. renderingGroupId: number;
  119359. }
  119360. /**
  119361. * The effect layer Helps adding post process effect blended with the main pass.
  119362. *
  119363. * This can be for instance use to generate glow or higlight effects on the scene.
  119364. *
  119365. * The effect layer class can not be used directly and is intented to inherited from to be
  119366. * customized per effects.
  119367. */
  119368. export abstract class EffectLayer {
  119369. private _vertexBuffers;
  119370. private _indexBuffer;
  119371. private _cachedDefines;
  119372. private _effectLayerMapGenerationEffect;
  119373. private _effectLayerOptions;
  119374. private _mergeEffect;
  119375. protected _scene: Scene;
  119376. protected _engine: Engine;
  119377. protected _maxSize: number;
  119378. protected _mainTextureDesiredSize: ISize;
  119379. protected _mainTexture: RenderTargetTexture;
  119380. protected _shouldRender: boolean;
  119381. protected _postProcesses: PostProcess[];
  119382. protected _textures: BaseTexture[];
  119383. protected _emissiveTextureAndColor: {
  119384. texture: Nullable<BaseTexture>;
  119385. color: Color4;
  119386. };
  119387. /**
  119388. * The name of the layer
  119389. */
  119390. name: string;
  119391. /**
  119392. * The clear color of the texture used to generate the glow map.
  119393. */
  119394. neutralColor: Color4;
  119395. /**
  119396. * Specifies wether the highlight layer is enabled or not.
  119397. */
  119398. isEnabled: boolean;
  119399. /**
  119400. * Gets the camera attached to the layer.
  119401. */
  119402. readonly camera: Nullable<Camera>;
  119403. /**
  119404. * Gets the rendering group id the layer should render in.
  119405. */
  119406. renderingGroupId: number;
  119407. /**
  119408. * An event triggered when the effect layer has been disposed.
  119409. */
  119410. onDisposeObservable: Observable<EffectLayer>;
  119411. /**
  119412. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  119413. */
  119414. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  119415. /**
  119416. * An event triggered when the generated texture is being merged in the scene.
  119417. */
  119418. onBeforeComposeObservable: Observable<EffectLayer>;
  119419. /**
  119420. * An event triggered when the mesh is rendered into the effect render target.
  119421. */
  119422. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  119423. /**
  119424. * An event triggered after the mesh has been rendered into the effect render target.
  119425. */
  119426. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  119427. /**
  119428. * An event triggered when the generated texture has been merged in the scene.
  119429. */
  119430. onAfterComposeObservable: Observable<EffectLayer>;
  119431. /**
  119432. * An event triggered when the efffect layer changes its size.
  119433. */
  119434. onSizeChangedObservable: Observable<EffectLayer>;
  119435. /** @hidden */
  119436. static _SceneComponentInitialization: (scene: Scene) => void;
  119437. /**
  119438. * Instantiates a new effect Layer and references it in the scene.
  119439. * @param name The name of the layer
  119440. * @param scene The scene to use the layer in
  119441. */
  119442. constructor(
  119443. /** The Friendly of the effect in the scene */
  119444. name: string, scene: Scene);
  119445. /**
  119446. * Get the effect name of the layer.
  119447. * @return The effect name
  119448. */
  119449. abstract getEffectName(): string;
  119450. /**
  119451. * Checks for the readiness of the element composing the layer.
  119452. * @param subMesh the mesh to check for
  119453. * @param useInstances specify wether or not to use instances to render the mesh
  119454. * @return true if ready otherwise, false
  119455. */
  119456. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119457. /**
  119458. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119459. * @returns true if the effect requires stencil during the main canvas render pass.
  119460. */
  119461. abstract needStencil(): boolean;
  119462. /**
  119463. * Create the merge effect. This is the shader use to blit the information back
  119464. * to the main canvas at the end of the scene rendering.
  119465. * @returns The effect containing the shader used to merge the effect on the main canvas
  119466. */
  119467. protected abstract _createMergeEffect(): Effect;
  119468. /**
  119469. * Creates the render target textures and post processes used in the effect layer.
  119470. */
  119471. protected abstract _createTextureAndPostProcesses(): void;
  119472. /**
  119473. * Implementation specific of rendering the generating effect on the main canvas.
  119474. * @param effect The effect used to render through
  119475. */
  119476. protected abstract _internalRender(effect: Effect): void;
  119477. /**
  119478. * Sets the required values for both the emissive texture and and the main color.
  119479. */
  119480. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119481. /**
  119482. * Free any resources and references associated to a mesh.
  119483. * Internal use
  119484. * @param mesh The mesh to free.
  119485. */
  119486. abstract _disposeMesh(mesh: Mesh): void;
  119487. /**
  119488. * Serializes this layer (Glow or Highlight for example)
  119489. * @returns a serialized layer object
  119490. */
  119491. abstract serialize?(): any;
  119492. /**
  119493. * Initializes the effect layer with the required options.
  119494. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  119495. */
  119496. protected _init(options: Partial<IEffectLayerOptions>): void;
  119497. /**
  119498. * Generates the index buffer of the full screen quad blending to the main canvas.
  119499. */
  119500. private _generateIndexBuffer;
  119501. /**
  119502. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  119503. */
  119504. private _generateVertexBuffer;
  119505. /**
  119506. * Sets the main texture desired size which is the closest power of two
  119507. * of the engine canvas size.
  119508. */
  119509. private _setMainTextureSize;
  119510. /**
  119511. * Creates the main texture for the effect layer.
  119512. */
  119513. protected _createMainTexture(): void;
  119514. /**
  119515. * Adds specific effects defines.
  119516. * @param defines The defines to add specifics to.
  119517. */
  119518. protected _addCustomEffectDefines(defines: string[]): void;
  119519. /**
  119520. * Checks for the readiness of the element composing the layer.
  119521. * @param subMesh the mesh to check for
  119522. * @param useInstances specify wether or not to use instances to render the mesh
  119523. * @param emissiveTexture the associated emissive texture used to generate the glow
  119524. * @return true if ready otherwise, false
  119525. */
  119526. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  119527. /**
  119528. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  119529. */
  119530. render(): void;
  119531. /**
  119532. * Determine if a given mesh will be used in the current effect.
  119533. * @param mesh mesh to test
  119534. * @returns true if the mesh will be used
  119535. */
  119536. hasMesh(mesh: AbstractMesh): boolean;
  119537. /**
  119538. * Returns true if the layer contains information to display, otherwise false.
  119539. * @returns true if the glow layer should be rendered
  119540. */
  119541. shouldRender(): boolean;
  119542. /**
  119543. * Returns true if the mesh should render, otherwise false.
  119544. * @param mesh The mesh to render
  119545. * @returns true if it should render otherwise false
  119546. */
  119547. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  119548. /**
  119549. * Returns true if the mesh can be rendered, otherwise false.
  119550. * @param mesh The mesh to render
  119551. * @param material The material used on the mesh
  119552. * @returns true if it can be rendered otherwise false
  119553. */
  119554. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119555. /**
  119556. * Returns true if the mesh should render, otherwise false.
  119557. * @param mesh The mesh to render
  119558. * @returns true if it should render otherwise false
  119559. */
  119560. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  119561. /**
  119562. * Renders the submesh passed in parameter to the generation map.
  119563. */
  119564. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  119565. /**
  119566. * Defines wether the current material of the mesh should be use to render the effect.
  119567. * @param mesh defines the current mesh to render
  119568. */
  119569. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119570. /**
  119571. * Rebuild the required buffers.
  119572. * @hidden Internal use only.
  119573. */
  119574. _rebuild(): void;
  119575. /**
  119576. * Dispose only the render target textures and post process.
  119577. */
  119578. private _disposeTextureAndPostProcesses;
  119579. /**
  119580. * Dispose the highlight layer and free resources.
  119581. */
  119582. dispose(): void;
  119583. /**
  119584. * Gets the class name of the effect layer
  119585. * @returns the string with the class name of the effect layer
  119586. */
  119587. getClassName(): string;
  119588. /**
  119589. * Creates an effect layer from parsed effect layer data
  119590. * @param parsedEffectLayer defines effect layer data
  119591. * @param scene defines the current scene
  119592. * @param rootUrl defines the root URL containing the effect layer information
  119593. * @returns a parsed effect Layer
  119594. */
  119595. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  119596. }
  119597. }
  119598. declare module BABYLON {
  119599. interface AbstractScene {
  119600. /**
  119601. * The list of effect layers (highlights/glow) added to the scene
  119602. * @see http://doc.babylonjs.com/how_to/highlight_layer
  119603. * @see http://doc.babylonjs.com/how_to/glow_layer
  119604. */
  119605. effectLayers: Array<EffectLayer>;
  119606. /**
  119607. * Removes the given effect layer from this scene.
  119608. * @param toRemove defines the effect layer to remove
  119609. * @returns the index of the removed effect layer
  119610. */
  119611. removeEffectLayer(toRemove: EffectLayer): number;
  119612. /**
  119613. * Adds the given effect layer to this scene
  119614. * @param newEffectLayer defines the effect layer to add
  119615. */
  119616. addEffectLayer(newEffectLayer: EffectLayer): void;
  119617. }
  119618. /**
  119619. * Defines the layer scene component responsible to manage any effect layers
  119620. * in a given scene.
  119621. */
  119622. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  119623. /**
  119624. * The component name helpfull to identify the component in the list of scene components.
  119625. */
  119626. readonly name: string;
  119627. /**
  119628. * The scene the component belongs to.
  119629. */
  119630. scene: Scene;
  119631. private _engine;
  119632. private _renderEffects;
  119633. private _needStencil;
  119634. private _previousStencilState;
  119635. /**
  119636. * Creates a new instance of the component for the given scene
  119637. * @param scene Defines the scene to register the component in
  119638. */
  119639. constructor(scene: Scene);
  119640. /**
  119641. * Registers the component in a given scene
  119642. */
  119643. register(): void;
  119644. /**
  119645. * Rebuilds the elements related to this component in case of
  119646. * context lost for instance.
  119647. */
  119648. rebuild(): void;
  119649. /**
  119650. * Serializes the component data to the specified json object
  119651. * @param serializationObject The object to serialize to
  119652. */
  119653. serialize(serializationObject: any): void;
  119654. /**
  119655. * Adds all the elements from the container to the scene
  119656. * @param container the container holding the elements
  119657. */
  119658. addFromContainer(container: AbstractScene): void;
  119659. /**
  119660. * Removes all the elements in the container from the scene
  119661. * @param container contains the elements to remove
  119662. * @param dispose if the removed element should be disposed (default: false)
  119663. */
  119664. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119665. /**
  119666. * Disposes the component and the associated ressources.
  119667. */
  119668. dispose(): void;
  119669. private _isReadyForMesh;
  119670. private _renderMainTexture;
  119671. private _setStencil;
  119672. private _setStencilBack;
  119673. private _draw;
  119674. private _drawCamera;
  119675. private _drawRenderingGroup;
  119676. }
  119677. }
  119678. declare module BABYLON {
  119679. /** @hidden */
  119680. export var glowMapMergePixelShader: {
  119681. name: string;
  119682. shader: string;
  119683. };
  119684. }
  119685. declare module BABYLON {
  119686. /** @hidden */
  119687. export var glowMapMergeVertexShader: {
  119688. name: string;
  119689. shader: string;
  119690. };
  119691. }
  119692. declare module BABYLON {
  119693. interface AbstractScene {
  119694. /**
  119695. * Return a the first highlight layer of the scene with a given name.
  119696. * @param name The name of the highlight layer to look for.
  119697. * @return The highlight layer if found otherwise null.
  119698. */
  119699. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  119700. }
  119701. /**
  119702. * Glow layer options. This helps customizing the behaviour
  119703. * of the glow layer.
  119704. */
  119705. export interface IGlowLayerOptions {
  119706. /**
  119707. * Multiplication factor apply to the canvas size to compute the render target size
  119708. * used to generated the glowing objects (the smaller the faster).
  119709. */
  119710. mainTextureRatio: number;
  119711. /**
  119712. * Enforces a fixed size texture to ensure resize independant blur.
  119713. */
  119714. mainTextureFixedSize?: number;
  119715. /**
  119716. * How big is the kernel of the blur texture.
  119717. */
  119718. blurKernelSize: number;
  119719. /**
  119720. * The camera attached to the layer.
  119721. */
  119722. camera: Nullable<Camera>;
  119723. /**
  119724. * Enable MSAA by chosing the number of samples.
  119725. */
  119726. mainTextureSamples?: number;
  119727. /**
  119728. * The rendering group to draw the layer in.
  119729. */
  119730. renderingGroupId: number;
  119731. }
  119732. /**
  119733. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  119734. *
  119735. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  119736. *
  119737. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  119738. */
  119739. export class GlowLayer extends EffectLayer {
  119740. /**
  119741. * Effect Name of the layer.
  119742. */
  119743. static readonly EffectName: string;
  119744. /**
  119745. * The default blur kernel size used for the glow.
  119746. */
  119747. static DefaultBlurKernelSize: number;
  119748. /**
  119749. * The default texture size ratio used for the glow.
  119750. */
  119751. static DefaultTextureRatio: number;
  119752. /**
  119753. * Sets the kernel size of the blur.
  119754. */
  119755. /**
  119756. * Gets the kernel size of the blur.
  119757. */
  119758. blurKernelSize: number;
  119759. /**
  119760. * Sets the glow intensity.
  119761. */
  119762. /**
  119763. * Gets the glow intensity.
  119764. */
  119765. intensity: number;
  119766. private _options;
  119767. private _intensity;
  119768. private _horizontalBlurPostprocess1;
  119769. private _verticalBlurPostprocess1;
  119770. private _horizontalBlurPostprocess2;
  119771. private _verticalBlurPostprocess2;
  119772. private _blurTexture1;
  119773. private _blurTexture2;
  119774. private _postProcesses1;
  119775. private _postProcesses2;
  119776. private _includedOnlyMeshes;
  119777. private _excludedMeshes;
  119778. private _meshesUsingTheirOwnMaterials;
  119779. /**
  119780. * Callback used to let the user override the color selection on a per mesh basis
  119781. */
  119782. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  119783. /**
  119784. * Callback used to let the user override the texture selection on a per mesh basis
  119785. */
  119786. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  119787. /**
  119788. * Instantiates a new glow Layer and references it to the scene.
  119789. * @param name The name of the layer
  119790. * @param scene The scene to use the layer in
  119791. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  119792. */
  119793. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  119794. /**
  119795. * Get the effect name of the layer.
  119796. * @return The effect name
  119797. */
  119798. getEffectName(): string;
  119799. /**
  119800. * Create the merge effect. This is the shader use to blit the information back
  119801. * to the main canvas at the end of the scene rendering.
  119802. */
  119803. protected _createMergeEffect(): Effect;
  119804. /**
  119805. * Creates the render target textures and post processes used in the glow layer.
  119806. */
  119807. protected _createTextureAndPostProcesses(): void;
  119808. /**
  119809. * Checks for the readiness of the element composing the layer.
  119810. * @param subMesh the mesh to check for
  119811. * @param useInstances specify wether or not to use instances to render the mesh
  119812. * @param emissiveTexture the associated emissive texture used to generate the glow
  119813. * @return true if ready otherwise, false
  119814. */
  119815. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119816. /**
  119817. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119818. */
  119819. needStencil(): boolean;
  119820. /**
  119821. * Returns true if the mesh can be rendered, otherwise false.
  119822. * @param mesh The mesh to render
  119823. * @param material The material used on the mesh
  119824. * @returns true if it can be rendered otherwise false
  119825. */
  119826. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119827. /**
  119828. * Implementation specific of rendering the generating effect on the main canvas.
  119829. * @param effect The effect used to render through
  119830. */
  119831. protected _internalRender(effect: Effect): void;
  119832. /**
  119833. * Sets the required values for both the emissive texture and and the main color.
  119834. */
  119835. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119836. /**
  119837. * Returns true if the mesh should render, otherwise false.
  119838. * @param mesh The mesh to render
  119839. * @returns true if it should render otherwise false
  119840. */
  119841. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119842. /**
  119843. * Adds specific effects defines.
  119844. * @param defines The defines to add specifics to.
  119845. */
  119846. protected _addCustomEffectDefines(defines: string[]): void;
  119847. /**
  119848. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  119849. * @param mesh The mesh to exclude from the glow layer
  119850. */
  119851. addExcludedMesh(mesh: Mesh): void;
  119852. /**
  119853. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  119854. * @param mesh The mesh to remove
  119855. */
  119856. removeExcludedMesh(mesh: Mesh): void;
  119857. /**
  119858. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  119859. * @param mesh The mesh to include in the glow layer
  119860. */
  119861. addIncludedOnlyMesh(mesh: Mesh): void;
  119862. /**
  119863. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  119864. * @param mesh The mesh to remove
  119865. */
  119866. removeIncludedOnlyMesh(mesh: Mesh): void;
  119867. /**
  119868. * Determine if a given mesh will be used in the glow layer
  119869. * @param mesh The mesh to test
  119870. * @returns true if the mesh will be highlighted by the current glow layer
  119871. */
  119872. hasMesh(mesh: AbstractMesh): boolean;
  119873. /**
  119874. * Defines wether the current material of the mesh should be use to render the effect.
  119875. * @param mesh defines the current mesh to render
  119876. */
  119877. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119878. /**
  119879. * Add a mesh to be rendered through its own material and not with emissive only.
  119880. * @param mesh The mesh for which we need to use its material
  119881. */
  119882. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  119883. /**
  119884. * Remove a mesh from being rendered through its own material and not with emissive only.
  119885. * @param mesh The mesh for which we need to not use its material
  119886. */
  119887. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  119888. /**
  119889. * Free any resources and references associated to a mesh.
  119890. * Internal use
  119891. * @param mesh The mesh to free.
  119892. * @hidden
  119893. */
  119894. _disposeMesh(mesh: Mesh): void;
  119895. /**
  119896. * Gets the class name of the effect layer
  119897. * @returns the string with the class name of the effect layer
  119898. */
  119899. getClassName(): string;
  119900. /**
  119901. * Serializes this glow layer
  119902. * @returns a serialized glow layer object
  119903. */
  119904. serialize(): any;
  119905. /**
  119906. * Creates a Glow Layer from parsed glow layer data
  119907. * @param parsedGlowLayer defines glow layer data
  119908. * @param scene defines the current scene
  119909. * @param rootUrl defines the root URL containing the glow layer information
  119910. * @returns a parsed Glow Layer
  119911. */
  119912. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  119913. }
  119914. }
  119915. declare module BABYLON {
  119916. /** @hidden */
  119917. export var glowBlurPostProcessPixelShader: {
  119918. name: string;
  119919. shader: string;
  119920. };
  119921. }
  119922. declare module BABYLON {
  119923. interface AbstractScene {
  119924. /**
  119925. * Return a the first highlight layer of the scene with a given name.
  119926. * @param name The name of the highlight layer to look for.
  119927. * @return The highlight layer if found otherwise null.
  119928. */
  119929. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  119930. }
  119931. /**
  119932. * Highlight layer options. This helps customizing the behaviour
  119933. * of the highlight layer.
  119934. */
  119935. export interface IHighlightLayerOptions {
  119936. /**
  119937. * Multiplication factor apply to the canvas size to compute the render target size
  119938. * used to generated the glowing objects (the smaller the faster).
  119939. */
  119940. mainTextureRatio: number;
  119941. /**
  119942. * Enforces a fixed size texture to ensure resize independant blur.
  119943. */
  119944. mainTextureFixedSize?: number;
  119945. /**
  119946. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  119947. * of the picture to blur (the smaller the faster).
  119948. */
  119949. blurTextureSizeRatio: number;
  119950. /**
  119951. * How big in texel of the blur texture is the vertical blur.
  119952. */
  119953. blurVerticalSize: number;
  119954. /**
  119955. * How big in texel of the blur texture is the horizontal blur.
  119956. */
  119957. blurHorizontalSize: number;
  119958. /**
  119959. * Alpha blending mode used to apply the blur. Default is combine.
  119960. */
  119961. alphaBlendingMode: number;
  119962. /**
  119963. * The camera attached to the layer.
  119964. */
  119965. camera: Nullable<Camera>;
  119966. /**
  119967. * Should we display highlight as a solid stroke?
  119968. */
  119969. isStroke?: boolean;
  119970. /**
  119971. * The rendering group to draw the layer in.
  119972. */
  119973. renderingGroupId: number;
  119974. }
  119975. /**
  119976. * The highlight layer Helps adding a glow effect around a mesh.
  119977. *
  119978. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  119979. * glowy meshes to your scene.
  119980. *
  119981. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  119982. */
  119983. export class HighlightLayer extends EffectLayer {
  119984. name: string;
  119985. /**
  119986. * Effect Name of the highlight layer.
  119987. */
  119988. static readonly EffectName: string;
  119989. /**
  119990. * The neutral color used during the preparation of the glow effect.
  119991. * This is black by default as the blend operation is a blend operation.
  119992. */
  119993. static NeutralColor: Color4;
  119994. /**
  119995. * Stencil value used for glowing meshes.
  119996. */
  119997. static GlowingMeshStencilReference: number;
  119998. /**
  119999. * Stencil value used for the other meshes in the scene.
  120000. */
  120001. static NormalMeshStencilReference: number;
  120002. /**
  120003. * Specifies whether or not the inner glow is ACTIVE in the layer.
  120004. */
  120005. innerGlow: boolean;
  120006. /**
  120007. * Specifies whether or not the outer glow is ACTIVE in the layer.
  120008. */
  120009. outerGlow: boolean;
  120010. /**
  120011. * Specifies the horizontal size of the blur.
  120012. */
  120013. /**
  120014. * Gets the horizontal size of the blur.
  120015. */
  120016. blurHorizontalSize: number;
  120017. /**
  120018. * Specifies the vertical size of the blur.
  120019. */
  120020. /**
  120021. * Gets the vertical size of the blur.
  120022. */
  120023. blurVerticalSize: number;
  120024. /**
  120025. * An event triggered when the highlight layer is being blurred.
  120026. */
  120027. onBeforeBlurObservable: Observable<HighlightLayer>;
  120028. /**
  120029. * An event triggered when the highlight layer has been blurred.
  120030. */
  120031. onAfterBlurObservable: Observable<HighlightLayer>;
  120032. private _instanceGlowingMeshStencilReference;
  120033. private _options;
  120034. private _downSamplePostprocess;
  120035. private _horizontalBlurPostprocess;
  120036. private _verticalBlurPostprocess;
  120037. private _blurTexture;
  120038. private _meshes;
  120039. private _excludedMeshes;
  120040. /**
  120041. * Instantiates a new highlight Layer and references it to the scene..
  120042. * @param name The name of the layer
  120043. * @param scene The scene to use the layer in
  120044. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  120045. */
  120046. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  120047. /**
  120048. * Get the effect name of the layer.
  120049. * @return The effect name
  120050. */
  120051. getEffectName(): string;
  120052. /**
  120053. * Create the merge effect. This is the shader use to blit the information back
  120054. * to the main canvas at the end of the scene rendering.
  120055. */
  120056. protected _createMergeEffect(): Effect;
  120057. /**
  120058. * Creates the render target textures and post processes used in the highlight layer.
  120059. */
  120060. protected _createTextureAndPostProcesses(): void;
  120061. /**
  120062. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  120063. */
  120064. needStencil(): boolean;
  120065. /**
  120066. * Checks for the readiness of the element composing the layer.
  120067. * @param subMesh the mesh to check for
  120068. * @param useInstances specify wether or not to use instances to render the mesh
  120069. * @param emissiveTexture the associated emissive texture used to generate the glow
  120070. * @return true if ready otherwise, false
  120071. */
  120072. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120073. /**
  120074. * Implementation specific of rendering the generating effect on the main canvas.
  120075. * @param effect The effect used to render through
  120076. */
  120077. protected _internalRender(effect: Effect): void;
  120078. /**
  120079. * Returns true if the layer contains information to display, otherwise false.
  120080. */
  120081. shouldRender(): boolean;
  120082. /**
  120083. * Returns true if the mesh should render, otherwise false.
  120084. * @param mesh The mesh to render
  120085. * @returns true if it should render otherwise false
  120086. */
  120087. protected _shouldRenderMesh(mesh: Mesh): boolean;
  120088. /**
  120089. * Sets the required values for both the emissive texture and and the main color.
  120090. */
  120091. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  120092. /**
  120093. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  120094. * @param mesh The mesh to exclude from the highlight layer
  120095. */
  120096. addExcludedMesh(mesh: Mesh): void;
  120097. /**
  120098. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  120099. * @param mesh The mesh to highlight
  120100. */
  120101. removeExcludedMesh(mesh: Mesh): void;
  120102. /**
  120103. * Determine if a given mesh will be highlighted by the current HighlightLayer
  120104. * @param mesh mesh to test
  120105. * @returns true if the mesh will be highlighted by the current HighlightLayer
  120106. */
  120107. hasMesh(mesh: AbstractMesh): boolean;
  120108. /**
  120109. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  120110. * @param mesh The mesh to highlight
  120111. * @param color The color of the highlight
  120112. * @param glowEmissiveOnly Extract the glow from the emissive texture
  120113. */
  120114. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  120115. /**
  120116. * Remove a mesh from the highlight layer in order to make it stop glowing.
  120117. * @param mesh The mesh to highlight
  120118. */
  120119. removeMesh(mesh: Mesh): void;
  120120. /**
  120121. * Force the stencil to the normal expected value for none glowing parts
  120122. */
  120123. private _defaultStencilReference;
  120124. /**
  120125. * Free any resources and references associated to a mesh.
  120126. * Internal use
  120127. * @param mesh The mesh to free.
  120128. * @hidden
  120129. */
  120130. _disposeMesh(mesh: Mesh): void;
  120131. /**
  120132. * Dispose the highlight layer and free resources.
  120133. */
  120134. dispose(): void;
  120135. /**
  120136. * Gets the class name of the effect layer
  120137. * @returns the string with the class name of the effect layer
  120138. */
  120139. getClassName(): string;
  120140. /**
  120141. * Serializes this Highlight layer
  120142. * @returns a serialized Highlight layer object
  120143. */
  120144. serialize(): any;
  120145. /**
  120146. * Creates a Highlight layer from parsed Highlight layer data
  120147. * @param parsedHightlightLayer defines the Highlight layer data
  120148. * @param scene defines the current scene
  120149. * @param rootUrl defines the root URL containing the Highlight layer information
  120150. * @returns a parsed Highlight layer
  120151. */
  120152. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  120153. }
  120154. }
  120155. declare module BABYLON {
  120156. interface AbstractScene {
  120157. /**
  120158. * The list of layers (background and foreground) of the scene
  120159. */
  120160. layers: Array<Layer>;
  120161. }
  120162. /**
  120163. * Defines the layer scene component responsible to manage any layers
  120164. * in a given scene.
  120165. */
  120166. export class LayerSceneComponent implements ISceneComponent {
  120167. /**
  120168. * The component name helpfull to identify the component in the list of scene components.
  120169. */
  120170. readonly name: string;
  120171. /**
  120172. * The scene the component belongs to.
  120173. */
  120174. scene: Scene;
  120175. private _engine;
  120176. /**
  120177. * Creates a new instance of the component for the given scene
  120178. * @param scene Defines the scene to register the component in
  120179. */
  120180. constructor(scene: Scene);
  120181. /**
  120182. * Registers the component in a given scene
  120183. */
  120184. register(): void;
  120185. /**
  120186. * Rebuilds the elements related to this component in case of
  120187. * context lost for instance.
  120188. */
  120189. rebuild(): void;
  120190. /**
  120191. * Disposes the component and the associated ressources.
  120192. */
  120193. dispose(): void;
  120194. private _draw;
  120195. private _drawCameraPredicate;
  120196. private _drawCameraBackground;
  120197. private _drawCameraForeground;
  120198. private _drawRenderTargetPredicate;
  120199. private _drawRenderTargetBackground;
  120200. private _drawRenderTargetForeground;
  120201. /**
  120202. * Adds all the elements from the container to the scene
  120203. * @param container the container holding the elements
  120204. */
  120205. addFromContainer(container: AbstractScene): void;
  120206. /**
  120207. * Removes all the elements in the container from the scene
  120208. * @param container contains the elements to remove
  120209. * @param dispose if the removed element should be disposed (default: false)
  120210. */
  120211. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120212. }
  120213. }
  120214. declare module BABYLON {
  120215. /** @hidden */
  120216. export var layerPixelShader: {
  120217. name: string;
  120218. shader: string;
  120219. };
  120220. }
  120221. declare module BABYLON {
  120222. /** @hidden */
  120223. export var layerVertexShader: {
  120224. name: string;
  120225. shader: string;
  120226. };
  120227. }
  120228. declare module BABYLON {
  120229. /**
  120230. * This represents a full screen 2d layer.
  120231. * This can be useful to display a picture in the background of your scene for instance.
  120232. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120233. */
  120234. export class Layer {
  120235. /**
  120236. * Define the name of the layer.
  120237. */
  120238. name: string;
  120239. /**
  120240. * Define the texture the layer should display.
  120241. */
  120242. texture: Nullable<Texture>;
  120243. /**
  120244. * Is the layer in background or foreground.
  120245. */
  120246. isBackground: boolean;
  120247. /**
  120248. * Define the color of the layer (instead of texture).
  120249. */
  120250. color: Color4;
  120251. /**
  120252. * Define the scale of the layer in order to zoom in out of the texture.
  120253. */
  120254. scale: Vector2;
  120255. /**
  120256. * Define an offset for the layer in order to shift the texture.
  120257. */
  120258. offset: Vector2;
  120259. /**
  120260. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  120261. */
  120262. alphaBlendingMode: number;
  120263. /**
  120264. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  120265. * Alpha test will not mix with the background color in case of transparency.
  120266. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  120267. */
  120268. alphaTest: boolean;
  120269. /**
  120270. * Define a mask to restrict the layer to only some of the scene cameras.
  120271. */
  120272. layerMask: number;
  120273. /**
  120274. * Define the list of render target the layer is visible into.
  120275. */
  120276. renderTargetTextures: RenderTargetTexture[];
  120277. /**
  120278. * Define if the layer is only used in renderTarget or if it also
  120279. * renders in the main frame buffer of the canvas.
  120280. */
  120281. renderOnlyInRenderTargetTextures: boolean;
  120282. private _scene;
  120283. private _vertexBuffers;
  120284. private _indexBuffer;
  120285. private _effect;
  120286. private _previousDefines;
  120287. /**
  120288. * An event triggered when the layer is disposed.
  120289. */
  120290. onDisposeObservable: Observable<Layer>;
  120291. private _onDisposeObserver;
  120292. /**
  120293. * Back compatibility with callback before the onDisposeObservable existed.
  120294. * The set callback will be triggered when the layer has been disposed.
  120295. */
  120296. onDispose: () => void;
  120297. /**
  120298. * An event triggered before rendering the scene
  120299. */
  120300. onBeforeRenderObservable: Observable<Layer>;
  120301. private _onBeforeRenderObserver;
  120302. /**
  120303. * Back compatibility with callback before the onBeforeRenderObservable existed.
  120304. * The set callback will be triggered just before rendering the layer.
  120305. */
  120306. onBeforeRender: () => void;
  120307. /**
  120308. * An event triggered after rendering the scene
  120309. */
  120310. onAfterRenderObservable: Observable<Layer>;
  120311. private _onAfterRenderObserver;
  120312. /**
  120313. * Back compatibility with callback before the onAfterRenderObservable existed.
  120314. * The set callback will be triggered just after rendering the layer.
  120315. */
  120316. onAfterRender: () => void;
  120317. /**
  120318. * Instantiates a new layer.
  120319. * This represents a full screen 2d layer.
  120320. * This can be useful to display a picture in the background of your scene for instance.
  120321. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120322. * @param name Define the name of the layer in the scene
  120323. * @param imgUrl Define the url of the texture to display in the layer
  120324. * @param scene Define the scene the layer belongs to
  120325. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  120326. * @param color Defines a color for the layer
  120327. */
  120328. constructor(
  120329. /**
  120330. * Define the name of the layer.
  120331. */
  120332. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  120333. private _createIndexBuffer;
  120334. /** @hidden */
  120335. _rebuild(): void;
  120336. /**
  120337. * Renders the layer in the scene.
  120338. */
  120339. render(): void;
  120340. /**
  120341. * Disposes and releases the associated ressources.
  120342. */
  120343. dispose(): void;
  120344. }
  120345. }
  120346. declare module BABYLON {
  120347. /** @hidden */
  120348. export var lensFlarePixelShader: {
  120349. name: string;
  120350. shader: string;
  120351. };
  120352. }
  120353. declare module BABYLON {
  120354. /** @hidden */
  120355. export var lensFlareVertexShader: {
  120356. name: string;
  120357. shader: string;
  120358. };
  120359. }
  120360. declare module BABYLON {
  120361. /**
  120362. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120363. * It is usually composed of several `lensFlare`.
  120364. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120365. */
  120366. export class LensFlareSystem {
  120367. /**
  120368. * Define the name of the lens flare system
  120369. */
  120370. name: string;
  120371. /**
  120372. * List of lens flares used in this system.
  120373. */
  120374. lensFlares: LensFlare[];
  120375. /**
  120376. * Define a limit from the border the lens flare can be visible.
  120377. */
  120378. borderLimit: number;
  120379. /**
  120380. * Define a viewport border we do not want to see the lens flare in.
  120381. */
  120382. viewportBorder: number;
  120383. /**
  120384. * Define a predicate which could limit the list of meshes able to occlude the effect.
  120385. */
  120386. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  120387. /**
  120388. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  120389. */
  120390. layerMask: number;
  120391. /**
  120392. * Define the id of the lens flare system in the scene.
  120393. * (equal to name by default)
  120394. */
  120395. id: string;
  120396. private _scene;
  120397. private _emitter;
  120398. private _vertexBuffers;
  120399. private _indexBuffer;
  120400. private _effect;
  120401. private _positionX;
  120402. private _positionY;
  120403. private _isEnabled;
  120404. /** @hidden */
  120405. static _SceneComponentInitialization: (scene: Scene) => void;
  120406. /**
  120407. * Instantiates a lens flare system.
  120408. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120409. * It is usually composed of several `lensFlare`.
  120410. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120411. * @param name Define the name of the lens flare system in the scene
  120412. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  120413. * @param scene Define the scene the lens flare system belongs to
  120414. */
  120415. constructor(
  120416. /**
  120417. * Define the name of the lens flare system
  120418. */
  120419. name: string, emitter: any, scene: Scene);
  120420. /**
  120421. * Define if the lens flare system is enabled.
  120422. */
  120423. isEnabled: boolean;
  120424. /**
  120425. * Get the scene the effects belongs to.
  120426. * @returns the scene holding the lens flare system
  120427. */
  120428. getScene(): Scene;
  120429. /**
  120430. * Get the emitter of the lens flare system.
  120431. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120432. * @returns the emitter of the lens flare system
  120433. */
  120434. getEmitter(): any;
  120435. /**
  120436. * Set the emitter of the lens flare system.
  120437. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120438. * @param newEmitter Define the new emitter of the system
  120439. */
  120440. setEmitter(newEmitter: any): void;
  120441. /**
  120442. * Get the lens flare system emitter position.
  120443. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  120444. * @returns the position
  120445. */
  120446. getEmitterPosition(): Vector3;
  120447. /**
  120448. * @hidden
  120449. */
  120450. computeEffectivePosition(globalViewport: Viewport): boolean;
  120451. /** @hidden */
  120452. _isVisible(): boolean;
  120453. /**
  120454. * @hidden
  120455. */
  120456. render(): boolean;
  120457. /**
  120458. * Dispose and release the lens flare with its associated resources.
  120459. */
  120460. dispose(): void;
  120461. /**
  120462. * Parse a lens flare system from a JSON repressentation
  120463. * @param parsedLensFlareSystem Define the JSON to parse
  120464. * @param scene Define the scene the parsed system should be instantiated in
  120465. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  120466. * @returns the parsed system
  120467. */
  120468. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  120469. /**
  120470. * Serialize the current Lens Flare System into a JSON representation.
  120471. * @returns the serialized JSON
  120472. */
  120473. serialize(): any;
  120474. }
  120475. }
  120476. declare module BABYLON {
  120477. /**
  120478. * This represents one of the lens effect in a `lensFlareSystem`.
  120479. * It controls one of the indiviual texture used in the effect.
  120480. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120481. */
  120482. export class LensFlare {
  120483. /**
  120484. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120485. */
  120486. size: number;
  120487. /**
  120488. * 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.
  120489. */
  120490. position: number;
  120491. /**
  120492. * Define the lens color.
  120493. */
  120494. color: Color3;
  120495. /**
  120496. * Define the lens texture.
  120497. */
  120498. texture: Nullable<Texture>;
  120499. /**
  120500. * Define the alpha mode to render this particular lens.
  120501. */
  120502. alphaMode: number;
  120503. private _system;
  120504. /**
  120505. * Creates a new Lens Flare.
  120506. * This represents one of the lens effect in a `lensFlareSystem`.
  120507. * It controls one of the indiviual texture used in the effect.
  120508. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120509. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  120510. * @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.
  120511. * @param color Define the lens color
  120512. * @param imgUrl Define the lens texture url
  120513. * @param system Define the `lensFlareSystem` this flare is part of
  120514. * @returns The newly created Lens Flare
  120515. */
  120516. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  120517. /**
  120518. * Instantiates a new Lens Flare.
  120519. * This represents one of the lens effect in a `lensFlareSystem`.
  120520. * It controls one of the indiviual texture used in the effect.
  120521. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120522. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  120523. * @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.
  120524. * @param color Define the lens color
  120525. * @param imgUrl Define the lens texture url
  120526. * @param system Define the `lensFlareSystem` this flare is part of
  120527. */
  120528. constructor(
  120529. /**
  120530. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120531. */
  120532. size: number,
  120533. /**
  120534. * 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.
  120535. */
  120536. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  120537. /**
  120538. * Dispose and release the lens flare with its associated resources.
  120539. */
  120540. dispose(): void;
  120541. }
  120542. }
  120543. declare module BABYLON {
  120544. interface AbstractScene {
  120545. /**
  120546. * The list of lens flare system added to the scene
  120547. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120548. */
  120549. lensFlareSystems: Array<LensFlareSystem>;
  120550. /**
  120551. * Removes the given lens flare system from this scene.
  120552. * @param toRemove The lens flare system to remove
  120553. * @returns The index of the removed lens flare system
  120554. */
  120555. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  120556. /**
  120557. * Adds the given lens flare system to this scene
  120558. * @param newLensFlareSystem The lens flare system to add
  120559. */
  120560. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  120561. /**
  120562. * Gets a lens flare system using its name
  120563. * @param name defines the name to look for
  120564. * @returns the lens flare system or null if not found
  120565. */
  120566. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  120567. /**
  120568. * Gets a lens flare system using its id
  120569. * @param id defines the id to look for
  120570. * @returns the lens flare system or null if not found
  120571. */
  120572. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  120573. }
  120574. /**
  120575. * Defines the lens flare scene component responsible to manage any lens flares
  120576. * in a given scene.
  120577. */
  120578. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  120579. /**
  120580. * The component name helpfull to identify the component in the list of scene components.
  120581. */
  120582. readonly name: string;
  120583. /**
  120584. * The scene the component belongs to.
  120585. */
  120586. scene: Scene;
  120587. /**
  120588. * Creates a new instance of the component for the given scene
  120589. * @param scene Defines the scene to register the component in
  120590. */
  120591. constructor(scene: Scene);
  120592. /**
  120593. * Registers the component in a given scene
  120594. */
  120595. register(): void;
  120596. /**
  120597. * Rebuilds the elements related to this component in case of
  120598. * context lost for instance.
  120599. */
  120600. rebuild(): void;
  120601. /**
  120602. * Adds all the elements from the container to the scene
  120603. * @param container the container holding the elements
  120604. */
  120605. addFromContainer(container: AbstractScene): void;
  120606. /**
  120607. * Removes all the elements in the container from the scene
  120608. * @param container contains the elements to remove
  120609. * @param dispose if the removed element should be disposed (default: false)
  120610. */
  120611. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120612. /**
  120613. * Serializes the component data to the specified json object
  120614. * @param serializationObject The object to serialize to
  120615. */
  120616. serialize(serializationObject: any): void;
  120617. /**
  120618. * Disposes the component and the associated ressources.
  120619. */
  120620. dispose(): void;
  120621. private _draw;
  120622. }
  120623. }
  120624. declare module BABYLON {
  120625. /**
  120626. * Defines the shadow generator component responsible to manage any shadow generators
  120627. * in a given scene.
  120628. */
  120629. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  120630. /**
  120631. * The component name helpfull to identify the component in the list of scene components.
  120632. */
  120633. readonly name: string;
  120634. /**
  120635. * The scene the component belongs to.
  120636. */
  120637. scene: Scene;
  120638. /**
  120639. * Creates a new instance of the component for the given scene
  120640. * @param scene Defines the scene to register the component in
  120641. */
  120642. constructor(scene: Scene);
  120643. /**
  120644. * Registers the component in a given scene
  120645. */
  120646. register(): void;
  120647. /**
  120648. * Rebuilds the elements related to this component in case of
  120649. * context lost for instance.
  120650. */
  120651. rebuild(): void;
  120652. /**
  120653. * Serializes the component data to the specified json object
  120654. * @param serializationObject The object to serialize to
  120655. */
  120656. serialize(serializationObject: any): void;
  120657. /**
  120658. * Adds all the elements from the container to the scene
  120659. * @param container the container holding the elements
  120660. */
  120661. addFromContainer(container: AbstractScene): void;
  120662. /**
  120663. * Removes all the elements in the container from the scene
  120664. * @param container contains the elements to remove
  120665. * @param dispose if the removed element should be disposed (default: false)
  120666. */
  120667. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120668. /**
  120669. * Rebuilds the elements related to this component in case of
  120670. * context lost for instance.
  120671. */
  120672. dispose(): void;
  120673. private _gatherRenderTargets;
  120674. }
  120675. }
  120676. declare module BABYLON {
  120677. /**
  120678. * A point light is a light defined by an unique point in world space.
  120679. * The light is emitted in every direction from this point.
  120680. * A good example of a point light is a standard light bulb.
  120681. * Documentation: https://doc.babylonjs.com/babylon101/lights
  120682. */
  120683. export class PointLight extends ShadowLight {
  120684. private _shadowAngle;
  120685. /**
  120686. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120687. * This specifies what angle the shadow will use to be created.
  120688. *
  120689. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120690. */
  120691. /**
  120692. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120693. * This specifies what angle the shadow will use to be created.
  120694. *
  120695. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120696. */
  120697. shadowAngle: number;
  120698. /**
  120699. * Gets the direction if it has been set.
  120700. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120701. */
  120702. /**
  120703. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120704. */
  120705. direction: Vector3;
  120706. /**
  120707. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  120708. * A PointLight emits the light in every direction.
  120709. * It can cast shadows.
  120710. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  120711. * ```javascript
  120712. * var pointLight = new PointLight("pl", camera.position, scene);
  120713. * ```
  120714. * Documentation : https://doc.babylonjs.com/babylon101/lights
  120715. * @param name The light friendly name
  120716. * @param position The position of the point light in the scene
  120717. * @param scene The scene the lights belongs to
  120718. */
  120719. constructor(name: string, position: Vector3, scene: Scene);
  120720. /**
  120721. * Returns the string "PointLight"
  120722. * @returns the class name
  120723. */
  120724. getClassName(): string;
  120725. /**
  120726. * Returns the integer 0.
  120727. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  120728. */
  120729. getTypeID(): number;
  120730. /**
  120731. * Specifies wether or not the shadowmap should be a cube texture.
  120732. * @returns true if the shadowmap needs to be a cube texture.
  120733. */
  120734. needCube(): boolean;
  120735. /**
  120736. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  120737. * @param faceIndex The index of the face we are computed the direction to generate shadow
  120738. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  120739. */
  120740. getShadowDirection(faceIndex?: number): Vector3;
  120741. /**
  120742. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  120743. * - fov = PI / 2
  120744. * - aspect ratio : 1.0
  120745. * - z-near and far equal to the active camera minZ and maxZ.
  120746. * Returns the PointLight.
  120747. */
  120748. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  120749. protected _buildUniformLayout(): void;
  120750. /**
  120751. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  120752. * @param effect The effect to update
  120753. * @param lightIndex The index of the light in the effect to update
  120754. * @returns The point light
  120755. */
  120756. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  120757. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  120758. /**
  120759. * Prepares the list of defines specific to the light type.
  120760. * @param defines the list of defines
  120761. * @param lightIndex defines the index of the light for the effect
  120762. */
  120763. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  120764. }
  120765. }
  120766. declare module BABYLON {
  120767. /**
  120768. * Header information of HDR texture files.
  120769. */
  120770. export interface HDRInfo {
  120771. /**
  120772. * The height of the texture in pixels.
  120773. */
  120774. height: number;
  120775. /**
  120776. * The width of the texture in pixels.
  120777. */
  120778. width: number;
  120779. /**
  120780. * The index of the beginning of the data in the binary file.
  120781. */
  120782. dataPosition: number;
  120783. }
  120784. /**
  120785. * This groups tools to convert HDR texture to native colors array.
  120786. */
  120787. export class HDRTools {
  120788. private static Ldexp;
  120789. private static Rgbe2float;
  120790. private static readStringLine;
  120791. /**
  120792. * Reads header information from an RGBE texture stored in a native array.
  120793. * More information on this format are available here:
  120794. * https://en.wikipedia.org/wiki/RGBE_image_format
  120795. *
  120796. * @param uint8array The binary file stored in native array.
  120797. * @return The header information.
  120798. */
  120799. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  120800. /**
  120801. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  120802. * This RGBE texture needs to store the information as a panorama.
  120803. *
  120804. * More information on this format are available here:
  120805. * https://en.wikipedia.org/wiki/RGBE_image_format
  120806. *
  120807. * @param buffer The binary file stored in an array buffer.
  120808. * @param size The expected size of the extracted cubemap.
  120809. * @return The Cube Map information.
  120810. */
  120811. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  120812. /**
  120813. * Returns the pixels data extracted from an RGBE texture.
  120814. * This pixels will be stored left to right up to down in the R G B order in one array.
  120815. *
  120816. * More information on this format are available here:
  120817. * https://en.wikipedia.org/wiki/RGBE_image_format
  120818. *
  120819. * @param uint8array The binary file stored in an array buffer.
  120820. * @param hdrInfo The header information of the file.
  120821. * @return The pixels data in RGB right to left up to down order.
  120822. */
  120823. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  120824. private static RGBE_ReadPixels_RLE;
  120825. }
  120826. }
  120827. declare module BABYLON {
  120828. /**
  120829. * This represents a texture coming from an HDR input.
  120830. *
  120831. * The only supported format is currently panorama picture stored in RGBE format.
  120832. * Example of such files can be found on HDRLib: http://hdrlib.com/
  120833. */
  120834. export class HDRCubeTexture extends BaseTexture {
  120835. private static _facesMapping;
  120836. private _generateHarmonics;
  120837. private _noMipmap;
  120838. private _textureMatrix;
  120839. private _size;
  120840. private _onLoad;
  120841. private _onError;
  120842. /**
  120843. * The texture URL.
  120844. */
  120845. url: string;
  120846. /**
  120847. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  120848. */
  120849. coordinatesMode: number;
  120850. protected _isBlocking: boolean;
  120851. /**
  120852. * Sets wether or not the texture is blocking during loading.
  120853. */
  120854. /**
  120855. * Gets wether or not the texture is blocking during loading.
  120856. */
  120857. isBlocking: boolean;
  120858. protected _rotationY: number;
  120859. /**
  120860. * Sets texture matrix rotation angle around Y axis in radians.
  120861. */
  120862. /**
  120863. * Gets texture matrix rotation angle around Y axis radians.
  120864. */
  120865. rotationY: number;
  120866. /**
  120867. * Gets or sets the center of the bounding box associated with the cube texture
  120868. * It must define where the camera used to render the texture was set
  120869. */
  120870. boundingBoxPosition: Vector3;
  120871. private _boundingBoxSize;
  120872. /**
  120873. * Gets or sets the size of the bounding box associated with the cube texture
  120874. * When defined, the cubemap will switch to local mode
  120875. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  120876. * @example https://www.babylonjs-playground.com/#RNASML
  120877. */
  120878. boundingBoxSize: Vector3;
  120879. /**
  120880. * Instantiates an HDRTexture from the following parameters.
  120881. *
  120882. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  120883. * @param scene The scene the texture will be used in
  120884. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120885. * @param noMipmap Forces to not generate the mipmap if true
  120886. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  120887. * @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)
  120888. * @param reserved Reserved flag for internal use.
  120889. */
  120890. 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>);
  120891. /**
  120892. * Get the current class name of the texture useful for serialization or dynamic coding.
  120893. * @returns "HDRCubeTexture"
  120894. */
  120895. getClassName(): string;
  120896. /**
  120897. * Occurs when the file is raw .hdr file.
  120898. */
  120899. private loadTexture;
  120900. clone(): HDRCubeTexture;
  120901. delayLoad(): void;
  120902. /**
  120903. * Get the texture reflection matrix used to rotate/transform the reflection.
  120904. * @returns the reflection matrix
  120905. */
  120906. getReflectionTextureMatrix(): Matrix;
  120907. /**
  120908. * Set the texture reflection matrix used to rotate/transform the reflection.
  120909. * @param value Define the reflection matrix to set
  120910. */
  120911. setReflectionTextureMatrix(value: Matrix): void;
  120912. /**
  120913. * Parses a JSON representation of an HDR Texture in order to create the texture
  120914. * @param parsedTexture Define the JSON representation
  120915. * @param scene Define the scene the texture should be created in
  120916. * @param rootUrl Define the root url in case we need to load relative dependencies
  120917. * @returns the newly created texture after parsing
  120918. */
  120919. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  120920. serialize(): any;
  120921. }
  120922. }
  120923. declare module BABYLON {
  120924. /**
  120925. * Class used to control physics engine
  120926. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120927. */
  120928. export class PhysicsEngine implements IPhysicsEngine {
  120929. private _physicsPlugin;
  120930. /**
  120931. * Global value used to control the smallest number supported by the simulation
  120932. */
  120933. static Epsilon: number;
  120934. private _impostors;
  120935. private _joints;
  120936. private _subTimeStep;
  120937. /**
  120938. * Gets the gravity vector used by the simulation
  120939. */
  120940. gravity: Vector3;
  120941. /**
  120942. * Factory used to create the default physics plugin.
  120943. * @returns The default physics plugin
  120944. */
  120945. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  120946. /**
  120947. * Creates a new Physics Engine
  120948. * @param gravity defines the gravity vector used by the simulation
  120949. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  120950. */
  120951. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  120952. /**
  120953. * Sets the gravity vector used by the simulation
  120954. * @param gravity defines the gravity vector to use
  120955. */
  120956. setGravity(gravity: Vector3): void;
  120957. /**
  120958. * Set the time step of the physics engine.
  120959. * Default is 1/60.
  120960. * To slow it down, enter 1/600 for example.
  120961. * To speed it up, 1/30
  120962. * @param newTimeStep defines the new timestep to apply to this world.
  120963. */
  120964. setTimeStep(newTimeStep?: number): void;
  120965. /**
  120966. * Get the time step of the physics engine.
  120967. * @returns the current time step
  120968. */
  120969. getTimeStep(): number;
  120970. /**
  120971. * Set the sub time step of the physics engine.
  120972. * Default is 0 meaning there is no sub steps
  120973. * To increase physics resolution precision, set a small value (like 1 ms)
  120974. * @param subTimeStep defines the new sub timestep used for physics resolution.
  120975. */
  120976. setSubTimeStep(subTimeStep?: number): void;
  120977. /**
  120978. * Get the sub time step of the physics engine.
  120979. * @returns the current sub time step
  120980. */
  120981. getSubTimeStep(): number;
  120982. /**
  120983. * Release all resources
  120984. */
  120985. dispose(): void;
  120986. /**
  120987. * Gets the name of the current physics plugin
  120988. * @returns the name of the plugin
  120989. */
  120990. getPhysicsPluginName(): string;
  120991. /**
  120992. * Adding a new impostor for the impostor tracking.
  120993. * This will be done by the impostor itself.
  120994. * @param impostor the impostor to add
  120995. */
  120996. addImpostor(impostor: PhysicsImpostor): void;
  120997. /**
  120998. * Remove an impostor from the engine.
  120999. * This impostor and its mesh will not longer be updated by the physics engine.
  121000. * @param impostor the impostor to remove
  121001. */
  121002. removeImpostor(impostor: PhysicsImpostor): void;
  121003. /**
  121004. * Add a joint to the physics engine
  121005. * @param mainImpostor defines the main impostor to which the joint is added.
  121006. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  121007. * @param joint defines the joint that will connect both impostors.
  121008. */
  121009. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  121010. /**
  121011. * Removes a joint from the simulation
  121012. * @param mainImpostor defines the impostor used with the joint
  121013. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  121014. * @param joint defines the joint to remove
  121015. */
  121016. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  121017. /**
  121018. * Called by the scene. No need to call it.
  121019. * @param delta defines the timespam between frames
  121020. */
  121021. _step(delta: number): void;
  121022. /**
  121023. * Gets the current plugin used to run the simulation
  121024. * @returns current plugin
  121025. */
  121026. getPhysicsPlugin(): IPhysicsEnginePlugin;
  121027. /**
  121028. * Gets the list of physic impostors
  121029. * @returns an array of PhysicsImpostor
  121030. */
  121031. getImpostors(): Array<PhysicsImpostor>;
  121032. /**
  121033. * Gets the impostor for a physics enabled object
  121034. * @param object defines the object impersonated by the impostor
  121035. * @returns the PhysicsImpostor or null if not found
  121036. */
  121037. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  121038. /**
  121039. * Gets the impostor for a physics body object
  121040. * @param body defines physics body used by the impostor
  121041. * @returns the PhysicsImpostor or null if not found
  121042. */
  121043. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  121044. /**
  121045. * Does a raycast in the physics world
  121046. * @param from when should the ray start?
  121047. * @param to when should the ray end?
  121048. * @returns PhysicsRaycastResult
  121049. */
  121050. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121051. }
  121052. }
  121053. declare module BABYLON {
  121054. /** @hidden */
  121055. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  121056. private _useDeltaForWorldStep;
  121057. world: any;
  121058. name: string;
  121059. private _physicsMaterials;
  121060. private _fixedTimeStep;
  121061. private _cannonRaycastResult;
  121062. private _raycastResult;
  121063. private _physicsBodysToRemoveAfterStep;
  121064. BJSCANNON: any;
  121065. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  121066. setGravity(gravity: Vector3): void;
  121067. setTimeStep(timeStep: number): void;
  121068. getTimeStep(): number;
  121069. executeStep(delta: number): void;
  121070. private _removeMarkedPhysicsBodiesFromWorld;
  121071. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121072. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121073. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121074. private _processChildMeshes;
  121075. removePhysicsBody(impostor: PhysicsImpostor): void;
  121076. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121077. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121078. private _addMaterial;
  121079. private _checkWithEpsilon;
  121080. private _createShape;
  121081. private _createHeightmap;
  121082. private _minus90X;
  121083. private _plus90X;
  121084. private _tmpPosition;
  121085. private _tmpDeltaPosition;
  121086. private _tmpUnityRotation;
  121087. private _updatePhysicsBodyTransformation;
  121088. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121089. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121090. isSupported(): boolean;
  121091. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121092. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121093. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121094. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121095. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121096. getBodyMass(impostor: PhysicsImpostor): number;
  121097. getBodyFriction(impostor: PhysicsImpostor): number;
  121098. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121099. getBodyRestitution(impostor: PhysicsImpostor): number;
  121100. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121101. sleepBody(impostor: PhysicsImpostor): void;
  121102. wakeUpBody(impostor: PhysicsImpostor): void;
  121103. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  121104. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121105. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121106. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121107. getRadius(impostor: PhysicsImpostor): number;
  121108. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121109. dispose(): void;
  121110. private _extendNamespace;
  121111. /**
  121112. * Does a raycast in the physics world
  121113. * @param from when should the ray start?
  121114. * @param to when should the ray end?
  121115. * @returns PhysicsRaycastResult
  121116. */
  121117. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121118. }
  121119. }
  121120. declare module BABYLON {
  121121. /** @hidden */
  121122. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  121123. world: any;
  121124. name: string;
  121125. BJSOIMO: any;
  121126. private _raycastResult;
  121127. constructor(iterations?: number, oimoInjection?: any);
  121128. setGravity(gravity: Vector3): void;
  121129. setTimeStep(timeStep: number): void;
  121130. getTimeStep(): number;
  121131. private _tmpImpostorsArray;
  121132. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121133. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121134. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121135. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121136. private _tmpPositionVector;
  121137. removePhysicsBody(impostor: PhysicsImpostor): void;
  121138. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121139. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121140. isSupported(): boolean;
  121141. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121142. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121143. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121144. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121145. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121146. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121147. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121148. getBodyMass(impostor: PhysicsImpostor): number;
  121149. getBodyFriction(impostor: PhysicsImpostor): number;
  121150. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121151. getBodyRestitution(impostor: PhysicsImpostor): number;
  121152. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121153. sleepBody(impostor: PhysicsImpostor): void;
  121154. wakeUpBody(impostor: PhysicsImpostor): void;
  121155. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121156. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  121157. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  121158. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121159. getRadius(impostor: PhysicsImpostor): number;
  121160. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121161. dispose(): void;
  121162. /**
  121163. * Does a raycast in the physics world
  121164. * @param from when should the ray start?
  121165. * @param to when should the ray end?
  121166. * @returns PhysicsRaycastResult
  121167. */
  121168. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121169. }
  121170. }
  121171. declare module BABYLON {
  121172. /**
  121173. * Class containing static functions to help procedurally build meshes
  121174. */
  121175. export class RibbonBuilder {
  121176. /**
  121177. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121178. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121179. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121180. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121181. * * 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
  121182. * * 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
  121183. * * 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
  121184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121186. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121187. * * 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
  121188. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121189. * * 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
  121190. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121192. * @param name defines the name of the mesh
  121193. * @param options defines the options used to create the mesh
  121194. * @param scene defines the hosting scene
  121195. * @returns the ribbon mesh
  121196. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121197. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121198. */
  121199. static CreateRibbon(name: string, options: {
  121200. pathArray: Vector3[][];
  121201. closeArray?: boolean;
  121202. closePath?: boolean;
  121203. offset?: number;
  121204. updatable?: boolean;
  121205. sideOrientation?: number;
  121206. frontUVs?: Vector4;
  121207. backUVs?: Vector4;
  121208. instance?: Mesh;
  121209. invertUV?: boolean;
  121210. uvs?: Vector2[];
  121211. colors?: Color4[];
  121212. }, scene?: Nullable<Scene>): Mesh;
  121213. }
  121214. }
  121215. declare module BABYLON {
  121216. /**
  121217. * Class containing static functions to help procedurally build meshes
  121218. */
  121219. export class ShapeBuilder {
  121220. /**
  121221. * 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.
  121222. * * 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.
  121223. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121224. * * 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.
  121225. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121226. * * 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
  121227. * * 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
  121228. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121231. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121233. * @param name defines the name of the mesh
  121234. * @param options defines the options used to create the mesh
  121235. * @param scene defines the hosting scene
  121236. * @returns the extruded shape mesh
  121237. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121238. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121239. */
  121240. static ExtrudeShape(name: string, options: {
  121241. shape: Vector3[];
  121242. path: Vector3[];
  121243. scale?: number;
  121244. rotation?: number;
  121245. cap?: number;
  121246. updatable?: boolean;
  121247. sideOrientation?: number;
  121248. frontUVs?: Vector4;
  121249. backUVs?: Vector4;
  121250. instance?: Mesh;
  121251. invertUV?: boolean;
  121252. }, scene?: Nullable<Scene>): Mesh;
  121253. /**
  121254. * Creates an custom extruded shape mesh.
  121255. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121256. * * 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.
  121257. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121258. * * 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
  121259. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121260. * * 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
  121261. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121262. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121263. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121264. * * 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
  121265. * * 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
  121266. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121269. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121271. * @param name defines the name of the mesh
  121272. * @param options defines the options used to create the mesh
  121273. * @param scene defines the hosting scene
  121274. * @returns the custom extruded shape mesh
  121275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121276. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121278. */
  121279. static ExtrudeShapeCustom(name: string, options: {
  121280. shape: Vector3[];
  121281. path: Vector3[];
  121282. scaleFunction?: any;
  121283. rotationFunction?: any;
  121284. ribbonCloseArray?: boolean;
  121285. ribbonClosePath?: boolean;
  121286. cap?: number;
  121287. updatable?: boolean;
  121288. sideOrientation?: number;
  121289. frontUVs?: Vector4;
  121290. backUVs?: Vector4;
  121291. instance?: Mesh;
  121292. invertUV?: boolean;
  121293. }, scene?: Nullable<Scene>): Mesh;
  121294. private static _ExtrudeShapeGeneric;
  121295. }
  121296. }
  121297. declare module BABYLON {
  121298. /**
  121299. * AmmoJS Physics plugin
  121300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  121301. * @see https://github.com/kripken/ammo.js/
  121302. */
  121303. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  121304. private _useDeltaForWorldStep;
  121305. /**
  121306. * Reference to the Ammo library
  121307. */
  121308. bjsAMMO: any;
  121309. /**
  121310. * Created ammoJS world which physics bodies are added to
  121311. */
  121312. world: any;
  121313. /**
  121314. * Name of the plugin
  121315. */
  121316. name: string;
  121317. private _timeStep;
  121318. private _fixedTimeStep;
  121319. private _maxSteps;
  121320. private _tmpQuaternion;
  121321. private _tmpAmmoTransform;
  121322. private _tmpAmmoQuaternion;
  121323. private _tmpAmmoConcreteContactResultCallback;
  121324. private _collisionConfiguration;
  121325. private _dispatcher;
  121326. private _overlappingPairCache;
  121327. private _solver;
  121328. private _softBodySolver;
  121329. private _tmpAmmoVectorA;
  121330. private _tmpAmmoVectorB;
  121331. private _tmpAmmoVectorC;
  121332. private _tmpAmmoVectorD;
  121333. private _tmpContactCallbackResult;
  121334. private _tmpAmmoVectorRCA;
  121335. private _tmpAmmoVectorRCB;
  121336. private _raycastResult;
  121337. private static readonly DISABLE_COLLISION_FLAG;
  121338. private static readonly KINEMATIC_FLAG;
  121339. private static readonly DISABLE_DEACTIVATION_FLAG;
  121340. /**
  121341. * Initializes the ammoJS plugin
  121342. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  121343. * @param ammoInjection can be used to inject your own ammo reference
  121344. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  121345. */
  121346. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  121347. /**
  121348. * Sets the gravity of the physics world (m/(s^2))
  121349. * @param gravity Gravity to set
  121350. */
  121351. setGravity(gravity: Vector3): void;
  121352. /**
  121353. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  121354. * @param timeStep timestep to use in seconds
  121355. */
  121356. setTimeStep(timeStep: number): void;
  121357. /**
  121358. * 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)
  121359. * @param fixedTimeStep fixedTimeStep to use in seconds
  121360. */
  121361. setFixedTimeStep(fixedTimeStep: number): void;
  121362. /**
  121363. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  121364. * @param maxSteps the maximum number of steps by the physics engine per frame
  121365. */
  121366. setMaxSteps(maxSteps: number): void;
  121367. /**
  121368. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  121369. * @returns the current timestep in seconds
  121370. */
  121371. getTimeStep(): number;
  121372. /**
  121373. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  121374. */
  121375. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  121376. private _isImpostorInContact;
  121377. private _isImpostorPairInContact;
  121378. private _stepSimulation;
  121379. /**
  121380. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  121381. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  121382. * After the step the babylon meshes are set to the position of the physics imposters
  121383. * @param delta amount of time to step forward
  121384. * @param impostors array of imposters to update before/after the step
  121385. */
  121386. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121387. /**
  121388. * Update babylon mesh to match physics world object
  121389. * @param impostor imposter to match
  121390. */
  121391. private _afterSoftStep;
  121392. /**
  121393. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121394. * @param impostor imposter to match
  121395. */
  121396. private _ropeStep;
  121397. /**
  121398. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121399. * @param impostor imposter to match
  121400. */
  121401. private _softbodyOrClothStep;
  121402. private _tmpVector;
  121403. private _tmpMatrix;
  121404. /**
  121405. * Applies an impulse on the imposter
  121406. * @param impostor imposter to apply impulse to
  121407. * @param force amount of force to be applied to the imposter
  121408. * @param contactPoint the location to apply the impulse on the imposter
  121409. */
  121410. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121411. /**
  121412. * Applies a force on the imposter
  121413. * @param impostor imposter to apply force
  121414. * @param force amount of force to be applied to the imposter
  121415. * @param contactPoint the location to apply the force on the imposter
  121416. */
  121417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121418. /**
  121419. * Creates a physics body using the plugin
  121420. * @param impostor the imposter to create the physics body on
  121421. */
  121422. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121423. /**
  121424. * Removes the physics body from the imposter and disposes of the body's memory
  121425. * @param impostor imposter to remove the physics body from
  121426. */
  121427. removePhysicsBody(impostor: PhysicsImpostor): void;
  121428. /**
  121429. * Generates a joint
  121430. * @param impostorJoint the imposter joint to create the joint with
  121431. */
  121432. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121433. /**
  121434. * Removes a joint
  121435. * @param impostorJoint the imposter joint to remove the joint from
  121436. */
  121437. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121438. private _addMeshVerts;
  121439. /**
  121440. * Initialise the soft body vertices to match its object's (mesh) vertices
  121441. * Softbody vertices (nodes) are in world space and to match this
  121442. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  121443. * @param impostor to create the softbody for
  121444. */
  121445. private _softVertexData;
  121446. /**
  121447. * Create an impostor's soft body
  121448. * @param impostor to create the softbody for
  121449. */
  121450. private _createSoftbody;
  121451. /**
  121452. * Create cloth for an impostor
  121453. * @param impostor to create the softbody for
  121454. */
  121455. private _createCloth;
  121456. /**
  121457. * Create rope for an impostor
  121458. * @param impostor to create the softbody for
  121459. */
  121460. private _createRope;
  121461. /**
  121462. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  121463. * @param impostor to create the custom physics shape for
  121464. */
  121465. private _createCustom;
  121466. private _addHullVerts;
  121467. private _createShape;
  121468. /**
  121469. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  121470. * @param impostor imposter containing the physics body and babylon object
  121471. */
  121472. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121473. /**
  121474. * Sets the babylon object's position/rotation from the physics body's position/rotation
  121475. * @param impostor imposter containing the physics body and babylon object
  121476. * @param newPosition new position
  121477. * @param newRotation new rotation
  121478. */
  121479. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121480. /**
  121481. * If this plugin is supported
  121482. * @returns true if its supported
  121483. */
  121484. isSupported(): boolean;
  121485. /**
  121486. * Sets the linear velocity of the physics body
  121487. * @param impostor imposter to set the velocity on
  121488. * @param velocity velocity to set
  121489. */
  121490. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121491. /**
  121492. * Sets the angular velocity of the physics body
  121493. * @param impostor imposter to set the velocity on
  121494. * @param velocity velocity to set
  121495. */
  121496. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121497. /**
  121498. * gets the linear velocity
  121499. * @param impostor imposter to get linear velocity from
  121500. * @returns linear velocity
  121501. */
  121502. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121503. /**
  121504. * gets the angular velocity
  121505. * @param impostor imposter to get angular velocity from
  121506. * @returns angular velocity
  121507. */
  121508. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121509. /**
  121510. * Sets the mass of physics body
  121511. * @param impostor imposter to set the mass on
  121512. * @param mass mass to set
  121513. */
  121514. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121515. /**
  121516. * Gets the mass of the physics body
  121517. * @param impostor imposter to get the mass from
  121518. * @returns mass
  121519. */
  121520. getBodyMass(impostor: PhysicsImpostor): number;
  121521. /**
  121522. * Gets friction of the impostor
  121523. * @param impostor impostor to get friction from
  121524. * @returns friction value
  121525. */
  121526. getBodyFriction(impostor: PhysicsImpostor): number;
  121527. /**
  121528. * Sets friction of the impostor
  121529. * @param impostor impostor to set friction on
  121530. * @param friction friction value
  121531. */
  121532. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121533. /**
  121534. * Gets restitution of the impostor
  121535. * @param impostor impostor to get restitution from
  121536. * @returns restitution value
  121537. */
  121538. getBodyRestitution(impostor: PhysicsImpostor): number;
  121539. /**
  121540. * Sets resitution of the impostor
  121541. * @param impostor impostor to set resitution on
  121542. * @param restitution resitution value
  121543. */
  121544. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121545. /**
  121546. * Gets pressure inside the impostor
  121547. * @param impostor impostor to get pressure from
  121548. * @returns pressure value
  121549. */
  121550. getBodyPressure(impostor: PhysicsImpostor): number;
  121551. /**
  121552. * Sets pressure inside a soft body impostor
  121553. * Cloth and rope must remain 0 pressure
  121554. * @param impostor impostor to set pressure on
  121555. * @param pressure pressure value
  121556. */
  121557. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  121558. /**
  121559. * Gets stiffness of the impostor
  121560. * @param impostor impostor to get stiffness from
  121561. * @returns pressure value
  121562. */
  121563. getBodyStiffness(impostor: PhysicsImpostor): number;
  121564. /**
  121565. * Sets stiffness of the impostor
  121566. * @param impostor impostor to set stiffness on
  121567. * @param stiffness stiffness value from 0 to 1
  121568. */
  121569. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  121570. /**
  121571. * Gets velocityIterations of the impostor
  121572. * @param impostor impostor to get velocity iterations from
  121573. * @returns velocityIterations value
  121574. */
  121575. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  121576. /**
  121577. * Sets velocityIterations of the impostor
  121578. * @param impostor impostor to set velocity iterations on
  121579. * @param velocityIterations velocityIterations value
  121580. */
  121581. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  121582. /**
  121583. * Gets positionIterations of the impostor
  121584. * @param impostor impostor to get position iterations from
  121585. * @returns positionIterations value
  121586. */
  121587. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  121588. /**
  121589. * Sets positionIterations of the impostor
  121590. * @param impostor impostor to set position on
  121591. * @param positionIterations positionIterations value
  121592. */
  121593. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  121594. /**
  121595. * Append an anchor to a cloth object
  121596. * @param impostor is the cloth impostor to add anchor to
  121597. * @param otherImpostor is the rigid impostor to anchor to
  121598. * @param width ratio across width from 0 to 1
  121599. * @param height ratio up height from 0 to 1
  121600. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  121601. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121602. */
  121603. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121604. /**
  121605. * Append an hook to a rope object
  121606. * @param impostor is the rope impostor to add hook to
  121607. * @param otherImpostor is the rigid impostor to hook to
  121608. * @param length ratio along the rope from 0 to 1
  121609. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  121610. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121611. */
  121612. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121613. /**
  121614. * Sleeps the physics body and stops it from being active
  121615. * @param impostor impostor to sleep
  121616. */
  121617. sleepBody(impostor: PhysicsImpostor): void;
  121618. /**
  121619. * Activates the physics body
  121620. * @param impostor impostor to activate
  121621. */
  121622. wakeUpBody(impostor: PhysicsImpostor): void;
  121623. /**
  121624. * Updates the distance parameters of the joint
  121625. * @param joint joint to update
  121626. * @param maxDistance maximum distance of the joint
  121627. * @param minDistance minimum distance of the joint
  121628. */
  121629. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121630. /**
  121631. * Sets a motor on the joint
  121632. * @param joint joint to set motor on
  121633. * @param speed speed of the motor
  121634. * @param maxForce maximum force of the motor
  121635. * @param motorIndex index of the motor
  121636. */
  121637. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121638. /**
  121639. * Sets the motors limit
  121640. * @param joint joint to set limit on
  121641. * @param upperLimit upper limit
  121642. * @param lowerLimit lower limit
  121643. */
  121644. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121645. /**
  121646. * Syncs the position and rotation of a mesh with the impostor
  121647. * @param mesh mesh to sync
  121648. * @param impostor impostor to update the mesh with
  121649. */
  121650. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121651. /**
  121652. * Gets the radius of the impostor
  121653. * @param impostor impostor to get radius from
  121654. * @returns the radius
  121655. */
  121656. getRadius(impostor: PhysicsImpostor): number;
  121657. /**
  121658. * Gets the box size of the impostor
  121659. * @param impostor impostor to get box size from
  121660. * @param result the resulting box size
  121661. */
  121662. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121663. /**
  121664. * Disposes of the impostor
  121665. */
  121666. dispose(): void;
  121667. /**
  121668. * Does a raycast in the physics world
  121669. * @param from when should the ray start?
  121670. * @param to when should the ray end?
  121671. * @returns PhysicsRaycastResult
  121672. */
  121673. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121674. }
  121675. }
  121676. declare module BABYLON {
  121677. interface AbstractScene {
  121678. /**
  121679. * The list of reflection probes added to the scene
  121680. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121681. */
  121682. reflectionProbes: Array<ReflectionProbe>;
  121683. /**
  121684. * Removes the given reflection probe from this scene.
  121685. * @param toRemove The reflection probe to remove
  121686. * @returns The index of the removed reflection probe
  121687. */
  121688. removeReflectionProbe(toRemove: ReflectionProbe): number;
  121689. /**
  121690. * Adds the given reflection probe to this scene.
  121691. * @param newReflectionProbe The reflection probe to add
  121692. */
  121693. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  121694. }
  121695. /**
  121696. * Class used to generate realtime reflection / refraction cube textures
  121697. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121698. */
  121699. export class ReflectionProbe {
  121700. /** defines the name of the probe */
  121701. name: string;
  121702. private _scene;
  121703. private _renderTargetTexture;
  121704. private _projectionMatrix;
  121705. private _viewMatrix;
  121706. private _target;
  121707. private _add;
  121708. private _attachedMesh;
  121709. private _invertYAxis;
  121710. /** Gets or sets probe position (center of the cube map) */
  121711. position: Vector3;
  121712. /**
  121713. * Creates a new reflection probe
  121714. * @param name defines the name of the probe
  121715. * @param size defines the texture resolution (for each face)
  121716. * @param scene defines the hosting scene
  121717. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  121718. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  121719. */
  121720. constructor(
  121721. /** defines the name of the probe */
  121722. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  121723. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  121724. samples: number;
  121725. /** Gets or sets the refresh rate to use (on every frame by default) */
  121726. refreshRate: number;
  121727. /**
  121728. * Gets the hosting scene
  121729. * @returns a Scene
  121730. */
  121731. getScene(): Scene;
  121732. /** Gets the internal CubeTexture used to render to */
  121733. readonly cubeTexture: RenderTargetTexture;
  121734. /** Gets the list of meshes to render */
  121735. readonly renderList: Nullable<AbstractMesh[]>;
  121736. /**
  121737. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  121738. * @param mesh defines the mesh to attach to
  121739. */
  121740. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121741. /**
  121742. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  121743. * @param renderingGroupId The rendering group id corresponding to its index
  121744. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121745. */
  121746. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  121747. /**
  121748. * Clean all associated resources
  121749. */
  121750. dispose(): void;
  121751. /**
  121752. * Converts the reflection probe information to a readable string for debug purpose.
  121753. * @param fullDetails Supports for multiple levels of logging within scene loading
  121754. * @returns the human readable reflection probe info
  121755. */
  121756. toString(fullDetails?: boolean): string;
  121757. /**
  121758. * Get the class name of the relfection probe.
  121759. * @returns "ReflectionProbe"
  121760. */
  121761. getClassName(): string;
  121762. /**
  121763. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  121764. * @returns The JSON representation of the texture
  121765. */
  121766. serialize(): any;
  121767. /**
  121768. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  121769. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  121770. * @param scene Define the scene the parsed reflection probe should be instantiated in
  121771. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  121772. * @returns The parsed reflection probe if successful
  121773. */
  121774. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  121775. }
  121776. }
  121777. declare module BABYLON {
  121778. /** @hidden */
  121779. export var _BabylonLoaderRegistered: boolean;
  121780. /**
  121781. * Helps setting up some configuration for the babylon file loader.
  121782. */
  121783. export class BabylonFileLoaderConfiguration {
  121784. /**
  121785. * The loader does not allow injecting custom physix engine into the plugins.
  121786. * Unfortunately in ES6, we need to manually inject them into the plugin.
  121787. * So you could set this variable to your engine import to make it work.
  121788. */
  121789. static LoaderInjectedPhysicsEngine: any;
  121790. }
  121791. }
  121792. declare module BABYLON {
  121793. /**
  121794. * The Physically based simple base material of BJS.
  121795. *
  121796. * This enables better naming and convention enforcements on top of the pbrMaterial.
  121797. * It is used as the base class for both the specGloss and metalRough conventions.
  121798. */
  121799. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  121800. /**
  121801. * Number of Simultaneous lights allowed on the material.
  121802. */
  121803. maxSimultaneousLights: number;
  121804. /**
  121805. * If sets to true, disables all the lights affecting the material.
  121806. */
  121807. disableLighting: boolean;
  121808. /**
  121809. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  121810. */
  121811. environmentTexture: BaseTexture;
  121812. /**
  121813. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121814. */
  121815. invertNormalMapX: boolean;
  121816. /**
  121817. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121818. */
  121819. invertNormalMapY: boolean;
  121820. /**
  121821. * Normal map used in the model.
  121822. */
  121823. normalTexture: BaseTexture;
  121824. /**
  121825. * Emissivie color used to self-illuminate the model.
  121826. */
  121827. emissiveColor: Color3;
  121828. /**
  121829. * Emissivie texture used to self-illuminate the model.
  121830. */
  121831. emissiveTexture: BaseTexture;
  121832. /**
  121833. * Occlusion Channel Strenght.
  121834. */
  121835. occlusionStrength: number;
  121836. /**
  121837. * Occlusion Texture of the material (adding extra occlusion effects).
  121838. */
  121839. occlusionTexture: BaseTexture;
  121840. /**
  121841. * Defines the alpha limits in alpha test mode.
  121842. */
  121843. alphaCutOff: number;
  121844. /**
  121845. * Gets the current double sided mode.
  121846. */
  121847. /**
  121848. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121849. */
  121850. doubleSided: boolean;
  121851. /**
  121852. * Stores the pre-calculated light information of a mesh in a texture.
  121853. */
  121854. lightmapTexture: BaseTexture;
  121855. /**
  121856. * If true, the light map contains occlusion information instead of lighting info.
  121857. */
  121858. useLightmapAsShadowmap: boolean;
  121859. /**
  121860. * Instantiates a new PBRMaterial instance.
  121861. *
  121862. * @param name The material name
  121863. * @param scene The scene the material will be use in.
  121864. */
  121865. constructor(name: string, scene: Scene);
  121866. getClassName(): string;
  121867. }
  121868. }
  121869. declare module BABYLON {
  121870. /**
  121871. * The PBR material of BJS following the metal roughness convention.
  121872. *
  121873. * This fits to the PBR convention in the GLTF definition:
  121874. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  121875. */
  121876. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  121877. /**
  121878. * The base color has two different interpretations depending on the value of metalness.
  121879. * When the material is a metal, the base color is the specific measured reflectance value
  121880. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  121881. * of the material.
  121882. */
  121883. baseColor: Color3;
  121884. /**
  121885. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  121886. * well as opacity information in the alpha channel.
  121887. */
  121888. baseTexture: BaseTexture;
  121889. /**
  121890. * Specifies the metallic scalar value of the material.
  121891. * Can also be used to scale the metalness values of the metallic texture.
  121892. */
  121893. metallic: number;
  121894. /**
  121895. * Specifies the roughness scalar value of the material.
  121896. * Can also be used to scale the roughness values of the metallic texture.
  121897. */
  121898. roughness: number;
  121899. /**
  121900. * Texture containing both the metallic value in the B channel and the
  121901. * roughness value in the G channel to keep better precision.
  121902. */
  121903. metallicRoughnessTexture: BaseTexture;
  121904. /**
  121905. * Instantiates a new PBRMetalRoughnessMaterial instance.
  121906. *
  121907. * @param name The material name
  121908. * @param scene The scene the material will be use in.
  121909. */
  121910. constructor(name: string, scene: Scene);
  121911. /**
  121912. * Return the currrent class name of the material.
  121913. */
  121914. getClassName(): string;
  121915. /**
  121916. * Makes a duplicate of the current material.
  121917. * @param name - name to use for the new material.
  121918. */
  121919. clone(name: string): PBRMetallicRoughnessMaterial;
  121920. /**
  121921. * Serialize the material to a parsable JSON object.
  121922. */
  121923. serialize(): any;
  121924. /**
  121925. * Parses a JSON object correponding to the serialize function.
  121926. */
  121927. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  121928. }
  121929. }
  121930. declare module BABYLON {
  121931. /**
  121932. * The PBR material of BJS following the specular glossiness convention.
  121933. *
  121934. * This fits to the PBR convention in the GLTF definition:
  121935. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  121936. */
  121937. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  121938. /**
  121939. * Specifies the diffuse color of the material.
  121940. */
  121941. diffuseColor: Color3;
  121942. /**
  121943. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  121944. * channel.
  121945. */
  121946. diffuseTexture: BaseTexture;
  121947. /**
  121948. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  121949. */
  121950. specularColor: Color3;
  121951. /**
  121952. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  121953. */
  121954. glossiness: number;
  121955. /**
  121956. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  121957. */
  121958. specularGlossinessTexture: BaseTexture;
  121959. /**
  121960. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  121961. *
  121962. * @param name The material name
  121963. * @param scene The scene the material will be use in.
  121964. */
  121965. constructor(name: string, scene: Scene);
  121966. /**
  121967. * Return the currrent class name of the material.
  121968. */
  121969. getClassName(): string;
  121970. /**
  121971. * Makes a duplicate of the current material.
  121972. * @param name - name to use for the new material.
  121973. */
  121974. clone(name: string): PBRSpecularGlossinessMaterial;
  121975. /**
  121976. * Serialize the material to a parsable JSON object.
  121977. */
  121978. serialize(): any;
  121979. /**
  121980. * Parses a JSON object correponding to the serialize function.
  121981. */
  121982. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  121983. }
  121984. }
  121985. declare module BABYLON {
  121986. /**
  121987. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  121988. * It can help converting any input color in a desired output one. This can then be used to create effects
  121989. * from sepia, black and white to sixties or futuristic rendering...
  121990. *
  121991. * The only supported format is currently 3dl.
  121992. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  121993. */
  121994. export class ColorGradingTexture extends BaseTexture {
  121995. /**
  121996. * The current texture matrix. (will always be identity in color grading texture)
  121997. */
  121998. private _textureMatrix;
  121999. /**
  122000. * The texture URL.
  122001. */
  122002. url: string;
  122003. /**
  122004. * Empty line regex stored for GC.
  122005. */
  122006. private static _noneEmptyLineRegex;
  122007. private _engine;
  122008. /**
  122009. * Instantiates a ColorGradingTexture from the following parameters.
  122010. *
  122011. * @param url The location of the color gradind data (currently only supporting 3dl)
  122012. * @param scene The scene the texture will be used in
  122013. */
  122014. constructor(url: string, scene: Scene);
  122015. /**
  122016. * Returns the texture matrix used in most of the material.
  122017. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  122018. */
  122019. getTextureMatrix(): Matrix;
  122020. /**
  122021. * Occurs when the file being loaded is a .3dl LUT file.
  122022. */
  122023. private load3dlTexture;
  122024. /**
  122025. * Starts the loading process of the texture.
  122026. */
  122027. private loadTexture;
  122028. /**
  122029. * Clones the color gradind texture.
  122030. */
  122031. clone(): ColorGradingTexture;
  122032. /**
  122033. * Called during delayed load for textures.
  122034. */
  122035. delayLoad(): void;
  122036. /**
  122037. * Parses a color grading texture serialized by Babylon.
  122038. * @param parsedTexture The texture information being parsedTexture
  122039. * @param scene The scene to load the texture in
  122040. * @param rootUrl The root url of the data assets to load
  122041. * @return A color gradind texture
  122042. */
  122043. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  122044. /**
  122045. * Serializes the LUT texture to json format.
  122046. */
  122047. serialize(): any;
  122048. }
  122049. }
  122050. declare module BABYLON {
  122051. /**
  122052. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  122053. */
  122054. export class EquiRectangularCubeTexture extends BaseTexture {
  122055. /** The six faces of the cube. */
  122056. private static _FacesMapping;
  122057. private _noMipmap;
  122058. private _onLoad;
  122059. private _onError;
  122060. /** The size of the cubemap. */
  122061. private _size;
  122062. /** The buffer of the image. */
  122063. private _buffer;
  122064. /** The width of the input image. */
  122065. private _width;
  122066. /** The height of the input image. */
  122067. private _height;
  122068. /** The URL to the image. */
  122069. url: string;
  122070. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  122071. coordinatesMode: number;
  122072. /**
  122073. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  122074. * @param url The location of the image
  122075. * @param scene The scene the texture will be used in
  122076. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  122077. * @param noMipmap Forces to not generate the mipmap if true
  122078. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  122079. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  122080. * @param onLoad — defines a callback called when texture is loaded
  122081. * @param onError — defines a callback called if there is an error
  122082. */
  122083. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  122084. /**
  122085. * Load the image data, by putting the image on a canvas and extracting its buffer.
  122086. */
  122087. private loadImage;
  122088. /**
  122089. * Convert the image buffer into a cubemap and create a CubeTexture.
  122090. */
  122091. private loadTexture;
  122092. /**
  122093. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  122094. * @param buffer The ArrayBuffer that should be converted.
  122095. * @returns The buffer as Float32Array.
  122096. */
  122097. private getFloat32ArrayFromArrayBuffer;
  122098. /**
  122099. * Get the current class name of the texture useful for serialization or dynamic coding.
  122100. * @returns "EquiRectangularCubeTexture"
  122101. */
  122102. getClassName(): string;
  122103. /**
  122104. * Create a clone of the current EquiRectangularCubeTexture and return it.
  122105. * @returns A clone of the current EquiRectangularCubeTexture.
  122106. */
  122107. clone(): EquiRectangularCubeTexture;
  122108. }
  122109. }
  122110. declare module BABYLON {
  122111. /**
  122112. * Based on jsTGALoader - Javascript loader for TGA file
  122113. * By Vincent Thibault
  122114. * @see http://blog.robrowser.com/javascript-tga-loader.html
  122115. */
  122116. export class TGATools {
  122117. private static _TYPE_INDEXED;
  122118. private static _TYPE_RGB;
  122119. private static _TYPE_GREY;
  122120. private static _TYPE_RLE_INDEXED;
  122121. private static _TYPE_RLE_RGB;
  122122. private static _TYPE_RLE_GREY;
  122123. private static _ORIGIN_MASK;
  122124. private static _ORIGIN_SHIFT;
  122125. private static _ORIGIN_BL;
  122126. private static _ORIGIN_BR;
  122127. private static _ORIGIN_UL;
  122128. private static _ORIGIN_UR;
  122129. /**
  122130. * Gets the header of a TGA file
  122131. * @param data defines the TGA data
  122132. * @returns the header
  122133. */
  122134. static GetTGAHeader(data: Uint8Array): any;
  122135. /**
  122136. * Uploads TGA content to a Babylon Texture
  122137. * @hidden
  122138. */
  122139. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  122140. /** @hidden */
  122141. 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;
  122142. /** @hidden */
  122143. 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;
  122144. /** @hidden */
  122145. 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;
  122146. /** @hidden */
  122147. 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;
  122148. /** @hidden */
  122149. 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;
  122150. /** @hidden */
  122151. 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;
  122152. }
  122153. }
  122154. declare module BABYLON {
  122155. /**
  122156. * Implementation of the TGA Texture Loader.
  122157. * @hidden
  122158. */
  122159. export class _TGATextureLoader implements IInternalTextureLoader {
  122160. /**
  122161. * Defines wether the loader supports cascade loading the different faces.
  122162. */
  122163. readonly supportCascades: boolean;
  122164. /**
  122165. * This returns if the loader support the current file information.
  122166. * @param extension defines the file extension of the file being loaded
  122167. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122168. * @param fallback defines the fallback internal texture if any
  122169. * @param isBase64 defines whether the texture is encoded as a base64
  122170. * @param isBuffer defines whether the texture data are stored as a buffer
  122171. * @returns true if the loader can load the specified file
  122172. */
  122173. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122174. /**
  122175. * Transform the url before loading if required.
  122176. * @param rootUrl the url of the texture
  122177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122178. * @returns the transformed texture
  122179. */
  122180. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122181. /**
  122182. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122183. * @param rootUrl the url of the texture
  122184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122185. * @returns the fallback texture
  122186. */
  122187. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122188. /**
  122189. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  122190. * @param data contains the texture data
  122191. * @param texture defines the BabylonJS internal texture
  122192. * @param createPolynomials will be true if polynomials have been requested
  122193. * @param onLoad defines the callback to trigger once the texture is ready
  122194. * @param onError defines the callback to trigger in case of error
  122195. */
  122196. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122197. /**
  122198. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122199. * @param data contains the texture data
  122200. * @param texture defines the BabylonJS internal texture
  122201. * @param callback defines the method to call once ready to upload
  122202. */
  122203. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122204. }
  122205. }
  122206. declare module BABYLON {
  122207. /**
  122208. * Info about the .basis files
  122209. */
  122210. class BasisFileInfo {
  122211. /**
  122212. * If the file has alpha
  122213. */
  122214. hasAlpha: boolean;
  122215. /**
  122216. * Info about each image of the basis file
  122217. */
  122218. images: Array<{
  122219. levels: Array<{
  122220. width: number;
  122221. height: number;
  122222. transcodedPixels: ArrayBufferView;
  122223. }>;
  122224. }>;
  122225. }
  122226. /**
  122227. * Result of transcoding a basis file
  122228. */
  122229. class TranscodeResult {
  122230. /**
  122231. * Info about the .basis file
  122232. */
  122233. fileInfo: BasisFileInfo;
  122234. /**
  122235. * Format to use when loading the file
  122236. */
  122237. format: number;
  122238. }
  122239. /**
  122240. * Configuration options for the Basis transcoder
  122241. */
  122242. export class BasisTranscodeConfiguration {
  122243. /**
  122244. * Supported compression formats used to determine the supported output format of the transcoder
  122245. */
  122246. supportedCompressionFormats?: {
  122247. /**
  122248. * etc1 compression format
  122249. */
  122250. etc1?: boolean;
  122251. /**
  122252. * s3tc compression format
  122253. */
  122254. s3tc?: boolean;
  122255. /**
  122256. * pvrtc compression format
  122257. */
  122258. pvrtc?: boolean;
  122259. /**
  122260. * etc2 compression format
  122261. */
  122262. etc2?: boolean;
  122263. };
  122264. /**
  122265. * If mipmap levels should be loaded for transcoded images (Default: true)
  122266. */
  122267. loadMipmapLevels?: boolean;
  122268. /**
  122269. * Index of a single image to load (Default: all images)
  122270. */
  122271. loadSingleImage?: number;
  122272. }
  122273. /**
  122274. * Used to load .Basis files
  122275. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  122276. */
  122277. export class BasisTools {
  122278. private static _IgnoreSupportedFormats;
  122279. /**
  122280. * URL to use when loading the basis transcoder
  122281. */
  122282. static JSModuleURL: string;
  122283. /**
  122284. * URL to use when loading the wasm module for the transcoder
  122285. */
  122286. static WasmModuleURL: string;
  122287. /**
  122288. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  122289. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  122290. * @returns internal format corresponding to the Basis format
  122291. */
  122292. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  122293. private static _WorkerPromise;
  122294. private static _Worker;
  122295. private static _actionId;
  122296. private static _CreateWorkerAsync;
  122297. /**
  122298. * Transcodes a loaded image file to compressed pixel data
  122299. * @param imageData image data to transcode
  122300. * @param config configuration options for the transcoding
  122301. * @returns a promise resulting in the transcoded image
  122302. */
  122303. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  122304. /**
  122305. * Loads a texture from the transcode result
  122306. * @param texture texture load to
  122307. * @param transcodeResult the result of transcoding the basis file to load from
  122308. */
  122309. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  122310. }
  122311. }
  122312. declare module BABYLON {
  122313. /**
  122314. * Loader for .basis file format
  122315. */
  122316. export class _BasisTextureLoader implements IInternalTextureLoader {
  122317. /**
  122318. * Defines whether the loader supports cascade loading the different faces.
  122319. */
  122320. readonly supportCascades: boolean;
  122321. /**
  122322. * This returns if the loader support the current file information.
  122323. * @param extension defines the file extension of the file being loaded
  122324. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122325. * @param fallback defines the fallback internal texture if any
  122326. * @param isBase64 defines whether the texture is encoded as a base64
  122327. * @param isBuffer defines whether the texture data are stored as a buffer
  122328. * @returns true if the loader can load the specified file
  122329. */
  122330. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122331. /**
  122332. * Transform the url before loading if required.
  122333. * @param rootUrl the url of the texture
  122334. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122335. * @returns the transformed texture
  122336. */
  122337. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122338. /**
  122339. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122340. * @param rootUrl the url of the texture
  122341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122342. * @returns the fallback texture
  122343. */
  122344. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122345. /**
  122346. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  122347. * @param data contains the texture data
  122348. * @param texture defines the BabylonJS internal texture
  122349. * @param createPolynomials will be true if polynomials have been requested
  122350. * @param onLoad defines the callback to trigger once the texture is ready
  122351. * @param onError defines the callback to trigger in case of error
  122352. */
  122353. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122354. /**
  122355. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122356. * @param data contains the texture data
  122357. * @param texture defines the BabylonJS internal texture
  122358. * @param callback defines the method to call once ready to upload
  122359. */
  122360. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122361. }
  122362. }
  122363. declare module BABYLON {
  122364. /**
  122365. * 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.
  122366. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122367. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122368. */
  122369. export class CustomProceduralTexture extends ProceduralTexture {
  122370. private _animate;
  122371. private _time;
  122372. private _config;
  122373. private _texturePath;
  122374. /**
  122375. * Instantiates a new Custom Procedural Texture.
  122376. * 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.
  122377. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122378. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122379. * @param name Define the name of the texture
  122380. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  122381. * @param size Define the size of the texture to create
  122382. * @param scene Define the scene the texture belongs to
  122383. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  122384. * @param generateMipMaps Define if the texture should creates mip maps or not
  122385. */
  122386. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122387. private _loadJson;
  122388. /**
  122389. * Is the texture ready to be used ? (rendered at least once)
  122390. * @returns true if ready, otherwise, false.
  122391. */
  122392. isReady(): boolean;
  122393. /**
  122394. * Render the texture to its associated render target.
  122395. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  122396. */
  122397. render(useCameraPostProcess?: boolean): void;
  122398. /**
  122399. * Update the list of dependant textures samplers in the shader.
  122400. */
  122401. updateTextures(): void;
  122402. /**
  122403. * Update the uniform values of the procedural texture in the shader.
  122404. */
  122405. updateShaderUniforms(): void;
  122406. /**
  122407. * Define if the texture animates or not.
  122408. */
  122409. animate: boolean;
  122410. }
  122411. }
  122412. declare module BABYLON {
  122413. /** @hidden */
  122414. export var noisePixelShader: {
  122415. name: string;
  122416. shader: string;
  122417. };
  122418. }
  122419. declare module BABYLON {
  122420. /**
  122421. * Class used to generate noise procedural textures
  122422. */
  122423. export class NoiseProceduralTexture extends ProceduralTexture {
  122424. private _time;
  122425. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  122426. brightness: number;
  122427. /** Defines the number of octaves to process */
  122428. octaves: number;
  122429. /** Defines the level of persistence (0.8 by default) */
  122430. persistence: number;
  122431. /** Gets or sets animation speed factor (default is 1) */
  122432. animationSpeedFactor: number;
  122433. /**
  122434. * Creates a new NoiseProceduralTexture
  122435. * @param name defines the name fo the texture
  122436. * @param size defines the size of the texture (default is 256)
  122437. * @param scene defines the hosting scene
  122438. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  122439. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  122440. */
  122441. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122442. private _updateShaderUniforms;
  122443. protected _getDefines(): string;
  122444. /** Generate the current state of the procedural texture */
  122445. render(useCameraPostProcess?: boolean): void;
  122446. /**
  122447. * Serializes this noise procedural texture
  122448. * @returns a serialized noise procedural texture object
  122449. */
  122450. serialize(): any;
  122451. /**
  122452. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  122453. * @param parsedTexture defines parsed texture data
  122454. * @param scene defines the current scene
  122455. * @param rootUrl defines the root URL containing noise procedural texture information
  122456. * @returns a parsed NoiseProceduralTexture
  122457. */
  122458. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  122459. }
  122460. }
  122461. declare module BABYLON {
  122462. /**
  122463. * Raw cube texture where the raw buffers are passed in
  122464. */
  122465. export class RawCubeTexture extends CubeTexture {
  122466. /**
  122467. * Creates a cube texture where the raw buffers are passed in.
  122468. * @param scene defines the scene the texture is attached to
  122469. * @param data defines the array of data to use to create each face
  122470. * @param size defines the size of the textures
  122471. * @param format defines the format of the data
  122472. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  122473. * @param generateMipMaps defines if the engine should generate the mip levels
  122474. * @param invertY defines if data must be stored with Y axis inverted
  122475. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  122476. * @param compression defines the compression used (null by default)
  122477. */
  122478. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  122479. /**
  122480. * Updates the raw cube texture.
  122481. * @param data defines the data to store
  122482. * @param format defines the data format
  122483. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122484. * @param invertY defines if data must be stored with Y axis inverted
  122485. * @param compression defines the compression used (null by default)
  122486. * @param level defines which level of the texture to update
  122487. */
  122488. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  122489. /**
  122490. * Updates a raw cube texture with RGBD encoded data.
  122491. * @param data defines the array of data [mipmap][face] to use to create each face
  122492. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  122493. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122494. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122495. * @returns a promsie that resolves when the operation is complete
  122496. */
  122497. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  122498. /**
  122499. * Clones the raw cube texture.
  122500. * @return a new cube texture
  122501. */
  122502. clone(): CubeTexture;
  122503. /** @hidden */
  122504. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122505. }
  122506. }
  122507. declare module BABYLON {
  122508. /**
  122509. * Class used to store 3D textures containing user data
  122510. */
  122511. export class RawTexture3D extends Texture {
  122512. /** Gets or sets the texture format to use */
  122513. format: number;
  122514. private _engine;
  122515. /**
  122516. * Create a new RawTexture3D
  122517. * @param data defines the data of the texture
  122518. * @param width defines the width of the texture
  122519. * @param height defines the height of the texture
  122520. * @param depth defines the depth of the texture
  122521. * @param format defines the texture format to use
  122522. * @param scene defines the hosting scene
  122523. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122524. * @param invertY defines if texture must be stored with Y axis inverted
  122525. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122526. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122527. */
  122528. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122529. /** Gets or sets the texture format to use */
  122530. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122531. /**
  122532. * Update the texture with new data
  122533. * @param data defines the data to store in the texture
  122534. */
  122535. update(data: ArrayBufferView): void;
  122536. }
  122537. }
  122538. declare module BABYLON {
  122539. /**
  122540. * Class used to store 2D array textures containing user data
  122541. */
  122542. export class RawTexture2DArray extends Texture {
  122543. /** Gets or sets the texture format to use */
  122544. format: number;
  122545. private _engine;
  122546. /**
  122547. * Create a new RawTexture2DArray
  122548. * @param data defines the data of the texture
  122549. * @param width defines the width of the texture
  122550. * @param height defines the height of the texture
  122551. * @param depth defines the number of layers of the texture
  122552. * @param format defines the texture format to use
  122553. * @param scene defines the hosting scene
  122554. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122555. * @param invertY defines if texture must be stored with Y axis inverted
  122556. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122557. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122558. */
  122559. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122560. /** Gets or sets the texture format to use */
  122561. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122562. /**
  122563. * Update the texture with new data
  122564. * @param data defines the data to store in the texture
  122565. */
  122566. update(data: ArrayBufferView): void;
  122567. }
  122568. }
  122569. declare module BABYLON {
  122570. /**
  122571. * Creates a refraction texture used by refraction channel of the standard material.
  122572. * It is like a mirror but to see through a material.
  122573. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122574. */
  122575. export class RefractionTexture extends RenderTargetTexture {
  122576. /**
  122577. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  122578. * 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.
  122579. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122580. */
  122581. refractionPlane: Plane;
  122582. /**
  122583. * Define how deep under the surface we should see.
  122584. */
  122585. depth: number;
  122586. /**
  122587. * Creates a refraction texture used by refraction channel of the standard material.
  122588. * It is like a mirror but to see through a material.
  122589. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122590. * @param name Define the texture name
  122591. * @param size Define the size of the underlying texture
  122592. * @param scene Define the scene the refraction belongs to
  122593. * @param generateMipMaps Define if we need to generate mips level for the refraction
  122594. */
  122595. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  122596. /**
  122597. * Clone the refraction texture.
  122598. * @returns the cloned texture
  122599. */
  122600. clone(): RefractionTexture;
  122601. /**
  122602. * Serialize the texture to a JSON representation you could use in Parse later on
  122603. * @returns the serialized JSON representation
  122604. */
  122605. serialize(): any;
  122606. }
  122607. }
  122608. declare module BABYLON {
  122609. /**
  122610. * Defines the options related to the creation of an HtmlElementTexture
  122611. */
  122612. export interface IHtmlElementTextureOptions {
  122613. /**
  122614. * Defines wether mip maps should be created or not.
  122615. */
  122616. generateMipMaps?: boolean;
  122617. /**
  122618. * Defines the sampling mode of the texture.
  122619. */
  122620. samplingMode?: number;
  122621. /**
  122622. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  122623. */
  122624. engine: Nullable<ThinEngine>;
  122625. /**
  122626. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  122627. */
  122628. scene: Nullable<Scene>;
  122629. }
  122630. /**
  122631. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  122632. * To be as efficient as possible depending on your constraints nothing aside the first upload
  122633. * is automatically managed.
  122634. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  122635. * in your application.
  122636. *
  122637. * As the update is not automatic, you need to call them manually.
  122638. */
  122639. export class HtmlElementTexture extends BaseTexture {
  122640. /**
  122641. * The texture URL.
  122642. */
  122643. element: HTMLVideoElement | HTMLCanvasElement;
  122644. private static readonly DefaultOptions;
  122645. private _textureMatrix;
  122646. private _engine;
  122647. private _isVideo;
  122648. private _generateMipMaps;
  122649. private _samplingMode;
  122650. /**
  122651. * Instantiates a HtmlElementTexture from the following parameters.
  122652. *
  122653. * @param name Defines the name of the texture
  122654. * @param element Defines the video or canvas the texture is filled with
  122655. * @param options Defines the other none mandatory texture creation options
  122656. */
  122657. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  122658. private _createInternalTexture;
  122659. /**
  122660. * Returns the texture matrix used in most of the material.
  122661. */
  122662. getTextureMatrix(): Matrix;
  122663. /**
  122664. * Updates the content of the texture.
  122665. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  122666. */
  122667. update(invertY?: Nullable<boolean>): void;
  122668. }
  122669. }
  122670. declare module BABYLON {
  122671. /**
  122672. * Enum used to define the target of a block
  122673. */
  122674. export enum NodeMaterialBlockTargets {
  122675. /** Vertex shader */
  122676. Vertex = 1,
  122677. /** Fragment shader */
  122678. Fragment = 2,
  122679. /** Neutral */
  122680. Neutral = 4,
  122681. /** Vertex and Fragment */
  122682. VertexAndFragment = 3
  122683. }
  122684. }
  122685. declare module BABYLON {
  122686. /**
  122687. * Defines the kind of connection point for node based material
  122688. */
  122689. export enum NodeMaterialBlockConnectionPointTypes {
  122690. /** Float */
  122691. Float = 1,
  122692. /** Int */
  122693. Int = 2,
  122694. /** Vector2 */
  122695. Vector2 = 4,
  122696. /** Vector3 */
  122697. Vector3 = 8,
  122698. /** Vector4 */
  122699. Vector4 = 16,
  122700. /** Color3 */
  122701. Color3 = 32,
  122702. /** Color4 */
  122703. Color4 = 64,
  122704. /** Matrix */
  122705. Matrix = 128,
  122706. /** Detect type based on connection */
  122707. AutoDetect = 1024,
  122708. /** Output type that will be defined by input type */
  122709. BasedOnInput = 2048
  122710. }
  122711. }
  122712. declare module BABYLON {
  122713. /**
  122714. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  122715. */
  122716. export enum NodeMaterialBlockConnectionPointMode {
  122717. /** Value is an uniform */
  122718. Uniform = 0,
  122719. /** Value is a mesh attribute */
  122720. Attribute = 1,
  122721. /** Value is a varying between vertex and fragment shaders */
  122722. Varying = 2,
  122723. /** Mode is undefined */
  122724. Undefined = 3
  122725. }
  122726. }
  122727. declare module BABYLON {
  122728. /**
  122729. * Enum used to define system values e.g. values automatically provided by the system
  122730. */
  122731. export enum NodeMaterialSystemValues {
  122732. /** World */
  122733. World = 1,
  122734. /** View */
  122735. View = 2,
  122736. /** Projection */
  122737. Projection = 3,
  122738. /** ViewProjection */
  122739. ViewProjection = 4,
  122740. /** WorldView */
  122741. WorldView = 5,
  122742. /** WorldViewProjection */
  122743. WorldViewProjection = 6,
  122744. /** CameraPosition */
  122745. CameraPosition = 7,
  122746. /** Fog Color */
  122747. FogColor = 8,
  122748. /** Delta time */
  122749. DeltaTime = 9
  122750. }
  122751. }
  122752. declare module BABYLON {
  122753. /**
  122754. * Root class for all node material optimizers
  122755. */
  122756. export class NodeMaterialOptimizer {
  122757. /**
  122758. * Function used to optimize a NodeMaterial graph
  122759. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  122760. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  122761. */
  122762. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  122763. }
  122764. }
  122765. declare module BABYLON {
  122766. /**
  122767. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  122768. */
  122769. export class TransformBlock extends NodeMaterialBlock {
  122770. /**
  122771. * Defines the value to use to complement W value to transform it to a Vector4
  122772. */
  122773. complementW: number;
  122774. /**
  122775. * Defines the value to use to complement z value to transform it to a Vector4
  122776. */
  122777. complementZ: number;
  122778. /**
  122779. * Creates a new TransformBlock
  122780. * @param name defines the block name
  122781. */
  122782. constructor(name: string);
  122783. /**
  122784. * Gets the current class name
  122785. * @returns the class name
  122786. */
  122787. getClassName(): string;
  122788. /**
  122789. * Gets the vector input
  122790. */
  122791. readonly vector: NodeMaterialConnectionPoint;
  122792. /**
  122793. * Gets the output component
  122794. */
  122795. readonly output: NodeMaterialConnectionPoint;
  122796. /**
  122797. * Gets the matrix transform input
  122798. */
  122799. readonly transform: NodeMaterialConnectionPoint;
  122800. protected _buildBlock(state: NodeMaterialBuildState): this;
  122801. serialize(): any;
  122802. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122803. protected _dumpPropertiesCode(): string;
  122804. }
  122805. }
  122806. declare module BABYLON {
  122807. /**
  122808. * Block used to output the vertex position
  122809. */
  122810. export class VertexOutputBlock extends NodeMaterialBlock {
  122811. /**
  122812. * Creates a new VertexOutputBlock
  122813. * @param name defines the block name
  122814. */
  122815. constructor(name: string);
  122816. /**
  122817. * Gets the current class name
  122818. * @returns the class name
  122819. */
  122820. getClassName(): string;
  122821. /**
  122822. * Gets the vector input component
  122823. */
  122824. readonly vector: NodeMaterialConnectionPoint;
  122825. protected _buildBlock(state: NodeMaterialBuildState): this;
  122826. }
  122827. }
  122828. declare module BABYLON {
  122829. /**
  122830. * Block used to output the final color
  122831. */
  122832. export class FragmentOutputBlock extends NodeMaterialBlock {
  122833. /**
  122834. * Create a new FragmentOutputBlock
  122835. * @param name defines the block name
  122836. */
  122837. constructor(name: string);
  122838. /**
  122839. * Gets the current class name
  122840. * @returns the class name
  122841. */
  122842. getClassName(): string;
  122843. /**
  122844. * Gets the rgba input component
  122845. */
  122846. readonly rgba: NodeMaterialConnectionPoint;
  122847. /**
  122848. * Gets the rgb input component
  122849. */
  122850. readonly rgb: NodeMaterialConnectionPoint;
  122851. /**
  122852. * Gets the a input component
  122853. */
  122854. readonly a: NodeMaterialConnectionPoint;
  122855. protected _buildBlock(state: NodeMaterialBuildState): this;
  122856. }
  122857. }
  122858. declare module BABYLON {
  122859. /**
  122860. * Block used to read a reflection texture from a sampler
  122861. */
  122862. export class ReflectionTextureBlock extends NodeMaterialBlock {
  122863. private _define3DName;
  122864. private _defineCubicName;
  122865. private _defineExplicitName;
  122866. private _defineProjectionName;
  122867. private _defineLocalCubicName;
  122868. private _defineSphericalName;
  122869. private _definePlanarName;
  122870. private _defineEquirectangularName;
  122871. private _defineMirroredEquirectangularFixedName;
  122872. private _defineEquirectangularFixedName;
  122873. private _defineSkyboxName;
  122874. private _cubeSamplerName;
  122875. private _2DSamplerName;
  122876. private _positionUVWName;
  122877. private _directionWName;
  122878. private _reflectionCoordsName;
  122879. private _reflection2DCoordsName;
  122880. private _reflectionColorName;
  122881. private _reflectionMatrixName;
  122882. /**
  122883. * Gets or sets the texture associated with the node
  122884. */
  122885. texture: Nullable<BaseTexture>;
  122886. /**
  122887. * Create a new TextureBlock
  122888. * @param name defines the block name
  122889. */
  122890. constructor(name: string);
  122891. /**
  122892. * Gets the current class name
  122893. * @returns the class name
  122894. */
  122895. getClassName(): string;
  122896. /**
  122897. * Gets the world position input component
  122898. */
  122899. readonly position: NodeMaterialConnectionPoint;
  122900. /**
  122901. * Gets the world position input component
  122902. */
  122903. readonly worldPosition: NodeMaterialConnectionPoint;
  122904. /**
  122905. * Gets the world normal input component
  122906. */
  122907. readonly worldNormal: NodeMaterialConnectionPoint;
  122908. /**
  122909. * Gets the world input component
  122910. */
  122911. readonly world: NodeMaterialConnectionPoint;
  122912. /**
  122913. * Gets the camera (or eye) position component
  122914. */
  122915. readonly cameraPosition: NodeMaterialConnectionPoint;
  122916. /**
  122917. * Gets the view input component
  122918. */
  122919. readonly view: NodeMaterialConnectionPoint;
  122920. /**
  122921. * Gets the rgb output component
  122922. */
  122923. readonly rgb: NodeMaterialConnectionPoint;
  122924. /**
  122925. * Gets the r output component
  122926. */
  122927. readonly r: NodeMaterialConnectionPoint;
  122928. /**
  122929. * Gets the g output component
  122930. */
  122931. readonly g: NodeMaterialConnectionPoint;
  122932. /**
  122933. * Gets the b output component
  122934. */
  122935. readonly b: NodeMaterialConnectionPoint;
  122936. autoConfigure(material: NodeMaterial): void;
  122937. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122938. isReady(): boolean;
  122939. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122940. private _injectVertexCode;
  122941. private _writeOutput;
  122942. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122943. protected _dumpPropertiesCode(): string;
  122944. serialize(): any;
  122945. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122946. }
  122947. }
  122948. declare module BABYLON {
  122949. /**
  122950. * Interface used to configure the node material editor
  122951. */
  122952. export interface INodeMaterialEditorOptions {
  122953. /** Define the URl to load node editor script */
  122954. editorURL?: string;
  122955. }
  122956. /** @hidden */
  122957. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  122958. /** BONES */
  122959. NUM_BONE_INFLUENCERS: number;
  122960. BonesPerMesh: number;
  122961. BONETEXTURE: boolean;
  122962. /** MORPH TARGETS */
  122963. MORPHTARGETS: boolean;
  122964. MORPHTARGETS_NORMAL: boolean;
  122965. MORPHTARGETS_TANGENT: boolean;
  122966. MORPHTARGETS_UV: boolean;
  122967. NUM_MORPH_INFLUENCERS: number;
  122968. /** IMAGE PROCESSING */
  122969. IMAGEPROCESSING: boolean;
  122970. VIGNETTE: boolean;
  122971. VIGNETTEBLENDMODEMULTIPLY: boolean;
  122972. VIGNETTEBLENDMODEOPAQUE: boolean;
  122973. TONEMAPPING: boolean;
  122974. TONEMAPPING_ACES: boolean;
  122975. CONTRAST: boolean;
  122976. EXPOSURE: boolean;
  122977. COLORCURVES: boolean;
  122978. COLORGRADING: boolean;
  122979. COLORGRADING3D: boolean;
  122980. SAMPLER3DGREENDEPTH: boolean;
  122981. SAMPLER3DBGRMAP: boolean;
  122982. IMAGEPROCESSINGPOSTPROCESS: boolean;
  122983. /** MISC. */
  122984. BUMPDIRECTUV: number;
  122985. constructor();
  122986. setValue(name: string, value: boolean): void;
  122987. }
  122988. /**
  122989. * Class used to configure NodeMaterial
  122990. */
  122991. export interface INodeMaterialOptions {
  122992. /**
  122993. * Defines if blocks should emit comments
  122994. */
  122995. emitComments: boolean;
  122996. }
  122997. /**
  122998. * Class used to create a node based material built by assembling shader blocks
  122999. */
  123000. export class NodeMaterial extends PushMaterial {
  123001. private static _BuildIdGenerator;
  123002. private _options;
  123003. private _vertexCompilationState;
  123004. private _fragmentCompilationState;
  123005. private _sharedData;
  123006. private _buildId;
  123007. private _buildWasSuccessful;
  123008. private _cachedWorldViewMatrix;
  123009. private _cachedWorldViewProjectionMatrix;
  123010. private _optimizers;
  123011. private _animationFrame;
  123012. /** Define the URl to load node editor script */
  123013. static EditorURL: string;
  123014. private BJSNODEMATERIALEDITOR;
  123015. /** Get the inspector from bundle or global */
  123016. private _getGlobalNodeMaterialEditor;
  123017. /**
  123018. * Gets or sets data used by visual editor
  123019. * @see https://nme.babylonjs.com
  123020. */
  123021. editorData: any;
  123022. /**
  123023. * 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)
  123024. */
  123025. ignoreAlpha: boolean;
  123026. /**
  123027. * Defines the maximum number of lights that can be used in the material
  123028. */
  123029. maxSimultaneousLights: number;
  123030. /**
  123031. * Observable raised when the material is built
  123032. */
  123033. onBuildObservable: Observable<NodeMaterial>;
  123034. /**
  123035. * Gets or sets the root nodes of the material vertex shader
  123036. */
  123037. _vertexOutputNodes: NodeMaterialBlock[];
  123038. /**
  123039. * Gets or sets the root nodes of the material fragment (pixel) shader
  123040. */
  123041. _fragmentOutputNodes: NodeMaterialBlock[];
  123042. /** Gets or sets options to control the node material overall behavior */
  123043. options: INodeMaterialOptions;
  123044. /**
  123045. * Default configuration related to image processing available in the standard Material.
  123046. */
  123047. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123048. /**
  123049. * Gets the image processing configuration used either in this material.
  123050. */
  123051. /**
  123052. * Sets the Default image processing configuration used either in the this material.
  123053. *
  123054. * If sets to null, the scene one is in use.
  123055. */
  123056. imageProcessingConfiguration: ImageProcessingConfiguration;
  123057. /**
  123058. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  123059. */
  123060. attachedBlocks: NodeMaterialBlock[];
  123061. /**
  123062. * Create a new node based material
  123063. * @param name defines the material name
  123064. * @param scene defines the hosting scene
  123065. * @param options defines creation option
  123066. */
  123067. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  123068. /**
  123069. * Gets the current class name of the material e.g. "NodeMaterial"
  123070. * @returns the class name
  123071. */
  123072. getClassName(): string;
  123073. /**
  123074. * Keep track of the image processing observer to allow dispose and replace.
  123075. */
  123076. private _imageProcessingObserver;
  123077. /**
  123078. * Attaches a new image processing configuration to the Standard Material.
  123079. * @param configuration
  123080. */
  123081. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123082. /**
  123083. * Get a block by its name
  123084. * @param name defines the name of the block to retrieve
  123085. * @returns the required block or null if not found
  123086. */
  123087. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  123088. /**
  123089. * Get a block by its name
  123090. * @param predicate defines the predicate used to find the good candidate
  123091. * @returns the required block or null if not found
  123092. */
  123093. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  123094. /**
  123095. * Get an input block by its name
  123096. * @param predicate defines the predicate used to find the good candidate
  123097. * @returns the required input block or null if not found
  123098. */
  123099. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  123100. /**
  123101. * Gets the list of input blocks attached to this material
  123102. * @returns an array of InputBlocks
  123103. */
  123104. getInputBlocks(): InputBlock[];
  123105. /**
  123106. * Adds a new optimizer to the list of optimizers
  123107. * @param optimizer defines the optimizers to add
  123108. * @returns the current material
  123109. */
  123110. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123111. /**
  123112. * Remove an optimizer from the list of optimizers
  123113. * @param optimizer defines the optimizers to remove
  123114. * @returns the current material
  123115. */
  123116. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123117. /**
  123118. * Add a new block to the list of output nodes
  123119. * @param node defines the node to add
  123120. * @returns the current material
  123121. */
  123122. addOutputNode(node: NodeMaterialBlock): this;
  123123. /**
  123124. * Remove a block from the list of root nodes
  123125. * @param node defines the node to remove
  123126. * @returns the current material
  123127. */
  123128. removeOutputNode(node: NodeMaterialBlock): this;
  123129. private _addVertexOutputNode;
  123130. private _removeVertexOutputNode;
  123131. private _addFragmentOutputNode;
  123132. private _removeFragmentOutputNode;
  123133. /**
  123134. * Specifies if the material will require alpha blending
  123135. * @returns a boolean specifying if alpha blending is needed
  123136. */
  123137. needAlphaBlending(): boolean;
  123138. /**
  123139. * Specifies if this material should be rendered in alpha test mode
  123140. * @returns a boolean specifying if an alpha test is needed.
  123141. */
  123142. needAlphaTesting(): boolean;
  123143. private _initializeBlock;
  123144. private _resetDualBlocks;
  123145. /**
  123146. * Remove a block from the current node material
  123147. * @param block defines the block to remove
  123148. */
  123149. removeBlock(block: NodeMaterialBlock): void;
  123150. /**
  123151. * Build the material and generates the inner effect
  123152. * @param verbose defines if the build should log activity
  123153. */
  123154. build(verbose?: boolean): void;
  123155. /**
  123156. * Runs an otpimization phase to try to improve the shader code
  123157. */
  123158. optimize(): void;
  123159. private _prepareDefinesForAttributes;
  123160. /**
  123161. * Get if the submesh is ready to be used and all its information available.
  123162. * Child classes can use it to update shaders
  123163. * @param mesh defines the mesh to check
  123164. * @param subMesh defines which submesh to check
  123165. * @param useInstances specifies that instances should be used
  123166. * @returns a boolean indicating that the submesh is ready or not
  123167. */
  123168. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123169. /**
  123170. * Get a string representing the shaders built by the current node graph
  123171. */
  123172. readonly compiledShaders: string;
  123173. /**
  123174. * Binds the world matrix to the material
  123175. * @param world defines the world transformation matrix
  123176. */
  123177. bindOnlyWorldMatrix(world: Matrix): void;
  123178. /**
  123179. * Binds the submesh to this material by preparing the effect and shader to draw
  123180. * @param world defines the world transformation matrix
  123181. * @param mesh defines the mesh containing the submesh
  123182. * @param subMesh defines the submesh to bind the material to
  123183. */
  123184. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123185. /**
  123186. * Gets the active textures from the material
  123187. * @returns an array of textures
  123188. */
  123189. getActiveTextures(): BaseTexture[];
  123190. /**
  123191. * Gets the list of texture blocks
  123192. * @returns an array of texture blocks
  123193. */
  123194. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  123195. /**
  123196. * Specifies if the material uses a texture
  123197. * @param texture defines the texture to check against the material
  123198. * @returns a boolean specifying if the material uses the texture
  123199. */
  123200. hasTexture(texture: BaseTexture): boolean;
  123201. /**
  123202. * Disposes the material
  123203. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  123204. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  123205. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  123206. */
  123207. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  123208. /** Creates the node editor window. */
  123209. private _createNodeEditor;
  123210. /**
  123211. * Launch the node material editor
  123212. * @param config Define the configuration of the editor
  123213. * @return a promise fulfilled when the node editor is visible
  123214. */
  123215. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  123216. /**
  123217. * Clear the current material
  123218. */
  123219. clear(): void;
  123220. /**
  123221. * Clear the current material and set it to a default state
  123222. */
  123223. setToDefault(): void;
  123224. /**
  123225. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  123226. * @param url defines the url to load from
  123227. * @returns a promise that will fullfil when the material is fully loaded
  123228. */
  123229. loadAsync(url: string): Promise<void>;
  123230. private _gatherBlocks;
  123231. /**
  123232. * Generate a string containing the code declaration required to create an equivalent of this material
  123233. * @returns a string
  123234. */
  123235. generateCode(): string;
  123236. /**
  123237. * Serializes this material in a JSON representation
  123238. * @returns the serialized material object
  123239. */
  123240. serialize(): any;
  123241. private _restoreConnections;
  123242. /**
  123243. * Clear the current graph and load a new one from a serialization object
  123244. * @param source defines the JSON representation of the material
  123245. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123246. */
  123247. loadFromSerialization(source: any, rootUrl?: string): void;
  123248. /**
  123249. * Creates a node material from parsed material data
  123250. * @param source defines the JSON representation of the material
  123251. * @param scene defines the hosting scene
  123252. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123253. * @returns a new node material
  123254. */
  123255. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  123256. /**
  123257. * Creates a new node material set to default basic configuration
  123258. * @param name defines the name of the material
  123259. * @param scene defines the hosting scene
  123260. * @returns a new NodeMaterial
  123261. */
  123262. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  123263. }
  123264. }
  123265. declare module BABYLON {
  123266. /**
  123267. * Block used to read a texture from a sampler
  123268. */
  123269. export class TextureBlock extends NodeMaterialBlock {
  123270. private _defineName;
  123271. private _linearDefineName;
  123272. private _tempTextureRead;
  123273. private _samplerName;
  123274. private _transformedUVName;
  123275. private _textureTransformName;
  123276. private _textureInfoName;
  123277. private _mainUVName;
  123278. private _mainUVDefineName;
  123279. /**
  123280. * Gets or sets the texture associated with the node
  123281. */
  123282. texture: Nullable<Texture>;
  123283. /**
  123284. * Create a new TextureBlock
  123285. * @param name defines the block name
  123286. */
  123287. constructor(name: string);
  123288. /**
  123289. * Gets the current class name
  123290. * @returns the class name
  123291. */
  123292. getClassName(): string;
  123293. /**
  123294. * Gets the uv input component
  123295. */
  123296. readonly uv: NodeMaterialConnectionPoint;
  123297. /**
  123298. * Gets the rgba output component
  123299. */
  123300. readonly rgba: NodeMaterialConnectionPoint;
  123301. /**
  123302. * Gets the rgb output component
  123303. */
  123304. readonly rgb: NodeMaterialConnectionPoint;
  123305. /**
  123306. * Gets the r output component
  123307. */
  123308. readonly r: NodeMaterialConnectionPoint;
  123309. /**
  123310. * Gets the g output component
  123311. */
  123312. readonly g: NodeMaterialConnectionPoint;
  123313. /**
  123314. * Gets the b output component
  123315. */
  123316. readonly b: NodeMaterialConnectionPoint;
  123317. /**
  123318. * Gets the a output component
  123319. */
  123320. readonly a: NodeMaterialConnectionPoint;
  123321. readonly target: NodeMaterialBlockTargets;
  123322. autoConfigure(material: NodeMaterial): void;
  123323. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123324. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123325. private _getTextureBase;
  123326. isReady(): boolean;
  123327. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123328. private readonly _isMixed;
  123329. private _injectVertexCode;
  123330. private _writeTextureRead;
  123331. private _writeOutput;
  123332. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123333. protected _dumpPropertiesCode(): string;
  123334. serialize(): any;
  123335. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123336. }
  123337. }
  123338. declare module BABYLON {
  123339. /**
  123340. * Class used to store shared data between 2 NodeMaterialBuildState
  123341. */
  123342. export class NodeMaterialBuildStateSharedData {
  123343. /**
  123344. * Gets the list of emitted varyings
  123345. */
  123346. temps: string[];
  123347. /**
  123348. * Gets the list of emitted varyings
  123349. */
  123350. varyings: string[];
  123351. /**
  123352. * Gets the varying declaration string
  123353. */
  123354. varyingDeclaration: string;
  123355. /**
  123356. * Input blocks
  123357. */
  123358. inputBlocks: InputBlock[];
  123359. /**
  123360. * Input blocks
  123361. */
  123362. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  123363. /**
  123364. * Bindable blocks (Blocks that need to set data to the effect)
  123365. */
  123366. bindableBlocks: NodeMaterialBlock[];
  123367. /**
  123368. * List of blocks that can provide a compilation fallback
  123369. */
  123370. blocksWithFallbacks: NodeMaterialBlock[];
  123371. /**
  123372. * List of blocks that can provide a define update
  123373. */
  123374. blocksWithDefines: NodeMaterialBlock[];
  123375. /**
  123376. * List of blocks that can provide a repeatable content
  123377. */
  123378. repeatableContentBlocks: NodeMaterialBlock[];
  123379. /**
  123380. * List of blocks that can provide a dynamic list of uniforms
  123381. */
  123382. dynamicUniformBlocks: NodeMaterialBlock[];
  123383. /**
  123384. * List of blocks that can block the isReady function for the material
  123385. */
  123386. blockingBlocks: NodeMaterialBlock[];
  123387. /**
  123388. * Gets the list of animated inputs
  123389. */
  123390. animatedInputs: InputBlock[];
  123391. /**
  123392. * Build Id used to avoid multiple recompilations
  123393. */
  123394. buildId: number;
  123395. /** List of emitted variables */
  123396. variableNames: {
  123397. [key: string]: number;
  123398. };
  123399. /** List of emitted defines */
  123400. defineNames: {
  123401. [key: string]: number;
  123402. };
  123403. /** Should emit comments? */
  123404. emitComments: boolean;
  123405. /** Emit build activity */
  123406. verbose: boolean;
  123407. /** Gets or sets the hosting scene */
  123408. scene: Scene;
  123409. /**
  123410. * Gets the compilation hints emitted at compilation time
  123411. */
  123412. hints: {
  123413. needWorldViewMatrix: boolean;
  123414. needWorldViewProjectionMatrix: boolean;
  123415. needAlphaBlending: boolean;
  123416. needAlphaTesting: boolean;
  123417. };
  123418. /**
  123419. * List of compilation checks
  123420. */
  123421. checks: {
  123422. emitVertex: boolean;
  123423. emitFragment: boolean;
  123424. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  123425. };
  123426. /** Creates a new shared data */
  123427. constructor();
  123428. /**
  123429. * Emits console errors and exceptions if there is a failing check
  123430. */
  123431. emitErrors(): void;
  123432. }
  123433. }
  123434. declare module BABYLON {
  123435. /**
  123436. * Class used to store node based material build state
  123437. */
  123438. export class NodeMaterialBuildState {
  123439. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  123440. supportUniformBuffers: boolean;
  123441. /**
  123442. * Gets the list of emitted attributes
  123443. */
  123444. attributes: string[];
  123445. /**
  123446. * Gets the list of emitted uniforms
  123447. */
  123448. uniforms: string[];
  123449. /**
  123450. * Gets the list of emitted constants
  123451. */
  123452. constants: string[];
  123453. /**
  123454. * Gets the list of emitted samplers
  123455. */
  123456. samplers: string[];
  123457. /**
  123458. * Gets the list of emitted functions
  123459. */
  123460. functions: {
  123461. [key: string]: string;
  123462. };
  123463. /**
  123464. * Gets the list of emitted extensions
  123465. */
  123466. extensions: {
  123467. [key: string]: string;
  123468. };
  123469. /**
  123470. * Gets the target of the compilation state
  123471. */
  123472. target: NodeMaterialBlockTargets;
  123473. /**
  123474. * Gets the list of emitted counters
  123475. */
  123476. counters: {
  123477. [key: string]: number;
  123478. };
  123479. /**
  123480. * Shared data between multiple NodeMaterialBuildState instances
  123481. */
  123482. sharedData: NodeMaterialBuildStateSharedData;
  123483. /** @hidden */
  123484. _vertexState: NodeMaterialBuildState;
  123485. /** @hidden */
  123486. _attributeDeclaration: string;
  123487. /** @hidden */
  123488. _uniformDeclaration: string;
  123489. /** @hidden */
  123490. _constantDeclaration: string;
  123491. /** @hidden */
  123492. _samplerDeclaration: string;
  123493. /** @hidden */
  123494. _varyingTransfer: string;
  123495. private _repeatableContentAnchorIndex;
  123496. /** @hidden */
  123497. _builtCompilationString: string;
  123498. /**
  123499. * Gets the emitted compilation strings
  123500. */
  123501. compilationString: string;
  123502. /**
  123503. * Finalize the compilation strings
  123504. * @param state defines the current compilation state
  123505. */
  123506. finalize(state: NodeMaterialBuildState): void;
  123507. /** @hidden */
  123508. readonly _repeatableContentAnchor: string;
  123509. /** @hidden */
  123510. _getFreeVariableName(prefix: string): string;
  123511. /** @hidden */
  123512. _getFreeDefineName(prefix: string): string;
  123513. /** @hidden */
  123514. _excludeVariableName(name: string): void;
  123515. /** @hidden */
  123516. _emit2DSampler(name: string): void;
  123517. /** @hidden */
  123518. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  123519. /** @hidden */
  123520. _emitExtension(name: string, extension: string): void;
  123521. /** @hidden */
  123522. _emitFunction(name: string, code: string, comments: string): void;
  123523. /** @hidden */
  123524. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  123525. replaceStrings?: {
  123526. search: RegExp;
  123527. replace: string;
  123528. }[];
  123529. repeatKey?: string;
  123530. }): string;
  123531. /** @hidden */
  123532. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  123533. repeatKey?: string;
  123534. removeAttributes?: boolean;
  123535. removeUniforms?: boolean;
  123536. removeVaryings?: boolean;
  123537. removeIfDef?: boolean;
  123538. replaceStrings?: {
  123539. search: RegExp;
  123540. replace: string;
  123541. }[];
  123542. }, storeKey?: string): void;
  123543. /** @hidden */
  123544. _registerTempVariable(name: string): boolean;
  123545. /** @hidden */
  123546. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  123547. /** @hidden */
  123548. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  123549. /** @hidden */
  123550. _emitFloat(value: number): string;
  123551. }
  123552. }
  123553. declare module BABYLON {
  123554. /**
  123555. * Defines a block that can be used inside a node based material
  123556. */
  123557. export class NodeMaterialBlock {
  123558. private _buildId;
  123559. private _buildTarget;
  123560. private _target;
  123561. private _isFinalMerger;
  123562. private _isInput;
  123563. protected _isUnique: boolean;
  123564. /** @hidden */
  123565. _codeVariableName: string;
  123566. /** @hidden */
  123567. _inputs: NodeMaterialConnectionPoint[];
  123568. /** @hidden */
  123569. _outputs: NodeMaterialConnectionPoint[];
  123570. /** @hidden */
  123571. _preparationId: number;
  123572. /**
  123573. * Gets or sets the name of the block
  123574. */
  123575. name: string;
  123576. /**
  123577. * Gets or sets the unique id of the node
  123578. */
  123579. uniqueId: number;
  123580. /**
  123581. * Gets or sets the comments associated with this block
  123582. */
  123583. comments: string;
  123584. /**
  123585. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  123586. */
  123587. readonly isUnique: boolean;
  123588. /**
  123589. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  123590. */
  123591. readonly isFinalMerger: boolean;
  123592. /**
  123593. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  123594. */
  123595. readonly isInput: boolean;
  123596. /**
  123597. * Gets or sets the build Id
  123598. */
  123599. buildId: number;
  123600. /**
  123601. * Gets or sets the target of the block
  123602. */
  123603. target: NodeMaterialBlockTargets;
  123604. /**
  123605. * Gets the list of input points
  123606. */
  123607. readonly inputs: NodeMaterialConnectionPoint[];
  123608. /** Gets the list of output points */
  123609. readonly outputs: NodeMaterialConnectionPoint[];
  123610. /**
  123611. * Find an input by its name
  123612. * @param name defines the name of the input to look for
  123613. * @returns the input or null if not found
  123614. */
  123615. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123616. /**
  123617. * Find an output by its name
  123618. * @param name defines the name of the outputto look for
  123619. * @returns the output or null if not found
  123620. */
  123621. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123622. /**
  123623. * Creates a new NodeMaterialBlock
  123624. * @param name defines the block name
  123625. * @param target defines the target of that block (Vertex by default)
  123626. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  123627. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  123628. */
  123629. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  123630. /**
  123631. * Initialize the block and prepare the context for build
  123632. * @param state defines the state that will be used for the build
  123633. */
  123634. initialize(state: NodeMaterialBuildState): void;
  123635. /**
  123636. * Bind data to effect. Will only be called for blocks with isBindable === true
  123637. * @param effect defines the effect to bind data to
  123638. * @param nodeMaterial defines the hosting NodeMaterial
  123639. * @param mesh defines the mesh that will be rendered
  123640. */
  123641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123642. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  123643. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  123644. protected _writeFloat(value: number): string;
  123645. /**
  123646. * Gets the current class name e.g. "NodeMaterialBlock"
  123647. * @returns the class name
  123648. */
  123649. getClassName(): string;
  123650. /**
  123651. * Register a new input. Must be called inside a block constructor
  123652. * @param name defines the connection point name
  123653. * @param type defines the connection point type
  123654. * @param isOptional defines a boolean indicating that this input can be omitted
  123655. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123656. * @returns the current block
  123657. */
  123658. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  123659. /**
  123660. * Register a new output. Must be called inside a block constructor
  123661. * @param name defines the connection point name
  123662. * @param type defines the connection point type
  123663. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123664. * @returns the current block
  123665. */
  123666. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  123667. /**
  123668. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  123669. * @param forOutput defines an optional connection point to check compatibility with
  123670. * @returns the first available input or null
  123671. */
  123672. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  123673. /**
  123674. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  123675. * @param forBlock defines an optional block to check compatibility with
  123676. * @returns the first available input or null
  123677. */
  123678. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  123679. /**
  123680. * Gets the sibling of the given output
  123681. * @param current defines the current output
  123682. * @returns the next output in the list or null
  123683. */
  123684. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  123685. /**
  123686. * Connect current block with another block
  123687. * @param other defines the block to connect with
  123688. * @param options define the various options to help pick the right connections
  123689. * @returns the current block
  123690. */
  123691. connectTo(other: NodeMaterialBlock, options?: {
  123692. input?: string;
  123693. output?: string;
  123694. outputSwizzle?: string;
  123695. }): this | undefined;
  123696. protected _buildBlock(state: NodeMaterialBuildState): void;
  123697. /**
  123698. * Add uniforms, samplers and uniform buffers at compilation time
  123699. * @param state defines the state to update
  123700. * @param nodeMaterial defines the node material requesting the update
  123701. * @param defines defines the material defines to update
  123702. * @param uniformBuffers defines the list of uniform buffer names
  123703. */
  123704. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123705. /**
  123706. * Add potential fallbacks if shader compilation fails
  123707. * @param mesh defines the mesh to be rendered
  123708. * @param fallbacks defines the current prioritized list of fallbacks
  123709. */
  123710. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  123711. /**
  123712. * Initialize defines for shader compilation
  123713. * @param mesh defines the mesh to be rendered
  123714. * @param nodeMaterial defines the node material requesting the update
  123715. * @param defines defines the material defines to update
  123716. * @param useInstances specifies that instances should be used
  123717. */
  123718. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123719. /**
  123720. * Update defines for shader compilation
  123721. * @param mesh defines the mesh to be rendered
  123722. * @param nodeMaterial defines the node material requesting the update
  123723. * @param defines defines the material defines to update
  123724. * @param useInstances specifies that instances should be used
  123725. */
  123726. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123727. /**
  123728. * Lets the block try to connect some inputs automatically
  123729. * @param material defines the hosting NodeMaterial
  123730. */
  123731. autoConfigure(material: NodeMaterial): void;
  123732. /**
  123733. * Function called when a block is declared as repeatable content generator
  123734. * @param vertexShaderState defines the current compilation state for the vertex shader
  123735. * @param fragmentShaderState defines the current compilation state for the fragment shader
  123736. * @param mesh defines the mesh to be rendered
  123737. * @param defines defines the material defines to update
  123738. */
  123739. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  123740. /**
  123741. * Checks if the block is ready
  123742. * @param mesh defines the mesh to be rendered
  123743. * @param nodeMaterial defines the node material requesting the update
  123744. * @param defines defines the material defines to update
  123745. * @param useInstances specifies that instances should be used
  123746. * @returns true if the block is ready
  123747. */
  123748. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  123749. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  123750. private _processBuild;
  123751. /**
  123752. * Compile the current node and generate the shader code
  123753. * @param state defines the current compilation state (uniforms, samplers, current string)
  123754. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  123755. * @returns true if already built
  123756. */
  123757. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  123758. protected _inputRename(name: string): string;
  123759. protected _outputRename(name: string): string;
  123760. protected _dumpPropertiesCode(): string;
  123761. /** @hidden */
  123762. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  123763. /** @hidden */
  123764. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  123765. /**
  123766. * Clone the current block to a new identical block
  123767. * @param scene defines the hosting scene
  123768. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123769. * @returns a copy of the current block
  123770. */
  123771. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  123772. /**
  123773. * Serializes this block in a JSON representation
  123774. * @returns the serialized block object
  123775. */
  123776. serialize(): any;
  123777. /** @hidden */
  123778. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123779. /**
  123780. * Release resources
  123781. */
  123782. dispose(): void;
  123783. }
  123784. }
  123785. declare module BABYLON {
  123786. /**
  123787. * Enum defining the type of animations supported by InputBlock
  123788. */
  123789. export enum AnimatedInputBlockTypes {
  123790. /** No animation */
  123791. None = 0,
  123792. /** Time based animation. Will only work for floats */
  123793. Time = 1
  123794. }
  123795. }
  123796. declare module BABYLON {
  123797. /**
  123798. * Block used to expose an input value
  123799. */
  123800. export class InputBlock extends NodeMaterialBlock {
  123801. private _mode;
  123802. private _associatedVariableName;
  123803. private _storedValue;
  123804. private _valueCallback;
  123805. private _type;
  123806. private _animationType;
  123807. /** Gets or set a value used to limit the range of float values */
  123808. min: number;
  123809. /** Gets or set a value used to limit the range of float values */
  123810. max: number;
  123811. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  123812. matrixMode: number;
  123813. /** @hidden */
  123814. _systemValue: Nullable<NodeMaterialSystemValues>;
  123815. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  123816. visibleInInspector: boolean;
  123817. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  123818. isConstant: boolean;
  123819. /**
  123820. * Gets or sets the connection point type (default is float)
  123821. */
  123822. readonly type: NodeMaterialBlockConnectionPointTypes;
  123823. /**
  123824. * Creates a new InputBlock
  123825. * @param name defines the block name
  123826. * @param target defines the target of that block (Vertex by default)
  123827. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  123828. */
  123829. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  123830. /**
  123831. * Gets the output component
  123832. */
  123833. readonly output: NodeMaterialConnectionPoint;
  123834. /**
  123835. * Set the source of this connection point to a vertex attribute
  123836. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  123837. * @returns the current connection point
  123838. */
  123839. setAsAttribute(attributeName?: string): InputBlock;
  123840. /**
  123841. * Set the source of this connection point to a system value
  123842. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  123843. * @returns the current connection point
  123844. */
  123845. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  123846. /**
  123847. * Gets or sets the value of that point.
  123848. * Please note that this value will be ignored if valueCallback is defined
  123849. */
  123850. value: any;
  123851. /**
  123852. * Gets or sets a callback used to get the value of that point.
  123853. * Please note that setting this value will force the connection point to ignore the value property
  123854. */
  123855. valueCallback: () => any;
  123856. /**
  123857. * Gets or sets the associated variable name in the shader
  123858. */
  123859. associatedVariableName: string;
  123860. /** Gets or sets the type of animation applied to the input */
  123861. animationType: AnimatedInputBlockTypes;
  123862. /**
  123863. * Gets a boolean indicating that this connection point not defined yet
  123864. */
  123865. readonly isUndefined: boolean;
  123866. /**
  123867. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  123868. * In this case the connection point name must be the name of the uniform to use.
  123869. * Can only be set on inputs
  123870. */
  123871. isUniform: boolean;
  123872. /**
  123873. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  123874. * In this case the connection point name must be the name of the attribute to use
  123875. * Can only be set on inputs
  123876. */
  123877. isAttribute: boolean;
  123878. /**
  123879. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  123880. * Can only be set on exit points
  123881. */
  123882. isVarying: boolean;
  123883. /**
  123884. * Gets a boolean indicating that the current connection point is a system value
  123885. */
  123886. readonly isSystemValue: boolean;
  123887. /**
  123888. * Gets or sets the current well known value or null if not defined as a system value
  123889. */
  123890. systemValue: Nullable<NodeMaterialSystemValues>;
  123891. /**
  123892. * Gets the current class name
  123893. * @returns the class name
  123894. */
  123895. getClassName(): string;
  123896. /**
  123897. * Animate the input if animationType !== None
  123898. * @param scene defines the rendering scene
  123899. */
  123900. animate(scene: Scene): void;
  123901. private _emitDefine;
  123902. initialize(state: NodeMaterialBuildState): void;
  123903. /**
  123904. * Set the input block to its default value (based on its type)
  123905. */
  123906. setDefaultValue(): void;
  123907. private _emitConstant;
  123908. private _emit;
  123909. /** @hidden */
  123910. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  123911. /** @hidden */
  123912. _transmit(effect: Effect, scene: Scene): void;
  123913. protected _buildBlock(state: NodeMaterialBuildState): void;
  123914. protected _dumpPropertiesCode(): string;
  123915. serialize(): any;
  123916. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123917. }
  123918. }
  123919. declare module BABYLON {
  123920. /**
  123921. * Enum used to define the compatibility state between two connection points
  123922. */
  123923. export enum NodeMaterialConnectionPointCompatibilityStates {
  123924. /** Points are compatibles */
  123925. Compatible = 0,
  123926. /** Points are incompatible because of their types */
  123927. TypeIncompatible = 1,
  123928. /** Points are incompatible because of their targets (vertex vs fragment) */
  123929. TargetIncompatible = 2
  123930. }
  123931. /**
  123932. * Defines the direction of a connection point
  123933. */
  123934. export enum NodeMaterialConnectionPointDirection {
  123935. /** Input */
  123936. Input = 0,
  123937. /** Output */
  123938. Output = 1
  123939. }
  123940. /**
  123941. * Defines a connection point for a block
  123942. */
  123943. export class NodeMaterialConnectionPoint {
  123944. /** @hidden */
  123945. _ownerBlock: NodeMaterialBlock;
  123946. /** @hidden */
  123947. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123948. private _endpoints;
  123949. private _associatedVariableName;
  123950. private _direction;
  123951. /** @hidden */
  123952. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123953. /** @hidden */
  123954. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123955. private _type;
  123956. /** @hidden */
  123957. _enforceAssociatedVariableName: boolean;
  123958. /** Gets the direction of the point */
  123959. readonly direction: NodeMaterialConnectionPointDirection;
  123960. /**
  123961. * Gets or sets the additional types supported by this connection point
  123962. */
  123963. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123964. /**
  123965. * Gets or sets the additional types excluded by this connection point
  123966. */
  123967. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123968. /**
  123969. * Observable triggered when this point is connected
  123970. */
  123971. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  123972. /**
  123973. * Gets or sets the associated variable name in the shader
  123974. */
  123975. associatedVariableName: string;
  123976. /**
  123977. * Gets or sets the connection point type (default is float)
  123978. */
  123979. type: NodeMaterialBlockConnectionPointTypes;
  123980. /**
  123981. * Gets or sets the connection point name
  123982. */
  123983. name: string;
  123984. /**
  123985. * Gets or sets a boolean indicating that this connection point can be omitted
  123986. */
  123987. isOptional: boolean;
  123988. /**
  123989. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  123990. */
  123991. define: string;
  123992. /** @hidden */
  123993. _prioritizeVertex: boolean;
  123994. private _target;
  123995. /** Gets or sets the target of that connection point */
  123996. target: NodeMaterialBlockTargets;
  123997. /**
  123998. * Gets a boolean indicating that the current point is connected
  123999. */
  124000. readonly isConnected: boolean;
  124001. /**
  124002. * Gets a boolean indicating that the current point is connected to an input block
  124003. */
  124004. readonly isConnectedToInputBlock: boolean;
  124005. /**
  124006. * Gets a the connected input block (if any)
  124007. */
  124008. readonly connectInputBlock: Nullable<InputBlock>;
  124009. /** Get the other side of the connection (if any) */
  124010. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  124011. /** Get the block that owns this connection point */
  124012. readonly ownerBlock: NodeMaterialBlock;
  124013. /** Get the block connected on the other side of this connection (if any) */
  124014. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  124015. /** Get the block connected on the endpoints of this connection (if any) */
  124016. readonly connectedBlocks: Array<NodeMaterialBlock>;
  124017. /** Gets the list of connected endpoints */
  124018. readonly endpoints: NodeMaterialConnectionPoint[];
  124019. /** Gets a boolean indicating if that output point is connected to at least one input */
  124020. readonly hasEndpoints: boolean;
  124021. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  124022. readonly isConnectedInVertexShader: boolean;
  124023. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  124024. readonly isConnectedInFragmentShader: boolean;
  124025. /**
  124026. * Creates a new connection point
  124027. * @param name defines the connection point name
  124028. * @param ownerBlock defines the block hosting this connection point
  124029. * @param direction defines the direction of the connection point
  124030. */
  124031. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  124032. /**
  124033. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  124034. * @returns the class name
  124035. */
  124036. getClassName(): string;
  124037. /**
  124038. * Gets a boolean indicating if the current point can be connected to another point
  124039. * @param connectionPoint defines the other connection point
  124040. * @returns a boolean
  124041. */
  124042. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  124043. /**
  124044. * Gets a number indicating if the current point can be connected to another point
  124045. * @param connectionPoint defines the other connection point
  124046. * @returns a number defining the compatibility state
  124047. */
  124048. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  124049. /**
  124050. * Connect this point to another connection point
  124051. * @param connectionPoint defines the other connection point
  124052. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  124053. * @returns the current connection point
  124054. */
  124055. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  124056. /**
  124057. * Disconnect this point from one of his endpoint
  124058. * @param endpoint defines the other connection point
  124059. * @returns the current connection point
  124060. */
  124061. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  124062. /**
  124063. * Serializes this point in a JSON representation
  124064. * @returns the serialized point object
  124065. */
  124066. serialize(): any;
  124067. /**
  124068. * Release resources
  124069. */
  124070. dispose(): void;
  124071. }
  124072. }
  124073. declare module BABYLON {
  124074. /**
  124075. * Block used to add support for vertex skinning (bones)
  124076. */
  124077. export class BonesBlock extends NodeMaterialBlock {
  124078. /**
  124079. * Creates a new BonesBlock
  124080. * @param name defines the block name
  124081. */
  124082. constructor(name: string);
  124083. /**
  124084. * Initialize the block and prepare the context for build
  124085. * @param state defines the state that will be used for the build
  124086. */
  124087. initialize(state: NodeMaterialBuildState): void;
  124088. /**
  124089. * Gets the current class name
  124090. * @returns the class name
  124091. */
  124092. getClassName(): string;
  124093. /**
  124094. * Gets the matrix indices input component
  124095. */
  124096. readonly matricesIndices: NodeMaterialConnectionPoint;
  124097. /**
  124098. * Gets the matrix weights input component
  124099. */
  124100. readonly matricesWeights: NodeMaterialConnectionPoint;
  124101. /**
  124102. * Gets the extra matrix indices input component
  124103. */
  124104. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  124105. /**
  124106. * Gets the extra matrix weights input component
  124107. */
  124108. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  124109. /**
  124110. * Gets the world input component
  124111. */
  124112. readonly world: NodeMaterialConnectionPoint;
  124113. /**
  124114. * Gets the output component
  124115. */
  124116. readonly output: NodeMaterialConnectionPoint;
  124117. autoConfigure(material: NodeMaterial): void;
  124118. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  124119. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124120. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124121. protected _buildBlock(state: NodeMaterialBuildState): this;
  124122. }
  124123. }
  124124. declare module BABYLON {
  124125. /**
  124126. * Block used to add support for instances
  124127. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  124128. */
  124129. export class InstancesBlock extends NodeMaterialBlock {
  124130. /**
  124131. * Creates a new InstancesBlock
  124132. * @param name defines the block name
  124133. */
  124134. constructor(name: string);
  124135. /**
  124136. * Gets the current class name
  124137. * @returns the class name
  124138. */
  124139. getClassName(): string;
  124140. /**
  124141. * Gets the first world row input component
  124142. */
  124143. readonly world0: NodeMaterialConnectionPoint;
  124144. /**
  124145. * Gets the second world row input component
  124146. */
  124147. readonly world1: NodeMaterialConnectionPoint;
  124148. /**
  124149. * Gets the third world row input component
  124150. */
  124151. readonly world2: NodeMaterialConnectionPoint;
  124152. /**
  124153. * Gets the forth world row input component
  124154. */
  124155. readonly world3: NodeMaterialConnectionPoint;
  124156. /**
  124157. * Gets the world input component
  124158. */
  124159. readonly world: NodeMaterialConnectionPoint;
  124160. /**
  124161. * Gets the output component
  124162. */
  124163. readonly output: NodeMaterialConnectionPoint;
  124164. autoConfigure(material: NodeMaterial): void;
  124165. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124166. protected _buildBlock(state: NodeMaterialBuildState): this;
  124167. }
  124168. }
  124169. declare module BABYLON {
  124170. /**
  124171. * Block used to add morph targets support to vertex shader
  124172. */
  124173. export class MorphTargetsBlock extends NodeMaterialBlock {
  124174. private _repeatableContentAnchor;
  124175. private _repeatebleContentGenerated;
  124176. /**
  124177. * Create a new MorphTargetsBlock
  124178. * @param name defines the block name
  124179. */
  124180. constructor(name: string);
  124181. /**
  124182. * Gets the current class name
  124183. * @returns the class name
  124184. */
  124185. getClassName(): string;
  124186. /**
  124187. * Gets the position input component
  124188. */
  124189. readonly position: NodeMaterialConnectionPoint;
  124190. /**
  124191. * Gets the normal input component
  124192. */
  124193. readonly normal: NodeMaterialConnectionPoint;
  124194. /**
  124195. * Gets the tangent input component
  124196. */
  124197. readonly tangent: NodeMaterialConnectionPoint;
  124198. /**
  124199. * Gets the tangent input component
  124200. */
  124201. readonly uv: NodeMaterialConnectionPoint;
  124202. /**
  124203. * Gets the position output component
  124204. */
  124205. readonly positionOutput: NodeMaterialConnectionPoint;
  124206. /**
  124207. * Gets the normal output component
  124208. */
  124209. readonly normalOutput: NodeMaterialConnectionPoint;
  124210. /**
  124211. * Gets the tangent output component
  124212. */
  124213. readonly tangentOutput: NodeMaterialConnectionPoint;
  124214. /**
  124215. * Gets the tangent output component
  124216. */
  124217. readonly uvOutput: NodeMaterialConnectionPoint;
  124218. initialize(state: NodeMaterialBuildState): void;
  124219. autoConfigure(material: NodeMaterial): void;
  124220. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124221. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124222. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  124223. protected _buildBlock(state: NodeMaterialBuildState): this;
  124224. }
  124225. }
  124226. declare module BABYLON {
  124227. /**
  124228. * Block used to get data information from a light
  124229. */
  124230. export class LightInformationBlock extends NodeMaterialBlock {
  124231. private _lightDataUniformName;
  124232. private _lightColorUniformName;
  124233. private _lightTypeDefineName;
  124234. /**
  124235. * Gets or sets the light associated with this block
  124236. */
  124237. light: Nullable<Light>;
  124238. /**
  124239. * Creates a new LightInformationBlock
  124240. * @param name defines the block name
  124241. */
  124242. constructor(name: string);
  124243. /**
  124244. * Gets the current class name
  124245. * @returns the class name
  124246. */
  124247. getClassName(): string;
  124248. /**
  124249. * Gets the world position input component
  124250. */
  124251. readonly worldPosition: NodeMaterialConnectionPoint;
  124252. /**
  124253. * Gets the direction output component
  124254. */
  124255. readonly direction: NodeMaterialConnectionPoint;
  124256. /**
  124257. * Gets the direction output component
  124258. */
  124259. readonly color: NodeMaterialConnectionPoint;
  124260. /**
  124261. * Gets the direction output component
  124262. */
  124263. readonly intensity: NodeMaterialConnectionPoint;
  124264. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124265. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124266. protected _buildBlock(state: NodeMaterialBuildState): this;
  124267. serialize(): any;
  124268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124269. }
  124270. }
  124271. declare module BABYLON {
  124272. /**
  124273. * Block used to add image processing support to fragment shader
  124274. */
  124275. export class ImageProcessingBlock extends NodeMaterialBlock {
  124276. /**
  124277. * Create a new ImageProcessingBlock
  124278. * @param name defines the block name
  124279. */
  124280. constructor(name: string);
  124281. /**
  124282. * Gets the current class name
  124283. * @returns the class name
  124284. */
  124285. getClassName(): string;
  124286. /**
  124287. * Gets the color input component
  124288. */
  124289. readonly color: NodeMaterialConnectionPoint;
  124290. /**
  124291. * Gets the output component
  124292. */
  124293. readonly output: NodeMaterialConnectionPoint;
  124294. /**
  124295. * Initialize the block and prepare the context for build
  124296. * @param state defines the state that will be used for the build
  124297. */
  124298. initialize(state: NodeMaterialBuildState): void;
  124299. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  124300. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124301. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124302. protected _buildBlock(state: NodeMaterialBuildState): this;
  124303. }
  124304. }
  124305. declare module BABYLON {
  124306. /**
  124307. * Block used to pertub normals based on a normal map
  124308. */
  124309. export class PerturbNormalBlock extends NodeMaterialBlock {
  124310. private _tangentSpaceParameterName;
  124311. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  124312. invertX: boolean;
  124313. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  124314. invertY: boolean;
  124315. /**
  124316. * Create a new PerturbNormalBlock
  124317. * @param name defines the block name
  124318. */
  124319. constructor(name: string);
  124320. /**
  124321. * Gets the current class name
  124322. * @returns the class name
  124323. */
  124324. getClassName(): string;
  124325. /**
  124326. * Gets the world position input component
  124327. */
  124328. readonly worldPosition: NodeMaterialConnectionPoint;
  124329. /**
  124330. * Gets the world normal input component
  124331. */
  124332. readonly worldNormal: NodeMaterialConnectionPoint;
  124333. /**
  124334. * Gets the uv input component
  124335. */
  124336. readonly uv: NodeMaterialConnectionPoint;
  124337. /**
  124338. * Gets the normal map color input component
  124339. */
  124340. readonly normalMapColor: NodeMaterialConnectionPoint;
  124341. /**
  124342. * Gets the strength input component
  124343. */
  124344. readonly strength: NodeMaterialConnectionPoint;
  124345. /**
  124346. * Gets the output component
  124347. */
  124348. readonly output: NodeMaterialConnectionPoint;
  124349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124350. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124351. autoConfigure(material: NodeMaterial): void;
  124352. protected _buildBlock(state: NodeMaterialBuildState): this;
  124353. protected _dumpPropertiesCode(): string;
  124354. serialize(): any;
  124355. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124356. }
  124357. }
  124358. declare module BABYLON {
  124359. /**
  124360. * Block used to discard a pixel if a value is smaller than a cutoff
  124361. */
  124362. export class DiscardBlock extends NodeMaterialBlock {
  124363. /**
  124364. * Create a new DiscardBlock
  124365. * @param name defines the block name
  124366. */
  124367. constructor(name: string);
  124368. /**
  124369. * Gets the current class name
  124370. * @returns the class name
  124371. */
  124372. getClassName(): string;
  124373. /**
  124374. * Gets the color input component
  124375. */
  124376. readonly value: NodeMaterialConnectionPoint;
  124377. /**
  124378. * Gets the cutoff input component
  124379. */
  124380. readonly cutoff: NodeMaterialConnectionPoint;
  124381. protected _buildBlock(state: NodeMaterialBuildState): this;
  124382. }
  124383. }
  124384. declare module BABYLON {
  124385. /**
  124386. * Block used to test if the fragment shader is front facing
  124387. */
  124388. export class FrontFacingBlock extends NodeMaterialBlock {
  124389. /**
  124390. * Creates a new FrontFacingBlock
  124391. * @param name defines the block name
  124392. */
  124393. constructor(name: string);
  124394. /**
  124395. * Gets the current class name
  124396. * @returns the class name
  124397. */
  124398. getClassName(): string;
  124399. /**
  124400. * Gets the output component
  124401. */
  124402. readonly output: NodeMaterialConnectionPoint;
  124403. protected _buildBlock(state: NodeMaterialBuildState): this;
  124404. }
  124405. }
  124406. declare module BABYLON {
  124407. /**
  124408. * Block used to get the derivative value on x and y of a given input
  124409. */
  124410. export class DerivativeBlock extends NodeMaterialBlock {
  124411. /**
  124412. * Create a new DerivativeBlock
  124413. * @param name defines the block name
  124414. */
  124415. constructor(name: string);
  124416. /**
  124417. * Gets the current class name
  124418. * @returns the class name
  124419. */
  124420. getClassName(): string;
  124421. /**
  124422. * Gets the input component
  124423. */
  124424. readonly input: NodeMaterialConnectionPoint;
  124425. /**
  124426. * Gets the derivative output on x
  124427. */
  124428. readonly dx: NodeMaterialConnectionPoint;
  124429. /**
  124430. * Gets the derivative output on y
  124431. */
  124432. readonly dy: NodeMaterialConnectionPoint;
  124433. protected _buildBlock(state: NodeMaterialBuildState): this;
  124434. }
  124435. }
  124436. declare module BABYLON {
  124437. /**
  124438. * Block used to add support for scene fog
  124439. */
  124440. export class FogBlock extends NodeMaterialBlock {
  124441. private _fogDistanceName;
  124442. private _fogParameters;
  124443. /**
  124444. * Create a new FogBlock
  124445. * @param name defines the block name
  124446. */
  124447. constructor(name: string);
  124448. /**
  124449. * Gets the current class name
  124450. * @returns the class name
  124451. */
  124452. getClassName(): string;
  124453. /**
  124454. * Gets the world position input component
  124455. */
  124456. readonly worldPosition: NodeMaterialConnectionPoint;
  124457. /**
  124458. * Gets the view input component
  124459. */
  124460. readonly view: NodeMaterialConnectionPoint;
  124461. /**
  124462. * Gets the color input component
  124463. */
  124464. readonly input: NodeMaterialConnectionPoint;
  124465. /**
  124466. * Gets the fog color input component
  124467. */
  124468. readonly fogColor: NodeMaterialConnectionPoint;
  124469. /**
  124470. * Gets the output component
  124471. */
  124472. readonly output: NodeMaterialConnectionPoint;
  124473. autoConfigure(material: NodeMaterial): void;
  124474. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124475. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124476. protected _buildBlock(state: NodeMaterialBuildState): this;
  124477. }
  124478. }
  124479. declare module BABYLON {
  124480. /**
  124481. * Block used to add light in the fragment shader
  124482. */
  124483. export class LightBlock extends NodeMaterialBlock {
  124484. private _lightId;
  124485. /**
  124486. * Gets or sets the light associated with this block
  124487. */
  124488. light: Nullable<Light>;
  124489. /**
  124490. * Create a new LightBlock
  124491. * @param name defines the block name
  124492. */
  124493. constructor(name: string);
  124494. /**
  124495. * Gets the current class name
  124496. * @returns the class name
  124497. */
  124498. getClassName(): string;
  124499. /**
  124500. * Gets the world position input component
  124501. */
  124502. readonly worldPosition: NodeMaterialConnectionPoint;
  124503. /**
  124504. * Gets the world normal input component
  124505. */
  124506. readonly worldNormal: NodeMaterialConnectionPoint;
  124507. /**
  124508. * Gets the camera (or eye) position component
  124509. */
  124510. readonly cameraPosition: NodeMaterialConnectionPoint;
  124511. /**
  124512. * Gets the glossiness component
  124513. */
  124514. readonly glossiness: NodeMaterialConnectionPoint;
  124515. /**
  124516. * Gets the glossinness power component
  124517. */
  124518. readonly glossPower: NodeMaterialConnectionPoint;
  124519. /**
  124520. * Gets the diffuse color component
  124521. */
  124522. readonly diffuseColor: NodeMaterialConnectionPoint;
  124523. /**
  124524. * Gets the specular color component
  124525. */
  124526. readonly specularColor: NodeMaterialConnectionPoint;
  124527. /**
  124528. * Gets the diffuse output component
  124529. */
  124530. readonly diffuseOutput: NodeMaterialConnectionPoint;
  124531. /**
  124532. * Gets the specular output component
  124533. */
  124534. readonly specularOutput: NodeMaterialConnectionPoint;
  124535. autoConfigure(material: NodeMaterial): void;
  124536. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124537. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  124538. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124539. private _injectVertexCode;
  124540. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124541. serialize(): any;
  124542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124543. }
  124544. }
  124545. declare module BABYLON {
  124546. /**
  124547. * Block used to multiply 2 values
  124548. */
  124549. export class MultiplyBlock extends NodeMaterialBlock {
  124550. /**
  124551. * Creates a new MultiplyBlock
  124552. * @param name defines the block name
  124553. */
  124554. constructor(name: string);
  124555. /**
  124556. * Gets the current class name
  124557. * @returns the class name
  124558. */
  124559. getClassName(): string;
  124560. /**
  124561. * Gets the left operand input component
  124562. */
  124563. readonly left: NodeMaterialConnectionPoint;
  124564. /**
  124565. * Gets the right operand input component
  124566. */
  124567. readonly right: NodeMaterialConnectionPoint;
  124568. /**
  124569. * Gets the output component
  124570. */
  124571. readonly output: NodeMaterialConnectionPoint;
  124572. protected _buildBlock(state: NodeMaterialBuildState): this;
  124573. }
  124574. }
  124575. declare module BABYLON {
  124576. /**
  124577. * Block used to add 2 vectors
  124578. */
  124579. export class AddBlock extends NodeMaterialBlock {
  124580. /**
  124581. * Creates a new AddBlock
  124582. * @param name defines the block name
  124583. */
  124584. constructor(name: string);
  124585. /**
  124586. * Gets the current class name
  124587. * @returns the class name
  124588. */
  124589. getClassName(): string;
  124590. /**
  124591. * Gets the left operand input component
  124592. */
  124593. readonly left: NodeMaterialConnectionPoint;
  124594. /**
  124595. * Gets the right operand input component
  124596. */
  124597. readonly right: NodeMaterialConnectionPoint;
  124598. /**
  124599. * Gets the output component
  124600. */
  124601. readonly output: NodeMaterialConnectionPoint;
  124602. protected _buildBlock(state: NodeMaterialBuildState): this;
  124603. }
  124604. }
  124605. declare module BABYLON {
  124606. /**
  124607. * Block used to scale a vector by a float
  124608. */
  124609. export class ScaleBlock extends NodeMaterialBlock {
  124610. /**
  124611. * Creates a new ScaleBlock
  124612. * @param name defines the block name
  124613. */
  124614. constructor(name: string);
  124615. /**
  124616. * Gets the current class name
  124617. * @returns the class name
  124618. */
  124619. getClassName(): string;
  124620. /**
  124621. * Gets the input component
  124622. */
  124623. readonly input: NodeMaterialConnectionPoint;
  124624. /**
  124625. * Gets the factor input component
  124626. */
  124627. readonly factor: NodeMaterialConnectionPoint;
  124628. /**
  124629. * Gets the output component
  124630. */
  124631. readonly output: NodeMaterialConnectionPoint;
  124632. protected _buildBlock(state: NodeMaterialBuildState): this;
  124633. }
  124634. }
  124635. declare module BABYLON {
  124636. /**
  124637. * Block used to clamp a float
  124638. */
  124639. export class ClampBlock extends NodeMaterialBlock {
  124640. /** Gets or sets the minimum range */
  124641. minimum: number;
  124642. /** Gets or sets the maximum range */
  124643. maximum: number;
  124644. /**
  124645. * Creates a new ClampBlock
  124646. * @param name defines the block name
  124647. */
  124648. constructor(name: string);
  124649. /**
  124650. * Gets the current class name
  124651. * @returns the class name
  124652. */
  124653. getClassName(): string;
  124654. /**
  124655. * Gets the value input component
  124656. */
  124657. readonly value: NodeMaterialConnectionPoint;
  124658. /**
  124659. * Gets the output component
  124660. */
  124661. readonly output: NodeMaterialConnectionPoint;
  124662. protected _buildBlock(state: NodeMaterialBuildState): this;
  124663. protected _dumpPropertiesCode(): string;
  124664. serialize(): any;
  124665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124666. }
  124667. }
  124668. declare module BABYLON {
  124669. /**
  124670. * Block used to apply a cross product between 2 vectors
  124671. */
  124672. export class CrossBlock extends NodeMaterialBlock {
  124673. /**
  124674. * Creates a new CrossBlock
  124675. * @param name defines the block name
  124676. */
  124677. constructor(name: string);
  124678. /**
  124679. * Gets the current class name
  124680. * @returns the class name
  124681. */
  124682. getClassName(): string;
  124683. /**
  124684. * Gets the left operand input component
  124685. */
  124686. readonly left: NodeMaterialConnectionPoint;
  124687. /**
  124688. * Gets the right operand input component
  124689. */
  124690. readonly right: NodeMaterialConnectionPoint;
  124691. /**
  124692. * Gets the output component
  124693. */
  124694. readonly output: NodeMaterialConnectionPoint;
  124695. protected _buildBlock(state: NodeMaterialBuildState): this;
  124696. }
  124697. }
  124698. declare module BABYLON {
  124699. /**
  124700. * Block used to apply a dot product between 2 vectors
  124701. */
  124702. export class DotBlock extends NodeMaterialBlock {
  124703. /**
  124704. * Creates a new DotBlock
  124705. * @param name defines the block name
  124706. */
  124707. constructor(name: string);
  124708. /**
  124709. * Gets the current class name
  124710. * @returns the class name
  124711. */
  124712. getClassName(): string;
  124713. /**
  124714. * Gets the left operand input component
  124715. */
  124716. readonly left: NodeMaterialConnectionPoint;
  124717. /**
  124718. * Gets the right operand input component
  124719. */
  124720. readonly right: NodeMaterialConnectionPoint;
  124721. /**
  124722. * Gets the output component
  124723. */
  124724. readonly output: NodeMaterialConnectionPoint;
  124725. protected _buildBlock(state: NodeMaterialBuildState): this;
  124726. }
  124727. }
  124728. declare module BABYLON {
  124729. /**
  124730. * Block used to remap a float from a range to a new one
  124731. */
  124732. export class RemapBlock extends NodeMaterialBlock {
  124733. /**
  124734. * Gets or sets the source range
  124735. */
  124736. sourceRange: Vector2;
  124737. /**
  124738. * Gets or sets the target range
  124739. */
  124740. targetRange: Vector2;
  124741. /**
  124742. * Creates a new RemapBlock
  124743. * @param name defines the block name
  124744. */
  124745. constructor(name: string);
  124746. /**
  124747. * Gets the current class name
  124748. * @returns the class name
  124749. */
  124750. getClassName(): string;
  124751. /**
  124752. * Gets the input component
  124753. */
  124754. readonly input: NodeMaterialConnectionPoint;
  124755. /**
  124756. * Gets the source min input component
  124757. */
  124758. readonly sourceMin: NodeMaterialConnectionPoint;
  124759. /**
  124760. * Gets the source max input component
  124761. */
  124762. readonly sourceMax: NodeMaterialConnectionPoint;
  124763. /**
  124764. * Gets the target min input component
  124765. */
  124766. readonly targetMin: NodeMaterialConnectionPoint;
  124767. /**
  124768. * Gets the target max input component
  124769. */
  124770. readonly targetMax: NodeMaterialConnectionPoint;
  124771. /**
  124772. * Gets the output component
  124773. */
  124774. readonly output: NodeMaterialConnectionPoint;
  124775. protected _buildBlock(state: NodeMaterialBuildState): this;
  124776. protected _dumpPropertiesCode(): string;
  124777. serialize(): any;
  124778. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124779. }
  124780. }
  124781. declare module BABYLON {
  124782. /**
  124783. * Block used to normalize a vector
  124784. */
  124785. export class NormalizeBlock extends NodeMaterialBlock {
  124786. /**
  124787. * Creates a new NormalizeBlock
  124788. * @param name defines the block name
  124789. */
  124790. constructor(name: string);
  124791. /**
  124792. * Gets the current class name
  124793. * @returns the class name
  124794. */
  124795. getClassName(): string;
  124796. /**
  124797. * Gets the input component
  124798. */
  124799. readonly input: NodeMaterialConnectionPoint;
  124800. /**
  124801. * Gets the output component
  124802. */
  124803. readonly output: NodeMaterialConnectionPoint;
  124804. protected _buildBlock(state: NodeMaterialBuildState): this;
  124805. }
  124806. }
  124807. declare module BABYLON {
  124808. /**
  124809. * Operations supported by the Trigonometry block
  124810. */
  124811. export enum TrigonometryBlockOperations {
  124812. /** Cos */
  124813. Cos = 0,
  124814. /** Sin */
  124815. Sin = 1,
  124816. /** Abs */
  124817. Abs = 2,
  124818. /** Exp */
  124819. Exp = 3,
  124820. /** Exp2 */
  124821. Exp2 = 4,
  124822. /** Round */
  124823. Round = 5,
  124824. /** Floor */
  124825. Floor = 6,
  124826. /** Ceiling */
  124827. Ceiling = 7,
  124828. /** Square root */
  124829. Sqrt = 8,
  124830. /** Log */
  124831. Log = 9,
  124832. /** Tangent */
  124833. Tan = 10,
  124834. /** Arc tangent */
  124835. ArcTan = 11,
  124836. /** Arc cosinus */
  124837. ArcCos = 12,
  124838. /** Arc sinus */
  124839. ArcSin = 13,
  124840. /** Fraction */
  124841. Fract = 14,
  124842. /** Sign */
  124843. Sign = 15,
  124844. /** To radians (from degrees) */
  124845. Radians = 16,
  124846. /** To degrees (from radians) */
  124847. Degrees = 17
  124848. }
  124849. /**
  124850. * Block used to apply trigonometry operation to floats
  124851. */
  124852. export class TrigonometryBlock extends NodeMaterialBlock {
  124853. /**
  124854. * Gets or sets the operation applied by the block
  124855. */
  124856. operation: TrigonometryBlockOperations;
  124857. /**
  124858. * Creates a new TrigonometryBlock
  124859. * @param name defines the block name
  124860. */
  124861. constructor(name: string);
  124862. /**
  124863. * Gets the current class name
  124864. * @returns the class name
  124865. */
  124866. getClassName(): string;
  124867. /**
  124868. * Gets the input component
  124869. */
  124870. readonly input: NodeMaterialConnectionPoint;
  124871. /**
  124872. * Gets the output component
  124873. */
  124874. readonly output: NodeMaterialConnectionPoint;
  124875. protected _buildBlock(state: NodeMaterialBuildState): this;
  124876. serialize(): any;
  124877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124878. protected _dumpPropertiesCode(): string;
  124879. }
  124880. }
  124881. declare module BABYLON {
  124882. /**
  124883. * Block used to create a Color3/4 out of individual inputs (one for each component)
  124884. */
  124885. export class ColorMergerBlock extends NodeMaterialBlock {
  124886. /**
  124887. * Create a new ColorMergerBlock
  124888. * @param name defines the block name
  124889. */
  124890. constructor(name: string);
  124891. /**
  124892. * Gets the current class name
  124893. * @returns the class name
  124894. */
  124895. getClassName(): string;
  124896. /**
  124897. * Gets the rgb component (input)
  124898. */
  124899. readonly rgbIn: NodeMaterialConnectionPoint;
  124900. /**
  124901. * Gets the r component (input)
  124902. */
  124903. readonly r: NodeMaterialConnectionPoint;
  124904. /**
  124905. * Gets the g component (input)
  124906. */
  124907. readonly g: NodeMaterialConnectionPoint;
  124908. /**
  124909. * Gets the b component (input)
  124910. */
  124911. readonly b: NodeMaterialConnectionPoint;
  124912. /**
  124913. * Gets the a component (input)
  124914. */
  124915. readonly a: NodeMaterialConnectionPoint;
  124916. /**
  124917. * Gets the rgba component (output)
  124918. */
  124919. readonly rgba: NodeMaterialConnectionPoint;
  124920. /**
  124921. * Gets the rgb component (output)
  124922. */
  124923. readonly rgbOut: NodeMaterialConnectionPoint;
  124924. /**
  124925. * Gets the rgb component (output)
  124926. * @deprecated Please use rgbOut instead.
  124927. */
  124928. readonly rgb: NodeMaterialConnectionPoint;
  124929. protected _buildBlock(state: NodeMaterialBuildState): this;
  124930. }
  124931. }
  124932. declare module BABYLON {
  124933. /**
  124934. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  124935. */
  124936. export class VectorMergerBlock extends NodeMaterialBlock {
  124937. /**
  124938. * Create a new VectorMergerBlock
  124939. * @param name defines the block name
  124940. */
  124941. constructor(name: string);
  124942. /**
  124943. * Gets the current class name
  124944. * @returns the class name
  124945. */
  124946. getClassName(): string;
  124947. /**
  124948. * Gets the xyz component (input)
  124949. */
  124950. readonly xyzIn: NodeMaterialConnectionPoint;
  124951. /**
  124952. * Gets the xy component (input)
  124953. */
  124954. readonly xyIn: NodeMaterialConnectionPoint;
  124955. /**
  124956. * Gets the x component (input)
  124957. */
  124958. readonly x: NodeMaterialConnectionPoint;
  124959. /**
  124960. * Gets the y component (input)
  124961. */
  124962. readonly y: NodeMaterialConnectionPoint;
  124963. /**
  124964. * Gets the z component (input)
  124965. */
  124966. readonly z: NodeMaterialConnectionPoint;
  124967. /**
  124968. * Gets the w component (input)
  124969. */
  124970. readonly w: NodeMaterialConnectionPoint;
  124971. /**
  124972. * Gets the xyzw component (output)
  124973. */
  124974. readonly xyzw: NodeMaterialConnectionPoint;
  124975. /**
  124976. * Gets the xyz component (output)
  124977. */
  124978. readonly xyzOut: NodeMaterialConnectionPoint;
  124979. /**
  124980. * Gets the xy component (output)
  124981. */
  124982. readonly xyOut: NodeMaterialConnectionPoint;
  124983. /**
  124984. * Gets the xy component (output)
  124985. * @deprecated Please use xyOut instead.
  124986. */
  124987. readonly xy: NodeMaterialConnectionPoint;
  124988. /**
  124989. * Gets the xyz component (output)
  124990. * @deprecated Please use xyzOut instead.
  124991. */
  124992. readonly xyz: NodeMaterialConnectionPoint;
  124993. protected _buildBlock(state: NodeMaterialBuildState): this;
  124994. }
  124995. }
  124996. declare module BABYLON {
  124997. /**
  124998. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  124999. */
  125000. export class ColorSplitterBlock extends NodeMaterialBlock {
  125001. /**
  125002. * Create a new ColorSplitterBlock
  125003. * @param name defines the block name
  125004. */
  125005. constructor(name: string);
  125006. /**
  125007. * Gets the current class name
  125008. * @returns the class name
  125009. */
  125010. getClassName(): string;
  125011. /**
  125012. * Gets the rgba component (input)
  125013. */
  125014. readonly rgba: NodeMaterialConnectionPoint;
  125015. /**
  125016. * Gets the rgb component (input)
  125017. */
  125018. readonly rgbIn: NodeMaterialConnectionPoint;
  125019. /**
  125020. * Gets the rgb component (output)
  125021. */
  125022. readonly rgbOut: NodeMaterialConnectionPoint;
  125023. /**
  125024. * Gets the r component (output)
  125025. */
  125026. readonly r: NodeMaterialConnectionPoint;
  125027. /**
  125028. * Gets the g component (output)
  125029. */
  125030. readonly g: NodeMaterialConnectionPoint;
  125031. /**
  125032. * Gets the b component (output)
  125033. */
  125034. readonly b: NodeMaterialConnectionPoint;
  125035. /**
  125036. * Gets the a component (output)
  125037. */
  125038. readonly a: NodeMaterialConnectionPoint;
  125039. protected _inputRename(name: string): string;
  125040. protected _outputRename(name: string): string;
  125041. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125042. }
  125043. }
  125044. declare module BABYLON {
  125045. /**
  125046. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  125047. */
  125048. export class VectorSplitterBlock extends NodeMaterialBlock {
  125049. /**
  125050. * Create a new VectorSplitterBlock
  125051. * @param name defines the block name
  125052. */
  125053. constructor(name: string);
  125054. /**
  125055. * Gets the current class name
  125056. * @returns the class name
  125057. */
  125058. getClassName(): string;
  125059. /**
  125060. * Gets the xyzw component (input)
  125061. */
  125062. readonly xyzw: NodeMaterialConnectionPoint;
  125063. /**
  125064. * Gets the xyz component (input)
  125065. */
  125066. readonly xyzIn: NodeMaterialConnectionPoint;
  125067. /**
  125068. * Gets the xy component (input)
  125069. */
  125070. readonly xyIn: NodeMaterialConnectionPoint;
  125071. /**
  125072. * Gets the xyz component (output)
  125073. */
  125074. readonly xyzOut: NodeMaterialConnectionPoint;
  125075. /**
  125076. * Gets the xy component (output)
  125077. */
  125078. readonly xyOut: NodeMaterialConnectionPoint;
  125079. /**
  125080. * Gets the x component (output)
  125081. */
  125082. readonly x: NodeMaterialConnectionPoint;
  125083. /**
  125084. * Gets the y component (output)
  125085. */
  125086. readonly y: NodeMaterialConnectionPoint;
  125087. /**
  125088. * Gets the z component (output)
  125089. */
  125090. readonly z: NodeMaterialConnectionPoint;
  125091. /**
  125092. * Gets the w component (output)
  125093. */
  125094. readonly w: NodeMaterialConnectionPoint;
  125095. protected _inputRename(name: string): string;
  125096. protected _outputRename(name: string): string;
  125097. protected _buildBlock(state: NodeMaterialBuildState): this;
  125098. }
  125099. }
  125100. declare module BABYLON {
  125101. /**
  125102. * Block used to lerp between 2 values
  125103. */
  125104. export class LerpBlock extends NodeMaterialBlock {
  125105. /**
  125106. * Creates a new LerpBlock
  125107. * @param name defines the block name
  125108. */
  125109. constructor(name: string);
  125110. /**
  125111. * Gets the current class name
  125112. * @returns the class name
  125113. */
  125114. getClassName(): string;
  125115. /**
  125116. * Gets the left operand input component
  125117. */
  125118. readonly left: NodeMaterialConnectionPoint;
  125119. /**
  125120. * Gets the right operand input component
  125121. */
  125122. readonly right: NodeMaterialConnectionPoint;
  125123. /**
  125124. * Gets the gradient operand input component
  125125. */
  125126. readonly gradient: NodeMaterialConnectionPoint;
  125127. /**
  125128. * Gets the output component
  125129. */
  125130. readonly output: NodeMaterialConnectionPoint;
  125131. protected _buildBlock(state: NodeMaterialBuildState): this;
  125132. }
  125133. }
  125134. declare module BABYLON {
  125135. /**
  125136. * Block used to divide 2 vectors
  125137. */
  125138. export class DivideBlock extends NodeMaterialBlock {
  125139. /**
  125140. * Creates a new DivideBlock
  125141. * @param name defines the block name
  125142. */
  125143. constructor(name: string);
  125144. /**
  125145. * Gets the current class name
  125146. * @returns the class name
  125147. */
  125148. getClassName(): string;
  125149. /**
  125150. * Gets the left operand input component
  125151. */
  125152. readonly left: NodeMaterialConnectionPoint;
  125153. /**
  125154. * Gets the right operand input component
  125155. */
  125156. readonly right: NodeMaterialConnectionPoint;
  125157. /**
  125158. * Gets the output component
  125159. */
  125160. readonly output: NodeMaterialConnectionPoint;
  125161. protected _buildBlock(state: NodeMaterialBuildState): this;
  125162. }
  125163. }
  125164. declare module BABYLON {
  125165. /**
  125166. * Block used to subtract 2 vectors
  125167. */
  125168. export class SubtractBlock extends NodeMaterialBlock {
  125169. /**
  125170. * Creates a new SubtractBlock
  125171. * @param name defines the block name
  125172. */
  125173. constructor(name: string);
  125174. /**
  125175. * Gets the current class name
  125176. * @returns the class name
  125177. */
  125178. getClassName(): string;
  125179. /**
  125180. * Gets the left operand input component
  125181. */
  125182. readonly left: NodeMaterialConnectionPoint;
  125183. /**
  125184. * Gets the right operand input component
  125185. */
  125186. readonly right: NodeMaterialConnectionPoint;
  125187. /**
  125188. * Gets the output component
  125189. */
  125190. readonly output: NodeMaterialConnectionPoint;
  125191. protected _buildBlock(state: NodeMaterialBuildState): this;
  125192. }
  125193. }
  125194. declare module BABYLON {
  125195. /**
  125196. * Block used to step a value
  125197. */
  125198. export class StepBlock extends NodeMaterialBlock {
  125199. /**
  125200. * Creates a new StepBlock
  125201. * @param name defines the block name
  125202. */
  125203. constructor(name: string);
  125204. /**
  125205. * Gets the current class name
  125206. * @returns the class name
  125207. */
  125208. getClassName(): string;
  125209. /**
  125210. * Gets the value operand input component
  125211. */
  125212. readonly value: NodeMaterialConnectionPoint;
  125213. /**
  125214. * Gets the edge operand input component
  125215. */
  125216. readonly edge: NodeMaterialConnectionPoint;
  125217. /**
  125218. * Gets the output component
  125219. */
  125220. readonly output: NodeMaterialConnectionPoint;
  125221. protected _buildBlock(state: NodeMaterialBuildState): this;
  125222. }
  125223. }
  125224. declare module BABYLON {
  125225. /**
  125226. * Block used to get the opposite (1 - x) of a value
  125227. */
  125228. export class OneMinusBlock extends NodeMaterialBlock {
  125229. /**
  125230. * Creates a new OneMinusBlock
  125231. * @param name defines the block name
  125232. */
  125233. constructor(name: string);
  125234. /**
  125235. * Gets the current class name
  125236. * @returns the class name
  125237. */
  125238. getClassName(): string;
  125239. /**
  125240. * Gets the input component
  125241. */
  125242. readonly input: NodeMaterialConnectionPoint;
  125243. /**
  125244. * Gets the output component
  125245. */
  125246. readonly output: NodeMaterialConnectionPoint;
  125247. protected _buildBlock(state: NodeMaterialBuildState): this;
  125248. }
  125249. }
  125250. declare module BABYLON {
  125251. /**
  125252. * Block used to get the view direction
  125253. */
  125254. export class ViewDirectionBlock extends NodeMaterialBlock {
  125255. /**
  125256. * Creates a new ViewDirectionBlock
  125257. * @param name defines the block name
  125258. */
  125259. constructor(name: string);
  125260. /**
  125261. * Gets the current class name
  125262. * @returns the class name
  125263. */
  125264. getClassName(): string;
  125265. /**
  125266. * Gets the world position component
  125267. */
  125268. readonly worldPosition: NodeMaterialConnectionPoint;
  125269. /**
  125270. * Gets the camera position component
  125271. */
  125272. readonly cameraPosition: NodeMaterialConnectionPoint;
  125273. /**
  125274. * Gets the output component
  125275. */
  125276. readonly output: NodeMaterialConnectionPoint;
  125277. autoConfigure(material: NodeMaterial): void;
  125278. protected _buildBlock(state: NodeMaterialBuildState): this;
  125279. }
  125280. }
  125281. declare module BABYLON {
  125282. /**
  125283. * Block used to compute fresnel value
  125284. */
  125285. export class FresnelBlock extends NodeMaterialBlock {
  125286. /**
  125287. * Create a new FresnelBlock
  125288. * @param name defines the block name
  125289. */
  125290. constructor(name: string);
  125291. /**
  125292. * Gets the current class name
  125293. * @returns the class name
  125294. */
  125295. getClassName(): string;
  125296. /**
  125297. * Gets the world normal input component
  125298. */
  125299. readonly worldNormal: NodeMaterialConnectionPoint;
  125300. /**
  125301. * Gets the view direction input component
  125302. */
  125303. readonly viewDirection: NodeMaterialConnectionPoint;
  125304. /**
  125305. * Gets the bias input component
  125306. */
  125307. readonly bias: NodeMaterialConnectionPoint;
  125308. /**
  125309. * Gets the camera (or eye) position component
  125310. */
  125311. readonly power: NodeMaterialConnectionPoint;
  125312. /**
  125313. * Gets the fresnel output component
  125314. */
  125315. readonly fresnel: NodeMaterialConnectionPoint;
  125316. autoConfigure(material: NodeMaterial): void;
  125317. protected _buildBlock(state: NodeMaterialBuildState): this;
  125318. }
  125319. }
  125320. declare module BABYLON {
  125321. /**
  125322. * Block used to get the max of 2 values
  125323. */
  125324. export class MaxBlock extends NodeMaterialBlock {
  125325. /**
  125326. * Creates a new MaxBlock
  125327. * @param name defines the block name
  125328. */
  125329. constructor(name: string);
  125330. /**
  125331. * Gets the current class name
  125332. * @returns the class name
  125333. */
  125334. getClassName(): string;
  125335. /**
  125336. * Gets the left operand input component
  125337. */
  125338. readonly left: NodeMaterialConnectionPoint;
  125339. /**
  125340. * Gets the right operand input component
  125341. */
  125342. readonly right: NodeMaterialConnectionPoint;
  125343. /**
  125344. * Gets the output component
  125345. */
  125346. readonly output: NodeMaterialConnectionPoint;
  125347. protected _buildBlock(state: NodeMaterialBuildState): this;
  125348. }
  125349. }
  125350. declare module BABYLON {
  125351. /**
  125352. * Block used to get the min of 2 values
  125353. */
  125354. export class MinBlock extends NodeMaterialBlock {
  125355. /**
  125356. * Creates a new MinBlock
  125357. * @param name defines the block name
  125358. */
  125359. constructor(name: string);
  125360. /**
  125361. * Gets the current class name
  125362. * @returns the class name
  125363. */
  125364. getClassName(): string;
  125365. /**
  125366. * Gets the left operand input component
  125367. */
  125368. readonly left: NodeMaterialConnectionPoint;
  125369. /**
  125370. * Gets the right operand input component
  125371. */
  125372. readonly right: NodeMaterialConnectionPoint;
  125373. /**
  125374. * Gets the output component
  125375. */
  125376. readonly output: NodeMaterialConnectionPoint;
  125377. protected _buildBlock(state: NodeMaterialBuildState): this;
  125378. }
  125379. }
  125380. declare module BABYLON {
  125381. /**
  125382. * Block used to get the distance between 2 values
  125383. */
  125384. export class DistanceBlock extends NodeMaterialBlock {
  125385. /**
  125386. * Creates a new DistanceBlock
  125387. * @param name defines the block name
  125388. */
  125389. constructor(name: string);
  125390. /**
  125391. * Gets the current class name
  125392. * @returns the class name
  125393. */
  125394. getClassName(): string;
  125395. /**
  125396. * Gets the left operand input component
  125397. */
  125398. readonly left: NodeMaterialConnectionPoint;
  125399. /**
  125400. * Gets the right operand input component
  125401. */
  125402. readonly right: NodeMaterialConnectionPoint;
  125403. /**
  125404. * Gets the output component
  125405. */
  125406. readonly output: NodeMaterialConnectionPoint;
  125407. protected _buildBlock(state: NodeMaterialBuildState): this;
  125408. }
  125409. }
  125410. declare module BABYLON {
  125411. /**
  125412. * Block used to get the length of a vector
  125413. */
  125414. export class LengthBlock extends NodeMaterialBlock {
  125415. /**
  125416. * Creates a new LengthBlock
  125417. * @param name defines the block name
  125418. */
  125419. constructor(name: string);
  125420. /**
  125421. * Gets the current class name
  125422. * @returns the class name
  125423. */
  125424. getClassName(): string;
  125425. /**
  125426. * Gets the value input component
  125427. */
  125428. readonly value: NodeMaterialConnectionPoint;
  125429. /**
  125430. * Gets the output component
  125431. */
  125432. readonly output: NodeMaterialConnectionPoint;
  125433. protected _buildBlock(state: NodeMaterialBuildState): this;
  125434. }
  125435. }
  125436. declare module BABYLON {
  125437. /**
  125438. * Block used to get negative version of a value (i.e. x * -1)
  125439. */
  125440. export class NegateBlock extends NodeMaterialBlock {
  125441. /**
  125442. * Creates a new NegateBlock
  125443. * @param name defines the block name
  125444. */
  125445. constructor(name: string);
  125446. /**
  125447. * Gets the current class name
  125448. * @returns the class name
  125449. */
  125450. getClassName(): string;
  125451. /**
  125452. * Gets the value input component
  125453. */
  125454. readonly value: NodeMaterialConnectionPoint;
  125455. /**
  125456. * Gets the output component
  125457. */
  125458. readonly output: NodeMaterialConnectionPoint;
  125459. protected _buildBlock(state: NodeMaterialBuildState): this;
  125460. }
  125461. }
  125462. declare module BABYLON {
  125463. /**
  125464. * Block used to get the value of the first parameter raised to the power of the second
  125465. */
  125466. export class PowBlock extends NodeMaterialBlock {
  125467. /**
  125468. * Creates a new PowBlock
  125469. * @param name defines the block name
  125470. */
  125471. constructor(name: string);
  125472. /**
  125473. * Gets the current class name
  125474. * @returns the class name
  125475. */
  125476. getClassName(): string;
  125477. /**
  125478. * Gets the value operand input component
  125479. */
  125480. readonly value: NodeMaterialConnectionPoint;
  125481. /**
  125482. * Gets the power operand input component
  125483. */
  125484. readonly power: NodeMaterialConnectionPoint;
  125485. /**
  125486. * Gets the output component
  125487. */
  125488. readonly output: NodeMaterialConnectionPoint;
  125489. protected _buildBlock(state: NodeMaterialBuildState): this;
  125490. }
  125491. }
  125492. declare module BABYLON {
  125493. /**
  125494. * Block used to get a random number
  125495. */
  125496. export class RandomNumberBlock extends NodeMaterialBlock {
  125497. /**
  125498. * Creates a new RandomNumberBlock
  125499. * @param name defines the block name
  125500. */
  125501. constructor(name: string);
  125502. /**
  125503. * Gets the current class name
  125504. * @returns the class name
  125505. */
  125506. getClassName(): string;
  125507. /**
  125508. * Gets the seed input component
  125509. */
  125510. readonly seed: NodeMaterialConnectionPoint;
  125511. /**
  125512. * Gets the output component
  125513. */
  125514. readonly output: NodeMaterialConnectionPoint;
  125515. protected _buildBlock(state: NodeMaterialBuildState): this;
  125516. }
  125517. }
  125518. declare module BABYLON {
  125519. /**
  125520. * Block used to compute arc tangent of 2 values
  125521. */
  125522. export class ArcTan2Block extends NodeMaterialBlock {
  125523. /**
  125524. * Creates a new ArcTan2Block
  125525. * @param name defines the block name
  125526. */
  125527. constructor(name: string);
  125528. /**
  125529. * Gets the current class name
  125530. * @returns the class name
  125531. */
  125532. getClassName(): string;
  125533. /**
  125534. * Gets the x operand input component
  125535. */
  125536. readonly x: NodeMaterialConnectionPoint;
  125537. /**
  125538. * Gets the y operand input component
  125539. */
  125540. readonly y: NodeMaterialConnectionPoint;
  125541. /**
  125542. * Gets the output component
  125543. */
  125544. readonly output: NodeMaterialConnectionPoint;
  125545. protected _buildBlock(state: NodeMaterialBuildState): this;
  125546. }
  125547. }
  125548. declare module BABYLON {
  125549. /**
  125550. * Block used to smooth step a value
  125551. */
  125552. export class SmoothStepBlock extends NodeMaterialBlock {
  125553. /**
  125554. * Creates a new SmoothStepBlock
  125555. * @param name defines the block name
  125556. */
  125557. constructor(name: string);
  125558. /**
  125559. * Gets the current class name
  125560. * @returns the class name
  125561. */
  125562. getClassName(): string;
  125563. /**
  125564. * Gets the value operand input component
  125565. */
  125566. readonly value: NodeMaterialConnectionPoint;
  125567. /**
  125568. * Gets the first edge operand input component
  125569. */
  125570. readonly edge0: NodeMaterialConnectionPoint;
  125571. /**
  125572. * Gets the second edge operand input component
  125573. */
  125574. readonly edge1: NodeMaterialConnectionPoint;
  125575. /**
  125576. * Gets the output component
  125577. */
  125578. readonly output: NodeMaterialConnectionPoint;
  125579. protected _buildBlock(state: NodeMaterialBuildState): this;
  125580. }
  125581. }
  125582. declare module BABYLON {
  125583. /**
  125584. * Block used to get the reciprocal (1 / x) of a value
  125585. */
  125586. export class ReciprocalBlock extends NodeMaterialBlock {
  125587. /**
  125588. * Creates a new ReciprocalBlock
  125589. * @param name defines the block name
  125590. */
  125591. constructor(name: string);
  125592. /**
  125593. * Gets the current class name
  125594. * @returns the class name
  125595. */
  125596. getClassName(): string;
  125597. /**
  125598. * Gets the input component
  125599. */
  125600. readonly input: NodeMaterialConnectionPoint;
  125601. /**
  125602. * Gets the output component
  125603. */
  125604. readonly output: NodeMaterialConnectionPoint;
  125605. protected _buildBlock(state: NodeMaterialBuildState): this;
  125606. }
  125607. }
  125608. declare module BABYLON {
  125609. /**
  125610. * Block used to replace a color by another one
  125611. */
  125612. export class ReplaceColorBlock extends NodeMaterialBlock {
  125613. /**
  125614. * Creates a new ReplaceColorBlock
  125615. * @param name defines the block name
  125616. */
  125617. constructor(name: string);
  125618. /**
  125619. * Gets the current class name
  125620. * @returns the class name
  125621. */
  125622. getClassName(): string;
  125623. /**
  125624. * Gets the value input component
  125625. */
  125626. readonly value: NodeMaterialConnectionPoint;
  125627. /**
  125628. * Gets the reference input component
  125629. */
  125630. readonly reference: NodeMaterialConnectionPoint;
  125631. /**
  125632. * Gets the distance input component
  125633. */
  125634. readonly distance: NodeMaterialConnectionPoint;
  125635. /**
  125636. * Gets the replacement input component
  125637. */
  125638. readonly replacement: NodeMaterialConnectionPoint;
  125639. /**
  125640. * Gets the output component
  125641. */
  125642. readonly output: NodeMaterialConnectionPoint;
  125643. protected _buildBlock(state: NodeMaterialBuildState): this;
  125644. }
  125645. }
  125646. declare module BABYLON {
  125647. /**
  125648. * Block used to posterize a value
  125649. * @see https://en.wikipedia.org/wiki/Posterization
  125650. */
  125651. export class PosterizeBlock extends NodeMaterialBlock {
  125652. /**
  125653. * Creates a new PosterizeBlock
  125654. * @param name defines the block name
  125655. */
  125656. constructor(name: string);
  125657. /**
  125658. * Gets the current class name
  125659. * @returns the class name
  125660. */
  125661. getClassName(): string;
  125662. /**
  125663. * Gets the value input component
  125664. */
  125665. readonly value: NodeMaterialConnectionPoint;
  125666. /**
  125667. * Gets the steps input component
  125668. */
  125669. readonly steps: NodeMaterialConnectionPoint;
  125670. /**
  125671. * Gets the output component
  125672. */
  125673. readonly output: NodeMaterialConnectionPoint;
  125674. protected _buildBlock(state: NodeMaterialBuildState): this;
  125675. }
  125676. }
  125677. declare module BABYLON {
  125678. /**
  125679. * Operations supported by the Wave block
  125680. */
  125681. export enum WaveBlockKind {
  125682. /** SawTooth */
  125683. SawTooth = 0,
  125684. /** Square */
  125685. Square = 1,
  125686. /** Triangle */
  125687. Triangle = 2
  125688. }
  125689. /**
  125690. * Block used to apply wave operation to floats
  125691. */
  125692. export class WaveBlock extends NodeMaterialBlock {
  125693. /**
  125694. * Gets or sets the kibnd of wave to be applied by the block
  125695. */
  125696. kind: WaveBlockKind;
  125697. /**
  125698. * Creates a new WaveBlock
  125699. * @param name defines the block name
  125700. */
  125701. constructor(name: string);
  125702. /**
  125703. * Gets the current class name
  125704. * @returns the class name
  125705. */
  125706. getClassName(): string;
  125707. /**
  125708. * Gets the input component
  125709. */
  125710. readonly input: NodeMaterialConnectionPoint;
  125711. /**
  125712. * Gets the output component
  125713. */
  125714. readonly output: NodeMaterialConnectionPoint;
  125715. protected _buildBlock(state: NodeMaterialBuildState): this;
  125716. serialize(): any;
  125717. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125718. }
  125719. }
  125720. declare module BABYLON {
  125721. /**
  125722. * Class used to store a color step for the GradientBlock
  125723. */
  125724. export class GradientBlockColorStep {
  125725. /**
  125726. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125727. */
  125728. step: number;
  125729. /**
  125730. * Gets or sets the color associated with this step
  125731. */
  125732. color: Color3;
  125733. /**
  125734. * Creates a new GradientBlockColorStep
  125735. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  125736. * @param color defines the color associated with this step
  125737. */
  125738. constructor(
  125739. /**
  125740. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125741. */
  125742. step: number,
  125743. /**
  125744. * Gets or sets the color associated with this step
  125745. */
  125746. color: Color3);
  125747. }
  125748. /**
  125749. * Block used to return a color from a gradient based on an input value between 0 and 1
  125750. */
  125751. export class GradientBlock extends NodeMaterialBlock {
  125752. /**
  125753. * Gets or sets the list of color steps
  125754. */
  125755. colorSteps: GradientBlockColorStep[];
  125756. /**
  125757. * Creates a new GradientBlock
  125758. * @param name defines the block name
  125759. */
  125760. constructor(name: string);
  125761. /**
  125762. * Gets the current class name
  125763. * @returns the class name
  125764. */
  125765. getClassName(): string;
  125766. /**
  125767. * Gets the gradient input component
  125768. */
  125769. readonly gradient: NodeMaterialConnectionPoint;
  125770. /**
  125771. * Gets the output component
  125772. */
  125773. readonly output: NodeMaterialConnectionPoint;
  125774. private _writeColorConstant;
  125775. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125776. serialize(): any;
  125777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125778. protected _dumpPropertiesCode(): string;
  125779. }
  125780. }
  125781. declare module BABYLON {
  125782. /**
  125783. * Block used to normalize lerp between 2 values
  125784. */
  125785. export class NLerpBlock extends NodeMaterialBlock {
  125786. /**
  125787. * Creates a new NLerpBlock
  125788. * @param name defines the block name
  125789. */
  125790. constructor(name: string);
  125791. /**
  125792. * Gets the current class name
  125793. * @returns the class name
  125794. */
  125795. getClassName(): string;
  125796. /**
  125797. * Gets the left operand input component
  125798. */
  125799. readonly left: NodeMaterialConnectionPoint;
  125800. /**
  125801. * Gets the right operand input component
  125802. */
  125803. readonly right: NodeMaterialConnectionPoint;
  125804. /**
  125805. * Gets the gradient operand input component
  125806. */
  125807. readonly gradient: NodeMaterialConnectionPoint;
  125808. /**
  125809. * Gets the output component
  125810. */
  125811. readonly output: NodeMaterialConnectionPoint;
  125812. protected _buildBlock(state: NodeMaterialBuildState): this;
  125813. }
  125814. }
  125815. declare module BABYLON {
  125816. /**
  125817. * block used to Generate a Worley Noise 3D Noise Pattern
  125818. */
  125819. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  125820. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  125821. manhattanDistance: boolean;
  125822. /**
  125823. * Creates a new WorleyNoise3DBlock
  125824. * @param name defines the block name
  125825. */
  125826. constructor(name: string);
  125827. /**
  125828. * Gets the current class name
  125829. * @returns the class name
  125830. */
  125831. getClassName(): string;
  125832. /**
  125833. * Gets the seed input component
  125834. */
  125835. readonly seed: NodeMaterialConnectionPoint;
  125836. /**
  125837. * Gets the jitter input component
  125838. */
  125839. readonly jitter: NodeMaterialConnectionPoint;
  125840. /**
  125841. * Gets the output component
  125842. */
  125843. readonly output: NodeMaterialConnectionPoint;
  125844. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125845. /**
  125846. * Exposes the properties to the UI?
  125847. */
  125848. protected _dumpPropertiesCode(): string;
  125849. /**
  125850. * Exposes the properties to the Seralize?
  125851. */
  125852. serialize(): any;
  125853. /**
  125854. * Exposes the properties to the deseralize?
  125855. */
  125856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125857. }
  125858. }
  125859. declare module BABYLON {
  125860. /**
  125861. * block used to Generate a Simplex Perlin 3d Noise Pattern
  125862. */
  125863. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  125864. /**
  125865. * Creates a new SimplexPerlin3DBlock
  125866. * @param name defines the block name
  125867. */
  125868. constructor(name: string);
  125869. /**
  125870. * Gets the current class name
  125871. * @returns the class name
  125872. */
  125873. getClassName(): string;
  125874. /**
  125875. * Gets the seed operand input component
  125876. */
  125877. readonly seed: NodeMaterialConnectionPoint;
  125878. /**
  125879. * Gets the output component
  125880. */
  125881. readonly output: NodeMaterialConnectionPoint;
  125882. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125883. }
  125884. }
  125885. declare module BABYLON {
  125886. /**
  125887. * Block used to blend normals
  125888. */
  125889. export class NormalBlendBlock extends NodeMaterialBlock {
  125890. /**
  125891. * Creates a new NormalBlendBlock
  125892. * @param name defines the block name
  125893. */
  125894. constructor(name: string);
  125895. /**
  125896. * Gets the current class name
  125897. * @returns the class name
  125898. */
  125899. getClassName(): string;
  125900. /**
  125901. * Gets the first input component
  125902. */
  125903. readonly normalMap0: NodeMaterialConnectionPoint;
  125904. /**
  125905. * Gets the second input component
  125906. */
  125907. readonly normalMap1: NodeMaterialConnectionPoint;
  125908. /**
  125909. * Gets the output component
  125910. */
  125911. readonly output: NodeMaterialConnectionPoint;
  125912. protected _buildBlock(state: NodeMaterialBuildState): this;
  125913. }
  125914. }
  125915. declare module BABYLON {
  125916. /**
  125917. * Block used to rotate a 2d vector by a given angle
  125918. */
  125919. export class Rotate2dBlock extends NodeMaterialBlock {
  125920. /**
  125921. * Creates a new Rotate2dBlock
  125922. * @param name defines the block name
  125923. */
  125924. constructor(name: string);
  125925. /**
  125926. * Gets the current class name
  125927. * @returns the class name
  125928. */
  125929. getClassName(): string;
  125930. /**
  125931. * Gets the input vector
  125932. */
  125933. readonly input: NodeMaterialConnectionPoint;
  125934. /**
  125935. * Gets the input angle
  125936. */
  125937. readonly angle: NodeMaterialConnectionPoint;
  125938. /**
  125939. * Gets the output component
  125940. */
  125941. readonly output: NodeMaterialConnectionPoint;
  125942. autoConfigure(material: NodeMaterial): void;
  125943. protected _buildBlock(state: NodeMaterialBuildState): this;
  125944. }
  125945. }
  125946. declare module BABYLON {
  125947. /**
  125948. * Block used to get the reflected vector from a direction and a normal
  125949. */
  125950. export class ReflectBlock extends NodeMaterialBlock {
  125951. /**
  125952. * Creates a new ReflectBlock
  125953. * @param name defines the block name
  125954. */
  125955. constructor(name: string);
  125956. /**
  125957. * Gets the current class name
  125958. * @returns the class name
  125959. */
  125960. getClassName(): string;
  125961. /**
  125962. * Gets the incident component
  125963. */
  125964. readonly incident: NodeMaterialConnectionPoint;
  125965. /**
  125966. * Gets the normal component
  125967. */
  125968. readonly normal: NodeMaterialConnectionPoint;
  125969. /**
  125970. * Gets the output component
  125971. */
  125972. readonly output: NodeMaterialConnectionPoint;
  125973. protected _buildBlock(state: NodeMaterialBuildState): this;
  125974. }
  125975. }
  125976. declare module BABYLON {
  125977. /**
  125978. * Block used to get the refracted vector from a direction and a normal
  125979. */
  125980. export class RefractBlock extends NodeMaterialBlock {
  125981. /**
  125982. * Creates a new RefractBlock
  125983. * @param name defines the block name
  125984. */
  125985. constructor(name: string);
  125986. /**
  125987. * Gets the current class name
  125988. * @returns the class name
  125989. */
  125990. getClassName(): string;
  125991. /**
  125992. * Gets the incident component
  125993. */
  125994. readonly incident: NodeMaterialConnectionPoint;
  125995. /**
  125996. * Gets the normal component
  125997. */
  125998. readonly normal: NodeMaterialConnectionPoint;
  125999. /**
  126000. * Gets the index of refraction component
  126001. */
  126002. readonly ior: NodeMaterialConnectionPoint;
  126003. /**
  126004. * Gets the output component
  126005. */
  126006. readonly output: NodeMaterialConnectionPoint;
  126007. protected _buildBlock(state: NodeMaterialBuildState): this;
  126008. }
  126009. }
  126010. declare module BABYLON {
  126011. /**
  126012. * Block used to desaturate a color
  126013. */
  126014. export class DesaturateBlock extends NodeMaterialBlock {
  126015. /**
  126016. * Creates a new DesaturateBlock
  126017. * @param name defines the block name
  126018. */
  126019. constructor(name: string);
  126020. /**
  126021. * Gets the current class name
  126022. * @returns the class name
  126023. */
  126024. getClassName(): string;
  126025. /**
  126026. * Gets the color operand input component
  126027. */
  126028. readonly color: NodeMaterialConnectionPoint;
  126029. /**
  126030. * Gets the level operand input component
  126031. */
  126032. readonly level: NodeMaterialConnectionPoint;
  126033. /**
  126034. * Gets the output component
  126035. */
  126036. readonly output: NodeMaterialConnectionPoint;
  126037. protected _buildBlock(state: NodeMaterialBuildState): this;
  126038. }
  126039. }
  126040. declare module BABYLON {
  126041. /**
  126042. * Effect Render Options
  126043. */
  126044. export interface IEffectRendererOptions {
  126045. /**
  126046. * Defines the vertices positions.
  126047. */
  126048. positions?: number[];
  126049. /**
  126050. * Defines the indices.
  126051. */
  126052. indices?: number[];
  126053. }
  126054. /**
  126055. * Helper class to render one or more effects
  126056. */
  126057. export class EffectRenderer {
  126058. private engine;
  126059. private static _DefaultOptions;
  126060. private _vertexBuffers;
  126061. private _indexBuffer;
  126062. private _ringBufferIndex;
  126063. private _ringScreenBuffer;
  126064. private _fullscreenViewport;
  126065. private _getNextFrameBuffer;
  126066. /**
  126067. * Creates an effect renderer
  126068. * @param engine the engine to use for rendering
  126069. * @param options defines the options of the effect renderer
  126070. */
  126071. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  126072. /**
  126073. * Sets the current viewport in normalized coordinates 0-1
  126074. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  126075. */
  126076. setViewport(viewport?: Viewport): void;
  126077. /**
  126078. * Binds the embedded attributes buffer to the effect.
  126079. * @param effect Defines the effect to bind the attributes for
  126080. */
  126081. bindBuffers(effect: Effect): void;
  126082. /**
  126083. * Sets the current effect wrapper to use during draw.
  126084. * The effect needs to be ready before calling this api.
  126085. * This also sets the default full screen position attribute.
  126086. * @param effectWrapper Defines the effect to draw with
  126087. */
  126088. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  126089. /**
  126090. * Draws a full screen quad.
  126091. */
  126092. draw(): void;
  126093. /**
  126094. * renders one or more effects to a specified texture
  126095. * @param effectWrappers list of effects to renderer
  126096. * @param outputTexture texture to draw to, if null it will render to the screen
  126097. */
  126098. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  126099. /**
  126100. * Disposes of the effect renderer
  126101. */
  126102. dispose(): void;
  126103. }
  126104. /**
  126105. * Options to create an EffectWrapper
  126106. */
  126107. interface EffectWrapperCreationOptions {
  126108. /**
  126109. * Engine to use to create the effect
  126110. */
  126111. engine: ThinEngine;
  126112. /**
  126113. * Fragment shader for the effect
  126114. */
  126115. fragmentShader: string;
  126116. /**
  126117. * Vertex shader for the effect
  126118. */
  126119. vertexShader?: string;
  126120. /**
  126121. * Attributes to use in the shader
  126122. */
  126123. attributeNames?: Array<string>;
  126124. /**
  126125. * Uniforms to use in the shader
  126126. */
  126127. uniformNames?: Array<string>;
  126128. /**
  126129. * Texture sampler names to use in the shader
  126130. */
  126131. samplerNames?: Array<string>;
  126132. /**
  126133. * The friendly name of the effect displayed in Spector.
  126134. */
  126135. name?: string;
  126136. }
  126137. /**
  126138. * Wraps an effect to be used for rendering
  126139. */
  126140. export class EffectWrapper {
  126141. /**
  126142. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  126143. */
  126144. onApplyObservable: Observable<{}>;
  126145. /**
  126146. * The underlying effect
  126147. */
  126148. effect: Effect;
  126149. /**
  126150. * Creates an effect to be renderer
  126151. * @param creationOptions options to create the effect
  126152. */
  126153. constructor(creationOptions: EffectWrapperCreationOptions);
  126154. /**
  126155. * Disposes of the effect wrapper
  126156. */
  126157. dispose(): void;
  126158. }
  126159. }
  126160. declare module BABYLON {
  126161. /**
  126162. * Helper class to push actions to a pool of workers.
  126163. */
  126164. export class WorkerPool implements IDisposable {
  126165. private _workerInfos;
  126166. private _pendingActions;
  126167. /**
  126168. * Constructor
  126169. * @param workers Array of workers to use for actions
  126170. */
  126171. constructor(workers: Array<Worker>);
  126172. /**
  126173. * Terminates all workers and clears any pending actions.
  126174. */
  126175. dispose(): void;
  126176. /**
  126177. * Pushes an action to the worker pool. If all the workers are active, the action will be
  126178. * pended until a worker has completed its action.
  126179. * @param action The action to perform. Call onComplete when the action is complete.
  126180. */
  126181. push(action: (worker: Worker, onComplete: () => void) => void): void;
  126182. private _execute;
  126183. }
  126184. }
  126185. declare module BABYLON {
  126186. /**
  126187. * Configuration for Draco compression
  126188. */
  126189. export interface IDracoCompressionConfiguration {
  126190. /**
  126191. * Configuration for the decoder.
  126192. */
  126193. decoder: {
  126194. /**
  126195. * The url to the WebAssembly module.
  126196. */
  126197. wasmUrl?: string;
  126198. /**
  126199. * The url to the WebAssembly binary.
  126200. */
  126201. wasmBinaryUrl?: string;
  126202. /**
  126203. * The url to the fallback JavaScript module.
  126204. */
  126205. fallbackUrl?: string;
  126206. };
  126207. }
  126208. /**
  126209. * Draco compression (https://google.github.io/draco/)
  126210. *
  126211. * This class wraps the Draco module.
  126212. *
  126213. * **Encoder**
  126214. *
  126215. * The encoder is not currently implemented.
  126216. *
  126217. * **Decoder**
  126218. *
  126219. * 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.
  126220. *
  126221. * To update the configuration, use the following code:
  126222. * ```javascript
  126223. * DracoCompression.Configuration = {
  126224. * decoder: {
  126225. * wasmUrl: "<url to the WebAssembly library>",
  126226. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  126227. * fallbackUrl: "<url to the fallback JavaScript library>",
  126228. * }
  126229. * };
  126230. * ```
  126231. *
  126232. * 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.
  126233. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  126234. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  126235. *
  126236. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  126237. * ```javascript
  126238. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  126239. * ```
  126240. *
  126241. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  126242. */
  126243. export class DracoCompression implements IDisposable {
  126244. private _workerPoolPromise?;
  126245. private _decoderModulePromise?;
  126246. /**
  126247. * The configuration. Defaults to the following urls:
  126248. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  126249. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  126250. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  126251. */
  126252. static Configuration: IDracoCompressionConfiguration;
  126253. /**
  126254. * Returns true if the decoder configuration is available.
  126255. */
  126256. static readonly DecoderAvailable: boolean;
  126257. /**
  126258. * Default number of workers to create when creating the draco compression object.
  126259. */
  126260. static DefaultNumWorkers: number;
  126261. private static GetDefaultNumWorkers;
  126262. private static _Default;
  126263. /**
  126264. * Default instance for the draco compression object.
  126265. */
  126266. static readonly Default: DracoCompression;
  126267. /**
  126268. * Constructor
  126269. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  126270. */
  126271. constructor(numWorkers?: number);
  126272. /**
  126273. * Stop all async operations and release resources.
  126274. */
  126275. dispose(): void;
  126276. /**
  126277. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  126278. * @returns a promise that resolves when ready
  126279. */
  126280. whenReadyAsync(): Promise<void>;
  126281. /**
  126282. * Decode Draco compressed mesh data to vertex data.
  126283. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  126284. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  126285. * @returns A promise that resolves with the decoded vertex data
  126286. */
  126287. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  126288. [kind: string]: number;
  126289. }): Promise<VertexData>;
  126290. }
  126291. }
  126292. declare module BABYLON {
  126293. /**
  126294. * Class for building Constructive Solid Geometry
  126295. */
  126296. export class CSG {
  126297. private polygons;
  126298. /**
  126299. * The world matrix
  126300. */
  126301. matrix: Matrix;
  126302. /**
  126303. * Stores the position
  126304. */
  126305. position: Vector3;
  126306. /**
  126307. * Stores the rotation
  126308. */
  126309. rotation: Vector3;
  126310. /**
  126311. * Stores the rotation quaternion
  126312. */
  126313. rotationQuaternion: Nullable<Quaternion>;
  126314. /**
  126315. * Stores the scaling vector
  126316. */
  126317. scaling: Vector3;
  126318. /**
  126319. * Convert the Mesh to CSG
  126320. * @param mesh The Mesh to convert to CSG
  126321. * @returns A new CSG from the Mesh
  126322. */
  126323. static FromMesh(mesh: Mesh): CSG;
  126324. /**
  126325. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  126326. * @param polygons Polygons used to construct a CSG solid
  126327. */
  126328. private static FromPolygons;
  126329. /**
  126330. * Clones, or makes a deep copy, of the CSG
  126331. * @returns A new CSG
  126332. */
  126333. clone(): CSG;
  126334. /**
  126335. * Unions this CSG with another CSG
  126336. * @param csg The CSG to union against this CSG
  126337. * @returns The unioned CSG
  126338. */
  126339. union(csg: CSG): CSG;
  126340. /**
  126341. * Unions this CSG with another CSG in place
  126342. * @param csg The CSG to union against this CSG
  126343. */
  126344. unionInPlace(csg: CSG): void;
  126345. /**
  126346. * Subtracts this CSG with another CSG
  126347. * @param csg The CSG to subtract against this CSG
  126348. * @returns A new CSG
  126349. */
  126350. subtract(csg: CSG): CSG;
  126351. /**
  126352. * Subtracts this CSG with another CSG in place
  126353. * @param csg The CSG to subtact against this CSG
  126354. */
  126355. subtractInPlace(csg: CSG): void;
  126356. /**
  126357. * Intersect this CSG with another CSG
  126358. * @param csg The CSG to intersect against this CSG
  126359. * @returns A new CSG
  126360. */
  126361. intersect(csg: CSG): CSG;
  126362. /**
  126363. * Intersects this CSG with another CSG in place
  126364. * @param csg The CSG to intersect against this CSG
  126365. */
  126366. intersectInPlace(csg: CSG): void;
  126367. /**
  126368. * Return a new CSG solid with solid and empty space switched. This solid is
  126369. * not modified.
  126370. * @returns A new CSG solid with solid and empty space switched
  126371. */
  126372. inverse(): CSG;
  126373. /**
  126374. * Inverses the CSG in place
  126375. */
  126376. inverseInPlace(): void;
  126377. /**
  126378. * This is used to keep meshes transformations so they can be restored
  126379. * when we build back a Babylon Mesh
  126380. * NB : All CSG operations are performed in world coordinates
  126381. * @param csg The CSG to copy the transform attributes from
  126382. * @returns This CSG
  126383. */
  126384. copyTransformAttributes(csg: CSG): CSG;
  126385. /**
  126386. * Build Raw mesh from CSG
  126387. * Coordinates here are in world space
  126388. * @param name The name of the mesh geometry
  126389. * @param scene The Scene
  126390. * @param keepSubMeshes Specifies if the submeshes should be kept
  126391. * @returns A new Mesh
  126392. */
  126393. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126394. /**
  126395. * Build Mesh from CSG taking material and transforms into account
  126396. * @param name The name of the Mesh
  126397. * @param material The material of the Mesh
  126398. * @param scene The Scene
  126399. * @param keepSubMeshes Specifies if submeshes should be kept
  126400. * @returns The new Mesh
  126401. */
  126402. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126403. }
  126404. }
  126405. declare module BABYLON {
  126406. /**
  126407. * Class used to create a trail following a mesh
  126408. */
  126409. export class TrailMesh extends Mesh {
  126410. private _generator;
  126411. private _autoStart;
  126412. private _running;
  126413. private _diameter;
  126414. private _length;
  126415. private _sectionPolygonPointsCount;
  126416. private _sectionVectors;
  126417. private _sectionNormalVectors;
  126418. private _beforeRenderObserver;
  126419. /**
  126420. * @constructor
  126421. * @param name The value used by scene.getMeshByName() to do a lookup.
  126422. * @param generator The mesh to generate a trail.
  126423. * @param scene The scene to add this mesh to.
  126424. * @param diameter Diameter of trailing mesh. Default is 1.
  126425. * @param length Length of trailing mesh. Default is 60.
  126426. * @param autoStart Automatically start trailing mesh. Default true.
  126427. */
  126428. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  126429. /**
  126430. * "TrailMesh"
  126431. * @returns "TrailMesh"
  126432. */
  126433. getClassName(): string;
  126434. private _createMesh;
  126435. /**
  126436. * Start trailing mesh.
  126437. */
  126438. start(): void;
  126439. /**
  126440. * Stop trailing mesh.
  126441. */
  126442. stop(): void;
  126443. /**
  126444. * Update trailing mesh geometry.
  126445. */
  126446. update(): void;
  126447. /**
  126448. * Returns a new TrailMesh object.
  126449. * @param name is a string, the name given to the new mesh
  126450. * @param newGenerator use new generator object for cloned trail mesh
  126451. * @returns a new mesh
  126452. */
  126453. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  126454. /**
  126455. * Serializes this trail mesh
  126456. * @param serializationObject object to write serialization to
  126457. */
  126458. serialize(serializationObject: any): void;
  126459. /**
  126460. * Parses a serialized trail mesh
  126461. * @param parsedMesh the serialized mesh
  126462. * @param scene the scene to create the trail mesh in
  126463. * @returns the created trail mesh
  126464. */
  126465. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  126466. }
  126467. }
  126468. declare module BABYLON {
  126469. /**
  126470. * Class containing static functions to help procedurally build meshes
  126471. */
  126472. export class TiledBoxBuilder {
  126473. /**
  126474. * Creates a box mesh
  126475. * 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)
  126476. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126480. * @param name defines the name of the mesh
  126481. * @param options defines the options used to create the mesh
  126482. * @param scene defines the hosting scene
  126483. * @returns the box mesh
  126484. */
  126485. static CreateTiledBox(name: string, options: {
  126486. pattern?: number;
  126487. width?: number;
  126488. height?: number;
  126489. depth?: number;
  126490. tileSize?: number;
  126491. tileWidth?: number;
  126492. tileHeight?: number;
  126493. alignHorizontal?: number;
  126494. alignVertical?: number;
  126495. faceUV?: Vector4[];
  126496. faceColors?: Color4[];
  126497. sideOrientation?: number;
  126498. updatable?: boolean;
  126499. }, scene?: Nullable<Scene>): Mesh;
  126500. }
  126501. }
  126502. declare module BABYLON {
  126503. /**
  126504. * Class containing static functions to help procedurally build meshes
  126505. */
  126506. export class TorusKnotBuilder {
  126507. /**
  126508. * Creates a torus knot mesh
  126509. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  126510. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  126511. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  126512. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  126513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126516. * @param name defines the name of the mesh
  126517. * @param options defines the options used to create the mesh
  126518. * @param scene defines the hosting scene
  126519. * @returns the torus knot mesh
  126520. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  126521. */
  126522. static CreateTorusKnot(name: string, options: {
  126523. radius?: number;
  126524. tube?: number;
  126525. radialSegments?: number;
  126526. tubularSegments?: number;
  126527. p?: number;
  126528. q?: number;
  126529. updatable?: boolean;
  126530. sideOrientation?: number;
  126531. frontUVs?: Vector4;
  126532. backUVs?: Vector4;
  126533. }, scene: any): Mesh;
  126534. }
  126535. }
  126536. declare module BABYLON {
  126537. /**
  126538. * Polygon
  126539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  126540. */
  126541. export class Polygon {
  126542. /**
  126543. * Creates a rectangle
  126544. * @param xmin bottom X coord
  126545. * @param ymin bottom Y coord
  126546. * @param xmax top X coord
  126547. * @param ymax top Y coord
  126548. * @returns points that make the resulting rectation
  126549. */
  126550. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  126551. /**
  126552. * Creates a circle
  126553. * @param radius radius of circle
  126554. * @param cx scale in x
  126555. * @param cy scale in y
  126556. * @param numberOfSides number of sides that make up the circle
  126557. * @returns points that make the resulting circle
  126558. */
  126559. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  126560. /**
  126561. * Creates a polygon from input string
  126562. * @param input Input polygon data
  126563. * @returns the parsed points
  126564. */
  126565. static Parse(input: string): Vector2[];
  126566. /**
  126567. * Starts building a polygon from x and y coordinates
  126568. * @param x x coordinate
  126569. * @param y y coordinate
  126570. * @returns the started path2
  126571. */
  126572. static StartingAt(x: number, y: number): Path2;
  126573. }
  126574. /**
  126575. * Builds a polygon
  126576. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  126577. */
  126578. export class PolygonMeshBuilder {
  126579. private _points;
  126580. private _outlinepoints;
  126581. private _holes;
  126582. private _name;
  126583. private _scene;
  126584. private _epoints;
  126585. private _eholes;
  126586. private _addToepoint;
  126587. /**
  126588. * Babylon reference to the earcut plugin.
  126589. */
  126590. bjsEarcut: any;
  126591. /**
  126592. * Creates a PolygonMeshBuilder
  126593. * @param name name of the builder
  126594. * @param contours Path of the polygon
  126595. * @param scene scene to add to when creating the mesh
  126596. * @param earcutInjection can be used to inject your own earcut reference
  126597. */
  126598. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  126599. /**
  126600. * Adds a whole within the polygon
  126601. * @param hole Array of points defining the hole
  126602. * @returns this
  126603. */
  126604. addHole(hole: Vector2[]): PolygonMeshBuilder;
  126605. /**
  126606. * Creates the polygon
  126607. * @param updatable If the mesh should be updatable
  126608. * @param depth The depth of the mesh created
  126609. * @returns the created mesh
  126610. */
  126611. build(updatable?: boolean, depth?: number): Mesh;
  126612. /**
  126613. * Creates the polygon
  126614. * @param depth The depth of the mesh created
  126615. * @returns the created VertexData
  126616. */
  126617. buildVertexData(depth?: number): VertexData;
  126618. /**
  126619. * Adds a side to the polygon
  126620. * @param positions points that make the polygon
  126621. * @param normals normals of the polygon
  126622. * @param uvs uvs of the polygon
  126623. * @param indices indices of the polygon
  126624. * @param bounds bounds of the polygon
  126625. * @param points points of the polygon
  126626. * @param depth depth of the polygon
  126627. * @param flip flip of the polygon
  126628. */
  126629. private addSide;
  126630. }
  126631. }
  126632. declare module BABYLON {
  126633. /**
  126634. * Class containing static functions to help procedurally build meshes
  126635. */
  126636. export class PolygonBuilder {
  126637. /**
  126638. * Creates a polygon mesh
  126639. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126640. * * 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
  126641. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126644. * * Remember you can only change the shape positions, not their number when updating a polygon
  126645. * @param name defines the name of the mesh
  126646. * @param options defines the options used to create the mesh
  126647. * @param scene defines the hosting scene
  126648. * @param earcutInjection can be used to inject your own earcut reference
  126649. * @returns the polygon mesh
  126650. */
  126651. static CreatePolygon(name: string, options: {
  126652. shape: Vector3[];
  126653. holes?: Vector3[][];
  126654. depth?: number;
  126655. faceUV?: Vector4[];
  126656. faceColors?: Color4[];
  126657. updatable?: boolean;
  126658. sideOrientation?: number;
  126659. frontUVs?: Vector4;
  126660. backUVs?: Vector4;
  126661. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126662. /**
  126663. * Creates an extruded polygon mesh, with depth in the Y direction.
  126664. * * 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)
  126665. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126666. * @param name defines the name of the mesh
  126667. * @param options defines the options used to create the mesh
  126668. * @param scene defines the hosting scene
  126669. * @param earcutInjection can be used to inject your own earcut reference
  126670. * @returns the polygon mesh
  126671. */
  126672. static ExtrudePolygon(name: string, options: {
  126673. shape: Vector3[];
  126674. holes?: Vector3[][];
  126675. depth?: number;
  126676. faceUV?: Vector4[];
  126677. faceColors?: Color4[];
  126678. updatable?: boolean;
  126679. sideOrientation?: number;
  126680. frontUVs?: Vector4;
  126681. backUVs?: Vector4;
  126682. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126683. }
  126684. }
  126685. declare module BABYLON {
  126686. /**
  126687. * Class containing static functions to help procedurally build meshes
  126688. */
  126689. export class LatheBuilder {
  126690. /**
  126691. * Creates lathe mesh.
  126692. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  126693. * * 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
  126694. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  126695. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  126696. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  126697. * * 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
  126698. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  126699. * * 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
  126700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126702. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126704. * @param name defines the name of the mesh
  126705. * @param options defines the options used to create the mesh
  126706. * @param scene defines the hosting scene
  126707. * @returns the lathe mesh
  126708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  126709. */
  126710. static CreateLathe(name: string, options: {
  126711. shape: Vector3[];
  126712. radius?: number;
  126713. tessellation?: number;
  126714. clip?: number;
  126715. arc?: number;
  126716. closed?: boolean;
  126717. updatable?: boolean;
  126718. sideOrientation?: number;
  126719. frontUVs?: Vector4;
  126720. backUVs?: Vector4;
  126721. cap?: number;
  126722. invertUV?: boolean;
  126723. }, scene?: Nullable<Scene>): Mesh;
  126724. }
  126725. }
  126726. declare module BABYLON {
  126727. /**
  126728. * Class containing static functions to help procedurally build meshes
  126729. */
  126730. export class TiledPlaneBuilder {
  126731. /**
  126732. * Creates a tiled plane mesh
  126733. * * The parameter `pattern` will, depending on value, do nothing or
  126734. * * * flip (reflect about central vertical) alternate tiles across and up
  126735. * * * flip every tile on alternate rows
  126736. * * * rotate (180 degs) alternate tiles across and up
  126737. * * * rotate every tile on alternate rows
  126738. * * * flip and rotate alternate tiles across and up
  126739. * * * flip and rotate every tile on alternate rows
  126740. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  126741. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  126742. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126744. * * 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)
  126745. * * 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)
  126746. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126747. * @param name defines the name of the mesh
  126748. * @param options defines the options used to create the mesh
  126749. * @param scene defines the hosting scene
  126750. * @returns the box mesh
  126751. */
  126752. static CreateTiledPlane(name: string, options: {
  126753. pattern?: number;
  126754. tileSize?: number;
  126755. tileWidth?: number;
  126756. tileHeight?: number;
  126757. size?: number;
  126758. width?: number;
  126759. height?: number;
  126760. alignHorizontal?: number;
  126761. alignVertical?: number;
  126762. sideOrientation?: number;
  126763. frontUVs?: Vector4;
  126764. backUVs?: Vector4;
  126765. updatable?: boolean;
  126766. }, scene?: Nullable<Scene>): Mesh;
  126767. }
  126768. }
  126769. declare module BABYLON {
  126770. /**
  126771. * Class containing static functions to help procedurally build meshes
  126772. */
  126773. export class TubeBuilder {
  126774. /**
  126775. * Creates a tube mesh.
  126776. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126777. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  126778. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  126779. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  126780. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  126781. * * 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)
  126782. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  126783. * * 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
  126784. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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 tube mesh
  126793. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126794. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126795. */
  126796. static CreateTube(name: string, options: {
  126797. path: Vector3[];
  126798. radius?: number;
  126799. tessellation?: number;
  126800. radiusFunction?: {
  126801. (i: number, distance: number): number;
  126802. };
  126803. cap?: number;
  126804. arc?: number;
  126805. updatable?: boolean;
  126806. sideOrientation?: number;
  126807. frontUVs?: Vector4;
  126808. backUVs?: Vector4;
  126809. instance?: Mesh;
  126810. invertUV?: boolean;
  126811. }, scene?: Nullable<Scene>): Mesh;
  126812. }
  126813. }
  126814. declare module BABYLON {
  126815. /**
  126816. * Class containing static functions to help procedurally build meshes
  126817. */
  126818. export class IcoSphereBuilder {
  126819. /**
  126820. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126821. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126822. * * 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`)
  126823. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126824. * * 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
  126825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126828. * @param name defines the name of the mesh
  126829. * @param options defines the options used to create the mesh
  126830. * @param scene defines the hosting scene
  126831. * @returns the icosahedron mesh
  126832. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126833. */
  126834. static CreateIcoSphere(name: string, options: {
  126835. radius?: number;
  126836. radiusX?: number;
  126837. radiusY?: number;
  126838. radiusZ?: number;
  126839. flat?: boolean;
  126840. subdivisions?: number;
  126841. sideOrientation?: number;
  126842. frontUVs?: Vector4;
  126843. backUVs?: Vector4;
  126844. updatable?: boolean;
  126845. }, scene?: Nullable<Scene>): Mesh;
  126846. }
  126847. }
  126848. declare module BABYLON {
  126849. /**
  126850. * Class containing static functions to help procedurally build meshes
  126851. */
  126852. export class DecalBuilder {
  126853. /**
  126854. * Creates a decal mesh.
  126855. * 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
  126856. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126857. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126858. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126859. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126860. * @param name defines the name of the mesh
  126861. * @param sourceMesh defines the mesh where the decal must be applied
  126862. * @param options defines the options used to create the mesh
  126863. * @param scene defines the hosting scene
  126864. * @returns the decal mesh
  126865. * @see https://doc.babylonjs.com/how_to/decals
  126866. */
  126867. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126868. position?: Vector3;
  126869. normal?: Vector3;
  126870. size?: Vector3;
  126871. angle?: number;
  126872. }): Mesh;
  126873. }
  126874. }
  126875. declare module BABYLON {
  126876. /**
  126877. * Class containing static functions to help procedurally build meshes
  126878. */
  126879. export class MeshBuilder {
  126880. /**
  126881. * Creates a box mesh
  126882. * * The parameter `size` sets the size (float) of each box side (default 1)
  126883. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126884. * * 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)
  126885. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126889. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126890. * @param name defines the name of the mesh
  126891. * @param options defines the options used to create the mesh
  126892. * @param scene defines the hosting scene
  126893. * @returns the box mesh
  126894. */
  126895. static CreateBox(name: string, options: {
  126896. size?: number;
  126897. width?: number;
  126898. height?: number;
  126899. depth?: number;
  126900. faceUV?: Vector4[];
  126901. faceColors?: Color4[];
  126902. sideOrientation?: number;
  126903. frontUVs?: Vector4;
  126904. backUVs?: Vector4;
  126905. updatable?: boolean;
  126906. }, scene?: Nullable<Scene>): Mesh;
  126907. /**
  126908. * Creates a tiled box mesh
  126909. * * faceTiles sets the pattern, tile size and number of tiles for a face
  126910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126911. * @param name defines the name of the mesh
  126912. * @param options defines the options used to create the mesh
  126913. * @param scene defines the hosting scene
  126914. * @returns the tiled box mesh
  126915. */
  126916. static CreateTiledBox(name: string, options: {
  126917. pattern?: number;
  126918. size?: number;
  126919. width?: number;
  126920. height?: number;
  126921. depth: number;
  126922. tileSize?: number;
  126923. tileWidth?: number;
  126924. tileHeight?: number;
  126925. faceUV?: Vector4[];
  126926. faceColors?: Color4[];
  126927. alignHorizontal?: number;
  126928. alignVertical?: number;
  126929. sideOrientation?: number;
  126930. updatable?: boolean;
  126931. }, scene?: Nullable<Scene>): Mesh;
  126932. /**
  126933. * Creates a sphere mesh
  126934. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126935. * * 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`)
  126936. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126937. * * 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
  126938. * * 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)
  126939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126942. * @param name defines the name of the mesh
  126943. * @param options defines the options used to create the mesh
  126944. * @param scene defines the hosting scene
  126945. * @returns the sphere mesh
  126946. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126947. */
  126948. static CreateSphere(name: string, options: {
  126949. segments?: number;
  126950. diameter?: number;
  126951. diameterX?: number;
  126952. diameterY?: number;
  126953. diameterZ?: number;
  126954. arc?: number;
  126955. slice?: number;
  126956. sideOrientation?: number;
  126957. frontUVs?: Vector4;
  126958. backUVs?: Vector4;
  126959. updatable?: boolean;
  126960. }, scene?: Nullable<Scene>): Mesh;
  126961. /**
  126962. * Creates a plane polygonal mesh. By default, this is a disc
  126963. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  126964. * * 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
  126965. * * 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
  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 plane polygonal mesh
  126973. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  126974. */
  126975. static CreateDisc(name: string, options: {
  126976. radius?: number;
  126977. tessellation?: number;
  126978. arc?: number;
  126979. updatable?: boolean;
  126980. sideOrientation?: number;
  126981. frontUVs?: Vector4;
  126982. backUVs?: Vector4;
  126983. }, scene?: Nullable<Scene>): Mesh;
  126984. /**
  126985. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126986. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126987. * * 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`)
  126988. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126989. * * 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
  126990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126993. * @param name defines the name of the mesh
  126994. * @param options defines the options used to create the mesh
  126995. * @param scene defines the hosting scene
  126996. * @returns the icosahedron mesh
  126997. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126998. */
  126999. static CreateIcoSphere(name: string, options: {
  127000. radius?: number;
  127001. radiusX?: number;
  127002. radiusY?: number;
  127003. radiusZ?: number;
  127004. flat?: boolean;
  127005. subdivisions?: number;
  127006. sideOrientation?: number;
  127007. frontUVs?: Vector4;
  127008. backUVs?: Vector4;
  127009. updatable?: boolean;
  127010. }, scene?: Nullable<Scene>): Mesh;
  127011. /**
  127012. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127013. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  127014. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  127015. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  127016. * * 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
  127017. * * 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
  127018. * * 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
  127019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127021. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127022. * * 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
  127023. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  127024. * * 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
  127025. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  127026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127027. * @param name defines the name of the mesh
  127028. * @param options defines the options used to create the mesh
  127029. * @param scene defines the hosting scene
  127030. * @returns the ribbon mesh
  127031. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  127032. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127033. */
  127034. static CreateRibbon(name: string, options: {
  127035. pathArray: Vector3[][];
  127036. closeArray?: boolean;
  127037. closePath?: boolean;
  127038. offset?: number;
  127039. updatable?: boolean;
  127040. sideOrientation?: number;
  127041. frontUVs?: Vector4;
  127042. backUVs?: Vector4;
  127043. instance?: Mesh;
  127044. invertUV?: boolean;
  127045. uvs?: Vector2[];
  127046. colors?: Color4[];
  127047. }, scene?: Nullable<Scene>): Mesh;
  127048. /**
  127049. * Creates a cylinder or a cone mesh
  127050. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127051. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127052. * * 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.
  127053. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127054. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127055. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127056. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127057. * * 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).
  127058. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127059. * * 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).
  127060. * * 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
  127061. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127062. * * 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
  127063. * * 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.
  127064. * * If `enclose` is false, a ring surface is one element.
  127065. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127066. * * 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
  127067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127070. * @param name defines the name of the mesh
  127071. * @param options defines the options used to create the mesh
  127072. * @param scene defines the hosting scene
  127073. * @returns the cylinder mesh
  127074. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127075. */
  127076. static CreateCylinder(name: string, options: {
  127077. height?: number;
  127078. diameterTop?: number;
  127079. diameterBottom?: number;
  127080. diameter?: number;
  127081. tessellation?: number;
  127082. subdivisions?: number;
  127083. arc?: number;
  127084. faceColors?: Color4[];
  127085. faceUV?: Vector4[];
  127086. updatable?: boolean;
  127087. hasRings?: boolean;
  127088. enclose?: boolean;
  127089. cap?: number;
  127090. sideOrientation?: number;
  127091. frontUVs?: Vector4;
  127092. backUVs?: Vector4;
  127093. }, scene?: Nullable<Scene>): Mesh;
  127094. /**
  127095. * Creates a torus mesh
  127096. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127097. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127098. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127102. * @param name defines the name of the mesh
  127103. * @param options defines the options used to create the mesh
  127104. * @param scene defines the hosting scene
  127105. * @returns the torus mesh
  127106. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127107. */
  127108. static CreateTorus(name: string, options: {
  127109. diameter?: number;
  127110. thickness?: number;
  127111. tessellation?: number;
  127112. updatable?: boolean;
  127113. sideOrientation?: number;
  127114. frontUVs?: Vector4;
  127115. backUVs?: Vector4;
  127116. }, scene?: Nullable<Scene>): Mesh;
  127117. /**
  127118. * Creates a torus knot mesh
  127119. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  127120. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  127121. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  127122. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  127123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127126. * @param name defines the name of the mesh
  127127. * @param options defines the options used to create the mesh
  127128. * @param scene defines the hosting scene
  127129. * @returns the torus knot mesh
  127130. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  127131. */
  127132. static CreateTorusKnot(name: string, options: {
  127133. radius?: number;
  127134. tube?: number;
  127135. radialSegments?: number;
  127136. tubularSegments?: number;
  127137. p?: number;
  127138. q?: number;
  127139. updatable?: boolean;
  127140. sideOrientation?: number;
  127141. frontUVs?: Vector4;
  127142. backUVs?: Vector4;
  127143. }, scene?: Nullable<Scene>): Mesh;
  127144. /**
  127145. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127146. * * 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
  127147. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127148. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127149. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127150. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127151. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127152. * * 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
  127153. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127155. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127156. * @param name defines the name of the new line system
  127157. * @param options defines the options used to create the line system
  127158. * @param scene defines the hosting scene
  127159. * @returns a new line system mesh
  127160. */
  127161. static CreateLineSystem(name: string, options: {
  127162. lines: Vector3[][];
  127163. updatable?: boolean;
  127164. instance?: Nullable<LinesMesh>;
  127165. colors?: Nullable<Color4[][]>;
  127166. useVertexAlpha?: boolean;
  127167. }, scene: Nullable<Scene>): LinesMesh;
  127168. /**
  127169. * Creates a line mesh
  127170. * 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
  127171. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127172. * * The parameter `points` is an array successive Vector3
  127173. * * 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
  127174. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127175. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127176. * * When updating an instance, remember that only point positions can change, not the number of points
  127177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127179. * @param name defines the name of the new line system
  127180. * @param options defines the options used to create the line system
  127181. * @param scene defines the hosting scene
  127182. * @returns a new line mesh
  127183. */
  127184. static CreateLines(name: string, options: {
  127185. points: Vector3[];
  127186. updatable?: boolean;
  127187. instance?: Nullable<LinesMesh>;
  127188. colors?: Color4[];
  127189. useVertexAlpha?: boolean;
  127190. }, scene?: Nullable<Scene>): LinesMesh;
  127191. /**
  127192. * Creates a dashed line mesh
  127193. * * 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
  127194. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127195. * * The parameter `points` is an array successive Vector3
  127196. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127197. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127198. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127199. * * 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
  127200. * * When updating an instance, remember that only point positions can change, not the number of points
  127201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127202. * @param name defines the name of the mesh
  127203. * @param options defines the options used to create the mesh
  127204. * @param scene defines the hosting scene
  127205. * @returns the dashed line mesh
  127206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127207. */
  127208. static CreateDashedLines(name: string, options: {
  127209. points: Vector3[];
  127210. dashSize?: number;
  127211. gapSize?: number;
  127212. dashNb?: number;
  127213. updatable?: boolean;
  127214. instance?: LinesMesh;
  127215. }, scene?: Nullable<Scene>): LinesMesh;
  127216. /**
  127217. * 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.
  127218. * * 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.
  127219. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127220. * * 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.
  127221. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127222. * * 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
  127223. * * 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
  127224. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127227. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  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 extruded shape mesh
  127233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127235. */
  127236. static ExtrudeShape(name: string, options: {
  127237. shape: Vector3[];
  127238. path: Vector3[];
  127239. scale?: number;
  127240. rotation?: number;
  127241. cap?: number;
  127242. updatable?: boolean;
  127243. sideOrientation?: number;
  127244. frontUVs?: Vector4;
  127245. backUVs?: Vector4;
  127246. instance?: Mesh;
  127247. invertUV?: boolean;
  127248. }, scene?: Nullable<Scene>): Mesh;
  127249. /**
  127250. * Creates an custom extruded shape mesh.
  127251. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127252. * * 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.
  127253. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127254. * * 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
  127255. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127256. * * 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
  127257. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127258. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127259. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127260. * * 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
  127261. * * 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
  127262. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127265. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127267. * @param name defines the name of the mesh
  127268. * @param options defines the options used to create the mesh
  127269. * @param scene defines the hosting scene
  127270. * @returns the custom extruded shape mesh
  127271. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127272. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127274. */
  127275. static ExtrudeShapeCustom(name: string, options: {
  127276. shape: Vector3[];
  127277. path: Vector3[];
  127278. scaleFunction?: any;
  127279. rotationFunction?: any;
  127280. ribbonCloseArray?: boolean;
  127281. ribbonClosePath?: boolean;
  127282. cap?: number;
  127283. updatable?: boolean;
  127284. sideOrientation?: number;
  127285. frontUVs?: Vector4;
  127286. backUVs?: Vector4;
  127287. instance?: Mesh;
  127288. invertUV?: boolean;
  127289. }, scene?: Nullable<Scene>): Mesh;
  127290. /**
  127291. * Creates lathe mesh.
  127292. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  127293. * * 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
  127294. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  127295. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  127296. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  127297. * * 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
  127298. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  127299. * * 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
  127300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127304. * @param name defines the name of the mesh
  127305. * @param options defines the options used to create the mesh
  127306. * @param scene defines the hosting scene
  127307. * @returns the lathe mesh
  127308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  127309. */
  127310. static CreateLathe(name: string, options: {
  127311. shape: Vector3[];
  127312. radius?: number;
  127313. tessellation?: number;
  127314. clip?: number;
  127315. arc?: number;
  127316. closed?: boolean;
  127317. updatable?: boolean;
  127318. sideOrientation?: number;
  127319. frontUVs?: Vector4;
  127320. backUVs?: Vector4;
  127321. cap?: number;
  127322. invertUV?: boolean;
  127323. }, scene?: Nullable<Scene>): Mesh;
  127324. /**
  127325. * Creates a tiled plane mesh
  127326. * * You can set a limited pattern arrangement with the tiles
  127327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127330. * @param name defines the name of the mesh
  127331. * @param options defines the options used to create the mesh
  127332. * @param scene defines the hosting scene
  127333. * @returns the plane mesh
  127334. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127335. */
  127336. static CreateTiledPlane(name: string, options: {
  127337. pattern?: number;
  127338. tileSize?: number;
  127339. tileWidth?: number;
  127340. tileHeight?: number;
  127341. size?: number;
  127342. width?: number;
  127343. height?: number;
  127344. alignHorizontal?: number;
  127345. alignVertical?: number;
  127346. sideOrientation?: number;
  127347. frontUVs?: Vector4;
  127348. backUVs?: Vector4;
  127349. updatable?: boolean;
  127350. }, scene?: Nullable<Scene>): Mesh;
  127351. /**
  127352. * Creates a plane mesh
  127353. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127354. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127355. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the plane mesh
  127363. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127364. */
  127365. static CreatePlane(name: string, options: {
  127366. size?: number;
  127367. width?: number;
  127368. height?: number;
  127369. sideOrientation?: number;
  127370. frontUVs?: Vector4;
  127371. backUVs?: Vector4;
  127372. updatable?: boolean;
  127373. sourcePlane?: Plane;
  127374. }, scene?: Nullable<Scene>): Mesh;
  127375. /**
  127376. * Creates a ground mesh
  127377. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127378. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the ground mesh
  127384. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127385. */
  127386. static CreateGround(name: string, options: {
  127387. width?: number;
  127388. height?: number;
  127389. subdivisions?: number;
  127390. subdivisionsX?: number;
  127391. subdivisionsY?: number;
  127392. updatable?: boolean;
  127393. }, scene?: Nullable<Scene>): Mesh;
  127394. /**
  127395. * Creates a tiled ground mesh
  127396. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127397. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127398. * * 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
  127399. * * 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
  127400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127401. * @param name defines the name of the mesh
  127402. * @param options defines the options used to create the mesh
  127403. * @param scene defines the hosting scene
  127404. * @returns the tiled ground mesh
  127405. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127406. */
  127407. static CreateTiledGround(name: string, options: {
  127408. xmin: number;
  127409. zmin: number;
  127410. xmax: number;
  127411. zmax: number;
  127412. subdivisions?: {
  127413. w: number;
  127414. h: number;
  127415. };
  127416. precision?: {
  127417. w: number;
  127418. h: number;
  127419. };
  127420. updatable?: boolean;
  127421. }, scene?: Nullable<Scene>): Mesh;
  127422. /**
  127423. * Creates a ground mesh from a height map
  127424. * * The parameter `url` sets the URL of the height map image resource.
  127425. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127426. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127427. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127428. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127429. * * 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.
  127430. * * 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).
  127431. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127433. * @param name defines the name of the mesh
  127434. * @param url defines the url to the height map
  127435. * @param options defines the options used to create the mesh
  127436. * @param scene defines the hosting scene
  127437. * @returns the ground mesh
  127438. * @see https://doc.babylonjs.com/babylon101/height_map
  127439. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127440. */
  127441. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127442. width?: number;
  127443. height?: number;
  127444. subdivisions?: number;
  127445. minHeight?: number;
  127446. maxHeight?: number;
  127447. colorFilter?: Color3;
  127448. alphaFilter?: number;
  127449. updatable?: boolean;
  127450. onReady?: (mesh: GroundMesh) => void;
  127451. }, scene?: Nullable<Scene>): GroundMesh;
  127452. /**
  127453. * Creates a polygon mesh
  127454. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  127455. * * 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
  127456. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  127457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  127459. * * Remember you can only change the shape positions, not their number when updating a polygon
  127460. * @param name defines the name of the mesh
  127461. * @param options defines the options used to create the mesh
  127462. * @param scene defines the hosting scene
  127463. * @param earcutInjection can be used to inject your own earcut reference
  127464. * @returns the polygon mesh
  127465. */
  127466. static CreatePolygon(name: string, options: {
  127467. shape: Vector3[];
  127468. holes?: Vector3[][];
  127469. depth?: number;
  127470. faceUV?: Vector4[];
  127471. faceColors?: Color4[];
  127472. updatable?: boolean;
  127473. sideOrientation?: number;
  127474. frontUVs?: Vector4;
  127475. backUVs?: Vector4;
  127476. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127477. /**
  127478. * Creates an extruded polygon mesh, with depth in the Y direction.
  127479. * * 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)
  127480. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127481. * @param name defines the name of the mesh
  127482. * @param options defines the options used to create the mesh
  127483. * @param scene defines the hosting scene
  127484. * @param earcutInjection can be used to inject your own earcut reference
  127485. * @returns the polygon mesh
  127486. */
  127487. static ExtrudePolygon(name: string, options: {
  127488. shape: Vector3[];
  127489. holes?: Vector3[][];
  127490. depth?: number;
  127491. faceUV?: Vector4[];
  127492. faceColors?: Color4[];
  127493. updatable?: boolean;
  127494. sideOrientation?: number;
  127495. frontUVs?: Vector4;
  127496. backUVs?: Vector4;
  127497. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127498. /**
  127499. * Creates a tube mesh.
  127500. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127501. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  127502. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  127503. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  127504. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  127505. * * 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)
  127506. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  127507. * * 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
  127508. * * 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
  127509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127511. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127513. * @param name defines the name of the mesh
  127514. * @param options defines the options used to create the mesh
  127515. * @param scene defines the hosting scene
  127516. * @returns the tube mesh
  127517. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127518. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  127519. */
  127520. static CreateTube(name: string, options: {
  127521. path: Vector3[];
  127522. radius?: number;
  127523. tessellation?: number;
  127524. radiusFunction?: {
  127525. (i: number, distance: number): number;
  127526. };
  127527. cap?: number;
  127528. arc?: number;
  127529. updatable?: boolean;
  127530. sideOrientation?: number;
  127531. frontUVs?: Vector4;
  127532. backUVs?: Vector4;
  127533. instance?: Mesh;
  127534. invertUV?: boolean;
  127535. }, scene?: Nullable<Scene>): Mesh;
  127536. /**
  127537. * Creates a polyhedron mesh
  127538. * * 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
  127539. * * The parameter `size` (positive float, default 1) sets the polygon size
  127540. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  127541. * * 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`
  127542. * * 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
  127543. * * 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)`)
  127544. * * 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
  127545. * * 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
  127546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127549. * @param name defines the name of the mesh
  127550. * @param options defines the options used to create the mesh
  127551. * @param scene defines the hosting scene
  127552. * @returns the polyhedron mesh
  127553. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  127554. */
  127555. static CreatePolyhedron(name: string, options: {
  127556. type?: number;
  127557. size?: number;
  127558. sizeX?: number;
  127559. sizeY?: number;
  127560. sizeZ?: number;
  127561. custom?: any;
  127562. faceUV?: Vector4[];
  127563. faceColors?: Color4[];
  127564. flat?: boolean;
  127565. updatable?: boolean;
  127566. sideOrientation?: number;
  127567. frontUVs?: Vector4;
  127568. backUVs?: Vector4;
  127569. }, scene?: Nullable<Scene>): Mesh;
  127570. /**
  127571. * Creates a decal mesh.
  127572. * 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
  127573. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  127574. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  127575. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  127576. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  127577. * @param name defines the name of the mesh
  127578. * @param sourceMesh defines the mesh where the decal must be applied
  127579. * @param options defines the options used to create the mesh
  127580. * @param scene defines the hosting scene
  127581. * @returns the decal mesh
  127582. * @see https://doc.babylonjs.com/how_to/decals
  127583. */
  127584. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  127585. position?: Vector3;
  127586. normal?: Vector3;
  127587. size?: Vector3;
  127588. angle?: number;
  127589. }): Mesh;
  127590. }
  127591. }
  127592. declare module BABYLON {
  127593. /**
  127594. * A simplifier interface for future simplification implementations
  127595. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127596. */
  127597. export interface ISimplifier {
  127598. /**
  127599. * Simplification of a given mesh according to the given settings.
  127600. * Since this requires computation, it is assumed that the function runs async.
  127601. * @param settings The settings of the simplification, including quality and distance
  127602. * @param successCallback A callback that will be called after the mesh was simplified.
  127603. * @param errorCallback in case of an error, this callback will be called. optional.
  127604. */
  127605. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  127606. }
  127607. /**
  127608. * Expected simplification settings.
  127609. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  127610. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127611. */
  127612. export interface ISimplificationSettings {
  127613. /**
  127614. * Gets or sets the expected quality
  127615. */
  127616. quality: number;
  127617. /**
  127618. * Gets or sets the distance when this optimized version should be used
  127619. */
  127620. distance: number;
  127621. /**
  127622. * Gets an already optimized mesh
  127623. */
  127624. optimizeMesh?: boolean;
  127625. }
  127626. /**
  127627. * Class used to specify simplification options
  127628. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127629. */
  127630. export class SimplificationSettings implements ISimplificationSettings {
  127631. /** expected quality */
  127632. quality: number;
  127633. /** distance when this optimized version should be used */
  127634. distance: number;
  127635. /** already optimized mesh */
  127636. optimizeMesh?: boolean | undefined;
  127637. /**
  127638. * Creates a SimplificationSettings
  127639. * @param quality expected quality
  127640. * @param distance distance when this optimized version should be used
  127641. * @param optimizeMesh already optimized mesh
  127642. */
  127643. constructor(
  127644. /** expected quality */
  127645. quality: number,
  127646. /** distance when this optimized version should be used */
  127647. distance: number,
  127648. /** already optimized mesh */
  127649. optimizeMesh?: boolean | undefined);
  127650. }
  127651. /**
  127652. * Interface used to define a simplification task
  127653. */
  127654. export interface ISimplificationTask {
  127655. /**
  127656. * Array of settings
  127657. */
  127658. settings: Array<ISimplificationSettings>;
  127659. /**
  127660. * Simplification type
  127661. */
  127662. simplificationType: SimplificationType;
  127663. /**
  127664. * Mesh to simplify
  127665. */
  127666. mesh: Mesh;
  127667. /**
  127668. * Callback called on success
  127669. */
  127670. successCallback?: () => void;
  127671. /**
  127672. * Defines if parallel processing can be used
  127673. */
  127674. parallelProcessing: boolean;
  127675. }
  127676. /**
  127677. * Queue used to order the simplification tasks
  127678. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127679. */
  127680. export class SimplificationQueue {
  127681. private _simplificationArray;
  127682. /**
  127683. * Gets a boolean indicating that the process is still running
  127684. */
  127685. running: boolean;
  127686. /**
  127687. * Creates a new queue
  127688. */
  127689. constructor();
  127690. /**
  127691. * Adds a new simplification task
  127692. * @param task defines a task to add
  127693. */
  127694. addTask(task: ISimplificationTask): void;
  127695. /**
  127696. * Execute next task
  127697. */
  127698. executeNext(): void;
  127699. /**
  127700. * Execute a simplification task
  127701. * @param task defines the task to run
  127702. */
  127703. runSimplification(task: ISimplificationTask): void;
  127704. private getSimplifier;
  127705. }
  127706. /**
  127707. * The implemented types of simplification
  127708. * At the moment only Quadratic Error Decimation is implemented
  127709. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127710. */
  127711. export enum SimplificationType {
  127712. /** Quadratic error decimation */
  127713. QUADRATIC = 0
  127714. }
  127715. }
  127716. declare module BABYLON {
  127717. interface Scene {
  127718. /** @hidden (Backing field) */
  127719. _simplificationQueue: SimplificationQueue;
  127720. /**
  127721. * Gets or sets the simplification queue attached to the scene
  127722. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127723. */
  127724. simplificationQueue: SimplificationQueue;
  127725. }
  127726. interface Mesh {
  127727. /**
  127728. * Simplify the mesh according to the given array of settings.
  127729. * Function will return immediately and will simplify async
  127730. * @param settings a collection of simplification settings
  127731. * @param parallelProcessing should all levels calculate parallel or one after the other
  127732. * @param simplificationType the type of simplification to run
  127733. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  127734. * @returns the current mesh
  127735. */
  127736. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  127737. }
  127738. /**
  127739. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  127740. * created in a scene
  127741. */
  127742. export class SimplicationQueueSceneComponent implements ISceneComponent {
  127743. /**
  127744. * The component name helpfull to identify the component in the list of scene components.
  127745. */
  127746. readonly name: string;
  127747. /**
  127748. * The scene the component belongs to.
  127749. */
  127750. scene: Scene;
  127751. /**
  127752. * Creates a new instance of the component for the given scene
  127753. * @param scene Defines the scene to register the component in
  127754. */
  127755. constructor(scene: Scene);
  127756. /**
  127757. * Registers the component in a given scene
  127758. */
  127759. register(): void;
  127760. /**
  127761. * Rebuilds the elements related to this component in case of
  127762. * context lost for instance.
  127763. */
  127764. rebuild(): void;
  127765. /**
  127766. * Disposes the component and the associated ressources
  127767. */
  127768. dispose(): void;
  127769. private _beforeCameraUpdate;
  127770. }
  127771. }
  127772. declare module BABYLON {
  127773. /**
  127774. * Navigation plugin interface to add navigation constrained by a navigation mesh
  127775. */
  127776. export interface INavigationEnginePlugin {
  127777. /**
  127778. * plugin name
  127779. */
  127780. name: string;
  127781. /**
  127782. * Creates a navigation mesh
  127783. * @param meshes array of all the geometry used to compute the navigatio mesh
  127784. * @param parameters bunch of parameters used to filter geometry
  127785. */
  127786. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  127787. /**
  127788. * Create a navigation mesh debug mesh
  127789. * @param scene is where the mesh will be added
  127790. * @returns debug display mesh
  127791. */
  127792. createDebugNavMesh(scene: Scene): Mesh;
  127793. /**
  127794. * Get a navigation mesh constrained position, closest to the parameter position
  127795. * @param position world position
  127796. * @returns the closest point to position constrained by the navigation mesh
  127797. */
  127798. getClosestPoint(position: Vector3): Vector3;
  127799. /**
  127800. * Get a navigation mesh constrained position, within a particular radius
  127801. * @param position world position
  127802. * @param maxRadius the maximum distance to the constrained world position
  127803. * @returns the closest point to position constrained by the navigation mesh
  127804. */
  127805. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  127806. /**
  127807. * Compute the final position from a segment made of destination-position
  127808. * @param position world position
  127809. * @param destination world position
  127810. * @returns the resulting point along the navmesh
  127811. */
  127812. moveAlong(position: Vector3, destination: Vector3): Vector3;
  127813. /**
  127814. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  127815. * @param start world position
  127816. * @param end world position
  127817. * @returns array containing world position composing the path
  127818. */
  127819. computePath(start: Vector3, end: Vector3): Vector3[];
  127820. /**
  127821. * If this plugin is supported
  127822. * @returns true if plugin is supported
  127823. */
  127824. isSupported(): boolean;
  127825. /**
  127826. * Create a new Crowd so you can add agents
  127827. * @param maxAgents the maximum agent count in the crowd
  127828. * @param maxAgentRadius the maximum radius an agent can have
  127829. * @param scene to attach the crowd to
  127830. * @returns the crowd you can add agents to
  127831. */
  127832. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  127833. /**
  127834. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127835. * The queries will try to find a solution within those bounds
  127836. * default is (1,1,1)
  127837. * @param extent x,y,z value that define the extent around the queries point of reference
  127838. */
  127839. setDefaultQueryExtent(extent: Vector3): void;
  127840. /**
  127841. * Get the Bounding box extent specified by setDefaultQueryExtent
  127842. * @returns the box extent values
  127843. */
  127844. getDefaultQueryExtent(): Vector3;
  127845. /**
  127846. * Release all resources
  127847. */
  127848. dispose(): void;
  127849. }
  127850. /**
  127851. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  127852. */
  127853. export interface ICrowd {
  127854. /**
  127855. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  127856. * You can attach anything to that node. The node position is updated in the scene update tick.
  127857. * @param pos world position that will be constrained by the navigation mesh
  127858. * @param parameters agent parameters
  127859. * @param transform hooked to the agent that will be update by the scene
  127860. * @returns agent index
  127861. */
  127862. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  127863. /**
  127864. * Returns the agent position in world space
  127865. * @param index agent index returned by addAgent
  127866. * @returns world space position
  127867. */
  127868. getAgentPosition(index: number): Vector3;
  127869. /**
  127870. * Gets the agent velocity in world space
  127871. * @param index agent index returned by addAgent
  127872. * @returns world space velocity
  127873. */
  127874. getAgentVelocity(index: number): Vector3;
  127875. /**
  127876. * remove a particular agent previously created
  127877. * @param index agent index returned by addAgent
  127878. */
  127879. removeAgent(index: number): void;
  127880. /**
  127881. * get the list of all agents attached to this crowd
  127882. * @returns list of agent indices
  127883. */
  127884. getAgents(): number[];
  127885. /**
  127886. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  127887. * @param deltaTime in seconds
  127888. */
  127889. update(deltaTime: number): void;
  127890. /**
  127891. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  127892. * @param index agent index returned by addAgent
  127893. * @param destination targeted world position
  127894. */
  127895. agentGoto(index: number, destination: Vector3): void;
  127896. /**
  127897. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127898. * The queries will try to find a solution within those bounds
  127899. * default is (1,1,1)
  127900. * @param extent x,y,z value that define the extent around the queries point of reference
  127901. */
  127902. setDefaultQueryExtent(extent: Vector3): void;
  127903. /**
  127904. * Get the Bounding box extent specified by setDefaultQueryExtent
  127905. * @returns the box extent values
  127906. */
  127907. getDefaultQueryExtent(): Vector3;
  127908. /**
  127909. * Release all resources
  127910. */
  127911. dispose(): void;
  127912. }
  127913. /**
  127914. * Configures an agent
  127915. */
  127916. export interface IAgentParameters {
  127917. /**
  127918. * Agent radius. [Limit: >= 0]
  127919. */
  127920. radius: number;
  127921. /**
  127922. * Agent height. [Limit: > 0]
  127923. */
  127924. height: number;
  127925. /**
  127926. * Maximum allowed acceleration. [Limit: >= 0]
  127927. */
  127928. maxAcceleration: number;
  127929. /**
  127930. * Maximum allowed speed. [Limit: >= 0]
  127931. */
  127932. maxSpeed: number;
  127933. /**
  127934. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  127935. */
  127936. collisionQueryRange: number;
  127937. /**
  127938. * The path visibility optimization range. [Limit: > 0]
  127939. */
  127940. pathOptimizationRange: number;
  127941. /**
  127942. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  127943. */
  127944. separationWeight: number;
  127945. }
  127946. /**
  127947. * Configures the navigation mesh creation
  127948. */
  127949. export interface INavMeshParameters {
  127950. /**
  127951. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  127952. */
  127953. cs: number;
  127954. /**
  127955. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  127956. */
  127957. ch: number;
  127958. /**
  127959. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  127960. */
  127961. walkableSlopeAngle: number;
  127962. /**
  127963. * Minimum floor to 'ceiling' height that will still allow the floor area to
  127964. * be considered walkable. [Limit: >= 3] [Units: vx]
  127965. */
  127966. walkableHeight: number;
  127967. /**
  127968. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  127969. */
  127970. walkableClimb: number;
  127971. /**
  127972. * The distance to erode/shrink the walkable area of the heightfield away from
  127973. * obstructions. [Limit: >=0] [Units: vx]
  127974. */
  127975. walkableRadius: number;
  127976. /**
  127977. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  127978. */
  127979. maxEdgeLen: number;
  127980. /**
  127981. * The maximum distance a simplfied contour's border edges should deviate
  127982. * the original raw contour. [Limit: >=0] [Units: vx]
  127983. */
  127984. maxSimplificationError: number;
  127985. /**
  127986. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  127987. */
  127988. minRegionArea: number;
  127989. /**
  127990. * Any regions with a span count smaller than this value will, if possible,
  127991. * be merged with larger regions. [Limit: >=0] [Units: vx]
  127992. */
  127993. mergeRegionArea: number;
  127994. /**
  127995. * The maximum number of vertices allowed for polygons generated during the
  127996. * contour to polygon conversion process. [Limit: >= 3]
  127997. */
  127998. maxVertsPerPoly: number;
  127999. /**
  128000. * Sets the sampling distance to use when generating the detail mesh.
  128001. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  128002. */
  128003. detailSampleDist: number;
  128004. /**
  128005. * The maximum distance the detail mesh surface should deviate from heightfield
  128006. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  128007. */
  128008. detailSampleMaxError: number;
  128009. }
  128010. }
  128011. declare module BABYLON {
  128012. /**
  128013. * RecastJS navigation plugin
  128014. */
  128015. export class RecastJSPlugin implements INavigationEnginePlugin {
  128016. /**
  128017. * Reference to the Recast library
  128018. */
  128019. bjsRECAST: any;
  128020. /**
  128021. * plugin name
  128022. */
  128023. name: string;
  128024. /**
  128025. * the first navmesh created. We might extend this to support multiple navmeshes
  128026. */
  128027. navMesh: any;
  128028. /**
  128029. * Initializes the recastJS plugin
  128030. * @param recastInjection can be used to inject your own recast reference
  128031. */
  128032. constructor(recastInjection?: any);
  128033. /**
  128034. * Creates a navigation mesh
  128035. * @param meshes array of all the geometry used to compute the navigatio mesh
  128036. * @param parameters bunch of parameters used to filter geometry
  128037. */
  128038. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  128039. /**
  128040. * Create a navigation mesh debug mesh
  128041. * @param scene is where the mesh will be added
  128042. * @returns debug display mesh
  128043. */
  128044. createDebugNavMesh(scene: Scene): Mesh;
  128045. /**
  128046. * Get a navigation mesh constrained position, closest to the parameter position
  128047. * @param position world position
  128048. * @returns the closest point to position constrained by the navigation mesh
  128049. */
  128050. getClosestPoint(position: Vector3): Vector3;
  128051. /**
  128052. * Get a navigation mesh constrained position, within a particular radius
  128053. * @param position world position
  128054. * @param maxRadius the maximum distance to the constrained world position
  128055. * @returns the closest point to position constrained by the navigation mesh
  128056. */
  128057. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  128058. /**
  128059. * Compute the final position from a segment made of destination-position
  128060. * @param position world position
  128061. * @param destination world position
  128062. * @returns the resulting point along the navmesh
  128063. */
  128064. moveAlong(position: Vector3, destination: Vector3): Vector3;
  128065. /**
  128066. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  128067. * @param start world position
  128068. * @param end world position
  128069. * @returns array containing world position composing the path
  128070. */
  128071. computePath(start: Vector3, end: Vector3): Vector3[];
  128072. /**
  128073. * Create a new Crowd so you can add agents
  128074. * @param maxAgents the maximum agent count in the crowd
  128075. * @param maxAgentRadius the maximum radius an agent can have
  128076. * @param scene to attach the crowd to
  128077. * @returns the crowd you can add agents to
  128078. */
  128079. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  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. * Disposes
  128094. */
  128095. dispose(): void;
  128096. /**
  128097. * If this plugin is supported
  128098. * @returns true if plugin is supported
  128099. */
  128100. isSupported(): boolean;
  128101. }
  128102. /**
  128103. * Recast detour crowd implementation
  128104. */
  128105. export class RecastJSCrowd implements ICrowd {
  128106. /**
  128107. * Recast/detour plugin
  128108. */
  128109. bjsRECASTPlugin: RecastJSPlugin;
  128110. /**
  128111. * Link to the detour crowd
  128112. */
  128113. recastCrowd: any;
  128114. /**
  128115. * One transform per agent
  128116. */
  128117. transforms: TransformNode[];
  128118. /**
  128119. * All agents created
  128120. */
  128121. agents: number[];
  128122. /**
  128123. * Link to the scene is kept to unregister the crowd from the scene
  128124. */
  128125. private _scene;
  128126. /**
  128127. * Observer for crowd updates
  128128. */
  128129. private _onBeforeAnimationsObserver;
  128130. /**
  128131. * Constructor
  128132. * @param plugin recastJS plugin
  128133. * @param maxAgents the maximum agent count in the crowd
  128134. * @param maxAgentRadius the maximum radius an agent can have
  128135. * @param scene to attach the crowd to
  128136. * @returns the crowd you can add agents to
  128137. */
  128138. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  128139. /**
  128140. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  128141. * You can attach anything to that node. The node position is updated in the scene update tick.
  128142. * @param pos world position that will be constrained by the navigation mesh
  128143. * @param parameters agent parameters
  128144. * @param transform hooked to the agent that will be update by the scene
  128145. * @returns agent index
  128146. */
  128147. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  128148. /**
  128149. * Returns the agent position in world space
  128150. * @param index agent index returned by addAgent
  128151. * @returns world space position
  128152. */
  128153. getAgentPosition(index: number): Vector3;
  128154. /**
  128155. * Returns the agent velocity in world space
  128156. * @param index agent index returned by addAgent
  128157. * @returns world space velocity
  128158. */
  128159. getAgentVelocity(index: number): Vector3;
  128160. /**
  128161. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  128162. * @param index agent index returned by addAgent
  128163. * @param destination targeted world position
  128164. */
  128165. agentGoto(index: number, destination: Vector3): void;
  128166. /**
  128167. * remove a particular agent previously created
  128168. * @param index agent index returned by addAgent
  128169. */
  128170. removeAgent(index: number): void;
  128171. /**
  128172. * get the list of all agents attached to this crowd
  128173. * @returns list of agent indices
  128174. */
  128175. getAgents(): number[];
  128176. /**
  128177. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  128178. * @param deltaTime in seconds
  128179. */
  128180. update(deltaTime: number): void;
  128181. /**
  128182. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128183. * The queries will try to find a solution within those bounds
  128184. * default is (1,1,1)
  128185. * @param extent x,y,z value that define the extent around the queries point of reference
  128186. */
  128187. setDefaultQueryExtent(extent: Vector3): void;
  128188. /**
  128189. * Get the Bounding box extent specified by setDefaultQueryExtent
  128190. * @returns the box extent values
  128191. */
  128192. getDefaultQueryExtent(): Vector3;
  128193. /**
  128194. * Release all resources
  128195. */
  128196. dispose(): void;
  128197. }
  128198. }
  128199. declare module BABYLON {
  128200. /**
  128201. * Class used to enable access to IndexedDB
  128202. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  128203. */
  128204. export class Database implements IOfflineProvider {
  128205. private _callbackManifestChecked;
  128206. private _currentSceneUrl;
  128207. private _db;
  128208. private _enableSceneOffline;
  128209. private _enableTexturesOffline;
  128210. private _manifestVersionFound;
  128211. private _mustUpdateRessources;
  128212. private _hasReachedQuota;
  128213. private _isSupported;
  128214. private _idbFactory;
  128215. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  128216. private static IsUASupportingBlobStorage;
  128217. /**
  128218. * Gets a boolean indicating if Database storate is enabled (off by default)
  128219. */
  128220. static IDBStorageEnabled: boolean;
  128221. /**
  128222. * Gets a boolean indicating if scene must be saved in the database
  128223. */
  128224. readonly enableSceneOffline: boolean;
  128225. /**
  128226. * Gets a boolean indicating if textures must be saved in the database
  128227. */
  128228. readonly enableTexturesOffline: boolean;
  128229. /**
  128230. * Creates a new Database
  128231. * @param urlToScene defines the url to load the scene
  128232. * @param callbackManifestChecked defines the callback to use when manifest is checked
  128233. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  128234. */
  128235. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  128236. private static _ParseURL;
  128237. private static _ReturnFullUrlLocation;
  128238. private _checkManifestFile;
  128239. /**
  128240. * Open the database and make it available
  128241. * @param successCallback defines the callback to call on success
  128242. * @param errorCallback defines the callback to call on error
  128243. */
  128244. open(successCallback: () => void, errorCallback: () => void): void;
  128245. /**
  128246. * Loads an image from the database
  128247. * @param url defines the url to load from
  128248. * @param image defines the target DOM image
  128249. */
  128250. loadImage(url: string, image: HTMLImageElement): void;
  128251. private _loadImageFromDBAsync;
  128252. private _saveImageIntoDBAsync;
  128253. private _checkVersionFromDB;
  128254. private _loadVersionFromDBAsync;
  128255. private _saveVersionIntoDBAsync;
  128256. /**
  128257. * Loads a file from database
  128258. * @param url defines the URL to load from
  128259. * @param sceneLoaded defines a callback to call on success
  128260. * @param progressCallBack defines a callback to call when progress changed
  128261. * @param errorCallback defines a callback to call on error
  128262. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  128263. */
  128264. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  128265. private _loadFileAsync;
  128266. private _saveFileAsync;
  128267. /**
  128268. * Validates if xhr data is correct
  128269. * @param xhr defines the request to validate
  128270. * @param dataType defines the expected data type
  128271. * @returns true if data is correct
  128272. */
  128273. private static _ValidateXHRData;
  128274. }
  128275. }
  128276. declare module BABYLON {
  128277. /** @hidden */
  128278. export var gpuUpdateParticlesPixelShader: {
  128279. name: string;
  128280. shader: string;
  128281. };
  128282. }
  128283. declare module BABYLON {
  128284. /** @hidden */
  128285. export var gpuUpdateParticlesVertexShader: {
  128286. name: string;
  128287. shader: string;
  128288. };
  128289. }
  128290. declare module BABYLON {
  128291. /** @hidden */
  128292. export var clipPlaneFragmentDeclaration2: {
  128293. name: string;
  128294. shader: string;
  128295. };
  128296. }
  128297. declare module BABYLON {
  128298. /** @hidden */
  128299. export var gpuRenderParticlesPixelShader: {
  128300. name: string;
  128301. shader: string;
  128302. };
  128303. }
  128304. declare module BABYLON {
  128305. /** @hidden */
  128306. export var clipPlaneVertexDeclaration2: {
  128307. name: string;
  128308. shader: string;
  128309. };
  128310. }
  128311. declare module BABYLON {
  128312. /** @hidden */
  128313. export var gpuRenderParticlesVertexShader: {
  128314. name: string;
  128315. shader: string;
  128316. };
  128317. }
  128318. declare module BABYLON {
  128319. /**
  128320. * This represents a GPU particle system in Babylon
  128321. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  128322. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  128323. */
  128324. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  128325. /**
  128326. * The layer mask we are rendering the particles through.
  128327. */
  128328. layerMask: number;
  128329. private _capacity;
  128330. private _activeCount;
  128331. private _currentActiveCount;
  128332. private _accumulatedCount;
  128333. private _renderEffect;
  128334. private _updateEffect;
  128335. private _buffer0;
  128336. private _buffer1;
  128337. private _spriteBuffer;
  128338. private _updateVAO;
  128339. private _renderVAO;
  128340. private _targetIndex;
  128341. private _sourceBuffer;
  128342. private _targetBuffer;
  128343. private _engine;
  128344. private _currentRenderId;
  128345. private _started;
  128346. private _stopped;
  128347. private _timeDelta;
  128348. private _randomTexture;
  128349. private _randomTexture2;
  128350. private _attributesStrideSize;
  128351. private _updateEffectOptions;
  128352. private _randomTextureSize;
  128353. private _actualFrame;
  128354. private readonly _rawTextureWidth;
  128355. /**
  128356. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  128357. */
  128358. static readonly IsSupported: boolean;
  128359. /**
  128360. * An event triggered when the system is disposed.
  128361. */
  128362. onDisposeObservable: Observable<GPUParticleSystem>;
  128363. /**
  128364. * Gets the maximum number of particles active at the same time.
  128365. * @returns The max number of active particles.
  128366. */
  128367. getCapacity(): number;
  128368. /**
  128369. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  128370. * to override the particles.
  128371. */
  128372. forceDepthWrite: boolean;
  128373. /**
  128374. * Gets or set the number of active particles
  128375. */
  128376. activeParticleCount: number;
  128377. private _preWarmDone;
  128378. /**
  128379. * Is this system ready to be used/rendered
  128380. * @return true if the system is ready
  128381. */
  128382. isReady(): boolean;
  128383. /**
  128384. * Gets if the system has been started. (Note: this will still be true after stop is called)
  128385. * @returns True if it has been started, otherwise false.
  128386. */
  128387. isStarted(): boolean;
  128388. /**
  128389. * Starts the particle system and begins to emit
  128390. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  128391. */
  128392. start(delay?: number): void;
  128393. /**
  128394. * Stops the particle system.
  128395. */
  128396. stop(): void;
  128397. /**
  128398. * Remove all active particles
  128399. */
  128400. reset(): void;
  128401. /**
  128402. * Returns the string "GPUParticleSystem"
  128403. * @returns a string containing the class name
  128404. */
  128405. getClassName(): string;
  128406. private _colorGradientsTexture;
  128407. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  128408. /**
  128409. * Adds a new color gradient
  128410. * @param gradient defines the gradient to use (between 0 and 1)
  128411. * @param color1 defines the color to affect to the specified gradient
  128412. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  128413. * @returns the current particle system
  128414. */
  128415. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  128416. /**
  128417. * Remove a specific color gradient
  128418. * @param gradient defines the gradient to remove
  128419. * @returns the current particle system
  128420. */
  128421. removeColorGradient(gradient: number): GPUParticleSystem;
  128422. private _angularSpeedGradientsTexture;
  128423. private _sizeGradientsTexture;
  128424. private _velocityGradientsTexture;
  128425. private _limitVelocityGradientsTexture;
  128426. private _dragGradientsTexture;
  128427. private _addFactorGradient;
  128428. /**
  128429. * Adds a new size gradient
  128430. * @param gradient defines the gradient to use (between 0 and 1)
  128431. * @param factor defines the size factor to affect to the specified gradient
  128432. * @returns the current particle system
  128433. */
  128434. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  128435. /**
  128436. * Remove a specific size gradient
  128437. * @param gradient defines the gradient to remove
  128438. * @returns the current particle system
  128439. */
  128440. removeSizeGradient(gradient: number): GPUParticleSystem;
  128441. /**
  128442. * Adds a new angular speed gradient
  128443. * @param gradient defines the gradient to use (between 0 and 1)
  128444. * @param factor defines the angular speed to affect to the specified gradient
  128445. * @returns the current particle system
  128446. */
  128447. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  128448. /**
  128449. * Remove a specific angular speed gradient
  128450. * @param gradient defines the gradient to remove
  128451. * @returns the current particle system
  128452. */
  128453. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  128454. /**
  128455. * Adds a new velocity gradient
  128456. * @param gradient defines the gradient to use (between 0 and 1)
  128457. * @param factor defines the velocity to affect to the specified gradient
  128458. * @returns the current particle system
  128459. */
  128460. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128461. /**
  128462. * Remove a specific velocity gradient
  128463. * @param gradient defines the gradient to remove
  128464. * @returns the current particle system
  128465. */
  128466. removeVelocityGradient(gradient: number): GPUParticleSystem;
  128467. /**
  128468. * Adds a new limit velocity gradient
  128469. * @param gradient defines the gradient to use (between 0 and 1)
  128470. * @param factor defines the limit velocity value to affect to the specified gradient
  128471. * @returns the current particle system
  128472. */
  128473. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128474. /**
  128475. * Remove a specific limit velocity gradient
  128476. * @param gradient defines the gradient to remove
  128477. * @returns the current particle system
  128478. */
  128479. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  128480. /**
  128481. * Adds a new drag gradient
  128482. * @param gradient defines the gradient to use (between 0 and 1)
  128483. * @param factor defines the drag value to affect to the specified gradient
  128484. * @returns the current particle system
  128485. */
  128486. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  128487. /**
  128488. * Remove a specific drag gradient
  128489. * @param gradient defines the gradient to remove
  128490. * @returns the current particle system
  128491. */
  128492. removeDragGradient(gradient: number): GPUParticleSystem;
  128493. /**
  128494. * Not supported by GPUParticleSystem
  128495. * @param gradient defines the gradient to use (between 0 and 1)
  128496. * @param factor defines the emit rate value to affect to the specified gradient
  128497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128498. * @returns the current particle system
  128499. */
  128500. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128501. /**
  128502. * Not supported by GPUParticleSystem
  128503. * @param gradient defines the gradient to remove
  128504. * @returns the current particle system
  128505. */
  128506. removeEmitRateGradient(gradient: number): IParticleSystem;
  128507. /**
  128508. * Not supported by GPUParticleSystem
  128509. * @param gradient defines the gradient to use (between 0 and 1)
  128510. * @param factor defines the start size value to affect to the specified gradient
  128511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128512. * @returns the current particle system
  128513. */
  128514. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128515. /**
  128516. * Not supported by GPUParticleSystem
  128517. * @param gradient defines the gradient to remove
  128518. * @returns the current particle system
  128519. */
  128520. removeStartSizeGradient(gradient: number): IParticleSystem;
  128521. /**
  128522. * Not supported by GPUParticleSystem
  128523. * @param gradient defines the gradient to use (between 0 and 1)
  128524. * @param min defines the color remap minimal range
  128525. * @param max defines the color remap maximal range
  128526. * @returns the current particle system
  128527. */
  128528. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128529. /**
  128530. * Not supported by GPUParticleSystem
  128531. * @param gradient defines the gradient to remove
  128532. * @returns the current particle system
  128533. */
  128534. removeColorRemapGradient(): IParticleSystem;
  128535. /**
  128536. * Not supported by GPUParticleSystem
  128537. * @param gradient defines the gradient to use (between 0 and 1)
  128538. * @param min defines the alpha remap minimal range
  128539. * @param max defines the alpha remap maximal range
  128540. * @returns the current particle system
  128541. */
  128542. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128543. /**
  128544. * Not supported by GPUParticleSystem
  128545. * @param gradient defines the gradient to remove
  128546. * @returns the current particle system
  128547. */
  128548. removeAlphaRemapGradient(): IParticleSystem;
  128549. /**
  128550. * Not supported by GPUParticleSystem
  128551. * @param gradient defines the gradient to use (between 0 and 1)
  128552. * @param color defines the color to affect to the specified gradient
  128553. * @returns the current particle system
  128554. */
  128555. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  128556. /**
  128557. * Not supported by GPUParticleSystem
  128558. * @param gradient defines the gradient to remove
  128559. * @returns the current particle system
  128560. */
  128561. removeRampGradient(): IParticleSystem;
  128562. /**
  128563. * Not supported by GPUParticleSystem
  128564. * @returns the list of ramp gradients
  128565. */
  128566. getRampGradients(): Nullable<Array<Color3Gradient>>;
  128567. /**
  128568. * Not supported by GPUParticleSystem
  128569. * Gets or sets a boolean indicating that ramp gradients must be used
  128570. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  128571. */
  128572. useRampGradients: boolean;
  128573. /**
  128574. * Not supported by GPUParticleSystem
  128575. * @param gradient defines the gradient to use (between 0 and 1)
  128576. * @param factor defines the life time factor to affect to the specified gradient
  128577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128578. * @returns the current particle system
  128579. */
  128580. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128581. /**
  128582. * Not supported by GPUParticleSystem
  128583. * @param gradient defines the gradient to remove
  128584. * @returns the current particle system
  128585. */
  128586. removeLifeTimeGradient(gradient: number): IParticleSystem;
  128587. /**
  128588. * Instantiates a GPU particle system.
  128589. * 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.
  128590. * @param name The name of the particle system
  128591. * @param options The options used to create the system
  128592. * @param scene The scene the particle system belongs to
  128593. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  128594. */
  128595. constructor(name: string, options: Partial<{
  128596. capacity: number;
  128597. randomTextureSize: number;
  128598. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  128599. protected _reset(): void;
  128600. private _createUpdateVAO;
  128601. private _createRenderVAO;
  128602. private _initialize;
  128603. /** @hidden */
  128604. _recreateUpdateEffect(): void;
  128605. /** @hidden */
  128606. _recreateRenderEffect(): void;
  128607. /**
  128608. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  128609. * @param preWarm defines if we are in the pre-warmimg phase
  128610. */
  128611. animate(preWarm?: boolean): void;
  128612. private _createFactorGradientTexture;
  128613. private _createSizeGradientTexture;
  128614. private _createAngularSpeedGradientTexture;
  128615. private _createVelocityGradientTexture;
  128616. private _createLimitVelocityGradientTexture;
  128617. private _createDragGradientTexture;
  128618. private _createColorGradientTexture;
  128619. /**
  128620. * Renders the particle system in its current state
  128621. * @param preWarm defines if the system should only update the particles but not render them
  128622. * @returns the current number of particles
  128623. */
  128624. render(preWarm?: boolean): number;
  128625. /**
  128626. * Rebuilds the particle system
  128627. */
  128628. rebuild(): void;
  128629. private _releaseBuffers;
  128630. private _releaseVAOs;
  128631. /**
  128632. * Disposes the particle system and free the associated resources
  128633. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  128634. */
  128635. dispose(disposeTexture?: boolean): void;
  128636. /**
  128637. * Clones the particle system.
  128638. * @param name The name of the cloned object
  128639. * @param newEmitter The new emitter to use
  128640. * @returns the cloned particle system
  128641. */
  128642. clone(name: string, newEmitter: any): GPUParticleSystem;
  128643. /**
  128644. * Serializes the particle system to a JSON object.
  128645. * @returns the JSON object
  128646. */
  128647. serialize(): any;
  128648. /**
  128649. * Parses a JSON object to create a GPU particle system.
  128650. * @param parsedParticleSystem The JSON object to parse
  128651. * @param scene The scene to create the particle system in
  128652. * @param rootUrl The root url to use to load external dependencies like texture
  128653. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  128654. * @returns the parsed GPU particle system
  128655. */
  128656. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  128657. }
  128658. }
  128659. declare module BABYLON {
  128660. /**
  128661. * Represents a set of particle systems working together to create a specific effect
  128662. */
  128663. export class ParticleSystemSet implements IDisposable {
  128664. /**
  128665. * Gets or sets base Assets URL
  128666. */
  128667. static BaseAssetsUrl: string;
  128668. private _emitterCreationOptions;
  128669. private _emitterNode;
  128670. /**
  128671. * Gets the particle system list
  128672. */
  128673. systems: IParticleSystem[];
  128674. /**
  128675. * Gets the emitter node used with this set
  128676. */
  128677. readonly emitterNode: Nullable<TransformNode>;
  128678. /**
  128679. * Creates a new emitter mesh as a sphere
  128680. * @param options defines the options used to create the sphere
  128681. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  128682. * @param scene defines the hosting scene
  128683. */
  128684. setEmitterAsSphere(options: {
  128685. diameter: number;
  128686. segments: number;
  128687. color: Color3;
  128688. }, renderingGroupId: number, scene: Scene): void;
  128689. /**
  128690. * Starts all particle systems of the set
  128691. * @param emitter defines an optional mesh to use as emitter for the particle systems
  128692. */
  128693. start(emitter?: AbstractMesh): void;
  128694. /**
  128695. * Release all associated resources
  128696. */
  128697. dispose(): void;
  128698. /**
  128699. * Serialize the set into a JSON compatible object
  128700. * @returns a JSON compatible representation of the set
  128701. */
  128702. serialize(): any;
  128703. /**
  128704. * Parse a new ParticleSystemSet from a serialized source
  128705. * @param data defines a JSON compatible representation of the set
  128706. * @param scene defines the hosting scene
  128707. * @param gpu defines if we want GPU particles or CPU particles
  128708. * @returns a new ParticleSystemSet
  128709. */
  128710. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  128711. }
  128712. }
  128713. declare module BABYLON {
  128714. /**
  128715. * This class is made for on one-liner static method to help creating particle system set.
  128716. */
  128717. export class ParticleHelper {
  128718. /**
  128719. * Gets or sets base Assets URL
  128720. */
  128721. static BaseAssetsUrl: string;
  128722. /**
  128723. * Create a default particle system that you can tweak
  128724. * @param emitter defines the emitter to use
  128725. * @param capacity defines the system capacity (default is 500 particles)
  128726. * @param scene defines the hosting scene
  128727. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  128728. * @returns the new Particle system
  128729. */
  128730. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  128731. /**
  128732. * This is the main static method (one-liner) of this helper to create different particle systems
  128733. * @param type This string represents the type to the particle system to create
  128734. * @param scene The scene where the particle system should live
  128735. * @param gpu If the system will use gpu
  128736. * @returns the ParticleSystemSet created
  128737. */
  128738. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  128739. /**
  128740. * Static function used to export a particle system to a ParticleSystemSet variable.
  128741. * Please note that the emitter shape is not exported
  128742. * @param systems defines the particle systems to export
  128743. * @returns the created particle system set
  128744. */
  128745. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  128746. }
  128747. }
  128748. declare module BABYLON {
  128749. interface Engine {
  128750. /**
  128751. * Create an effect to use with particle systems.
  128752. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  128753. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  128754. * @param uniformsNames defines a list of attribute names
  128755. * @param samplers defines an array of string used to represent textures
  128756. * @param defines defines the string containing the defines to use to compile the shaders
  128757. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  128758. * @param onCompiled defines a function to call when the effect creation is successful
  128759. * @param onError defines a function to call when the effect creation has failed
  128760. * @returns the new Effect
  128761. */
  128762. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  128763. }
  128764. interface Mesh {
  128765. /**
  128766. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  128767. * @returns an array of IParticleSystem
  128768. */
  128769. getEmittedParticleSystems(): IParticleSystem[];
  128770. /**
  128771. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  128772. * @returns an array of IParticleSystem
  128773. */
  128774. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  128775. }
  128776. /**
  128777. * @hidden
  128778. */
  128779. export var _IDoNeedToBeInTheBuild: number;
  128780. }
  128781. declare module BABYLON {
  128782. /** Defines the 4 color options */
  128783. export enum PointColor {
  128784. /** color value */
  128785. Color = 2,
  128786. /** uv value */
  128787. UV = 1,
  128788. /** random value */
  128789. Random = 0,
  128790. /** stated value */
  128791. Stated = 3
  128792. }
  128793. /**
  128794. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  128795. * 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.
  128796. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  128797. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  128798. *
  128799. * Full documentation here : TO BE ENTERED
  128800. */
  128801. export class PointsCloudSystem implements IDisposable {
  128802. /**
  128803. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  128804. * Example : var p = SPS.particles[i];
  128805. */
  128806. particles: CloudPoint[];
  128807. /**
  128808. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  128809. */
  128810. nbParticles: number;
  128811. /**
  128812. * This a counter for your own usage. It's not set by any SPS functions.
  128813. */
  128814. counter: number;
  128815. /**
  128816. * The PCS name. This name is also given to the underlying mesh.
  128817. */
  128818. name: string;
  128819. /**
  128820. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  128821. */
  128822. mesh: Mesh;
  128823. /**
  128824. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  128825. * Please read :
  128826. */
  128827. vars: any;
  128828. /**
  128829. * @hidden
  128830. */
  128831. _size: number;
  128832. private _scene;
  128833. private _promises;
  128834. private _positions;
  128835. private _indices;
  128836. private _normals;
  128837. private _colors;
  128838. private _uvs;
  128839. private _indices32;
  128840. private _positions32;
  128841. private _colors32;
  128842. private _uvs32;
  128843. private _updatable;
  128844. private _isVisibilityBoxLocked;
  128845. private _alwaysVisible;
  128846. private _groups;
  128847. private _groupCounter;
  128848. private _computeParticleColor;
  128849. private _computeParticleTexture;
  128850. private _computeParticleRotation;
  128851. private _computeBoundingBox;
  128852. private _isReady;
  128853. /**
  128854. * Creates a PCS (Points Cloud System) object
  128855. * @param name (String) is the PCS name, this will be the underlying mesh name
  128856. * @param pointSize (number) is the size for each point
  128857. * @param scene (Scene) is the scene in which the PCS is added
  128858. * @param options defines the options of the PCS e.g.
  128859. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  128860. */
  128861. constructor(name: string, pointSize: number, scene: Scene, options?: {
  128862. updatable?: boolean;
  128863. });
  128864. /**
  128865. * Builds the PCS underlying mesh. Returns a standard Mesh.
  128866. * If no points were added to the PCS, the returned mesh is just a single point.
  128867. * @returns a promise for the created mesh
  128868. */
  128869. buildMeshAsync(): Promise<Mesh>;
  128870. /**
  128871. * @hidden
  128872. */
  128873. private _buildMesh;
  128874. private _addParticle;
  128875. private _randomUnitVector;
  128876. private _getColorIndicesForCoord;
  128877. private _setPointsColorOrUV;
  128878. private _colorFromTexture;
  128879. private _calculateDensity;
  128880. /**
  128881. * Adds points to the PCS in random positions within a unit sphere
  128882. * @param nb (positive integer) the number of particles to be created from this model
  128883. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  128884. * @returns the number of groups in the system
  128885. */
  128886. addPoints(nb: number, pointFunction?: any): number;
  128887. /**
  128888. * Adds points to the PCS from the surface of the model shape
  128889. * @param mesh is any Mesh object that will be used as a surface model for the points
  128890. * @param nb (positive integer) the number of particles to be created from this model
  128891. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128892. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128893. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128894. * @returns the number of groups in the system
  128895. */
  128896. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128897. /**
  128898. * Adds points to the PCS inside the model shape
  128899. * @param mesh is any Mesh object that will be used as a surface model for the points
  128900. * @param nb (positive integer) the number of particles to be created from this model
  128901. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128902. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128903. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128904. * @returns the number of groups in the system
  128905. */
  128906. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128907. /**
  128908. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  128909. * This method calls `updateParticle()` for each particle of the SPS.
  128910. * For an animated SPS, it is usually called within the render loop.
  128911. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  128912. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  128913. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  128914. * @returns the PCS.
  128915. */
  128916. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  128917. /**
  128918. * Disposes the PCS.
  128919. */
  128920. dispose(): void;
  128921. /**
  128922. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  128923. * doc :
  128924. * @returns the PCS.
  128925. */
  128926. refreshVisibleSize(): PointsCloudSystem;
  128927. /**
  128928. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  128929. * @param size the size (float) of the visibility box
  128930. * note : this doesn't lock the PCS mesh bounding box.
  128931. * doc :
  128932. */
  128933. setVisibilityBox(size: number): void;
  128934. /**
  128935. * Gets whether the PCS is always visible or not
  128936. * doc :
  128937. */
  128938. /**
  128939. * Sets the PCS as always visible or not
  128940. * doc :
  128941. */
  128942. isAlwaysVisible: boolean;
  128943. /**
  128944. * Tells to `setParticles()` to compute the particle rotations or not
  128945. * Default value : false. The PCS is faster when it's set to false
  128946. * Note : particle rotations are only applied to parent particles
  128947. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  128948. */
  128949. computeParticleRotation: boolean;
  128950. /**
  128951. * Tells to `setParticles()` to compute the particle colors or not.
  128952. * Default value : true. The PCS is faster when it's set to false.
  128953. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128954. */
  128955. /**
  128956. * Gets if `setParticles()` computes the particle colors or not.
  128957. * Default value : false. The PCS is faster when it's set to false.
  128958. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128959. */
  128960. computeParticleColor: boolean;
  128961. /**
  128962. * Gets if `setParticles()` computes the particle textures or not.
  128963. * Default value : false. The PCS is faster when it's set to false.
  128964. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  128965. */
  128966. computeParticleTexture: boolean;
  128967. /**
  128968. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  128969. */
  128970. /**
  128971. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  128972. */
  128973. computeBoundingBox: boolean;
  128974. /**
  128975. * This function does nothing. It may be overwritten to set all the particle first values.
  128976. * The PCS doesn't call this function, you may have to call it by your own.
  128977. * doc :
  128978. */
  128979. initParticles(): void;
  128980. /**
  128981. * This function does nothing. It may be overwritten to recycle a particle
  128982. * The PCS doesn't call this function, you can to call it
  128983. * doc :
  128984. * @param particle The particle to recycle
  128985. * @returns the recycled particle
  128986. */
  128987. recycleParticle(particle: CloudPoint): CloudPoint;
  128988. /**
  128989. * Updates a particle : this function should be overwritten by the user.
  128990. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  128991. * doc :
  128992. * @example : just set a particle position or velocity and recycle conditions
  128993. * @param particle The particle to update
  128994. * @returns the updated particle
  128995. */
  128996. updateParticle(particle: CloudPoint): CloudPoint;
  128997. /**
  128998. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  128999. * This does nothing and may be overwritten by the user.
  129000. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  129001. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  129002. * @param update the boolean update value actually passed to setParticles()
  129003. */
  129004. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  129005. /**
  129006. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  129007. * This will be passed three parameters.
  129008. * This does nothing and may be overwritten by the user.
  129009. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  129010. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  129011. * @param update the boolean update value actually passed to setParticles()
  129012. */
  129013. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  129014. }
  129015. }
  129016. declare module BABYLON {
  129017. /**
  129018. * Represents one particle of a points cloud system.
  129019. */
  129020. export class CloudPoint {
  129021. /**
  129022. * particle global index
  129023. */
  129024. idx: number;
  129025. /**
  129026. * The color of the particle
  129027. */
  129028. color: Nullable<Color4>;
  129029. /**
  129030. * The world space position of the particle.
  129031. */
  129032. position: Vector3;
  129033. /**
  129034. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  129035. */
  129036. rotation: Vector3;
  129037. /**
  129038. * The world space rotation quaternion of the particle.
  129039. */
  129040. rotationQuaternion: Nullable<Quaternion>;
  129041. /**
  129042. * The uv of the particle.
  129043. */
  129044. uv: Nullable<Vector2>;
  129045. /**
  129046. * The current speed of the particle.
  129047. */
  129048. velocity: Vector3;
  129049. /**
  129050. * The pivot point in the particle local space.
  129051. */
  129052. pivot: Vector3;
  129053. /**
  129054. * Must the particle be translated from its pivot point in its local space ?
  129055. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  129056. * Default : false
  129057. */
  129058. translateFromPivot: boolean;
  129059. /**
  129060. * Index of this particle in the global "positions" array (Internal use)
  129061. * @hidden
  129062. */
  129063. _pos: number;
  129064. /**
  129065. * @hidden Index of this particle in the global "indices" array (Internal use)
  129066. */
  129067. _ind: number;
  129068. /**
  129069. * Group this particle belongs to
  129070. */
  129071. _group: PointsGroup;
  129072. /**
  129073. * Group id of this particle
  129074. */
  129075. groupId: number;
  129076. /**
  129077. * Index of the particle in its group id (Internal use)
  129078. */
  129079. idxInGroup: number;
  129080. /**
  129081. * @hidden Particle BoundingInfo object (Internal use)
  129082. */
  129083. _boundingInfo: BoundingInfo;
  129084. /**
  129085. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  129086. */
  129087. _pcs: PointsCloudSystem;
  129088. /**
  129089. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  129090. */
  129091. _stillInvisible: boolean;
  129092. /**
  129093. * @hidden Last computed particle rotation matrix
  129094. */
  129095. _rotationMatrix: number[];
  129096. /**
  129097. * Parent particle Id, if any.
  129098. * Default null.
  129099. */
  129100. parentId: Nullable<number>;
  129101. /**
  129102. * @hidden Internal global position in the PCS.
  129103. */
  129104. _globalPosition: Vector3;
  129105. /**
  129106. * Creates a Point Cloud object.
  129107. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  129108. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  129109. * @param group (PointsGroup) is the group the particle belongs to
  129110. * @param groupId (integer) is the group identifier in the PCS.
  129111. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  129112. * @param pcs defines the PCS it is associated to
  129113. */
  129114. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  129115. /**
  129116. * get point size
  129117. */
  129118. /**
  129119. * Set point size
  129120. */
  129121. size: Vector3;
  129122. /**
  129123. * Legacy support, changed quaternion to rotationQuaternion
  129124. */
  129125. /**
  129126. * Legacy support, changed quaternion to rotationQuaternion
  129127. */
  129128. quaternion: Nullable<Quaternion>;
  129129. /**
  129130. * Returns a boolean. True if the particle intersects a mesh, else false
  129131. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  129132. * @param target is the object (point or mesh) what the intersection is computed against
  129133. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  129134. * @returns true if it intersects
  129135. */
  129136. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  129137. /**
  129138. * get the rotation matrix of the particle
  129139. * @hidden
  129140. */
  129141. getRotationMatrix(m: Matrix): void;
  129142. }
  129143. /**
  129144. * Represents a group of points in a points cloud system
  129145. * * PCS internal tool, don't use it manually.
  129146. */
  129147. export class PointsGroup {
  129148. /**
  129149. * The group id
  129150. * @hidden
  129151. */
  129152. groupID: number;
  129153. /**
  129154. * image data for group (internal use)
  129155. * @hidden
  129156. */
  129157. _groupImageData: Nullable<ArrayBufferView>;
  129158. /**
  129159. * Image Width (internal use)
  129160. * @hidden
  129161. */
  129162. _groupImgWidth: number;
  129163. /**
  129164. * Image Height (internal use)
  129165. * @hidden
  129166. */
  129167. _groupImgHeight: number;
  129168. /**
  129169. * Custom position function (internal use)
  129170. * @hidden
  129171. */
  129172. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  129173. /**
  129174. * density per facet for surface points
  129175. * @hidden
  129176. */
  129177. _groupDensity: number[];
  129178. /**
  129179. * Only when points are colored by texture carries pointer to texture list array
  129180. * @hidden
  129181. */
  129182. _textureNb: number;
  129183. /**
  129184. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  129185. * PCS internal tool, don't use it manually.
  129186. * @hidden
  129187. */
  129188. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  129189. }
  129190. }
  129191. declare module BABYLON {
  129192. interface Scene {
  129193. /** @hidden (Backing field) */
  129194. _physicsEngine: Nullable<IPhysicsEngine>;
  129195. /** @hidden */
  129196. _physicsTimeAccumulator: number;
  129197. /**
  129198. * Gets the current physics engine
  129199. * @returns a IPhysicsEngine or null if none attached
  129200. */
  129201. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  129202. /**
  129203. * Enables physics to the current scene
  129204. * @param gravity defines the scene's gravity for the physics engine
  129205. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  129206. * @return a boolean indicating if the physics engine was initialized
  129207. */
  129208. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  129209. /**
  129210. * Disables and disposes the physics engine associated with the scene
  129211. */
  129212. disablePhysicsEngine(): void;
  129213. /**
  129214. * Gets a boolean indicating if there is an active physics engine
  129215. * @returns a boolean indicating if there is an active physics engine
  129216. */
  129217. isPhysicsEnabled(): boolean;
  129218. /**
  129219. * Deletes a physics compound impostor
  129220. * @param compound defines the compound to delete
  129221. */
  129222. deleteCompoundImpostor(compound: any): void;
  129223. /**
  129224. * An event triggered when physic simulation is about to be run
  129225. */
  129226. onBeforePhysicsObservable: Observable<Scene>;
  129227. /**
  129228. * An event triggered when physic simulation has been done
  129229. */
  129230. onAfterPhysicsObservable: Observable<Scene>;
  129231. }
  129232. interface AbstractMesh {
  129233. /** @hidden */
  129234. _physicsImpostor: Nullable<PhysicsImpostor>;
  129235. /**
  129236. * Gets or sets impostor used for physic simulation
  129237. * @see http://doc.babylonjs.com/features/physics_engine
  129238. */
  129239. physicsImpostor: Nullable<PhysicsImpostor>;
  129240. /**
  129241. * Gets the current physics impostor
  129242. * @see http://doc.babylonjs.com/features/physics_engine
  129243. * @returns a physics impostor or null
  129244. */
  129245. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  129246. /** Apply a physic impulse to the mesh
  129247. * @param force defines the force to apply
  129248. * @param contactPoint defines where to apply the force
  129249. * @returns the current mesh
  129250. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129251. */
  129252. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  129253. /**
  129254. * Creates a physic joint between two meshes
  129255. * @param otherMesh defines the other mesh to use
  129256. * @param pivot1 defines the pivot to use on this mesh
  129257. * @param pivot2 defines the pivot to use on the other mesh
  129258. * @param options defines additional options (can be plugin dependent)
  129259. * @returns the current mesh
  129260. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  129261. */
  129262. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  129263. /** @hidden */
  129264. _disposePhysicsObserver: Nullable<Observer<Node>>;
  129265. }
  129266. /**
  129267. * Defines the physics engine scene component responsible to manage a physics engine
  129268. */
  129269. export class PhysicsEngineSceneComponent implements ISceneComponent {
  129270. /**
  129271. * The component name helpful to identify the component in the list of scene components.
  129272. */
  129273. readonly name: string;
  129274. /**
  129275. * The scene the component belongs to.
  129276. */
  129277. scene: Scene;
  129278. /**
  129279. * Creates a new instance of the component for the given scene
  129280. * @param scene Defines the scene to register the component in
  129281. */
  129282. constructor(scene: Scene);
  129283. /**
  129284. * Registers the component in a given scene
  129285. */
  129286. register(): void;
  129287. /**
  129288. * Rebuilds the elements related to this component in case of
  129289. * context lost for instance.
  129290. */
  129291. rebuild(): void;
  129292. /**
  129293. * Disposes the component and the associated ressources
  129294. */
  129295. dispose(): void;
  129296. }
  129297. }
  129298. declare module BABYLON {
  129299. /**
  129300. * A helper for physics simulations
  129301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129302. */
  129303. export class PhysicsHelper {
  129304. private _scene;
  129305. private _physicsEngine;
  129306. /**
  129307. * Initializes the Physics helper
  129308. * @param scene Babylon.js scene
  129309. */
  129310. constructor(scene: Scene);
  129311. /**
  129312. * Applies a radial explosion impulse
  129313. * @param origin the origin of the explosion
  129314. * @param radiusOrEventOptions the radius or the options of radial explosion
  129315. * @param strength the explosion strength
  129316. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129317. * @returns A physics radial explosion event, or null
  129318. */
  129319. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129320. /**
  129321. * Applies a radial explosion force
  129322. * @param origin the origin of the explosion
  129323. * @param radiusOrEventOptions the radius or the options of radial explosion
  129324. * @param strength the explosion strength
  129325. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129326. * @returns A physics radial explosion event, or null
  129327. */
  129328. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129329. /**
  129330. * Creates a gravitational field
  129331. * @param origin the origin of the explosion
  129332. * @param radiusOrEventOptions the radius or the options of radial explosion
  129333. * @param strength the explosion strength
  129334. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129335. * @returns A physics gravitational field event, or null
  129336. */
  129337. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  129338. /**
  129339. * Creates a physics updraft event
  129340. * @param origin the origin of the updraft
  129341. * @param radiusOrEventOptions the radius or the options of the updraft
  129342. * @param strength the strength of the updraft
  129343. * @param height the height of the updraft
  129344. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  129345. * @returns A physics updraft event, or null
  129346. */
  129347. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  129348. /**
  129349. * Creates a physics vortex event
  129350. * @param origin the of the vortex
  129351. * @param radiusOrEventOptions the radius or the options of the vortex
  129352. * @param strength the strength of the vortex
  129353. * @param height the height of the vortex
  129354. * @returns a Physics vortex event, or null
  129355. * A physics vortex event or null
  129356. */
  129357. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  129358. }
  129359. /**
  129360. * Represents a physics radial explosion event
  129361. */
  129362. class PhysicsRadialExplosionEvent {
  129363. private _scene;
  129364. private _options;
  129365. private _sphere;
  129366. private _dataFetched;
  129367. /**
  129368. * Initializes a radial explosioin event
  129369. * @param _scene BabylonJS scene
  129370. * @param _options The options for the vortex event
  129371. */
  129372. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  129373. /**
  129374. * Returns the data related to the radial explosion event (sphere).
  129375. * @returns The radial explosion event data
  129376. */
  129377. getData(): PhysicsRadialExplosionEventData;
  129378. /**
  129379. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  129380. * @param impostor A physics imposter
  129381. * @param origin the origin of the explosion
  129382. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  129383. */
  129384. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  129385. /**
  129386. * Triggers affecterd impostors callbacks
  129387. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  129388. */
  129389. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  129390. /**
  129391. * Disposes the sphere.
  129392. * @param force Specifies if the sphere should be disposed by force
  129393. */
  129394. dispose(force?: boolean): void;
  129395. /*** Helpers ***/
  129396. private _prepareSphere;
  129397. private _intersectsWithSphere;
  129398. }
  129399. /**
  129400. * Represents a gravitational field event
  129401. */
  129402. class PhysicsGravitationalFieldEvent {
  129403. private _physicsHelper;
  129404. private _scene;
  129405. private _origin;
  129406. private _options;
  129407. private _tickCallback;
  129408. private _sphere;
  129409. private _dataFetched;
  129410. /**
  129411. * Initializes the physics gravitational field event
  129412. * @param _physicsHelper A physics helper
  129413. * @param _scene BabylonJS scene
  129414. * @param _origin The origin position of the gravitational field event
  129415. * @param _options The options for the vortex event
  129416. */
  129417. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  129418. /**
  129419. * Returns the data related to the gravitational field event (sphere).
  129420. * @returns A gravitational field event
  129421. */
  129422. getData(): PhysicsGravitationalFieldEventData;
  129423. /**
  129424. * Enables the gravitational field.
  129425. */
  129426. enable(): void;
  129427. /**
  129428. * Disables the gravitational field.
  129429. */
  129430. disable(): void;
  129431. /**
  129432. * Disposes the sphere.
  129433. * @param force The force to dispose from the gravitational field event
  129434. */
  129435. dispose(force?: boolean): void;
  129436. private _tick;
  129437. }
  129438. /**
  129439. * Represents a physics updraft event
  129440. */
  129441. class PhysicsUpdraftEvent {
  129442. private _scene;
  129443. private _origin;
  129444. private _options;
  129445. private _physicsEngine;
  129446. private _originTop;
  129447. private _originDirection;
  129448. private _tickCallback;
  129449. private _cylinder;
  129450. private _cylinderPosition;
  129451. private _dataFetched;
  129452. /**
  129453. * Initializes the physics updraft event
  129454. * @param _scene BabylonJS scene
  129455. * @param _origin The origin position of the updraft
  129456. * @param _options The options for the updraft event
  129457. */
  129458. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  129459. /**
  129460. * Returns the data related to the updraft event (cylinder).
  129461. * @returns A physics updraft event
  129462. */
  129463. getData(): PhysicsUpdraftEventData;
  129464. /**
  129465. * Enables the updraft.
  129466. */
  129467. enable(): void;
  129468. /**
  129469. * Disables the updraft.
  129470. */
  129471. disable(): void;
  129472. /**
  129473. * Disposes the cylinder.
  129474. * @param force Specifies if the updraft should be disposed by force
  129475. */
  129476. dispose(force?: boolean): void;
  129477. private getImpostorHitData;
  129478. private _tick;
  129479. /*** Helpers ***/
  129480. private _prepareCylinder;
  129481. private _intersectsWithCylinder;
  129482. }
  129483. /**
  129484. * Represents a physics vortex event
  129485. */
  129486. class PhysicsVortexEvent {
  129487. private _scene;
  129488. private _origin;
  129489. private _options;
  129490. private _physicsEngine;
  129491. private _originTop;
  129492. private _tickCallback;
  129493. private _cylinder;
  129494. private _cylinderPosition;
  129495. private _dataFetched;
  129496. /**
  129497. * Initializes the physics vortex event
  129498. * @param _scene The BabylonJS scene
  129499. * @param _origin The origin position of the vortex
  129500. * @param _options The options for the vortex event
  129501. */
  129502. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  129503. /**
  129504. * Returns the data related to the vortex event (cylinder).
  129505. * @returns The physics vortex event data
  129506. */
  129507. getData(): PhysicsVortexEventData;
  129508. /**
  129509. * Enables the vortex.
  129510. */
  129511. enable(): void;
  129512. /**
  129513. * Disables the cortex.
  129514. */
  129515. disable(): void;
  129516. /**
  129517. * Disposes the sphere.
  129518. * @param force
  129519. */
  129520. dispose(force?: boolean): void;
  129521. private getImpostorHitData;
  129522. private _tick;
  129523. /*** Helpers ***/
  129524. private _prepareCylinder;
  129525. private _intersectsWithCylinder;
  129526. }
  129527. /**
  129528. * Options fot the radial explosion event
  129529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129530. */
  129531. export class PhysicsRadialExplosionEventOptions {
  129532. /**
  129533. * The radius of the sphere for the radial explosion.
  129534. */
  129535. radius: number;
  129536. /**
  129537. * The strenth of the explosion.
  129538. */
  129539. strength: number;
  129540. /**
  129541. * The strenght of the force in correspondence to the distance of the affected object
  129542. */
  129543. falloff: PhysicsRadialImpulseFalloff;
  129544. /**
  129545. * Sphere options for the radial explosion.
  129546. */
  129547. sphere: {
  129548. segments: number;
  129549. diameter: number;
  129550. };
  129551. /**
  129552. * Sphere options for the radial explosion.
  129553. */
  129554. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  129555. }
  129556. /**
  129557. * Options fot the updraft event
  129558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129559. */
  129560. export class PhysicsUpdraftEventOptions {
  129561. /**
  129562. * The radius of the cylinder for the vortex
  129563. */
  129564. radius: number;
  129565. /**
  129566. * The strenth of the updraft.
  129567. */
  129568. strength: number;
  129569. /**
  129570. * The height of the cylinder for the updraft.
  129571. */
  129572. height: number;
  129573. /**
  129574. * The mode for the the updraft.
  129575. */
  129576. updraftMode: PhysicsUpdraftMode;
  129577. }
  129578. /**
  129579. * Options fot the vortex event
  129580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129581. */
  129582. export class PhysicsVortexEventOptions {
  129583. /**
  129584. * The radius of the cylinder for the vortex
  129585. */
  129586. radius: number;
  129587. /**
  129588. * The strenth of the vortex.
  129589. */
  129590. strength: number;
  129591. /**
  129592. * The height of the cylinder for the vortex.
  129593. */
  129594. height: number;
  129595. /**
  129596. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  129597. */
  129598. centripetalForceThreshold: number;
  129599. /**
  129600. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  129601. */
  129602. centripetalForceMultiplier: number;
  129603. /**
  129604. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  129605. */
  129606. centrifugalForceMultiplier: number;
  129607. /**
  129608. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  129609. */
  129610. updraftForceMultiplier: number;
  129611. }
  129612. /**
  129613. * The strenght of the force in correspondence to the distance of the affected object
  129614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129615. */
  129616. export enum PhysicsRadialImpulseFalloff {
  129617. /** Defines that impulse is constant in strength across it's whole radius */
  129618. Constant = 0,
  129619. /** Defines that impulse gets weaker if it's further from the origin */
  129620. Linear = 1
  129621. }
  129622. /**
  129623. * The strength of the force in correspondence to the distance of the affected object
  129624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129625. */
  129626. export enum PhysicsUpdraftMode {
  129627. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  129628. Center = 0,
  129629. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  129630. Perpendicular = 1
  129631. }
  129632. /**
  129633. * Interface for a physics hit data
  129634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129635. */
  129636. export interface PhysicsHitData {
  129637. /**
  129638. * The force applied at the contact point
  129639. */
  129640. force: Vector3;
  129641. /**
  129642. * The contact point
  129643. */
  129644. contactPoint: Vector3;
  129645. /**
  129646. * The distance from the origin to the contact point
  129647. */
  129648. distanceFromOrigin: number;
  129649. }
  129650. /**
  129651. * Interface for radial explosion event data
  129652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129653. */
  129654. export interface PhysicsRadialExplosionEventData {
  129655. /**
  129656. * A sphere used for the radial explosion event
  129657. */
  129658. sphere: Mesh;
  129659. }
  129660. /**
  129661. * Interface for gravitational field event data
  129662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129663. */
  129664. export interface PhysicsGravitationalFieldEventData {
  129665. /**
  129666. * A sphere mesh used for the gravitational field event
  129667. */
  129668. sphere: Mesh;
  129669. }
  129670. /**
  129671. * Interface for updraft event data
  129672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129673. */
  129674. export interface PhysicsUpdraftEventData {
  129675. /**
  129676. * A cylinder used for the updraft event
  129677. */
  129678. cylinder: Mesh;
  129679. }
  129680. /**
  129681. * Interface for vortex event data
  129682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129683. */
  129684. export interface PhysicsVortexEventData {
  129685. /**
  129686. * A cylinder used for the vortex event
  129687. */
  129688. cylinder: Mesh;
  129689. }
  129690. /**
  129691. * Interface for an affected physics impostor
  129692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129693. */
  129694. export interface PhysicsAffectedImpostorWithData {
  129695. /**
  129696. * The impostor affected by the effect
  129697. */
  129698. impostor: PhysicsImpostor;
  129699. /**
  129700. * The data about the hit/horce from the explosion
  129701. */
  129702. hitData: PhysicsHitData;
  129703. }
  129704. }
  129705. declare module BABYLON {
  129706. /** @hidden */
  129707. export var blackAndWhitePixelShader: {
  129708. name: string;
  129709. shader: string;
  129710. };
  129711. }
  129712. declare module BABYLON {
  129713. /**
  129714. * Post process used to render in black and white
  129715. */
  129716. export class BlackAndWhitePostProcess extends PostProcess {
  129717. /**
  129718. * Linear about to convert he result to black and white (default: 1)
  129719. */
  129720. degree: number;
  129721. /**
  129722. * Creates a black and white post process
  129723. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  129724. * @param name The name of the effect.
  129725. * @param options The required width/height ratio to downsize to before computing the render pass.
  129726. * @param camera The camera to apply the render pass to.
  129727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129728. * @param engine The engine which the post process will be applied. (default: current engine)
  129729. * @param reusable If the post process can be reused on the same frame. (default: false)
  129730. */
  129731. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129732. }
  129733. }
  129734. declare module BABYLON {
  129735. /**
  129736. * This represents a set of one or more post processes in Babylon.
  129737. * A post process can be used to apply a shader to a texture after it is rendered.
  129738. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129739. */
  129740. export class PostProcessRenderEffect {
  129741. private _postProcesses;
  129742. private _getPostProcesses;
  129743. private _singleInstance;
  129744. private _cameras;
  129745. private _indicesForCamera;
  129746. /**
  129747. * Name of the effect
  129748. * @hidden
  129749. */
  129750. _name: string;
  129751. /**
  129752. * Instantiates a post process render effect.
  129753. * A post process can be used to apply a shader to a texture after it is rendered.
  129754. * @param engine The engine the effect is tied to
  129755. * @param name The name of the effect
  129756. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  129757. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  129758. */
  129759. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  129760. /**
  129761. * Checks if all the post processes in the effect are supported.
  129762. */
  129763. readonly isSupported: boolean;
  129764. /**
  129765. * Updates the current state of the effect
  129766. * @hidden
  129767. */
  129768. _update(): void;
  129769. /**
  129770. * Attaches the effect on cameras
  129771. * @param cameras The camera to attach to.
  129772. * @hidden
  129773. */
  129774. _attachCameras(cameras: Camera): void;
  129775. /**
  129776. * Attaches the effect on cameras
  129777. * @param cameras The camera to attach to.
  129778. * @hidden
  129779. */
  129780. _attachCameras(cameras: Camera[]): void;
  129781. /**
  129782. * Detaches the effect on cameras
  129783. * @param cameras The camera to detatch from.
  129784. * @hidden
  129785. */
  129786. _detachCameras(cameras: Camera): void;
  129787. /**
  129788. * Detatches the effect on cameras
  129789. * @param cameras The camera to detatch from.
  129790. * @hidden
  129791. */
  129792. _detachCameras(cameras: Camera[]): void;
  129793. /**
  129794. * Enables the effect on given cameras
  129795. * @param cameras The camera to enable.
  129796. * @hidden
  129797. */
  129798. _enable(cameras: Camera): void;
  129799. /**
  129800. * Enables the effect on given cameras
  129801. * @param cameras The camera to enable.
  129802. * @hidden
  129803. */
  129804. _enable(cameras: Nullable<Camera[]>): void;
  129805. /**
  129806. * Disables the effect on the given cameras
  129807. * @param cameras The camera to disable.
  129808. * @hidden
  129809. */
  129810. _disable(cameras: Camera): void;
  129811. /**
  129812. * Disables the effect on the given cameras
  129813. * @param cameras The camera to disable.
  129814. * @hidden
  129815. */
  129816. _disable(cameras: Nullable<Camera[]>): void;
  129817. /**
  129818. * Gets a list of the post processes contained in the effect.
  129819. * @param camera The camera to get the post processes on.
  129820. * @returns The list of the post processes in the effect.
  129821. */
  129822. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  129823. }
  129824. }
  129825. declare module BABYLON {
  129826. /** @hidden */
  129827. export var extractHighlightsPixelShader: {
  129828. name: string;
  129829. shader: string;
  129830. };
  129831. }
  129832. declare module BABYLON {
  129833. /**
  129834. * 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.
  129835. */
  129836. export class ExtractHighlightsPostProcess extends PostProcess {
  129837. /**
  129838. * The luminance threshold, pixels below this value will be set to black.
  129839. */
  129840. threshold: number;
  129841. /** @hidden */
  129842. _exposure: number;
  129843. /**
  129844. * Post process which has the input texture to be used when performing highlight extraction
  129845. * @hidden
  129846. */
  129847. _inputPostProcess: Nullable<PostProcess>;
  129848. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129849. }
  129850. }
  129851. declare module BABYLON {
  129852. /** @hidden */
  129853. export var bloomMergePixelShader: {
  129854. name: string;
  129855. shader: string;
  129856. };
  129857. }
  129858. declare module BABYLON {
  129859. /**
  129860. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  129861. */
  129862. export class BloomMergePostProcess extends PostProcess {
  129863. /** Weight of the bloom to be added to the original input. */
  129864. weight: number;
  129865. /**
  129866. * Creates a new instance of @see BloomMergePostProcess
  129867. * @param name The name of the effect.
  129868. * @param originalFromInput Post process which's input will be used for the merge.
  129869. * @param blurred Blurred highlights post process which's output will be used.
  129870. * @param weight Weight of the bloom to be added to the original input.
  129871. * @param options The required width/height ratio to downsize to before computing the render pass.
  129872. * @param camera The camera to apply the render pass to.
  129873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129874. * @param engine The engine which the post process will be applied. (default: current engine)
  129875. * @param reusable If the post process can be reused on the same frame. (default: false)
  129876. * @param textureType Type of textures used when performing the post process. (default: 0)
  129877. * @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)
  129878. */
  129879. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  129880. /** Weight of the bloom to be added to the original input. */
  129881. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129882. }
  129883. }
  129884. declare module BABYLON {
  129885. /**
  129886. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  129887. */
  129888. export class BloomEffect extends PostProcessRenderEffect {
  129889. private bloomScale;
  129890. /**
  129891. * @hidden Internal
  129892. */
  129893. _effects: Array<PostProcess>;
  129894. /**
  129895. * @hidden Internal
  129896. */
  129897. _downscale: ExtractHighlightsPostProcess;
  129898. private _blurX;
  129899. private _blurY;
  129900. private _merge;
  129901. /**
  129902. * The luminance threshold to find bright areas of the image to bloom.
  129903. */
  129904. threshold: number;
  129905. /**
  129906. * The strength of the bloom.
  129907. */
  129908. weight: number;
  129909. /**
  129910. * Specifies the size of the bloom blur kernel, relative to the final output size
  129911. */
  129912. kernel: number;
  129913. /**
  129914. * Creates a new instance of @see BloomEffect
  129915. * @param scene The scene the effect belongs to.
  129916. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  129917. * @param bloomKernel The size of the kernel to be used when applying the blur.
  129918. * @param bloomWeight The the strength of bloom.
  129919. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  129920. * @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)
  129921. */
  129922. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  129923. /**
  129924. * Disposes each of the internal effects for a given camera.
  129925. * @param camera The camera to dispose the effect on.
  129926. */
  129927. disposeEffects(camera: Camera): void;
  129928. /**
  129929. * @hidden Internal
  129930. */
  129931. _updateEffects(): void;
  129932. /**
  129933. * Internal
  129934. * @returns if all the contained post processes are ready.
  129935. * @hidden
  129936. */
  129937. _isReady(): boolean;
  129938. }
  129939. }
  129940. declare module BABYLON {
  129941. /** @hidden */
  129942. export var chromaticAberrationPixelShader: {
  129943. name: string;
  129944. shader: string;
  129945. };
  129946. }
  129947. declare module BABYLON {
  129948. /**
  129949. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  129950. */
  129951. export class ChromaticAberrationPostProcess extends PostProcess {
  129952. /**
  129953. * The amount of seperation of rgb channels (default: 30)
  129954. */
  129955. aberrationAmount: number;
  129956. /**
  129957. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  129958. */
  129959. radialIntensity: number;
  129960. /**
  129961. * 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))
  129962. */
  129963. direction: Vector2;
  129964. /**
  129965. * 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))
  129966. */
  129967. centerPosition: Vector2;
  129968. /**
  129969. * Creates a new instance ChromaticAberrationPostProcess
  129970. * @param name The name of the effect.
  129971. * @param screenWidth The width of the screen to apply the effect on.
  129972. * @param screenHeight The height of the screen to apply the effect on.
  129973. * @param options The required width/height ratio to downsize to before computing the render pass.
  129974. * @param camera The camera to apply the render pass to.
  129975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129976. * @param engine The engine which the post process will be applied. (default: current engine)
  129977. * @param reusable If the post process can be reused on the same frame. (default: false)
  129978. * @param textureType Type of textures used when performing the post process. (default: 0)
  129979. * @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)
  129980. */
  129981. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129982. }
  129983. }
  129984. declare module BABYLON {
  129985. /** @hidden */
  129986. export var circleOfConfusionPixelShader: {
  129987. name: string;
  129988. shader: string;
  129989. };
  129990. }
  129991. declare module BABYLON {
  129992. /**
  129993. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  129994. */
  129995. export class CircleOfConfusionPostProcess extends PostProcess {
  129996. /**
  129997. * 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.
  129998. */
  129999. lensSize: number;
  130000. /**
  130001. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130002. */
  130003. fStop: number;
  130004. /**
  130005. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130006. */
  130007. focusDistance: number;
  130008. /**
  130009. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  130010. */
  130011. focalLength: number;
  130012. private _depthTexture;
  130013. /**
  130014. * Creates a new instance CircleOfConfusionPostProcess
  130015. * @param name The name of the effect.
  130016. * @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.
  130017. * @param options The required width/height ratio to downsize to before computing the render pass.
  130018. * @param camera The camera to apply the render pass to.
  130019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130020. * @param engine The engine which the post process will be applied. (default: current engine)
  130021. * @param reusable If the post process can be reused on the same frame. (default: false)
  130022. * @param textureType Type of textures used when performing the post process. (default: 0)
  130023. * @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)
  130024. */
  130025. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130026. /**
  130027. * 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.
  130028. */
  130029. depthTexture: RenderTargetTexture;
  130030. }
  130031. }
  130032. declare module BABYLON {
  130033. /** @hidden */
  130034. export var colorCorrectionPixelShader: {
  130035. name: string;
  130036. shader: string;
  130037. };
  130038. }
  130039. declare module BABYLON {
  130040. /**
  130041. *
  130042. * This post-process allows the modification of rendered colors by using
  130043. * a 'look-up table' (LUT). This effect is also called Color Grading.
  130044. *
  130045. * The object needs to be provided an url to a texture containing the color
  130046. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  130047. * Use an image editing software to tweak the LUT to match your needs.
  130048. *
  130049. * For an example of a color LUT, see here:
  130050. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  130051. * For explanations on color grading, see here:
  130052. * @see http://udn.epicgames.com/Three/ColorGrading.html
  130053. *
  130054. */
  130055. export class ColorCorrectionPostProcess extends PostProcess {
  130056. private _colorTableTexture;
  130057. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130058. }
  130059. }
  130060. declare module BABYLON {
  130061. /** @hidden */
  130062. export var convolutionPixelShader: {
  130063. name: string;
  130064. shader: string;
  130065. };
  130066. }
  130067. declare module BABYLON {
  130068. /**
  130069. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  130070. * input texture to perform effects such as edge detection or sharpening
  130071. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130072. */
  130073. export class ConvolutionPostProcess extends PostProcess {
  130074. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130075. kernel: number[];
  130076. /**
  130077. * Creates a new instance ConvolutionPostProcess
  130078. * @param name The name of the effect.
  130079. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  130080. * @param options The required width/height ratio to downsize to before computing the render pass.
  130081. * @param camera The camera to apply the render pass to.
  130082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130083. * @param engine The engine which the post process will be applied. (default: current engine)
  130084. * @param reusable If the post process can be reused on the same frame. (default: false)
  130085. * @param textureType Type of textures used when performing the post process. (default: 0)
  130086. */
  130087. constructor(name: string,
  130088. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130089. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130090. /**
  130091. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130092. */
  130093. static EdgeDetect0Kernel: number[];
  130094. /**
  130095. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130096. */
  130097. static EdgeDetect1Kernel: number[];
  130098. /**
  130099. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130100. */
  130101. static EdgeDetect2Kernel: number[];
  130102. /**
  130103. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130104. */
  130105. static SharpenKernel: number[];
  130106. /**
  130107. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130108. */
  130109. static EmbossKernel: number[];
  130110. /**
  130111. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130112. */
  130113. static GaussianKernel: number[];
  130114. }
  130115. }
  130116. declare module BABYLON {
  130117. /**
  130118. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  130119. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  130120. * based on samples that have a large difference in distance than the center pixel.
  130121. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  130122. */
  130123. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  130124. direction: Vector2;
  130125. /**
  130126. * Creates a new instance CircleOfConfusionPostProcess
  130127. * @param name The name of the effect.
  130128. * @param scene The scene the effect belongs to.
  130129. * @param direction The direction the blur should be applied.
  130130. * @param kernel The size of the kernel used to blur.
  130131. * @param options The required width/height ratio to downsize to before computing the render pass.
  130132. * @param camera The camera to apply the render pass to.
  130133. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  130134. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  130135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130136. * @param engine The engine which the post process will be applied. (default: current engine)
  130137. * @param reusable If the post process can be reused on the same frame. (default: false)
  130138. * @param textureType Type of textures used when performing the post process. (default: 0)
  130139. * @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)
  130140. */
  130141. 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);
  130142. }
  130143. }
  130144. declare module BABYLON {
  130145. /** @hidden */
  130146. export var depthOfFieldMergePixelShader: {
  130147. name: string;
  130148. shader: string;
  130149. };
  130150. }
  130151. declare module BABYLON {
  130152. /**
  130153. * Options to be set when merging outputs from the default pipeline.
  130154. */
  130155. export class DepthOfFieldMergePostProcessOptions {
  130156. /**
  130157. * The original image to merge on top of
  130158. */
  130159. originalFromInput: PostProcess;
  130160. /**
  130161. * Parameters to perform the merge of the depth of field effect
  130162. */
  130163. depthOfField?: {
  130164. circleOfConfusion: PostProcess;
  130165. blurSteps: Array<PostProcess>;
  130166. };
  130167. /**
  130168. * Parameters to perform the merge of bloom effect
  130169. */
  130170. bloom?: {
  130171. blurred: PostProcess;
  130172. weight: number;
  130173. };
  130174. }
  130175. /**
  130176. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  130177. */
  130178. export class DepthOfFieldMergePostProcess extends PostProcess {
  130179. private blurSteps;
  130180. /**
  130181. * Creates a new instance of DepthOfFieldMergePostProcess
  130182. * @param name The name of the effect.
  130183. * @param originalFromInput Post process which's input will be used for the merge.
  130184. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  130185. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  130186. * @param options The required width/height ratio to downsize to before computing the render pass.
  130187. * @param camera The camera to apply the render pass to.
  130188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130189. * @param engine The engine which the post process will be applied. (default: current engine)
  130190. * @param reusable If the post process can be reused on the same frame. (default: false)
  130191. * @param textureType Type of textures used when performing the post process. (default: 0)
  130192. * @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)
  130193. */
  130194. 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);
  130195. /**
  130196. * Updates the effect with the current post process compile time values and recompiles the shader.
  130197. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  130198. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  130199. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  130200. * @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
  130201. * @param onCompiled Called when the shader has been compiled.
  130202. * @param onError Called if there is an error when compiling a shader.
  130203. */
  130204. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  130205. }
  130206. }
  130207. declare module BABYLON {
  130208. /**
  130209. * Specifies the level of max blur that should be applied when using the depth of field effect
  130210. */
  130211. export enum DepthOfFieldEffectBlurLevel {
  130212. /**
  130213. * Subtle blur
  130214. */
  130215. Low = 0,
  130216. /**
  130217. * Medium blur
  130218. */
  130219. Medium = 1,
  130220. /**
  130221. * Large blur
  130222. */
  130223. High = 2
  130224. }
  130225. /**
  130226. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  130227. */
  130228. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  130229. private _circleOfConfusion;
  130230. /**
  130231. * @hidden Internal, blurs from high to low
  130232. */
  130233. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  130234. private _depthOfFieldBlurY;
  130235. private _dofMerge;
  130236. /**
  130237. * @hidden Internal post processes in depth of field effect
  130238. */
  130239. _effects: Array<PostProcess>;
  130240. /**
  130241. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  130242. */
  130243. focalLength: number;
  130244. /**
  130245. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130246. */
  130247. fStop: number;
  130248. /**
  130249. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130250. */
  130251. focusDistance: number;
  130252. /**
  130253. * 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.
  130254. */
  130255. lensSize: number;
  130256. /**
  130257. * Creates a new instance DepthOfFieldEffect
  130258. * @param scene The scene the effect belongs to.
  130259. * @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.
  130260. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  130261. * @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)
  130262. */
  130263. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  130264. /**
  130265. * Get the current class name of the current effet
  130266. * @returns "DepthOfFieldEffect"
  130267. */
  130268. getClassName(): string;
  130269. /**
  130270. * 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.
  130271. */
  130272. depthTexture: RenderTargetTexture;
  130273. /**
  130274. * Disposes each of the internal effects for a given camera.
  130275. * @param camera The camera to dispose the effect on.
  130276. */
  130277. disposeEffects(camera: Camera): void;
  130278. /**
  130279. * @hidden Internal
  130280. */
  130281. _updateEffects(): void;
  130282. /**
  130283. * Internal
  130284. * @returns if all the contained post processes are ready.
  130285. * @hidden
  130286. */
  130287. _isReady(): boolean;
  130288. }
  130289. }
  130290. declare module BABYLON {
  130291. /** @hidden */
  130292. export var displayPassPixelShader: {
  130293. name: string;
  130294. shader: string;
  130295. };
  130296. }
  130297. declare module BABYLON {
  130298. /**
  130299. * DisplayPassPostProcess which produces an output the same as it's input
  130300. */
  130301. export class DisplayPassPostProcess extends PostProcess {
  130302. /**
  130303. * Creates the DisplayPassPostProcess
  130304. * @param name The name of the effect.
  130305. * @param options The required width/height ratio to downsize to before computing the render pass.
  130306. * @param camera The camera to apply the render pass to.
  130307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130308. * @param engine The engine which the post process will be applied. (default: current engine)
  130309. * @param reusable If the post process can be reused on the same frame. (default: false)
  130310. */
  130311. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130312. }
  130313. }
  130314. declare module BABYLON {
  130315. /** @hidden */
  130316. export var filterPixelShader: {
  130317. name: string;
  130318. shader: string;
  130319. };
  130320. }
  130321. declare module BABYLON {
  130322. /**
  130323. * Applies a kernel filter to the image
  130324. */
  130325. export class FilterPostProcess extends PostProcess {
  130326. /** The matrix to be applied to the image */
  130327. kernelMatrix: Matrix;
  130328. /**
  130329. *
  130330. * @param name The name of the effect.
  130331. * @param kernelMatrix The matrix to be applied to the image
  130332. * @param options The required width/height ratio to downsize to before computing the render pass.
  130333. * @param camera The camera to apply the render pass to.
  130334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130335. * @param engine The engine which the post process will be applied. (default: current engine)
  130336. * @param reusable If the post process can be reused on the same frame. (default: false)
  130337. */
  130338. constructor(name: string,
  130339. /** The matrix to be applied to the image */
  130340. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130341. }
  130342. }
  130343. declare module BABYLON {
  130344. /** @hidden */
  130345. export var fxaaPixelShader: {
  130346. name: string;
  130347. shader: string;
  130348. };
  130349. }
  130350. declare module BABYLON {
  130351. /** @hidden */
  130352. export var fxaaVertexShader: {
  130353. name: string;
  130354. shader: string;
  130355. };
  130356. }
  130357. declare module BABYLON {
  130358. /**
  130359. * Fxaa post process
  130360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  130361. */
  130362. export class FxaaPostProcess extends PostProcess {
  130363. /** @hidden */
  130364. texelWidth: number;
  130365. /** @hidden */
  130366. texelHeight: number;
  130367. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130368. private _getDefines;
  130369. }
  130370. }
  130371. declare module BABYLON {
  130372. /** @hidden */
  130373. export var grainPixelShader: {
  130374. name: string;
  130375. shader: string;
  130376. };
  130377. }
  130378. declare module BABYLON {
  130379. /**
  130380. * The GrainPostProcess adds noise to the image at mid luminance levels
  130381. */
  130382. export class GrainPostProcess extends PostProcess {
  130383. /**
  130384. * The intensity of the grain added (default: 30)
  130385. */
  130386. intensity: number;
  130387. /**
  130388. * If the grain should be randomized on every frame
  130389. */
  130390. animated: boolean;
  130391. /**
  130392. * Creates a new instance of @see GrainPostProcess
  130393. * @param name The name of the effect.
  130394. * @param options The required width/height ratio to downsize to before computing the render pass.
  130395. * @param camera The camera to apply the render pass to.
  130396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130397. * @param engine The engine which the post process will be applied. (default: current engine)
  130398. * @param reusable If the post process can be reused on the same frame. (default: false)
  130399. * @param textureType Type of textures used when performing the post process. (default: 0)
  130400. * @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)
  130401. */
  130402. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130403. }
  130404. }
  130405. declare module BABYLON {
  130406. /** @hidden */
  130407. export var highlightsPixelShader: {
  130408. name: string;
  130409. shader: string;
  130410. };
  130411. }
  130412. declare module BABYLON {
  130413. /**
  130414. * Extracts highlights from the image
  130415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130416. */
  130417. export class HighlightsPostProcess extends PostProcess {
  130418. /**
  130419. * Extracts highlights from the image
  130420. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130421. * @param name The name of the effect.
  130422. * @param options The required width/height ratio to downsize to before computing the render pass.
  130423. * @param camera The camera to apply the render pass to.
  130424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130425. * @param engine The engine which the post process will be applied. (default: current engine)
  130426. * @param reusable If the post process can be reused on the same frame. (default: false)
  130427. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  130428. */
  130429. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130430. }
  130431. }
  130432. declare module BABYLON {
  130433. /** @hidden */
  130434. export var mrtFragmentDeclaration: {
  130435. name: string;
  130436. shader: string;
  130437. };
  130438. }
  130439. declare module BABYLON {
  130440. /** @hidden */
  130441. export var geometryPixelShader: {
  130442. name: string;
  130443. shader: string;
  130444. };
  130445. }
  130446. declare module BABYLON {
  130447. /** @hidden */
  130448. export var geometryVertexShader: {
  130449. name: string;
  130450. shader: string;
  130451. };
  130452. }
  130453. declare module BABYLON {
  130454. /** @hidden */
  130455. interface ISavedTransformationMatrix {
  130456. world: Matrix;
  130457. viewProjection: Matrix;
  130458. }
  130459. /**
  130460. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  130461. */
  130462. export class GeometryBufferRenderer {
  130463. /**
  130464. * Constant used to retrieve the position texture index in the G-Buffer textures array
  130465. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  130466. */
  130467. static readonly POSITION_TEXTURE_TYPE: number;
  130468. /**
  130469. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  130470. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  130471. */
  130472. static readonly VELOCITY_TEXTURE_TYPE: number;
  130473. /**
  130474. * Dictionary used to store the previous transformation matrices of each rendered mesh
  130475. * in order to compute objects velocities when enableVelocity is set to "true"
  130476. * @hidden
  130477. */
  130478. _previousTransformationMatrices: {
  130479. [index: number]: ISavedTransformationMatrix;
  130480. };
  130481. /**
  130482. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  130483. * in order to compute objects velocities when enableVelocity is set to "true"
  130484. * @hidden
  130485. */
  130486. _previousBonesTransformationMatrices: {
  130487. [index: number]: Float32Array;
  130488. };
  130489. /**
  130490. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  130491. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  130492. */
  130493. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  130494. private _scene;
  130495. private _multiRenderTarget;
  130496. private _ratio;
  130497. private _enablePosition;
  130498. private _enableVelocity;
  130499. private _positionIndex;
  130500. private _velocityIndex;
  130501. protected _effect: Effect;
  130502. protected _cachedDefines: string;
  130503. /**
  130504. * Set the render list (meshes to be rendered) used in the G buffer.
  130505. */
  130506. renderList: Mesh[];
  130507. /**
  130508. * Gets wether or not G buffer are supported by the running hardware.
  130509. * This requires draw buffer supports
  130510. */
  130511. readonly isSupported: boolean;
  130512. /**
  130513. * Returns the index of the given texture type in the G-Buffer textures array
  130514. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  130515. * @returns the index of the given texture type in the G-Buffer textures array
  130516. */
  130517. getTextureIndex(textureType: number): number;
  130518. /**
  130519. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  130520. */
  130521. /**
  130522. * Sets whether or not objects positions are enabled for the G buffer.
  130523. */
  130524. enablePosition: boolean;
  130525. /**
  130526. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  130527. */
  130528. /**
  130529. * Sets wether or not objects velocities are enabled for the G buffer.
  130530. */
  130531. enableVelocity: boolean;
  130532. /**
  130533. * Gets the scene associated with the buffer.
  130534. */
  130535. readonly scene: Scene;
  130536. /**
  130537. * Gets the ratio used by the buffer during its creation.
  130538. * How big is the buffer related to the main canvas.
  130539. */
  130540. readonly ratio: number;
  130541. /** @hidden */
  130542. static _SceneComponentInitialization: (scene: Scene) => void;
  130543. /**
  130544. * Creates a new G Buffer for the scene
  130545. * @param scene The scene the buffer belongs to
  130546. * @param ratio How big is the buffer related to the main canvas.
  130547. */
  130548. constructor(scene: Scene, ratio?: number);
  130549. /**
  130550. * Checks wether everything is ready to render a submesh to the G buffer.
  130551. * @param subMesh the submesh to check readiness for
  130552. * @param useInstances is the mesh drawn using instance or not
  130553. * @returns true if ready otherwise false
  130554. */
  130555. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130556. /**
  130557. * Gets the current underlying G Buffer.
  130558. * @returns the buffer
  130559. */
  130560. getGBuffer(): MultiRenderTarget;
  130561. /**
  130562. * Gets the number of samples used to render the buffer (anti aliasing).
  130563. */
  130564. /**
  130565. * Sets the number of samples used to render the buffer (anti aliasing).
  130566. */
  130567. samples: number;
  130568. /**
  130569. * Disposes the renderer and frees up associated resources.
  130570. */
  130571. dispose(): void;
  130572. protected _createRenderTargets(): void;
  130573. private _copyBonesTransformationMatrices;
  130574. }
  130575. }
  130576. declare module BABYLON {
  130577. interface Scene {
  130578. /** @hidden (Backing field) */
  130579. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130580. /**
  130581. * Gets or Sets the current geometry buffer associated to the scene.
  130582. */
  130583. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130584. /**
  130585. * Enables a GeometryBufferRender and associates it with the scene
  130586. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  130587. * @returns the GeometryBufferRenderer
  130588. */
  130589. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  130590. /**
  130591. * Disables the GeometryBufferRender associated with the scene
  130592. */
  130593. disableGeometryBufferRenderer(): void;
  130594. }
  130595. /**
  130596. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  130597. * in several rendering techniques.
  130598. */
  130599. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  130600. /**
  130601. * The component name helpful to identify the component in the list of scene components.
  130602. */
  130603. readonly name: string;
  130604. /**
  130605. * The scene the component belongs to.
  130606. */
  130607. scene: Scene;
  130608. /**
  130609. * Creates a new instance of the component for the given scene
  130610. * @param scene Defines the scene to register the component in
  130611. */
  130612. constructor(scene: Scene);
  130613. /**
  130614. * Registers the component in a given scene
  130615. */
  130616. register(): void;
  130617. /**
  130618. * Rebuilds the elements related to this component in case of
  130619. * context lost for instance.
  130620. */
  130621. rebuild(): void;
  130622. /**
  130623. * Disposes the component and the associated ressources
  130624. */
  130625. dispose(): void;
  130626. private _gatherRenderTargets;
  130627. }
  130628. }
  130629. declare module BABYLON {
  130630. /** @hidden */
  130631. export var motionBlurPixelShader: {
  130632. name: string;
  130633. shader: string;
  130634. };
  130635. }
  130636. declare module BABYLON {
  130637. /**
  130638. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  130639. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  130640. * As an example, all you have to do is to create the post-process:
  130641. * var mb = new BABYLON.MotionBlurPostProcess(
  130642. * 'mb', // The name of the effect.
  130643. * scene, // The scene containing the objects to blur according to their velocity.
  130644. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  130645. * camera // The camera to apply the render pass to.
  130646. * );
  130647. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  130648. */
  130649. export class MotionBlurPostProcess extends PostProcess {
  130650. /**
  130651. * Defines how much the image is blurred by the movement. Default value is equal to 1
  130652. */
  130653. motionStrength: number;
  130654. /**
  130655. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  130656. */
  130657. /**
  130658. * Sets the number of iterations to be used for motion blur quality
  130659. */
  130660. motionBlurSamples: number;
  130661. private _motionBlurSamples;
  130662. private _geometryBufferRenderer;
  130663. /**
  130664. * Creates a new instance MotionBlurPostProcess
  130665. * @param name The name of the effect.
  130666. * @param scene The scene containing the objects to blur according to their velocity.
  130667. * @param options The required width/height ratio to downsize to before computing the render pass.
  130668. * @param camera The camera to apply the render pass to.
  130669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130670. * @param engine The engine which the post process will be applied. (default: current engine)
  130671. * @param reusable If the post process can be reused on the same frame. (default: false)
  130672. * @param textureType Type of textures used when performing the post process. (default: 0)
  130673. * @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)
  130674. */
  130675. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130676. /**
  130677. * Excludes the given skinned mesh from computing bones velocities.
  130678. * 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.
  130679. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  130680. */
  130681. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130682. /**
  130683. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  130684. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  130685. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  130686. */
  130687. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130688. /**
  130689. * Disposes the post process.
  130690. * @param camera The camera to dispose the post process on.
  130691. */
  130692. dispose(camera?: Camera): void;
  130693. }
  130694. }
  130695. declare module BABYLON {
  130696. /** @hidden */
  130697. export var refractionPixelShader: {
  130698. name: string;
  130699. shader: string;
  130700. };
  130701. }
  130702. declare module BABYLON {
  130703. /**
  130704. * Post process which applies a refractin texture
  130705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130706. */
  130707. export class RefractionPostProcess extends PostProcess {
  130708. /** the base color of the refraction (used to taint the rendering) */
  130709. color: Color3;
  130710. /** simulated refraction depth */
  130711. depth: number;
  130712. /** the coefficient of the base color (0 to remove base color tainting) */
  130713. colorLevel: number;
  130714. private _refTexture;
  130715. private _ownRefractionTexture;
  130716. /**
  130717. * Gets or sets the refraction texture
  130718. * Please note that you are responsible for disposing the texture if you set it manually
  130719. */
  130720. refractionTexture: Texture;
  130721. /**
  130722. * Initializes the RefractionPostProcess
  130723. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130724. * @param name The name of the effect.
  130725. * @param refractionTextureUrl Url of the refraction texture to use
  130726. * @param color the base color of the refraction (used to taint the rendering)
  130727. * @param depth simulated refraction depth
  130728. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  130729. * @param camera The camera to apply the render pass to.
  130730. * @param options The required width/height ratio to downsize to before computing the render pass.
  130731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130732. * @param engine The engine which the post process will be applied. (default: current engine)
  130733. * @param reusable If the post process can be reused on the same frame. (default: false)
  130734. */
  130735. constructor(name: string, refractionTextureUrl: string,
  130736. /** the base color of the refraction (used to taint the rendering) */
  130737. color: Color3,
  130738. /** simulated refraction depth */
  130739. depth: number,
  130740. /** the coefficient of the base color (0 to remove base color tainting) */
  130741. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130742. /**
  130743. * Disposes of the post process
  130744. * @param camera Camera to dispose post process on
  130745. */
  130746. dispose(camera: Camera): void;
  130747. }
  130748. }
  130749. declare module BABYLON {
  130750. /** @hidden */
  130751. export var sharpenPixelShader: {
  130752. name: string;
  130753. shader: string;
  130754. };
  130755. }
  130756. declare module BABYLON {
  130757. /**
  130758. * The SharpenPostProcess applies a sharpen kernel to every pixel
  130759. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130760. */
  130761. export class SharpenPostProcess extends PostProcess {
  130762. /**
  130763. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  130764. */
  130765. colorAmount: number;
  130766. /**
  130767. * How much sharpness should be applied (default: 0.3)
  130768. */
  130769. edgeAmount: number;
  130770. /**
  130771. * Creates a new instance ConvolutionPostProcess
  130772. * @param name The name of the effect.
  130773. * @param options The required width/height ratio to downsize to before computing the render pass.
  130774. * @param camera The camera to apply the render pass to.
  130775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130776. * @param engine The engine which the post process will be applied. (default: current engine)
  130777. * @param reusable If the post process can be reused on the same frame. (default: false)
  130778. * @param textureType Type of textures used when performing the post process. (default: 0)
  130779. * @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)
  130780. */
  130781. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130782. }
  130783. }
  130784. declare module BABYLON {
  130785. /**
  130786. * PostProcessRenderPipeline
  130787. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130788. */
  130789. export class PostProcessRenderPipeline {
  130790. private engine;
  130791. private _renderEffects;
  130792. private _renderEffectsForIsolatedPass;
  130793. /**
  130794. * List of inspectable custom properties (used by the Inspector)
  130795. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  130796. */
  130797. inspectableCustomProperties: IInspectable[];
  130798. /**
  130799. * @hidden
  130800. */
  130801. protected _cameras: Camera[];
  130802. /** @hidden */
  130803. _name: string;
  130804. /**
  130805. * Gets pipeline name
  130806. */
  130807. readonly name: string;
  130808. /** Gets the list of attached cameras */
  130809. readonly cameras: Camera[];
  130810. /**
  130811. * Initializes a PostProcessRenderPipeline
  130812. * @param engine engine to add the pipeline to
  130813. * @param name name of the pipeline
  130814. */
  130815. constructor(engine: Engine, name: string);
  130816. /**
  130817. * Gets the class name
  130818. * @returns "PostProcessRenderPipeline"
  130819. */
  130820. getClassName(): string;
  130821. /**
  130822. * If all the render effects in the pipeline are supported
  130823. */
  130824. readonly isSupported: boolean;
  130825. /**
  130826. * Adds an effect to the pipeline
  130827. * @param renderEffect the effect to add
  130828. */
  130829. addEffect(renderEffect: PostProcessRenderEffect): void;
  130830. /** @hidden */
  130831. _rebuild(): void;
  130832. /** @hidden */
  130833. _enableEffect(renderEffectName: string, cameras: Camera): void;
  130834. /** @hidden */
  130835. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  130836. /** @hidden */
  130837. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130838. /** @hidden */
  130839. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130840. /** @hidden */
  130841. _attachCameras(cameras: Camera, unique: boolean): void;
  130842. /** @hidden */
  130843. _attachCameras(cameras: Camera[], unique: boolean): void;
  130844. /** @hidden */
  130845. _detachCameras(cameras: Camera): void;
  130846. /** @hidden */
  130847. _detachCameras(cameras: Nullable<Camera[]>): void;
  130848. /** @hidden */
  130849. _update(): void;
  130850. /** @hidden */
  130851. _reset(): void;
  130852. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  130853. /**
  130854. * Disposes of the pipeline
  130855. */
  130856. dispose(): void;
  130857. }
  130858. }
  130859. declare module BABYLON {
  130860. /**
  130861. * PostProcessRenderPipelineManager class
  130862. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130863. */
  130864. export class PostProcessRenderPipelineManager {
  130865. private _renderPipelines;
  130866. /**
  130867. * Initializes a PostProcessRenderPipelineManager
  130868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130869. */
  130870. constructor();
  130871. /**
  130872. * Gets the list of supported render pipelines
  130873. */
  130874. readonly supportedPipelines: PostProcessRenderPipeline[];
  130875. /**
  130876. * Adds a pipeline to the manager
  130877. * @param renderPipeline The pipeline to add
  130878. */
  130879. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  130880. /**
  130881. * Attaches a camera to the pipeline
  130882. * @param renderPipelineName The name of the pipeline to attach to
  130883. * @param cameras the camera to attach
  130884. * @param unique if the camera can be attached multiple times to the pipeline
  130885. */
  130886. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  130887. /**
  130888. * Detaches a camera from the pipeline
  130889. * @param renderPipelineName The name of the pipeline to detach from
  130890. * @param cameras the camera to detach
  130891. */
  130892. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  130893. /**
  130894. * Enables an effect by name on a pipeline
  130895. * @param renderPipelineName the name of the pipeline to enable the effect in
  130896. * @param renderEffectName the name of the effect to enable
  130897. * @param cameras the cameras that the effect should be enabled on
  130898. */
  130899. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130900. /**
  130901. * Disables an effect by name on a pipeline
  130902. * @param renderPipelineName the name of the pipeline to disable the effect in
  130903. * @param renderEffectName the name of the effect to disable
  130904. * @param cameras the cameras that the effect should be disabled on
  130905. */
  130906. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130907. /**
  130908. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  130909. */
  130910. update(): void;
  130911. /** @hidden */
  130912. _rebuild(): void;
  130913. /**
  130914. * Disposes of the manager and pipelines
  130915. */
  130916. dispose(): void;
  130917. }
  130918. }
  130919. declare module BABYLON {
  130920. interface Scene {
  130921. /** @hidden (Backing field) */
  130922. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130923. /**
  130924. * Gets the postprocess render pipeline manager
  130925. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130926. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130927. */
  130928. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130929. }
  130930. /**
  130931. * Defines the Render Pipeline scene component responsible to rendering pipelines
  130932. */
  130933. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  130934. /**
  130935. * The component name helpfull to identify the component in the list of scene components.
  130936. */
  130937. readonly name: string;
  130938. /**
  130939. * The scene the component belongs to.
  130940. */
  130941. scene: Scene;
  130942. /**
  130943. * Creates a new instance of the component for the given scene
  130944. * @param scene Defines the scene to register the component in
  130945. */
  130946. constructor(scene: Scene);
  130947. /**
  130948. * Registers the component in a given scene
  130949. */
  130950. register(): void;
  130951. /**
  130952. * Rebuilds the elements related to this component in case of
  130953. * context lost for instance.
  130954. */
  130955. rebuild(): void;
  130956. /**
  130957. * Disposes the component and the associated ressources
  130958. */
  130959. dispose(): void;
  130960. private _gatherRenderTargets;
  130961. }
  130962. }
  130963. declare module BABYLON {
  130964. /**
  130965. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  130966. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130967. */
  130968. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130969. private _scene;
  130970. private _camerasToBeAttached;
  130971. /**
  130972. * ID of the sharpen post process,
  130973. */
  130974. private readonly SharpenPostProcessId;
  130975. /**
  130976. * @ignore
  130977. * ID of the image processing post process;
  130978. */
  130979. readonly ImageProcessingPostProcessId: string;
  130980. /**
  130981. * @ignore
  130982. * ID of the Fast Approximate Anti-Aliasing post process;
  130983. */
  130984. readonly FxaaPostProcessId: string;
  130985. /**
  130986. * ID of the chromatic aberration post process,
  130987. */
  130988. private readonly ChromaticAberrationPostProcessId;
  130989. /**
  130990. * ID of the grain post process
  130991. */
  130992. private readonly GrainPostProcessId;
  130993. /**
  130994. * Sharpen post process which will apply a sharpen convolution to enhance edges
  130995. */
  130996. sharpen: SharpenPostProcess;
  130997. private _sharpenEffect;
  130998. private bloom;
  130999. /**
  131000. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  131001. */
  131002. depthOfField: DepthOfFieldEffect;
  131003. /**
  131004. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  131005. */
  131006. fxaa: FxaaPostProcess;
  131007. /**
  131008. * Image post processing pass used to perform operations such as tone mapping or color grading.
  131009. */
  131010. imageProcessing: ImageProcessingPostProcess;
  131011. /**
  131012. * Chromatic aberration post process which will shift rgb colors in the image
  131013. */
  131014. chromaticAberration: ChromaticAberrationPostProcess;
  131015. private _chromaticAberrationEffect;
  131016. /**
  131017. * Grain post process which add noise to the image
  131018. */
  131019. grain: GrainPostProcess;
  131020. private _grainEffect;
  131021. /**
  131022. * Glow post process which adds a glow to emissive areas of the image
  131023. */
  131024. private _glowLayer;
  131025. /**
  131026. * Animations which can be used to tweak settings over a period of time
  131027. */
  131028. animations: Animation[];
  131029. private _imageProcessingConfigurationObserver;
  131030. private _sharpenEnabled;
  131031. private _bloomEnabled;
  131032. private _depthOfFieldEnabled;
  131033. private _depthOfFieldBlurLevel;
  131034. private _fxaaEnabled;
  131035. private _imageProcessingEnabled;
  131036. private _defaultPipelineTextureType;
  131037. private _bloomScale;
  131038. private _chromaticAberrationEnabled;
  131039. private _grainEnabled;
  131040. private _buildAllowed;
  131041. /**
  131042. * Gets active scene
  131043. */
  131044. readonly scene: Scene;
  131045. /**
  131046. * Enable or disable the sharpen process from the pipeline
  131047. */
  131048. sharpenEnabled: boolean;
  131049. private _resizeObserver;
  131050. private _hardwareScaleLevel;
  131051. private _bloomKernel;
  131052. /**
  131053. * Specifies the size of the bloom blur kernel, relative to the final output size
  131054. */
  131055. bloomKernel: number;
  131056. /**
  131057. * Specifies the weight of the bloom in the final rendering
  131058. */
  131059. private _bloomWeight;
  131060. /**
  131061. * Specifies the luma threshold for the area that will be blurred by the bloom
  131062. */
  131063. private _bloomThreshold;
  131064. private _hdr;
  131065. /**
  131066. * The strength of the bloom.
  131067. */
  131068. bloomWeight: number;
  131069. /**
  131070. * The strength of the bloom.
  131071. */
  131072. bloomThreshold: number;
  131073. /**
  131074. * The scale of the bloom, lower value will provide better performance.
  131075. */
  131076. bloomScale: number;
  131077. /**
  131078. * Enable or disable the bloom from the pipeline
  131079. */
  131080. bloomEnabled: boolean;
  131081. private _rebuildBloom;
  131082. /**
  131083. * If the depth of field is enabled.
  131084. */
  131085. depthOfFieldEnabled: boolean;
  131086. /**
  131087. * Blur level of the depth of field effect. (Higher blur will effect performance)
  131088. */
  131089. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  131090. /**
  131091. * If the anti aliasing is enabled.
  131092. */
  131093. fxaaEnabled: boolean;
  131094. private _samples;
  131095. /**
  131096. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131097. */
  131098. samples: number;
  131099. /**
  131100. * If image processing is enabled.
  131101. */
  131102. imageProcessingEnabled: boolean;
  131103. /**
  131104. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  131105. */
  131106. glowLayerEnabled: boolean;
  131107. /**
  131108. * Gets the glow layer (or null if not defined)
  131109. */
  131110. readonly glowLayer: Nullable<GlowLayer>;
  131111. /**
  131112. * Enable or disable the chromaticAberration process from the pipeline
  131113. */
  131114. chromaticAberrationEnabled: boolean;
  131115. /**
  131116. * Enable or disable the grain process from the pipeline
  131117. */
  131118. grainEnabled: boolean;
  131119. /**
  131120. * @constructor
  131121. * @param name - The rendering pipeline name (default: "")
  131122. * @param hdr - If high dynamic range textures should be used (default: true)
  131123. * @param scene - The scene linked to this pipeline (default: the last created scene)
  131124. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  131125. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  131126. */
  131127. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  131128. /**
  131129. * Get the class name
  131130. * @returns "DefaultRenderingPipeline"
  131131. */
  131132. getClassName(): string;
  131133. /**
  131134. * Force the compilation of the entire pipeline.
  131135. */
  131136. prepare(): void;
  131137. private _hasCleared;
  131138. private _prevPostProcess;
  131139. private _prevPrevPostProcess;
  131140. private _setAutoClearAndTextureSharing;
  131141. private _depthOfFieldSceneObserver;
  131142. private _buildPipeline;
  131143. private _disposePostProcesses;
  131144. /**
  131145. * Adds a camera to the pipeline
  131146. * @param camera the camera to be added
  131147. */
  131148. addCamera(camera: Camera): void;
  131149. /**
  131150. * Removes a camera from the pipeline
  131151. * @param camera the camera to remove
  131152. */
  131153. removeCamera(camera: Camera): void;
  131154. /**
  131155. * Dispose of the pipeline and stop all post processes
  131156. */
  131157. dispose(): void;
  131158. /**
  131159. * Serialize the rendering pipeline (Used when exporting)
  131160. * @returns the serialized object
  131161. */
  131162. serialize(): any;
  131163. /**
  131164. * Parse the serialized pipeline
  131165. * @param source Source pipeline.
  131166. * @param scene The scene to load the pipeline to.
  131167. * @param rootUrl The URL of the serialized pipeline.
  131168. * @returns An instantiated pipeline from the serialized object.
  131169. */
  131170. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  131171. }
  131172. }
  131173. declare module BABYLON {
  131174. /** @hidden */
  131175. export var lensHighlightsPixelShader: {
  131176. name: string;
  131177. shader: string;
  131178. };
  131179. }
  131180. declare module BABYLON {
  131181. /** @hidden */
  131182. export var depthOfFieldPixelShader: {
  131183. name: string;
  131184. shader: string;
  131185. };
  131186. }
  131187. declare module BABYLON {
  131188. /**
  131189. * BABYLON.JS Chromatic Aberration GLSL Shader
  131190. * Author: Olivier Guyot
  131191. * Separates very slightly R, G and B colors on the edges of the screen
  131192. * Inspired by Francois Tarlier & Martins Upitis
  131193. */
  131194. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  131195. /**
  131196. * @ignore
  131197. * The chromatic aberration PostProcess id in the pipeline
  131198. */
  131199. LensChromaticAberrationEffect: string;
  131200. /**
  131201. * @ignore
  131202. * The highlights enhancing PostProcess id in the pipeline
  131203. */
  131204. HighlightsEnhancingEffect: string;
  131205. /**
  131206. * @ignore
  131207. * The depth-of-field PostProcess id in the pipeline
  131208. */
  131209. LensDepthOfFieldEffect: string;
  131210. private _scene;
  131211. private _depthTexture;
  131212. private _grainTexture;
  131213. private _chromaticAberrationPostProcess;
  131214. private _highlightsPostProcess;
  131215. private _depthOfFieldPostProcess;
  131216. private _edgeBlur;
  131217. private _grainAmount;
  131218. private _chromaticAberration;
  131219. private _distortion;
  131220. private _highlightsGain;
  131221. private _highlightsThreshold;
  131222. private _dofDistance;
  131223. private _dofAperture;
  131224. private _dofDarken;
  131225. private _dofPentagon;
  131226. private _blurNoise;
  131227. /**
  131228. * @constructor
  131229. *
  131230. * Effect parameters are as follow:
  131231. * {
  131232. * chromatic_aberration: number; // from 0 to x (1 for realism)
  131233. * edge_blur: number; // from 0 to x (1 for realism)
  131234. * distortion: number; // from 0 to x (1 for realism)
  131235. * grain_amount: number; // from 0 to 1
  131236. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  131237. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  131238. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  131239. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  131240. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  131241. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  131242. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  131243. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  131244. * }
  131245. * Note: if an effect parameter is unset, effect is disabled
  131246. *
  131247. * @param name The rendering pipeline name
  131248. * @param parameters - An object containing all parameters (see above)
  131249. * @param scene The scene linked to this pipeline
  131250. * @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)
  131251. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131252. */
  131253. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  131254. /**
  131255. * Get the class name
  131256. * @returns "LensRenderingPipeline"
  131257. */
  131258. getClassName(): string;
  131259. /**
  131260. * Gets associated scene
  131261. */
  131262. readonly scene: Scene;
  131263. /**
  131264. * Gets or sets the edge blur
  131265. */
  131266. edgeBlur: number;
  131267. /**
  131268. * Gets or sets the grain amount
  131269. */
  131270. grainAmount: number;
  131271. /**
  131272. * Gets or sets the chromatic aberration amount
  131273. */
  131274. chromaticAberration: number;
  131275. /**
  131276. * Gets or sets the depth of field aperture
  131277. */
  131278. dofAperture: number;
  131279. /**
  131280. * Gets or sets the edge distortion
  131281. */
  131282. edgeDistortion: number;
  131283. /**
  131284. * Gets or sets the depth of field distortion
  131285. */
  131286. dofDistortion: number;
  131287. /**
  131288. * Gets or sets the darken out of focus amount
  131289. */
  131290. darkenOutOfFocus: number;
  131291. /**
  131292. * Gets or sets a boolean indicating if blur noise is enabled
  131293. */
  131294. blurNoise: boolean;
  131295. /**
  131296. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  131297. */
  131298. pentagonBokeh: boolean;
  131299. /**
  131300. * Gets or sets the highlight grain amount
  131301. */
  131302. highlightsGain: number;
  131303. /**
  131304. * Gets or sets the highlight threshold
  131305. */
  131306. highlightsThreshold: number;
  131307. /**
  131308. * Sets the amount of blur at the edges
  131309. * @param amount blur amount
  131310. */
  131311. setEdgeBlur(amount: number): void;
  131312. /**
  131313. * Sets edge blur to 0
  131314. */
  131315. disableEdgeBlur(): void;
  131316. /**
  131317. * Sets the amout of grain
  131318. * @param amount Amount of grain
  131319. */
  131320. setGrainAmount(amount: number): void;
  131321. /**
  131322. * Set grain amount to 0
  131323. */
  131324. disableGrain(): void;
  131325. /**
  131326. * Sets the chromatic aberration amount
  131327. * @param amount amount of chromatic aberration
  131328. */
  131329. setChromaticAberration(amount: number): void;
  131330. /**
  131331. * Sets chromatic aberration amount to 0
  131332. */
  131333. disableChromaticAberration(): void;
  131334. /**
  131335. * Sets the EdgeDistortion amount
  131336. * @param amount amount of EdgeDistortion
  131337. */
  131338. setEdgeDistortion(amount: number): void;
  131339. /**
  131340. * Sets edge distortion to 0
  131341. */
  131342. disableEdgeDistortion(): void;
  131343. /**
  131344. * Sets the FocusDistance amount
  131345. * @param amount amount of FocusDistance
  131346. */
  131347. setFocusDistance(amount: number): void;
  131348. /**
  131349. * Disables depth of field
  131350. */
  131351. disableDepthOfField(): void;
  131352. /**
  131353. * Sets the Aperture amount
  131354. * @param amount amount of Aperture
  131355. */
  131356. setAperture(amount: number): void;
  131357. /**
  131358. * Sets the DarkenOutOfFocus amount
  131359. * @param amount amount of DarkenOutOfFocus
  131360. */
  131361. setDarkenOutOfFocus(amount: number): void;
  131362. private _pentagonBokehIsEnabled;
  131363. /**
  131364. * Creates a pentagon bokeh effect
  131365. */
  131366. enablePentagonBokeh(): void;
  131367. /**
  131368. * Disables the pentagon bokeh effect
  131369. */
  131370. disablePentagonBokeh(): void;
  131371. /**
  131372. * Enables noise blur
  131373. */
  131374. enableNoiseBlur(): void;
  131375. /**
  131376. * Disables noise blur
  131377. */
  131378. disableNoiseBlur(): void;
  131379. /**
  131380. * Sets the HighlightsGain amount
  131381. * @param amount amount of HighlightsGain
  131382. */
  131383. setHighlightsGain(amount: number): void;
  131384. /**
  131385. * Sets the HighlightsThreshold amount
  131386. * @param amount amount of HighlightsThreshold
  131387. */
  131388. setHighlightsThreshold(amount: number): void;
  131389. /**
  131390. * Disables highlights
  131391. */
  131392. disableHighlights(): void;
  131393. /**
  131394. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  131395. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  131396. */
  131397. dispose(disableDepthRender?: boolean): void;
  131398. private _createChromaticAberrationPostProcess;
  131399. private _createHighlightsPostProcess;
  131400. private _createDepthOfFieldPostProcess;
  131401. private _createGrainTexture;
  131402. }
  131403. }
  131404. declare module BABYLON {
  131405. /** @hidden */
  131406. export var ssao2PixelShader: {
  131407. name: string;
  131408. shader: string;
  131409. };
  131410. }
  131411. declare module BABYLON {
  131412. /** @hidden */
  131413. export var ssaoCombinePixelShader: {
  131414. name: string;
  131415. shader: string;
  131416. };
  131417. }
  131418. declare module BABYLON {
  131419. /**
  131420. * Render pipeline to produce ssao effect
  131421. */
  131422. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  131423. /**
  131424. * @ignore
  131425. * The PassPostProcess id in the pipeline that contains the original scene color
  131426. */
  131427. SSAOOriginalSceneColorEffect: string;
  131428. /**
  131429. * @ignore
  131430. * The SSAO PostProcess id in the pipeline
  131431. */
  131432. SSAORenderEffect: string;
  131433. /**
  131434. * @ignore
  131435. * The horizontal blur PostProcess id in the pipeline
  131436. */
  131437. SSAOBlurHRenderEffect: string;
  131438. /**
  131439. * @ignore
  131440. * The vertical blur PostProcess id in the pipeline
  131441. */
  131442. SSAOBlurVRenderEffect: string;
  131443. /**
  131444. * @ignore
  131445. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131446. */
  131447. SSAOCombineRenderEffect: string;
  131448. /**
  131449. * The output strength of the SSAO post-process. Default value is 1.0.
  131450. */
  131451. totalStrength: number;
  131452. /**
  131453. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  131454. */
  131455. maxZ: number;
  131456. /**
  131457. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  131458. */
  131459. minZAspect: number;
  131460. private _samples;
  131461. /**
  131462. * Number of samples used for the SSAO calculations. Default value is 8
  131463. */
  131464. samples: number;
  131465. private _textureSamples;
  131466. /**
  131467. * Number of samples to use for antialiasing
  131468. */
  131469. textureSamples: number;
  131470. /**
  131471. * Ratio object used for SSAO ratio and blur ratio
  131472. */
  131473. private _ratio;
  131474. /**
  131475. * Dynamically generated sphere sampler.
  131476. */
  131477. private _sampleSphere;
  131478. /**
  131479. * Blur filter offsets
  131480. */
  131481. private _samplerOffsets;
  131482. private _expensiveBlur;
  131483. /**
  131484. * If bilateral blur should be used
  131485. */
  131486. expensiveBlur: boolean;
  131487. /**
  131488. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  131489. */
  131490. radius: number;
  131491. /**
  131492. * The base color of the SSAO post-process
  131493. * The final result is "base + ssao" between [0, 1]
  131494. */
  131495. base: number;
  131496. /**
  131497. * Support test.
  131498. */
  131499. static readonly IsSupported: boolean;
  131500. private _scene;
  131501. private _depthTexture;
  131502. private _normalTexture;
  131503. private _randomTexture;
  131504. private _originalColorPostProcess;
  131505. private _ssaoPostProcess;
  131506. private _blurHPostProcess;
  131507. private _blurVPostProcess;
  131508. private _ssaoCombinePostProcess;
  131509. /**
  131510. * Gets active scene
  131511. */
  131512. readonly scene: Scene;
  131513. /**
  131514. * @constructor
  131515. * @param name The rendering pipeline name
  131516. * @param scene The scene linked to this pipeline
  131517. * @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 }
  131518. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131519. */
  131520. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131521. /**
  131522. * Get the class name
  131523. * @returns "SSAO2RenderingPipeline"
  131524. */
  131525. getClassName(): string;
  131526. /**
  131527. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131528. */
  131529. dispose(disableGeometryBufferRenderer?: boolean): void;
  131530. private _createBlurPostProcess;
  131531. /** @hidden */
  131532. _rebuild(): void;
  131533. private _bits;
  131534. private _radicalInverse_VdC;
  131535. private _hammersley;
  131536. private _hemisphereSample_uniform;
  131537. private _generateHemisphere;
  131538. private _createSSAOPostProcess;
  131539. private _createSSAOCombinePostProcess;
  131540. private _createRandomTexture;
  131541. /**
  131542. * Serialize the rendering pipeline (Used when exporting)
  131543. * @returns the serialized object
  131544. */
  131545. serialize(): any;
  131546. /**
  131547. * Parse the serialized pipeline
  131548. * @param source Source pipeline.
  131549. * @param scene The scene to load the pipeline to.
  131550. * @param rootUrl The URL of the serialized pipeline.
  131551. * @returns An instantiated pipeline from the serialized object.
  131552. */
  131553. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  131554. }
  131555. }
  131556. declare module BABYLON {
  131557. /** @hidden */
  131558. export var ssaoPixelShader: {
  131559. name: string;
  131560. shader: string;
  131561. };
  131562. }
  131563. declare module BABYLON {
  131564. /**
  131565. * Render pipeline to produce ssao effect
  131566. */
  131567. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  131568. /**
  131569. * @ignore
  131570. * The PassPostProcess id in the pipeline that contains the original scene color
  131571. */
  131572. SSAOOriginalSceneColorEffect: string;
  131573. /**
  131574. * @ignore
  131575. * The SSAO PostProcess id in the pipeline
  131576. */
  131577. SSAORenderEffect: string;
  131578. /**
  131579. * @ignore
  131580. * The horizontal blur PostProcess id in the pipeline
  131581. */
  131582. SSAOBlurHRenderEffect: string;
  131583. /**
  131584. * @ignore
  131585. * The vertical blur PostProcess id in the pipeline
  131586. */
  131587. SSAOBlurVRenderEffect: string;
  131588. /**
  131589. * @ignore
  131590. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131591. */
  131592. SSAOCombineRenderEffect: string;
  131593. /**
  131594. * The output strength of the SSAO post-process. Default value is 1.0.
  131595. */
  131596. totalStrength: number;
  131597. /**
  131598. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  131599. */
  131600. radius: number;
  131601. /**
  131602. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  131603. * Must not be equal to fallOff and superior to fallOff.
  131604. * Default value is 0.0075
  131605. */
  131606. area: number;
  131607. /**
  131608. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  131609. * Must not be equal to area and inferior to area.
  131610. * Default value is 0.000001
  131611. */
  131612. fallOff: number;
  131613. /**
  131614. * The base color of the SSAO post-process
  131615. * The final result is "base + ssao" between [0, 1]
  131616. */
  131617. base: number;
  131618. private _scene;
  131619. private _depthTexture;
  131620. private _randomTexture;
  131621. private _originalColorPostProcess;
  131622. private _ssaoPostProcess;
  131623. private _blurHPostProcess;
  131624. private _blurVPostProcess;
  131625. private _ssaoCombinePostProcess;
  131626. private _firstUpdate;
  131627. /**
  131628. * Gets active scene
  131629. */
  131630. readonly scene: Scene;
  131631. /**
  131632. * @constructor
  131633. * @param name - The rendering pipeline name
  131634. * @param scene - The scene linked to this pipeline
  131635. * @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 }
  131636. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  131637. */
  131638. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131639. /**
  131640. * Get the class name
  131641. * @returns "SSAORenderingPipeline"
  131642. */
  131643. getClassName(): string;
  131644. /**
  131645. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131646. */
  131647. dispose(disableDepthRender?: boolean): void;
  131648. private _createBlurPostProcess;
  131649. /** @hidden */
  131650. _rebuild(): void;
  131651. private _createSSAOPostProcess;
  131652. private _createSSAOCombinePostProcess;
  131653. private _createRandomTexture;
  131654. }
  131655. }
  131656. declare module BABYLON {
  131657. /** @hidden */
  131658. export var standardPixelShader: {
  131659. name: string;
  131660. shader: string;
  131661. };
  131662. }
  131663. declare module BABYLON {
  131664. /**
  131665. * Standard rendering pipeline
  131666. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131667. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  131668. */
  131669. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  131670. /**
  131671. * Public members
  131672. */
  131673. /**
  131674. * Post-process which contains the original scene color before the pipeline applies all the effects
  131675. */
  131676. originalPostProcess: Nullable<PostProcess>;
  131677. /**
  131678. * Post-process used to down scale an image x4
  131679. */
  131680. downSampleX4PostProcess: Nullable<PostProcess>;
  131681. /**
  131682. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  131683. */
  131684. brightPassPostProcess: Nullable<PostProcess>;
  131685. /**
  131686. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  131687. */
  131688. blurHPostProcesses: PostProcess[];
  131689. /**
  131690. * Post-process array storing all the vertical blur post-processes used by the pipeline
  131691. */
  131692. blurVPostProcesses: PostProcess[];
  131693. /**
  131694. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  131695. */
  131696. textureAdderPostProcess: Nullable<PostProcess>;
  131697. /**
  131698. * Post-process used to create volumetric lighting effect
  131699. */
  131700. volumetricLightPostProcess: Nullable<PostProcess>;
  131701. /**
  131702. * Post-process used to smooth the previous volumetric light post-process on the X axis
  131703. */
  131704. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  131705. /**
  131706. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  131707. */
  131708. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  131709. /**
  131710. * Post-process used to merge the volumetric light effect and the real scene color
  131711. */
  131712. volumetricLightMergePostProces: Nullable<PostProcess>;
  131713. /**
  131714. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  131715. */
  131716. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  131717. /**
  131718. * Base post-process used to calculate the average luminance of the final image for HDR
  131719. */
  131720. luminancePostProcess: Nullable<PostProcess>;
  131721. /**
  131722. * Post-processes used to create down sample post-processes in order to get
  131723. * the average luminance of the final image for HDR
  131724. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  131725. */
  131726. luminanceDownSamplePostProcesses: PostProcess[];
  131727. /**
  131728. * Post-process used to create a HDR effect (light adaptation)
  131729. */
  131730. hdrPostProcess: Nullable<PostProcess>;
  131731. /**
  131732. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  131733. */
  131734. textureAdderFinalPostProcess: Nullable<PostProcess>;
  131735. /**
  131736. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  131737. */
  131738. lensFlareFinalPostProcess: Nullable<PostProcess>;
  131739. /**
  131740. * Post-process used to merge the final HDR post-process and the real scene color
  131741. */
  131742. hdrFinalPostProcess: Nullable<PostProcess>;
  131743. /**
  131744. * Post-process used to create a lens flare effect
  131745. */
  131746. lensFlarePostProcess: Nullable<PostProcess>;
  131747. /**
  131748. * Post-process that merges the result of the lens flare post-process and the real scene color
  131749. */
  131750. lensFlareComposePostProcess: Nullable<PostProcess>;
  131751. /**
  131752. * Post-process used to create a motion blur effect
  131753. */
  131754. motionBlurPostProcess: Nullable<PostProcess>;
  131755. /**
  131756. * Post-process used to create a depth of field effect
  131757. */
  131758. depthOfFieldPostProcess: Nullable<PostProcess>;
  131759. /**
  131760. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  131761. */
  131762. fxaaPostProcess: Nullable<FxaaPostProcess>;
  131763. /**
  131764. * Represents the brightness threshold in order to configure the illuminated surfaces
  131765. */
  131766. brightThreshold: number;
  131767. /**
  131768. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  131769. */
  131770. blurWidth: number;
  131771. /**
  131772. * Sets if the blur for highlighted surfaces must be only horizontal
  131773. */
  131774. horizontalBlur: boolean;
  131775. /**
  131776. * Gets the overall exposure used by the pipeline
  131777. */
  131778. /**
  131779. * Sets the overall exposure used by the pipeline
  131780. */
  131781. exposure: number;
  131782. /**
  131783. * Texture used typically to simulate "dirty" on camera lens
  131784. */
  131785. lensTexture: Nullable<Texture>;
  131786. /**
  131787. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  131788. */
  131789. volumetricLightCoefficient: number;
  131790. /**
  131791. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  131792. */
  131793. volumetricLightPower: number;
  131794. /**
  131795. * Used the set the blur intensity to smooth the volumetric lights
  131796. */
  131797. volumetricLightBlurScale: number;
  131798. /**
  131799. * Light (spot or directional) used to generate the volumetric lights rays
  131800. * The source light must have a shadow generate so the pipeline can get its
  131801. * depth map
  131802. */
  131803. sourceLight: Nullable<SpotLight | DirectionalLight>;
  131804. /**
  131805. * For eye adaptation, represents the minimum luminance the eye can see
  131806. */
  131807. hdrMinimumLuminance: number;
  131808. /**
  131809. * For eye adaptation, represents the decrease luminance speed
  131810. */
  131811. hdrDecreaseRate: number;
  131812. /**
  131813. * For eye adaptation, represents the increase luminance speed
  131814. */
  131815. hdrIncreaseRate: number;
  131816. /**
  131817. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131818. */
  131819. /**
  131820. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131821. */
  131822. hdrAutoExposure: boolean;
  131823. /**
  131824. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  131825. */
  131826. lensColorTexture: Nullable<Texture>;
  131827. /**
  131828. * The overall strengh for the lens flare effect
  131829. */
  131830. lensFlareStrength: number;
  131831. /**
  131832. * Dispersion coefficient for lens flare ghosts
  131833. */
  131834. lensFlareGhostDispersal: number;
  131835. /**
  131836. * Main lens flare halo width
  131837. */
  131838. lensFlareHaloWidth: number;
  131839. /**
  131840. * Based on the lens distortion effect, defines how much the lens flare result
  131841. * is distorted
  131842. */
  131843. lensFlareDistortionStrength: number;
  131844. /**
  131845. * Configures the blur intensity used for for lens flare (halo)
  131846. */
  131847. lensFlareBlurWidth: number;
  131848. /**
  131849. * Lens star texture must be used to simulate rays on the flares and is available
  131850. * in the documentation
  131851. */
  131852. lensStarTexture: Nullable<Texture>;
  131853. /**
  131854. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  131855. * flare effect by taking account of the dirt texture
  131856. */
  131857. lensFlareDirtTexture: Nullable<Texture>;
  131858. /**
  131859. * Represents the focal length for the depth of field effect
  131860. */
  131861. depthOfFieldDistance: number;
  131862. /**
  131863. * Represents the blur intensity for the blurred part of the depth of field effect
  131864. */
  131865. depthOfFieldBlurWidth: number;
  131866. /**
  131867. * Gets how much the image is blurred by the movement while using the motion blur post-process
  131868. */
  131869. /**
  131870. * Sets how much the image is blurred by the movement while using the motion blur post-process
  131871. */
  131872. motionStrength: number;
  131873. /**
  131874. * Gets wether or not the motion blur post-process is object based or screen based.
  131875. */
  131876. /**
  131877. * Sets wether or not the motion blur post-process should be object based or screen based
  131878. */
  131879. objectBasedMotionBlur: boolean;
  131880. /**
  131881. * List of animations for the pipeline (IAnimatable implementation)
  131882. */
  131883. animations: Animation[];
  131884. /**
  131885. * Private members
  131886. */
  131887. private _scene;
  131888. private _currentDepthOfFieldSource;
  131889. private _basePostProcess;
  131890. private _fixedExposure;
  131891. private _currentExposure;
  131892. private _hdrAutoExposure;
  131893. private _hdrCurrentLuminance;
  131894. private _motionStrength;
  131895. private _isObjectBasedMotionBlur;
  131896. private _floatTextureType;
  131897. private _camerasToBeAttached;
  131898. private _ratio;
  131899. private _bloomEnabled;
  131900. private _depthOfFieldEnabled;
  131901. private _vlsEnabled;
  131902. private _lensFlareEnabled;
  131903. private _hdrEnabled;
  131904. private _motionBlurEnabled;
  131905. private _fxaaEnabled;
  131906. private _motionBlurSamples;
  131907. private _volumetricLightStepsCount;
  131908. private _samples;
  131909. /**
  131910. * @ignore
  131911. * Specifies if the bloom pipeline is enabled
  131912. */
  131913. BloomEnabled: boolean;
  131914. /**
  131915. * @ignore
  131916. * Specifies if the depth of field pipeline is enabed
  131917. */
  131918. DepthOfFieldEnabled: boolean;
  131919. /**
  131920. * @ignore
  131921. * Specifies if the lens flare pipeline is enabed
  131922. */
  131923. LensFlareEnabled: boolean;
  131924. /**
  131925. * @ignore
  131926. * Specifies if the HDR pipeline is enabled
  131927. */
  131928. HDREnabled: boolean;
  131929. /**
  131930. * @ignore
  131931. * Specifies if the volumetric lights scattering effect is enabled
  131932. */
  131933. VLSEnabled: boolean;
  131934. /**
  131935. * @ignore
  131936. * Specifies if the motion blur effect is enabled
  131937. */
  131938. MotionBlurEnabled: boolean;
  131939. /**
  131940. * Specifies if anti-aliasing is enabled
  131941. */
  131942. fxaaEnabled: boolean;
  131943. /**
  131944. * Specifies the number of steps used to calculate the volumetric lights
  131945. * Typically in interval [50, 200]
  131946. */
  131947. volumetricLightStepsCount: number;
  131948. /**
  131949. * Specifies the number of samples used for the motion blur effect
  131950. * Typically in interval [16, 64]
  131951. */
  131952. motionBlurSamples: number;
  131953. /**
  131954. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131955. */
  131956. samples: number;
  131957. /**
  131958. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131959. * @constructor
  131960. * @param name The rendering pipeline name
  131961. * @param scene The scene linked to this pipeline
  131962. * @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)
  131963. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  131964. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131965. */
  131966. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  131967. private _buildPipeline;
  131968. private _createDownSampleX4PostProcess;
  131969. private _createBrightPassPostProcess;
  131970. private _createBlurPostProcesses;
  131971. private _createTextureAdderPostProcess;
  131972. private _createVolumetricLightPostProcess;
  131973. private _createLuminancePostProcesses;
  131974. private _createHdrPostProcess;
  131975. private _createLensFlarePostProcess;
  131976. private _createDepthOfFieldPostProcess;
  131977. private _createMotionBlurPostProcess;
  131978. private _getDepthTexture;
  131979. private _disposePostProcesses;
  131980. /**
  131981. * Dispose of the pipeline and stop all post processes
  131982. */
  131983. dispose(): void;
  131984. /**
  131985. * Serialize the rendering pipeline (Used when exporting)
  131986. * @returns the serialized object
  131987. */
  131988. serialize(): any;
  131989. /**
  131990. * Parse the serialized pipeline
  131991. * @param source Source pipeline.
  131992. * @param scene The scene to load the pipeline to.
  131993. * @param rootUrl The URL of the serialized pipeline.
  131994. * @returns An instantiated pipeline from the serialized object.
  131995. */
  131996. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  131997. /**
  131998. * Luminance steps
  131999. */
  132000. static LuminanceSteps: number;
  132001. }
  132002. }
  132003. declare module BABYLON {
  132004. /** @hidden */
  132005. export var tonemapPixelShader: {
  132006. name: string;
  132007. shader: string;
  132008. };
  132009. }
  132010. declare module BABYLON {
  132011. /** Defines operator used for tonemapping */
  132012. export enum TonemappingOperator {
  132013. /** Hable */
  132014. Hable = 0,
  132015. /** Reinhard */
  132016. Reinhard = 1,
  132017. /** HejiDawson */
  132018. HejiDawson = 2,
  132019. /** Photographic */
  132020. Photographic = 3
  132021. }
  132022. /**
  132023. * Defines a post process to apply tone mapping
  132024. */
  132025. export class TonemapPostProcess extends PostProcess {
  132026. private _operator;
  132027. /** Defines the required exposure adjustement */
  132028. exposureAdjustment: number;
  132029. /**
  132030. * Creates a new TonemapPostProcess
  132031. * @param name defines the name of the postprocess
  132032. * @param _operator defines the operator to use
  132033. * @param exposureAdjustment defines the required exposure adjustement
  132034. * @param camera defines the camera to use (can be null)
  132035. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  132036. * @param engine defines the hosting engine (can be ignore if camera is set)
  132037. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  132038. */
  132039. constructor(name: string, _operator: TonemappingOperator,
  132040. /** Defines the required exposure adjustement */
  132041. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  132042. }
  132043. }
  132044. declare module BABYLON {
  132045. /** @hidden */
  132046. export var depthVertexShader: {
  132047. name: string;
  132048. shader: string;
  132049. };
  132050. }
  132051. declare module BABYLON {
  132052. /** @hidden */
  132053. export var volumetricLightScatteringPixelShader: {
  132054. name: string;
  132055. shader: string;
  132056. };
  132057. }
  132058. declare module BABYLON {
  132059. /** @hidden */
  132060. export var volumetricLightScatteringPassVertexShader: {
  132061. name: string;
  132062. shader: string;
  132063. };
  132064. }
  132065. declare module BABYLON {
  132066. /** @hidden */
  132067. export var volumetricLightScatteringPassPixelShader: {
  132068. name: string;
  132069. shader: string;
  132070. };
  132071. }
  132072. declare module BABYLON {
  132073. /**
  132074. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  132075. */
  132076. export class VolumetricLightScatteringPostProcess extends PostProcess {
  132077. private _volumetricLightScatteringPass;
  132078. private _volumetricLightScatteringRTT;
  132079. private _viewPort;
  132080. private _screenCoordinates;
  132081. private _cachedDefines;
  132082. /**
  132083. * If not undefined, the mesh position is computed from the attached node position
  132084. */
  132085. attachedNode: {
  132086. position: Vector3;
  132087. };
  132088. /**
  132089. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  132090. */
  132091. customMeshPosition: Vector3;
  132092. /**
  132093. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  132094. */
  132095. useCustomMeshPosition: boolean;
  132096. /**
  132097. * If the post-process should inverse the light scattering direction
  132098. */
  132099. invert: boolean;
  132100. /**
  132101. * The internal mesh used by the post-process
  132102. */
  132103. mesh: Mesh;
  132104. /**
  132105. * @hidden
  132106. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  132107. */
  132108. useDiffuseColor: boolean;
  132109. /**
  132110. * Array containing the excluded meshes not rendered in the internal pass
  132111. */
  132112. excludedMeshes: AbstractMesh[];
  132113. /**
  132114. * Controls the overall intensity of the post-process
  132115. */
  132116. exposure: number;
  132117. /**
  132118. * Dissipates each sample's contribution in range [0, 1]
  132119. */
  132120. decay: number;
  132121. /**
  132122. * Controls the overall intensity of each sample
  132123. */
  132124. weight: number;
  132125. /**
  132126. * Controls the density of each sample
  132127. */
  132128. density: number;
  132129. /**
  132130. * @constructor
  132131. * @param name The post-process name
  132132. * @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)
  132133. * @param camera The camera that the post-process will be attached to
  132134. * @param mesh The mesh used to create the light scattering
  132135. * @param samples The post-process quality, default 100
  132136. * @param samplingModeThe post-process filtering mode
  132137. * @param engine The babylon engine
  132138. * @param reusable If the post-process is reusable
  132139. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  132140. */
  132141. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  132142. /**
  132143. * Returns the string "VolumetricLightScatteringPostProcess"
  132144. * @returns "VolumetricLightScatteringPostProcess"
  132145. */
  132146. getClassName(): string;
  132147. private _isReady;
  132148. /**
  132149. * Sets the new light position for light scattering effect
  132150. * @param position The new custom light position
  132151. */
  132152. setCustomMeshPosition(position: Vector3): void;
  132153. /**
  132154. * Returns the light position for light scattering effect
  132155. * @return Vector3 The custom light position
  132156. */
  132157. getCustomMeshPosition(): Vector3;
  132158. /**
  132159. * Disposes the internal assets and detaches the post-process from the camera
  132160. */
  132161. dispose(camera: Camera): void;
  132162. /**
  132163. * Returns the render target texture used by the post-process
  132164. * @return the render target texture used by the post-process
  132165. */
  132166. getPass(): RenderTargetTexture;
  132167. private _meshExcluded;
  132168. private _createPass;
  132169. private _updateMeshScreenCoordinates;
  132170. /**
  132171. * Creates a default mesh for the Volumeric Light Scattering post-process
  132172. * @param name The mesh name
  132173. * @param scene The scene where to create the mesh
  132174. * @return the default mesh
  132175. */
  132176. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  132177. }
  132178. }
  132179. declare module BABYLON {
  132180. interface Scene {
  132181. /** @hidden (Backing field) */
  132182. _boundingBoxRenderer: BoundingBoxRenderer;
  132183. /** @hidden (Backing field) */
  132184. _forceShowBoundingBoxes: boolean;
  132185. /**
  132186. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  132187. */
  132188. forceShowBoundingBoxes: boolean;
  132189. /**
  132190. * Gets the bounding box renderer associated with the scene
  132191. * @returns a BoundingBoxRenderer
  132192. */
  132193. getBoundingBoxRenderer(): BoundingBoxRenderer;
  132194. }
  132195. interface AbstractMesh {
  132196. /** @hidden (Backing field) */
  132197. _showBoundingBox: boolean;
  132198. /**
  132199. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  132200. */
  132201. showBoundingBox: boolean;
  132202. }
  132203. /**
  132204. * Component responsible of rendering the bounding box of the meshes in a scene.
  132205. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  132206. */
  132207. export class BoundingBoxRenderer implements ISceneComponent {
  132208. /**
  132209. * The component name helpfull to identify the component in the list of scene components.
  132210. */
  132211. readonly name: string;
  132212. /**
  132213. * The scene the component belongs to.
  132214. */
  132215. scene: Scene;
  132216. /**
  132217. * Color of the bounding box lines placed in front of an object
  132218. */
  132219. frontColor: Color3;
  132220. /**
  132221. * Color of the bounding box lines placed behind an object
  132222. */
  132223. backColor: Color3;
  132224. /**
  132225. * Defines if the renderer should show the back lines or not
  132226. */
  132227. showBackLines: boolean;
  132228. /**
  132229. * @hidden
  132230. */
  132231. renderList: SmartArray<BoundingBox>;
  132232. private _colorShader;
  132233. private _vertexBuffers;
  132234. private _indexBuffer;
  132235. private _fillIndexBuffer;
  132236. private _fillIndexData;
  132237. /**
  132238. * Instantiates a new bounding box renderer in a scene.
  132239. * @param scene the scene the renderer renders in
  132240. */
  132241. constructor(scene: Scene);
  132242. /**
  132243. * Registers the component in a given scene
  132244. */
  132245. register(): void;
  132246. private _evaluateSubMesh;
  132247. private _activeMesh;
  132248. private _prepareRessources;
  132249. private _createIndexBuffer;
  132250. /**
  132251. * Rebuilds the elements related to this component in case of
  132252. * context lost for instance.
  132253. */
  132254. rebuild(): void;
  132255. /**
  132256. * @hidden
  132257. */
  132258. reset(): void;
  132259. /**
  132260. * Render the bounding boxes of a specific rendering group
  132261. * @param renderingGroupId defines the rendering group to render
  132262. */
  132263. render(renderingGroupId: number): void;
  132264. /**
  132265. * In case of occlusion queries, we can render the occlusion bounding box through this method
  132266. * @param mesh Define the mesh to render the occlusion bounding box for
  132267. */
  132268. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  132269. /**
  132270. * Dispose and release the resources attached to this renderer.
  132271. */
  132272. dispose(): void;
  132273. }
  132274. }
  132275. declare module BABYLON {
  132276. /** @hidden */
  132277. export var depthPixelShader: {
  132278. name: string;
  132279. shader: string;
  132280. };
  132281. }
  132282. declare module BABYLON {
  132283. /**
  132284. * This represents a depth renderer in Babylon.
  132285. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  132286. */
  132287. export class DepthRenderer {
  132288. private _scene;
  132289. private _depthMap;
  132290. private _effect;
  132291. private readonly _storeNonLinearDepth;
  132292. private readonly _clearColor;
  132293. /** Get if the depth renderer is using packed depth or not */
  132294. readonly isPacked: boolean;
  132295. private _cachedDefines;
  132296. private _camera;
  132297. /**
  132298. * Specifiess that the depth renderer will only be used within
  132299. * the camera it is created for.
  132300. * This can help forcing its rendering during the camera processing.
  132301. */
  132302. useOnlyInActiveCamera: boolean;
  132303. /** @hidden */
  132304. static _SceneComponentInitialization: (scene: Scene) => void;
  132305. /**
  132306. * Instantiates a depth renderer
  132307. * @param scene The scene the renderer belongs to
  132308. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  132309. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  132310. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132311. */
  132312. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  132313. /**
  132314. * Creates the depth rendering effect and checks if the effect is ready.
  132315. * @param subMesh The submesh to be used to render the depth map of
  132316. * @param useInstances If multiple world instances should be used
  132317. * @returns if the depth renderer is ready to render the depth map
  132318. */
  132319. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132320. /**
  132321. * Gets the texture which the depth map will be written to.
  132322. * @returns The depth map texture
  132323. */
  132324. getDepthMap(): RenderTargetTexture;
  132325. /**
  132326. * Disposes of the depth renderer.
  132327. */
  132328. dispose(): void;
  132329. }
  132330. }
  132331. declare module BABYLON {
  132332. interface Scene {
  132333. /** @hidden (Backing field) */
  132334. _depthRenderer: {
  132335. [id: string]: DepthRenderer;
  132336. };
  132337. /**
  132338. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  132339. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  132340. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132341. * @returns the created depth renderer
  132342. */
  132343. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  132344. /**
  132345. * Disables a depth renderer for a given camera
  132346. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  132347. */
  132348. disableDepthRenderer(camera?: Nullable<Camera>): void;
  132349. }
  132350. /**
  132351. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  132352. * in several rendering techniques.
  132353. */
  132354. export class DepthRendererSceneComponent implements ISceneComponent {
  132355. /**
  132356. * The component name helpfull to identify the component in the list of scene components.
  132357. */
  132358. readonly name: string;
  132359. /**
  132360. * The scene the component belongs to.
  132361. */
  132362. scene: Scene;
  132363. /**
  132364. * Creates a new instance of the component for the given scene
  132365. * @param scene Defines the scene to register the component in
  132366. */
  132367. constructor(scene: Scene);
  132368. /**
  132369. * Registers the component in a given scene
  132370. */
  132371. register(): void;
  132372. /**
  132373. * Rebuilds the elements related to this component in case of
  132374. * context lost for instance.
  132375. */
  132376. rebuild(): void;
  132377. /**
  132378. * Disposes the component and the associated ressources
  132379. */
  132380. dispose(): void;
  132381. private _gatherRenderTargets;
  132382. private _gatherActiveCameraRenderTargets;
  132383. }
  132384. }
  132385. declare module BABYLON {
  132386. /** @hidden */
  132387. export var outlinePixelShader: {
  132388. name: string;
  132389. shader: string;
  132390. };
  132391. }
  132392. declare module BABYLON {
  132393. /** @hidden */
  132394. export var outlineVertexShader: {
  132395. name: string;
  132396. shader: string;
  132397. };
  132398. }
  132399. declare module BABYLON {
  132400. interface Scene {
  132401. /** @hidden */
  132402. _outlineRenderer: OutlineRenderer;
  132403. /**
  132404. * Gets the outline renderer associated with the scene
  132405. * @returns a OutlineRenderer
  132406. */
  132407. getOutlineRenderer(): OutlineRenderer;
  132408. }
  132409. interface AbstractMesh {
  132410. /** @hidden (Backing field) */
  132411. _renderOutline: boolean;
  132412. /**
  132413. * Gets or sets a boolean indicating if the outline must be rendered as well
  132414. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  132415. */
  132416. renderOutline: boolean;
  132417. /** @hidden (Backing field) */
  132418. _renderOverlay: boolean;
  132419. /**
  132420. * Gets or sets a boolean indicating if the overlay must be rendered as well
  132421. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  132422. */
  132423. renderOverlay: boolean;
  132424. }
  132425. /**
  132426. * This class is responsible to draw bothe outline/overlay of meshes.
  132427. * It should not be used directly but through the available method on mesh.
  132428. */
  132429. export class OutlineRenderer implements ISceneComponent {
  132430. /**
  132431. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  132432. */
  132433. private static _StencilReference;
  132434. /**
  132435. * The name of the component. Each component must have a unique name.
  132436. */
  132437. name: string;
  132438. /**
  132439. * The scene the component belongs to.
  132440. */
  132441. scene: Scene;
  132442. /**
  132443. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  132444. */
  132445. zOffset: number;
  132446. private _engine;
  132447. private _effect;
  132448. private _cachedDefines;
  132449. private _savedDepthWrite;
  132450. /**
  132451. * Instantiates a new outline renderer. (There could be only one per scene).
  132452. * @param scene Defines the scene it belongs to
  132453. */
  132454. constructor(scene: Scene);
  132455. /**
  132456. * Register the component to one instance of a scene.
  132457. */
  132458. register(): void;
  132459. /**
  132460. * Rebuilds the elements related to this component in case of
  132461. * context lost for instance.
  132462. */
  132463. rebuild(): void;
  132464. /**
  132465. * Disposes the component and the associated ressources.
  132466. */
  132467. dispose(): void;
  132468. /**
  132469. * Renders the outline in the canvas.
  132470. * @param subMesh Defines the sumesh to render
  132471. * @param batch Defines the batch of meshes in case of instances
  132472. * @param useOverlay Defines if the rendering is for the overlay or the outline
  132473. */
  132474. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  132475. /**
  132476. * Returns whether or not the outline renderer is ready for a given submesh.
  132477. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  132478. * @param subMesh Defines the submesh to check readyness for
  132479. * @param useInstances Defines wheter wee are trying to render instances or not
  132480. * @returns true if ready otherwise false
  132481. */
  132482. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132483. private _beforeRenderingMesh;
  132484. private _afterRenderingMesh;
  132485. }
  132486. }
  132487. declare module BABYLON {
  132488. /**
  132489. * Class used to manage multiple sprites of different sizes on the same spritesheet
  132490. * @see http://doc.babylonjs.com/babylon101/sprites
  132491. */
  132492. export class SpritePackedManager extends SpriteManager {
  132493. /** defines the packed manager's name */
  132494. name: string;
  132495. /**
  132496. * Creates a new sprite manager from a packed sprite sheet
  132497. * @param name defines the manager's name
  132498. * @param imgUrl defines the sprite sheet url
  132499. * @param capacity defines the maximum allowed number of sprites
  132500. * @param scene defines the hosting scene
  132501. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  132502. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  132503. * @param samplingMode defines the smapling mode to use with spritesheet
  132504. * @param fromPacked set to true; do not alter
  132505. */
  132506. constructor(
  132507. /** defines the packed manager's name */
  132508. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  132509. }
  132510. }
  132511. declare module BABYLON {
  132512. /**
  132513. * Defines the list of states available for a task inside a AssetsManager
  132514. */
  132515. export enum AssetTaskState {
  132516. /**
  132517. * Initialization
  132518. */
  132519. INIT = 0,
  132520. /**
  132521. * Running
  132522. */
  132523. RUNNING = 1,
  132524. /**
  132525. * Done
  132526. */
  132527. DONE = 2,
  132528. /**
  132529. * Error
  132530. */
  132531. ERROR = 3
  132532. }
  132533. /**
  132534. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  132535. */
  132536. export abstract class AbstractAssetTask {
  132537. /**
  132538. * Task name
  132539. */ name: string;
  132540. /**
  132541. * Callback called when the task is successful
  132542. */
  132543. onSuccess: (task: any) => void;
  132544. /**
  132545. * Callback called when the task is not successful
  132546. */
  132547. onError: (task: any, message?: string, exception?: any) => void;
  132548. /**
  132549. * Creates a new AssetsManager
  132550. * @param name defines the name of the task
  132551. */
  132552. constructor(
  132553. /**
  132554. * Task name
  132555. */ name: string);
  132556. private _isCompleted;
  132557. private _taskState;
  132558. private _errorObject;
  132559. /**
  132560. * Get if the task is completed
  132561. */
  132562. readonly isCompleted: boolean;
  132563. /**
  132564. * Gets the current state of the task
  132565. */
  132566. readonly taskState: AssetTaskState;
  132567. /**
  132568. * Gets the current error object (if task is in error)
  132569. */
  132570. readonly errorObject: {
  132571. message?: string;
  132572. exception?: any;
  132573. };
  132574. /**
  132575. * Internal only
  132576. * @hidden
  132577. */
  132578. _setErrorObject(message?: string, exception?: any): void;
  132579. /**
  132580. * Execute the current task
  132581. * @param scene defines the scene where you want your assets to be loaded
  132582. * @param onSuccess is a callback called when the task is successfully executed
  132583. * @param onError is a callback called if an error occurs
  132584. */
  132585. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132586. /**
  132587. * Execute the current task
  132588. * @param scene defines the scene where you want your assets to be loaded
  132589. * @param onSuccess is a callback called when the task is successfully executed
  132590. * @param onError is a callback called if an error occurs
  132591. */
  132592. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132593. /**
  132594. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  132595. * This can be used with failed tasks that have the reason for failure fixed.
  132596. */
  132597. reset(): void;
  132598. private onErrorCallback;
  132599. private onDoneCallback;
  132600. }
  132601. /**
  132602. * Define the interface used by progress events raised during assets loading
  132603. */
  132604. export interface IAssetsProgressEvent {
  132605. /**
  132606. * Defines the number of remaining tasks to process
  132607. */
  132608. remainingCount: number;
  132609. /**
  132610. * Defines the total number of tasks
  132611. */
  132612. totalCount: number;
  132613. /**
  132614. * Defines the task that was just processed
  132615. */
  132616. task: AbstractAssetTask;
  132617. }
  132618. /**
  132619. * Class used to share progress information about assets loading
  132620. */
  132621. export class AssetsProgressEvent implements IAssetsProgressEvent {
  132622. /**
  132623. * Defines the number of remaining tasks to process
  132624. */
  132625. remainingCount: number;
  132626. /**
  132627. * Defines the total number of tasks
  132628. */
  132629. totalCount: number;
  132630. /**
  132631. * Defines the task that was just processed
  132632. */
  132633. task: AbstractAssetTask;
  132634. /**
  132635. * Creates a AssetsProgressEvent
  132636. * @param remainingCount defines the number of remaining tasks to process
  132637. * @param totalCount defines the total number of tasks
  132638. * @param task defines the task that was just processed
  132639. */
  132640. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  132641. }
  132642. /**
  132643. * Define a task used by AssetsManager to load meshes
  132644. */
  132645. export class MeshAssetTask extends AbstractAssetTask {
  132646. /**
  132647. * Defines the name of the task
  132648. */
  132649. name: string;
  132650. /**
  132651. * Defines the list of mesh's names you want to load
  132652. */
  132653. meshesNames: any;
  132654. /**
  132655. * Defines the root url to use as a base to load your meshes and associated resources
  132656. */
  132657. rootUrl: string;
  132658. /**
  132659. * Defines the filename of the scene to load from
  132660. */
  132661. sceneFilename: string;
  132662. /**
  132663. * Gets the list of loaded meshes
  132664. */
  132665. loadedMeshes: Array<AbstractMesh>;
  132666. /**
  132667. * Gets the list of loaded particle systems
  132668. */
  132669. loadedParticleSystems: Array<IParticleSystem>;
  132670. /**
  132671. * Gets the list of loaded skeletons
  132672. */
  132673. loadedSkeletons: Array<Skeleton>;
  132674. /**
  132675. * Gets the list of loaded animation groups
  132676. */
  132677. loadedAnimationGroups: Array<AnimationGroup>;
  132678. /**
  132679. * Callback called when the task is successful
  132680. */
  132681. onSuccess: (task: MeshAssetTask) => void;
  132682. /**
  132683. * Callback called when the task is successful
  132684. */
  132685. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  132686. /**
  132687. * Creates a new MeshAssetTask
  132688. * @param name defines the name of the task
  132689. * @param meshesNames defines the list of mesh's names you want to load
  132690. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  132691. * @param sceneFilename defines the filename of the scene to load from
  132692. */
  132693. constructor(
  132694. /**
  132695. * Defines the name of the task
  132696. */
  132697. name: string,
  132698. /**
  132699. * Defines the list of mesh's names you want to load
  132700. */
  132701. meshesNames: any,
  132702. /**
  132703. * Defines the root url to use as a base to load your meshes and associated resources
  132704. */
  132705. rootUrl: string,
  132706. /**
  132707. * Defines the filename of the scene to load from
  132708. */
  132709. sceneFilename: string);
  132710. /**
  132711. * Execute the current task
  132712. * @param scene defines the scene where you want your assets to be loaded
  132713. * @param onSuccess is a callback called when the task is successfully executed
  132714. * @param onError is a callback called if an error occurs
  132715. */
  132716. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132717. }
  132718. /**
  132719. * Define a task used by AssetsManager to load text content
  132720. */
  132721. export class TextFileAssetTask extends AbstractAssetTask {
  132722. /**
  132723. * Defines the name of the task
  132724. */
  132725. name: string;
  132726. /**
  132727. * Defines the location of the file to load
  132728. */
  132729. url: string;
  132730. /**
  132731. * Gets the loaded text string
  132732. */
  132733. text: string;
  132734. /**
  132735. * Callback called when the task is successful
  132736. */
  132737. onSuccess: (task: TextFileAssetTask) => void;
  132738. /**
  132739. * Callback called when the task is successful
  132740. */
  132741. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  132742. /**
  132743. * Creates a new TextFileAssetTask object
  132744. * @param name defines the name of the task
  132745. * @param url defines the location of the file to load
  132746. */
  132747. constructor(
  132748. /**
  132749. * Defines the name of the task
  132750. */
  132751. name: string,
  132752. /**
  132753. * Defines the location of the file to load
  132754. */
  132755. url: string);
  132756. /**
  132757. * Execute the current task
  132758. * @param scene defines the scene where you want your assets to be loaded
  132759. * @param onSuccess is a callback called when the task is successfully executed
  132760. * @param onError is a callback called if an error occurs
  132761. */
  132762. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132763. }
  132764. /**
  132765. * Define a task used by AssetsManager to load binary data
  132766. */
  132767. export class BinaryFileAssetTask extends AbstractAssetTask {
  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. * Gets the lodaded data (as an array buffer)
  132778. */
  132779. data: ArrayBuffer;
  132780. /**
  132781. * Callback called when the task is successful
  132782. */
  132783. onSuccess: (task: BinaryFileAssetTask) => void;
  132784. /**
  132785. * Callback called when the task is successful
  132786. */
  132787. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  132788. /**
  132789. * Creates a new BinaryFileAssetTask object
  132790. * @param name defines the name of the new task
  132791. * @param url defines the location of the file to load
  132792. */
  132793. constructor(
  132794. /**
  132795. * Defines the name of the task
  132796. */
  132797. name: string,
  132798. /**
  132799. * Defines the location of the file to load
  132800. */
  132801. url: string);
  132802. /**
  132803. * Execute the current task
  132804. * @param scene defines the scene where you want your assets to be loaded
  132805. * @param onSuccess is a callback called when the task is successfully executed
  132806. * @param onError is a callback called if an error occurs
  132807. */
  132808. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132809. }
  132810. /**
  132811. * Define a task used by AssetsManager to load images
  132812. */
  132813. export class ImageAssetTask extends AbstractAssetTask {
  132814. /**
  132815. * Defines the name of the task
  132816. */
  132817. name: string;
  132818. /**
  132819. * Defines the location of the image to load
  132820. */
  132821. url: string;
  132822. /**
  132823. * Gets the loaded images
  132824. */
  132825. image: HTMLImageElement;
  132826. /**
  132827. * Callback called when the task is successful
  132828. */
  132829. onSuccess: (task: ImageAssetTask) => void;
  132830. /**
  132831. * Callback called when the task is successful
  132832. */
  132833. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  132834. /**
  132835. * Creates a new ImageAssetTask
  132836. * @param name defines the name of the task
  132837. * @param url defines the location of the image to load
  132838. */
  132839. constructor(
  132840. /**
  132841. * Defines the name of the task
  132842. */
  132843. name: string,
  132844. /**
  132845. * Defines the location of the image to load
  132846. */
  132847. url: string);
  132848. /**
  132849. * Execute the current task
  132850. * @param scene defines the scene where you want your assets to be loaded
  132851. * @param onSuccess is a callback called when the task is successfully executed
  132852. * @param onError is a callback called if an error occurs
  132853. */
  132854. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132855. }
  132856. /**
  132857. * Defines the interface used by texture loading tasks
  132858. */
  132859. export interface ITextureAssetTask<TEX extends BaseTexture> {
  132860. /**
  132861. * Gets the loaded texture
  132862. */
  132863. texture: TEX;
  132864. }
  132865. /**
  132866. * Define a task used by AssetsManager to load 2D textures
  132867. */
  132868. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  132869. /**
  132870. * Defines the name of the task
  132871. */
  132872. name: string;
  132873. /**
  132874. * Defines the location of the file to load
  132875. */
  132876. url: string;
  132877. /**
  132878. * Defines if mipmap should not be generated (default is false)
  132879. */
  132880. noMipmap?: boolean | undefined;
  132881. /**
  132882. * Defines if texture must be inverted on Y axis (default is false)
  132883. */
  132884. invertY?: boolean | undefined;
  132885. /**
  132886. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132887. */
  132888. samplingMode: number;
  132889. /**
  132890. * Gets the loaded texture
  132891. */
  132892. texture: Texture;
  132893. /**
  132894. * Callback called when the task is successful
  132895. */
  132896. onSuccess: (task: TextureAssetTask) => void;
  132897. /**
  132898. * Callback called when the task is successful
  132899. */
  132900. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  132901. /**
  132902. * Creates a new TextureAssetTask object
  132903. * @param name defines the name of the task
  132904. * @param url defines the location of the file to load
  132905. * @param noMipmap defines if mipmap should not be generated (default is false)
  132906. * @param invertY defines if texture must be inverted on Y axis (default is false)
  132907. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132908. */
  132909. constructor(
  132910. /**
  132911. * Defines the name of the task
  132912. */
  132913. name: string,
  132914. /**
  132915. * Defines the location of the file to load
  132916. */
  132917. url: string,
  132918. /**
  132919. * Defines if mipmap should not be generated (default is false)
  132920. */
  132921. noMipmap?: boolean | undefined,
  132922. /**
  132923. * Defines if texture must be inverted on Y axis (default is false)
  132924. */
  132925. invertY?: boolean | undefined,
  132926. /**
  132927. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132928. */
  132929. samplingMode?: number);
  132930. /**
  132931. * Execute the current task
  132932. * @param scene defines the scene where you want your assets to be loaded
  132933. * @param onSuccess is a callback called when the task is successfully executed
  132934. * @param onError is a callback called if an error occurs
  132935. */
  132936. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132937. }
  132938. /**
  132939. * Define a task used by AssetsManager to load cube textures
  132940. */
  132941. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  132942. /**
  132943. * Defines the name of the task
  132944. */
  132945. name: string;
  132946. /**
  132947. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132948. */
  132949. url: string;
  132950. /**
  132951. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132952. */
  132953. extensions?: string[] | undefined;
  132954. /**
  132955. * Defines if mipmaps should not be generated (default is false)
  132956. */
  132957. noMipmap?: boolean | undefined;
  132958. /**
  132959. * Defines the explicit list of files (undefined by default)
  132960. */
  132961. files?: string[] | undefined;
  132962. /**
  132963. * Gets the loaded texture
  132964. */
  132965. texture: CubeTexture;
  132966. /**
  132967. * Callback called when the task is successful
  132968. */
  132969. onSuccess: (task: CubeTextureAssetTask) => void;
  132970. /**
  132971. * Callback called when the task is successful
  132972. */
  132973. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  132974. /**
  132975. * Creates a new CubeTextureAssetTask
  132976. * @param name defines the name of the task
  132977. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132978. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132979. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132980. * @param files defines the explicit list of files (undefined by default)
  132981. */
  132982. constructor(
  132983. /**
  132984. * Defines the name of the task
  132985. */
  132986. name: string,
  132987. /**
  132988. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132989. */
  132990. url: string,
  132991. /**
  132992. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132993. */
  132994. extensions?: string[] | undefined,
  132995. /**
  132996. * Defines if mipmaps should not be generated (default is false)
  132997. */
  132998. noMipmap?: boolean | undefined,
  132999. /**
  133000. * Defines the explicit list of files (undefined by default)
  133001. */
  133002. files?: string[] | undefined);
  133003. /**
  133004. * Execute the current task
  133005. * @param scene defines the scene where you want your assets to be loaded
  133006. * @param onSuccess is a callback called when the task is successfully executed
  133007. * @param onError is a callback called if an error occurs
  133008. */
  133009. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133010. }
  133011. /**
  133012. * Define a task used by AssetsManager to load HDR cube textures
  133013. */
  133014. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  133015. /**
  133016. * Defines the name of the task
  133017. */
  133018. name: string;
  133019. /**
  133020. * Defines the location of the file to load
  133021. */
  133022. url: string;
  133023. /**
  133024. * Defines the desired size (the more it increases the longer the generation will be)
  133025. */
  133026. size: number;
  133027. /**
  133028. * Defines if mipmaps should not be generated (default is false)
  133029. */
  133030. noMipmap: boolean;
  133031. /**
  133032. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133033. */
  133034. generateHarmonics: boolean;
  133035. /**
  133036. * 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)
  133037. */
  133038. gammaSpace: boolean;
  133039. /**
  133040. * Internal Use Only
  133041. */
  133042. reserved: boolean;
  133043. /**
  133044. * Gets the loaded texture
  133045. */
  133046. texture: HDRCubeTexture;
  133047. /**
  133048. * Callback called when the task is successful
  133049. */
  133050. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  133051. /**
  133052. * Callback called when the task is successful
  133053. */
  133054. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  133055. /**
  133056. * Creates a new HDRCubeTextureAssetTask object
  133057. * @param name defines the name of the task
  133058. * @param url defines the location of the file to load
  133059. * @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.
  133060. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133061. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133062. * @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)
  133063. * @param reserved Internal use only
  133064. */
  133065. constructor(
  133066. /**
  133067. * Defines the name of the task
  133068. */
  133069. name: string,
  133070. /**
  133071. * Defines the location of the file to load
  133072. */
  133073. url: string,
  133074. /**
  133075. * Defines the desired size (the more it increases the longer the generation will be)
  133076. */
  133077. size: number,
  133078. /**
  133079. * Defines if mipmaps should not be generated (default is false)
  133080. */
  133081. noMipmap?: boolean,
  133082. /**
  133083. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133084. */
  133085. generateHarmonics?: boolean,
  133086. /**
  133087. * 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)
  133088. */
  133089. gammaSpace?: boolean,
  133090. /**
  133091. * Internal Use Only
  133092. */
  133093. reserved?: boolean);
  133094. /**
  133095. * Execute the current task
  133096. * @param scene defines the scene where you want your assets to be loaded
  133097. * @param onSuccess is a callback called when the task is successfully executed
  133098. * @param onError is a callback called if an error occurs
  133099. */
  133100. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133101. }
  133102. /**
  133103. * Define a task used by AssetsManager to load Equirectangular cube textures
  133104. */
  133105. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  133106. /**
  133107. * Defines the name of the task
  133108. */
  133109. name: string;
  133110. /**
  133111. * Defines the location of the file to load
  133112. */
  133113. url: string;
  133114. /**
  133115. * Defines the desired size (the more it increases the longer the generation will be)
  133116. */
  133117. size: number;
  133118. /**
  133119. * Defines if mipmaps should not be generated (default is false)
  133120. */
  133121. noMipmap: boolean;
  133122. /**
  133123. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133124. * but the standard material would require them in Gamma space) (default is true)
  133125. */
  133126. gammaSpace: boolean;
  133127. /**
  133128. * Gets the loaded texture
  133129. */
  133130. texture: EquiRectangularCubeTexture;
  133131. /**
  133132. * Callback called when the task is successful
  133133. */
  133134. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  133135. /**
  133136. * Callback called when the task is successful
  133137. */
  133138. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  133139. /**
  133140. * Creates a new EquiRectangularCubeTextureAssetTask object
  133141. * @param name defines the name of the task
  133142. * @param url defines the location of the file to load
  133143. * @param size defines the desired size (the more it increases the longer the generation will be)
  133144. * If the size is omitted this implies you are using a preprocessed cubemap.
  133145. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133146. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  133147. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  133148. * (default is true)
  133149. */
  133150. constructor(
  133151. /**
  133152. * Defines the name of the task
  133153. */
  133154. name: string,
  133155. /**
  133156. * Defines the location of the file to load
  133157. */
  133158. url: string,
  133159. /**
  133160. * Defines the desired size (the more it increases the longer the generation will be)
  133161. */
  133162. size: number,
  133163. /**
  133164. * Defines if mipmaps should not be generated (default is false)
  133165. */
  133166. noMipmap?: boolean,
  133167. /**
  133168. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133169. * but the standard material would require them in Gamma space) (default is true)
  133170. */
  133171. gammaSpace?: boolean);
  133172. /**
  133173. * Execute the current task
  133174. * @param scene defines the scene where you want your assets to be loaded
  133175. * @param onSuccess is a callback called when the task is successfully executed
  133176. * @param onError is a callback called if an error occurs
  133177. */
  133178. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133179. }
  133180. /**
  133181. * This class can be used to easily import assets into a scene
  133182. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  133183. */
  133184. export class AssetsManager {
  133185. private _scene;
  133186. private _isLoading;
  133187. protected _tasks: AbstractAssetTask[];
  133188. protected _waitingTasksCount: number;
  133189. protected _totalTasksCount: number;
  133190. /**
  133191. * Callback called when all tasks are processed
  133192. */
  133193. onFinish: (tasks: AbstractAssetTask[]) => void;
  133194. /**
  133195. * Callback called when a task is successful
  133196. */
  133197. onTaskSuccess: (task: AbstractAssetTask) => void;
  133198. /**
  133199. * Callback called when a task had an error
  133200. */
  133201. onTaskError: (task: AbstractAssetTask) => void;
  133202. /**
  133203. * Callback called when a task is done (whatever the result is)
  133204. */
  133205. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  133206. /**
  133207. * Observable called when all tasks are processed
  133208. */
  133209. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  133210. /**
  133211. * Observable called when a task had an error
  133212. */
  133213. onTaskErrorObservable: Observable<AbstractAssetTask>;
  133214. /**
  133215. * Observable called when all tasks were executed
  133216. */
  133217. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  133218. /**
  133219. * Observable called when a task is done (whatever the result is)
  133220. */
  133221. onProgressObservable: Observable<IAssetsProgressEvent>;
  133222. /**
  133223. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  133224. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  133225. */
  133226. useDefaultLoadingScreen: boolean;
  133227. /**
  133228. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  133229. * when all assets have been downloaded.
  133230. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  133231. */
  133232. autoHideLoadingUI: boolean;
  133233. /**
  133234. * Creates a new AssetsManager
  133235. * @param scene defines the scene to work on
  133236. */
  133237. constructor(scene: Scene);
  133238. /**
  133239. * Add a MeshAssetTask to the list of active tasks
  133240. * @param taskName defines the name of the new task
  133241. * @param meshesNames defines the name of meshes to load
  133242. * @param rootUrl defines the root url to use to locate files
  133243. * @param sceneFilename defines the filename of the scene file
  133244. * @returns a new MeshAssetTask object
  133245. */
  133246. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  133247. /**
  133248. * Add a TextFileAssetTask to the list of active tasks
  133249. * @param taskName defines the name of the new task
  133250. * @param url defines the url of the file to load
  133251. * @returns a new TextFileAssetTask object
  133252. */
  133253. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  133254. /**
  133255. * Add a BinaryFileAssetTask to the list of active tasks
  133256. * @param taskName defines the name of the new task
  133257. * @param url defines the url of the file to load
  133258. * @returns a new BinaryFileAssetTask object
  133259. */
  133260. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  133261. /**
  133262. * Add a ImageAssetTask to the list of active tasks
  133263. * @param taskName defines the name of the new task
  133264. * @param url defines the url of the file to load
  133265. * @returns a new ImageAssetTask object
  133266. */
  133267. addImageTask(taskName: string, url: string): ImageAssetTask;
  133268. /**
  133269. * Add a TextureAssetTask to the list of active tasks
  133270. * @param taskName defines the name of the new task
  133271. * @param url defines the url of the file to load
  133272. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133273. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  133274. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133275. * @returns a new TextureAssetTask object
  133276. */
  133277. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  133278. /**
  133279. * Add a CubeTextureAssetTask to the list of active tasks
  133280. * @param taskName defines the name of the new task
  133281. * @param url defines the url of the file to load
  133282. * @param extensions defines the extension to use to load the cube map (can be null)
  133283. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133284. * @param files defines the list of files to load (can be null)
  133285. * @returns a new CubeTextureAssetTask object
  133286. */
  133287. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  133288. /**
  133289. *
  133290. * Add a HDRCubeTextureAssetTask to the list of active tasks
  133291. * @param taskName defines the name of the new task
  133292. * @param url defines the url of the file to load
  133293. * @param size defines the size you want for the cubemap (can be null)
  133294. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133295. * @param generateHarmonics defines if you want to automatically generate (true by default)
  133296. * @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)
  133297. * @param reserved Internal use only
  133298. * @returns a new HDRCubeTextureAssetTask object
  133299. */
  133300. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  133301. /**
  133302. *
  133303. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  133304. * @param taskName defines the name of the new task
  133305. * @param url defines the url of the file to load
  133306. * @param size defines the size you want for the cubemap (can be null)
  133307. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133308. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  133309. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  133310. * @returns a new EquiRectangularCubeTextureAssetTask object
  133311. */
  133312. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  133313. /**
  133314. * Remove a task from the assets manager.
  133315. * @param task the task to remove
  133316. */
  133317. removeTask(task: AbstractAssetTask): void;
  133318. private _decreaseWaitingTasksCount;
  133319. private _runTask;
  133320. /**
  133321. * Reset the AssetsManager and remove all tasks
  133322. * @return the current instance of the AssetsManager
  133323. */
  133324. reset(): AssetsManager;
  133325. /**
  133326. * Start the loading process
  133327. * @return the current instance of the AssetsManager
  133328. */
  133329. load(): AssetsManager;
  133330. /**
  133331. * Start the loading process as an async operation
  133332. * @return a promise returning the list of failed tasks
  133333. */
  133334. loadAsync(): Promise<void>;
  133335. }
  133336. }
  133337. declare module BABYLON {
  133338. /**
  133339. * Wrapper class for promise with external resolve and reject.
  133340. */
  133341. export class Deferred<T> {
  133342. /**
  133343. * The promise associated with this deferred object.
  133344. */
  133345. readonly promise: Promise<T>;
  133346. private _resolve;
  133347. private _reject;
  133348. /**
  133349. * The resolve method of the promise associated with this deferred object.
  133350. */
  133351. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  133352. /**
  133353. * The reject method of the promise associated with this deferred object.
  133354. */
  133355. readonly reject: (reason?: any) => void;
  133356. /**
  133357. * Constructor for this deferred object.
  133358. */
  133359. constructor();
  133360. }
  133361. }
  133362. declare module BABYLON {
  133363. /**
  133364. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  133365. */
  133366. export class MeshExploder {
  133367. private _centerMesh;
  133368. private _meshes;
  133369. private _meshesOrigins;
  133370. private _toCenterVectors;
  133371. private _scaledDirection;
  133372. private _newPosition;
  133373. private _centerPosition;
  133374. /**
  133375. * Explodes meshes from a center mesh.
  133376. * @param meshes The meshes to explode.
  133377. * @param centerMesh The mesh to be center of explosion.
  133378. */
  133379. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  133380. private _setCenterMesh;
  133381. /**
  133382. * Get class name
  133383. * @returns "MeshExploder"
  133384. */
  133385. getClassName(): string;
  133386. /**
  133387. * "Exploded meshes"
  133388. * @returns Array of meshes with the centerMesh at index 0.
  133389. */
  133390. getMeshes(): Array<Mesh>;
  133391. /**
  133392. * Explodes meshes giving a specific direction
  133393. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  133394. */
  133395. explode(direction?: number): void;
  133396. }
  133397. }
  133398. declare module BABYLON {
  133399. /**
  133400. * Class used to help managing file picking and drag'n'drop
  133401. */
  133402. export class FilesInput {
  133403. /**
  133404. * List of files ready to be loaded
  133405. */
  133406. static readonly FilesToLoad: {
  133407. [key: string]: File;
  133408. };
  133409. /**
  133410. * Callback called when a file is processed
  133411. */
  133412. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  133413. private _engine;
  133414. private _currentScene;
  133415. private _sceneLoadedCallback;
  133416. private _progressCallback;
  133417. private _additionalRenderLoopLogicCallback;
  133418. private _textureLoadingCallback;
  133419. private _startingProcessingFilesCallback;
  133420. private _onReloadCallback;
  133421. private _errorCallback;
  133422. private _elementToMonitor;
  133423. private _sceneFileToLoad;
  133424. private _filesToLoad;
  133425. /**
  133426. * Creates a new FilesInput
  133427. * @param engine defines the rendering engine
  133428. * @param scene defines the hosting scene
  133429. * @param sceneLoadedCallback callback called when scene is loaded
  133430. * @param progressCallback callback called to track progress
  133431. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  133432. * @param textureLoadingCallback callback called when a texture is loading
  133433. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  133434. * @param onReloadCallback callback called when a reload is requested
  133435. * @param errorCallback callback call if an error occurs
  133436. */
  133437. 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);
  133438. private _dragEnterHandler;
  133439. private _dragOverHandler;
  133440. private _dropHandler;
  133441. /**
  133442. * Calls this function to listen to drag'n'drop events on a specific DOM element
  133443. * @param elementToMonitor defines the DOM element to track
  133444. */
  133445. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  133446. /**
  133447. * Release all associated resources
  133448. */
  133449. dispose(): void;
  133450. private renderFunction;
  133451. private drag;
  133452. private drop;
  133453. private _traverseFolder;
  133454. private _processFiles;
  133455. /**
  133456. * Load files from a drop event
  133457. * @param event defines the drop event to use as source
  133458. */
  133459. loadFiles(event: any): void;
  133460. private _processReload;
  133461. /**
  133462. * Reload the current scene from the loaded files
  133463. */
  133464. reload(): void;
  133465. }
  133466. }
  133467. declare module BABYLON {
  133468. /**
  133469. * Defines the root class used to create scene optimization to use with SceneOptimizer
  133470. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133471. */
  133472. export class SceneOptimization {
  133473. /**
  133474. * Defines the priority of this optimization (0 by default which means first in the list)
  133475. */
  133476. priority: number;
  133477. /**
  133478. * Gets a string describing the action executed by the current optimization
  133479. * @returns description string
  133480. */
  133481. getDescription(): string;
  133482. /**
  133483. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133484. * @param scene defines the current scene where to apply this optimization
  133485. * @param optimizer defines the current optimizer
  133486. * @returns true if everything that can be done was applied
  133487. */
  133488. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133489. /**
  133490. * Creates the SceneOptimization object
  133491. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133492. * @param desc defines the description associated with the optimization
  133493. */
  133494. constructor(
  133495. /**
  133496. * Defines the priority of this optimization (0 by default which means first in the list)
  133497. */
  133498. priority?: number);
  133499. }
  133500. /**
  133501. * Defines an optimization used to reduce the size of render target textures
  133502. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133503. */
  133504. export class TextureOptimization extends SceneOptimization {
  133505. /**
  133506. * Defines the priority of this optimization (0 by default which means first in the list)
  133507. */
  133508. priority: number;
  133509. /**
  133510. * 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
  133511. */
  133512. maximumSize: number;
  133513. /**
  133514. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133515. */
  133516. step: number;
  133517. /**
  133518. * Gets a string describing the action executed by the current optimization
  133519. * @returns description string
  133520. */
  133521. getDescription(): string;
  133522. /**
  133523. * Creates the TextureOptimization object
  133524. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133525. * @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
  133526. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133527. */
  133528. constructor(
  133529. /**
  133530. * Defines the priority of this optimization (0 by default which means first in the list)
  133531. */
  133532. priority?: number,
  133533. /**
  133534. * 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
  133535. */
  133536. maximumSize?: number,
  133537. /**
  133538. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133539. */
  133540. step?: number);
  133541. /**
  133542. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133543. * @param scene defines the current scene where to apply this optimization
  133544. * @param optimizer defines the current optimizer
  133545. * @returns true if everything that can be done was applied
  133546. */
  133547. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133548. }
  133549. /**
  133550. * Defines an optimization used to increase or decrease the rendering resolution
  133551. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133552. */
  133553. export class HardwareScalingOptimization extends SceneOptimization {
  133554. /**
  133555. * Defines the priority of this optimization (0 by default which means first in the list)
  133556. */
  133557. priority: number;
  133558. /**
  133559. * Defines the maximum scale to use (2 by default)
  133560. */
  133561. maximumScale: number;
  133562. /**
  133563. * Defines the step to use between two passes (0.5 by default)
  133564. */
  133565. step: number;
  133566. private _currentScale;
  133567. private _directionOffset;
  133568. /**
  133569. * Gets a string describing the action executed by the current optimization
  133570. * @return description string
  133571. */
  133572. getDescription(): string;
  133573. /**
  133574. * Creates the HardwareScalingOptimization object
  133575. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133576. * @param maximumScale defines the maximum scale to use (2 by default)
  133577. * @param step defines the step to use between two passes (0.5 by default)
  133578. */
  133579. constructor(
  133580. /**
  133581. * Defines the priority of this optimization (0 by default which means first in the list)
  133582. */
  133583. priority?: number,
  133584. /**
  133585. * Defines the maximum scale to use (2 by default)
  133586. */
  133587. maximumScale?: number,
  133588. /**
  133589. * Defines the step to use between two passes (0.5 by default)
  133590. */
  133591. step?: number);
  133592. /**
  133593. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133594. * @param scene defines the current scene where to apply this optimization
  133595. * @param optimizer defines the current optimizer
  133596. * @returns true if everything that can be done was applied
  133597. */
  133598. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133599. }
  133600. /**
  133601. * Defines an optimization used to remove shadows
  133602. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133603. */
  133604. export class ShadowsOptimization extends SceneOptimization {
  133605. /**
  133606. * Gets a string describing the action executed by the current optimization
  133607. * @return description string
  133608. */
  133609. getDescription(): string;
  133610. /**
  133611. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133612. * @param scene defines the current scene where to apply this optimization
  133613. * @param optimizer defines the current optimizer
  133614. * @returns true if everything that can be done was applied
  133615. */
  133616. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133617. }
  133618. /**
  133619. * Defines an optimization used to turn post-processes off
  133620. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133621. */
  133622. export class PostProcessesOptimization extends SceneOptimization {
  133623. /**
  133624. * Gets a string describing the action executed by the current optimization
  133625. * @return description string
  133626. */
  133627. getDescription(): string;
  133628. /**
  133629. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133630. * @param scene defines the current scene where to apply this optimization
  133631. * @param optimizer defines the current optimizer
  133632. * @returns true if everything that can be done was applied
  133633. */
  133634. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133635. }
  133636. /**
  133637. * Defines an optimization used to turn lens flares off
  133638. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133639. */
  133640. export class LensFlaresOptimization extends SceneOptimization {
  133641. /**
  133642. * Gets a string describing the action executed by the current optimization
  133643. * @return description string
  133644. */
  133645. getDescription(): string;
  133646. /**
  133647. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133648. * @param scene defines the current scene where to apply this optimization
  133649. * @param optimizer defines the current optimizer
  133650. * @returns true if everything that can be done was applied
  133651. */
  133652. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133653. }
  133654. /**
  133655. * Defines an optimization based on user defined callback.
  133656. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133657. */
  133658. export class CustomOptimization extends SceneOptimization {
  133659. /**
  133660. * Callback called to apply the custom optimization.
  133661. */
  133662. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  133663. /**
  133664. * Callback called to get custom description
  133665. */
  133666. onGetDescription: () => string;
  133667. /**
  133668. * Gets a string describing the action executed by the current optimization
  133669. * @returns description string
  133670. */
  133671. getDescription(): string;
  133672. /**
  133673. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133674. * @param scene defines the current scene where to apply this optimization
  133675. * @param optimizer defines the current optimizer
  133676. * @returns true if everything that can be done was applied
  133677. */
  133678. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133679. }
  133680. /**
  133681. * Defines an optimization used to turn particles off
  133682. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133683. */
  133684. export class ParticlesOptimization extends SceneOptimization {
  133685. /**
  133686. * Gets a string describing the action executed by the current optimization
  133687. * @return description string
  133688. */
  133689. getDescription(): string;
  133690. /**
  133691. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133692. * @param scene defines the current scene where to apply this optimization
  133693. * @param optimizer defines the current optimizer
  133694. * @returns true if everything that can be done was applied
  133695. */
  133696. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133697. }
  133698. /**
  133699. * Defines an optimization used to turn render targets off
  133700. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133701. */
  133702. export class RenderTargetsOptimization extends SceneOptimization {
  133703. /**
  133704. * Gets a string describing the action executed by the current optimization
  133705. * @return description string
  133706. */
  133707. getDescription(): string;
  133708. /**
  133709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133710. * @param scene defines the current scene where to apply this optimization
  133711. * @param optimizer defines the current optimizer
  133712. * @returns true if everything that can be done was applied
  133713. */
  133714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133715. }
  133716. /**
  133717. * Defines an optimization used to merge meshes with compatible materials
  133718. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133719. */
  133720. export class MergeMeshesOptimization extends SceneOptimization {
  133721. private static _UpdateSelectionTree;
  133722. /**
  133723. * Gets or sets a boolean which defines if optimization octree has to be updated
  133724. */
  133725. /**
  133726. * Gets or sets a boolean which defines if optimization octree has to be updated
  133727. */
  133728. static UpdateSelectionTree: boolean;
  133729. /**
  133730. * Gets a string describing the action executed by the current optimization
  133731. * @return description string
  133732. */
  133733. getDescription(): string;
  133734. private _canBeMerged;
  133735. /**
  133736. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133737. * @param scene defines the current scene where to apply this optimization
  133738. * @param optimizer defines the current optimizer
  133739. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  133740. * @returns true if everything that can be done was applied
  133741. */
  133742. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  133743. }
  133744. /**
  133745. * Defines a list of options used by SceneOptimizer
  133746. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133747. */
  133748. export class SceneOptimizerOptions {
  133749. /**
  133750. * Defines the target frame rate to reach (60 by default)
  133751. */
  133752. targetFrameRate: number;
  133753. /**
  133754. * Defines the interval between two checkes (2000ms by default)
  133755. */
  133756. trackerDuration: number;
  133757. /**
  133758. * Gets the list of optimizations to apply
  133759. */
  133760. optimizations: SceneOptimization[];
  133761. /**
  133762. * Creates a new list of options used by SceneOptimizer
  133763. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  133764. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  133765. */
  133766. constructor(
  133767. /**
  133768. * Defines the target frame rate to reach (60 by default)
  133769. */
  133770. targetFrameRate?: number,
  133771. /**
  133772. * Defines the interval between two checkes (2000ms by default)
  133773. */
  133774. trackerDuration?: number);
  133775. /**
  133776. * Add a new optimization
  133777. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  133778. * @returns the current SceneOptimizerOptions
  133779. */
  133780. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  133781. /**
  133782. * Add a new custom optimization
  133783. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  133784. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  133785. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133786. * @returns the current SceneOptimizerOptions
  133787. */
  133788. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  133789. /**
  133790. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  133791. * @param targetFrameRate defines the target frame rate (60 by default)
  133792. * @returns a SceneOptimizerOptions object
  133793. */
  133794. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133795. /**
  133796. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  133797. * @param targetFrameRate defines the target frame rate (60 by default)
  133798. * @returns a SceneOptimizerOptions object
  133799. */
  133800. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133801. /**
  133802. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  133803. * @param targetFrameRate defines the target frame rate (60 by default)
  133804. * @returns a SceneOptimizerOptions object
  133805. */
  133806. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133807. }
  133808. /**
  133809. * Class used to run optimizations in order to reach a target frame rate
  133810. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133811. */
  133812. export class SceneOptimizer implements IDisposable {
  133813. private _isRunning;
  133814. private _options;
  133815. private _scene;
  133816. private _currentPriorityLevel;
  133817. private _targetFrameRate;
  133818. private _trackerDuration;
  133819. private _currentFrameRate;
  133820. private _sceneDisposeObserver;
  133821. private _improvementMode;
  133822. /**
  133823. * Defines an observable called when the optimizer reaches the target frame rate
  133824. */
  133825. onSuccessObservable: Observable<SceneOptimizer>;
  133826. /**
  133827. * Defines an observable called when the optimizer enables an optimization
  133828. */
  133829. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  133830. /**
  133831. * Defines an observable called when the optimizer is not able to reach the target frame rate
  133832. */
  133833. onFailureObservable: Observable<SceneOptimizer>;
  133834. /**
  133835. * Gets a boolean indicating if the optimizer is in improvement mode
  133836. */
  133837. readonly isInImprovementMode: boolean;
  133838. /**
  133839. * Gets the current priority level (0 at start)
  133840. */
  133841. readonly currentPriorityLevel: number;
  133842. /**
  133843. * Gets the current frame rate checked by the SceneOptimizer
  133844. */
  133845. readonly currentFrameRate: number;
  133846. /**
  133847. * Gets or sets the current target frame rate (60 by default)
  133848. */
  133849. /**
  133850. * Gets or sets the current target frame rate (60 by default)
  133851. */
  133852. targetFrameRate: number;
  133853. /**
  133854. * Gets or sets the current interval between two checks (every 2000ms by default)
  133855. */
  133856. /**
  133857. * Gets or sets the current interval between two checks (every 2000ms by default)
  133858. */
  133859. trackerDuration: number;
  133860. /**
  133861. * Gets the list of active optimizations
  133862. */
  133863. readonly optimizations: SceneOptimization[];
  133864. /**
  133865. * Creates a new SceneOptimizer
  133866. * @param scene defines the scene to work on
  133867. * @param options defines the options to use with the SceneOptimizer
  133868. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  133869. * @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)
  133870. */
  133871. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  133872. /**
  133873. * Stops the current optimizer
  133874. */
  133875. stop(): void;
  133876. /**
  133877. * Reset the optimizer to initial step (current priority level = 0)
  133878. */
  133879. reset(): void;
  133880. /**
  133881. * Start the optimizer. By default it will try to reach a specific framerate
  133882. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  133883. */
  133884. start(): void;
  133885. private _checkCurrentState;
  133886. /**
  133887. * Release all resources
  133888. */
  133889. dispose(): void;
  133890. /**
  133891. * Helper function to create a SceneOptimizer with one single line of code
  133892. * @param scene defines the scene to work on
  133893. * @param options defines the options to use with the SceneOptimizer
  133894. * @param onSuccess defines a callback to call on success
  133895. * @param onFailure defines a callback to call on failure
  133896. * @returns the new SceneOptimizer object
  133897. */
  133898. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  133899. }
  133900. }
  133901. declare module BABYLON {
  133902. /**
  133903. * Class used to serialize a scene into a string
  133904. */
  133905. export class SceneSerializer {
  133906. /**
  133907. * Clear cache used by a previous serialization
  133908. */
  133909. static ClearCache(): void;
  133910. /**
  133911. * Serialize a scene into a JSON compatible object
  133912. * @param scene defines the scene to serialize
  133913. * @returns a JSON compatible object
  133914. */
  133915. static Serialize(scene: Scene): any;
  133916. /**
  133917. * Serialize a mesh into a JSON compatible object
  133918. * @param toSerialize defines the mesh to serialize
  133919. * @param withParents defines if parents must be serialized as well
  133920. * @param withChildren defines if children must be serialized as well
  133921. * @returns a JSON compatible object
  133922. */
  133923. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  133924. }
  133925. }
  133926. declare module BABYLON {
  133927. /**
  133928. * Class used to host texture specific utilities
  133929. */
  133930. export class TextureTools {
  133931. /**
  133932. * Uses the GPU to create a copy texture rescaled at a given size
  133933. * @param texture Texture to copy from
  133934. * @param width defines the desired width
  133935. * @param height defines the desired height
  133936. * @param useBilinearMode defines if bilinear mode has to be used
  133937. * @return the generated texture
  133938. */
  133939. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  133940. }
  133941. }
  133942. declare module BABYLON {
  133943. /**
  133944. * This represents the different options available for the video capture.
  133945. */
  133946. export interface VideoRecorderOptions {
  133947. /** Defines the mime type of the video. */
  133948. mimeType: string;
  133949. /** Defines the FPS the video should be recorded at. */
  133950. fps: number;
  133951. /** Defines the chunk size for the recording data. */
  133952. recordChunckSize: number;
  133953. /** The audio tracks to attach to the recording. */
  133954. audioTracks?: MediaStreamTrack[];
  133955. }
  133956. /**
  133957. * This can help with recording videos from BabylonJS.
  133958. * This is based on the available WebRTC functionalities of the browser.
  133959. *
  133960. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  133961. */
  133962. export class VideoRecorder {
  133963. private static readonly _defaultOptions;
  133964. /**
  133965. * Returns whether or not the VideoRecorder is available in your browser.
  133966. * @param engine Defines the Babylon Engine.
  133967. * @returns true if supported otherwise false.
  133968. */
  133969. static IsSupported(engine: Engine): boolean;
  133970. private readonly _options;
  133971. private _canvas;
  133972. private _mediaRecorder;
  133973. private _recordedChunks;
  133974. private _fileName;
  133975. private _resolve;
  133976. private _reject;
  133977. /**
  133978. * True when a recording is already in progress.
  133979. */
  133980. readonly isRecording: boolean;
  133981. /**
  133982. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  133983. * @param engine Defines the BabylonJS Engine you wish to record.
  133984. * @param options Defines options that can be used to customize the capture.
  133985. */
  133986. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  133987. /**
  133988. * Stops the current recording before the default capture timeout passed in the startRecording function.
  133989. */
  133990. stopRecording(): void;
  133991. /**
  133992. * Starts recording the canvas for a max duration specified in parameters.
  133993. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  133994. * If null no automatic download will start and you can rely on the promise to get the data back.
  133995. * @param maxDuration Defines the maximum recording time in seconds.
  133996. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  133997. * @return A promise callback at the end of the recording with the video data in Blob.
  133998. */
  133999. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  134000. /**
  134001. * Releases internal resources used during the recording.
  134002. */
  134003. dispose(): void;
  134004. private _handleDataAvailable;
  134005. private _handleError;
  134006. private _handleStop;
  134007. }
  134008. }
  134009. declare module BABYLON {
  134010. /**
  134011. * Class containing a set of static utilities functions for screenshots
  134012. */
  134013. export class ScreenshotTools {
  134014. /**
  134015. * Captures a screenshot of the current rendering
  134016. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134017. * @param engine defines the rendering engine
  134018. * @param camera defines the source camera
  134019. * @param size This parameter can be set to a single number or to an object with the
  134020. * following (optional) properties: precision, width, height. If a single number is passed,
  134021. * it will be used for both width and height. If an object is passed, the screenshot size
  134022. * will be derived from the parameters. The precision property is a multiplier allowing
  134023. * rendering at a higher or lower resolution
  134024. * @param successCallback defines the callback receives a single parameter which contains the
  134025. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  134026. * src parameter of an <img> to display it
  134027. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  134028. * Check your browser for supported MIME types
  134029. */
  134030. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  134031. /**
  134032. * Captures a screenshot of the current rendering
  134033. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134034. * @param engine defines the rendering engine
  134035. * @param camera defines the source camera
  134036. * @param size This parameter can be set to a single number or to an object with the
  134037. * following (optional) properties: precision, width, height. If a single number is passed,
  134038. * it will be used for both width and height. If an object is passed, the screenshot size
  134039. * will be derived from the parameters. The precision property is a multiplier allowing
  134040. * rendering at a higher or lower resolution
  134041. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  134042. * Check your browser for supported MIME types
  134043. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  134044. * to the src parameter of an <img> to display it
  134045. */
  134046. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  134047. /**
  134048. * Generates an image screenshot from the specified camera.
  134049. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134050. * @param engine The engine to use for rendering
  134051. * @param camera The camera to use for rendering
  134052. * @param size This parameter can be set to a single number or to an object with the
  134053. * following (optional) properties: precision, width, height. If a single number is passed,
  134054. * it will be used for both width and height. If an object is passed, the screenshot size
  134055. * will be derived from the parameters. The precision property is a multiplier allowing
  134056. * rendering at a higher or lower resolution
  134057. * @param successCallback The callback receives a single parameter which contains the
  134058. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  134059. * src parameter of an <img> to display it
  134060. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134061. * Check your browser for supported MIME types
  134062. * @param samples Texture samples (default: 1)
  134063. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134064. * @param fileName A name for for the downloaded file.
  134065. */
  134066. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  134067. /**
  134068. * Generates an image screenshot from the specified camera.
  134069. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134070. * @param engine The engine to use for rendering
  134071. * @param camera The camera to use for rendering
  134072. * @param size This parameter can be set to a single number or to an object with the
  134073. * following (optional) properties: precision, width, height. If a single number is passed,
  134074. * it will be used for both width and height. If an object is passed, the screenshot size
  134075. * will be derived from the parameters. The precision property is a multiplier allowing
  134076. * rendering at a higher or lower resolution
  134077. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134078. * Check your browser for supported MIME types
  134079. * @param samples Texture samples (default: 1)
  134080. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134081. * @param fileName A name for for the downloaded file.
  134082. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  134083. * to the src parameter of an <img> to display it
  134084. */
  134085. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  134086. /**
  134087. * Gets height and width for screenshot size
  134088. * @private
  134089. */
  134090. private static _getScreenshotSize;
  134091. }
  134092. }
  134093. declare module BABYLON {
  134094. /**
  134095. * Interface for a data buffer
  134096. */
  134097. export interface IDataBuffer {
  134098. /**
  134099. * Reads bytes from the data buffer.
  134100. * @param byteOffset The byte offset to read
  134101. * @param byteLength The byte length to read
  134102. * @returns A promise that resolves when the bytes are read
  134103. */
  134104. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  134105. /**
  134106. * The byte length of the buffer.
  134107. */
  134108. readonly byteLength: number;
  134109. }
  134110. /**
  134111. * Utility class for reading from a data buffer
  134112. */
  134113. export class DataReader {
  134114. /**
  134115. * The data buffer associated with this data reader.
  134116. */
  134117. readonly buffer: IDataBuffer;
  134118. /**
  134119. * The current byte offset from the beginning of the data buffer.
  134120. */
  134121. byteOffset: number;
  134122. private _dataView;
  134123. private _dataByteOffset;
  134124. /**
  134125. * Constructor
  134126. * @param buffer The buffer to read
  134127. */
  134128. constructor(buffer: IDataBuffer);
  134129. /**
  134130. * Loads the given byte length.
  134131. * @param byteLength The byte length to load
  134132. * @returns A promise that resolves when the load is complete
  134133. */
  134134. loadAsync(byteLength: number): Promise<void>;
  134135. /**
  134136. * Read a unsigned 32-bit integer from the currently loaded data range.
  134137. * @returns The 32-bit integer read
  134138. */
  134139. readUint32(): number;
  134140. /**
  134141. * Read a byte array from the currently loaded data range.
  134142. * @param byteLength The byte length to read
  134143. * @returns The byte array read
  134144. */
  134145. readUint8Array(byteLength: number): Uint8Array;
  134146. /**
  134147. * Read a string from the currently loaded data range.
  134148. * @param byteLength The byte length to read
  134149. * @returns The string read
  134150. */
  134151. readString(byteLength: number): string;
  134152. /**
  134153. * Skips the given byte length the currently loaded data range.
  134154. * @param byteLength The byte length to skip
  134155. */
  134156. skipBytes(byteLength: number): void;
  134157. }
  134158. }
  134159. declare module BABYLON {
  134160. /**
  134161. * A cursor which tracks a point on a path
  134162. */
  134163. export class PathCursor {
  134164. private path;
  134165. /**
  134166. * Stores path cursor callbacks for when an onchange event is triggered
  134167. */
  134168. private _onchange;
  134169. /**
  134170. * The value of the path cursor
  134171. */
  134172. value: number;
  134173. /**
  134174. * The animation array of the path cursor
  134175. */
  134176. animations: Animation[];
  134177. /**
  134178. * Initializes the path cursor
  134179. * @param path The path to track
  134180. */
  134181. constructor(path: Path2);
  134182. /**
  134183. * Gets the cursor point on the path
  134184. * @returns A point on the path cursor at the cursor location
  134185. */
  134186. getPoint(): Vector3;
  134187. /**
  134188. * Moves the cursor ahead by the step amount
  134189. * @param step The amount to move the cursor forward
  134190. * @returns This path cursor
  134191. */
  134192. moveAhead(step?: number): PathCursor;
  134193. /**
  134194. * Moves the cursor behind by the step amount
  134195. * @param step The amount to move the cursor back
  134196. * @returns This path cursor
  134197. */
  134198. moveBack(step?: number): PathCursor;
  134199. /**
  134200. * Moves the cursor by the step amount
  134201. * If the step amount is greater than one, an exception is thrown
  134202. * @param step The amount to move the cursor
  134203. * @returns This path cursor
  134204. */
  134205. move(step: number): PathCursor;
  134206. /**
  134207. * Ensures that the value is limited between zero and one
  134208. * @returns This path cursor
  134209. */
  134210. private ensureLimits;
  134211. /**
  134212. * Runs onchange callbacks on change (used by the animation engine)
  134213. * @returns This path cursor
  134214. */
  134215. private raiseOnChange;
  134216. /**
  134217. * Executes a function on change
  134218. * @param f A path cursor onchange callback
  134219. * @returns This path cursor
  134220. */
  134221. onchange(f: (cursor: PathCursor) => void): PathCursor;
  134222. }
  134223. }
  134224. declare module BABYLON {
  134225. /** @hidden */
  134226. export var blurPixelShader: {
  134227. name: string;
  134228. shader: string;
  134229. };
  134230. }
  134231. declare module BABYLON {
  134232. /** @hidden */
  134233. export var pointCloudVertexDeclaration: {
  134234. name: string;
  134235. shader: string;
  134236. };
  134237. }
  134238. // Mixins
  134239. interface Window {
  134240. mozIndexedDB: IDBFactory;
  134241. webkitIndexedDB: IDBFactory;
  134242. msIndexedDB: IDBFactory;
  134243. webkitURL: typeof URL;
  134244. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  134245. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  134246. WebGLRenderingContext: WebGLRenderingContext;
  134247. MSGesture: MSGesture;
  134248. CANNON: any;
  134249. AudioContext: AudioContext;
  134250. webkitAudioContext: AudioContext;
  134251. PointerEvent: any;
  134252. Math: Math;
  134253. Uint8Array: Uint8ArrayConstructor;
  134254. Float32Array: Float32ArrayConstructor;
  134255. mozURL: typeof URL;
  134256. msURL: typeof URL;
  134257. VRFrameData: any; // WebVR, from specs 1.1
  134258. DracoDecoderModule: any;
  134259. setImmediate(handler: (...args: any[]) => void): number;
  134260. }
  134261. interface HTMLCanvasElement {
  134262. requestPointerLock(): void;
  134263. msRequestPointerLock?(): void;
  134264. mozRequestPointerLock?(): void;
  134265. webkitRequestPointerLock?(): void;
  134266. /** Track wether a record is in progress */
  134267. isRecording: boolean;
  134268. /** Capture Stream method defined by some browsers */
  134269. captureStream(fps?: number): MediaStream;
  134270. }
  134271. interface CanvasRenderingContext2D {
  134272. msImageSmoothingEnabled: boolean;
  134273. }
  134274. interface MouseEvent {
  134275. mozMovementX: number;
  134276. mozMovementY: number;
  134277. webkitMovementX: number;
  134278. webkitMovementY: number;
  134279. msMovementX: number;
  134280. msMovementY: number;
  134281. }
  134282. interface Navigator {
  134283. mozGetVRDevices: (any: any) => any;
  134284. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134285. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134286. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134287. webkitGetGamepads(): Gamepad[];
  134288. msGetGamepads(): Gamepad[];
  134289. webkitGamepads(): Gamepad[];
  134290. }
  134291. interface HTMLVideoElement {
  134292. mozSrcObject: any;
  134293. }
  134294. interface Math {
  134295. fround(x: number): number;
  134296. imul(a: number, b: number): number;
  134297. }
  134298. interface WebGLRenderingContext {
  134299. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  134300. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  134301. vertexAttribDivisor(index: number, divisor: number): void;
  134302. createVertexArray(): any;
  134303. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  134304. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  134305. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  134306. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  134307. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  134308. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  134309. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  134310. // Queries
  134311. createQuery(): WebGLQuery;
  134312. deleteQuery(query: WebGLQuery): void;
  134313. beginQuery(target: number, query: WebGLQuery): void;
  134314. endQuery(target: number): void;
  134315. getQueryParameter(query: WebGLQuery, pname: number): any;
  134316. getQuery(target: number, pname: number): any;
  134317. MAX_SAMPLES: number;
  134318. RGBA8: number;
  134319. READ_FRAMEBUFFER: number;
  134320. DRAW_FRAMEBUFFER: number;
  134321. UNIFORM_BUFFER: number;
  134322. HALF_FLOAT_OES: number;
  134323. RGBA16F: number;
  134324. RGBA32F: number;
  134325. R32F: number;
  134326. RG32F: number;
  134327. RGB32F: number;
  134328. R16F: number;
  134329. RG16F: number;
  134330. RGB16F: number;
  134331. RED: number;
  134332. RG: number;
  134333. R8: number;
  134334. RG8: number;
  134335. UNSIGNED_INT_24_8: number;
  134336. DEPTH24_STENCIL8: number;
  134337. MIN: number;
  134338. MAX: number;
  134339. /* Multiple Render Targets */
  134340. drawBuffers(buffers: number[]): void;
  134341. readBuffer(src: number): void;
  134342. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  134343. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  134344. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  134345. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  134346. // Occlusion Query
  134347. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  134348. ANY_SAMPLES_PASSED: number;
  134349. QUERY_RESULT_AVAILABLE: number;
  134350. QUERY_RESULT: number;
  134351. }
  134352. interface WebGLProgram {
  134353. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  134354. }
  134355. interface EXT_disjoint_timer_query {
  134356. QUERY_COUNTER_BITS_EXT: number;
  134357. TIME_ELAPSED_EXT: number;
  134358. TIMESTAMP_EXT: number;
  134359. GPU_DISJOINT_EXT: number;
  134360. QUERY_RESULT_EXT: number;
  134361. QUERY_RESULT_AVAILABLE_EXT: number;
  134362. queryCounterEXT(query: WebGLQuery, target: number): void;
  134363. createQueryEXT(): WebGLQuery;
  134364. beginQueryEXT(target: number, query: WebGLQuery): void;
  134365. endQueryEXT(target: number): void;
  134366. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  134367. deleteQueryEXT(query: WebGLQuery): void;
  134368. }
  134369. interface WebGLUniformLocation {
  134370. _currentState: any;
  134371. }
  134372. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  134373. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  134374. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  134375. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  134376. interface WebGLRenderingContext {
  134377. readonly RASTERIZER_DISCARD: number;
  134378. readonly DEPTH_COMPONENT24: number;
  134379. readonly TEXTURE_3D: number;
  134380. readonly TEXTURE_2D_ARRAY: number;
  134381. readonly TEXTURE_COMPARE_FUNC: number;
  134382. readonly TEXTURE_COMPARE_MODE: number;
  134383. readonly COMPARE_REF_TO_TEXTURE: number;
  134384. readonly TEXTURE_WRAP_R: number;
  134385. readonly HALF_FLOAT: number;
  134386. readonly RGB8: number;
  134387. readonly RED_INTEGER: number;
  134388. readonly RG_INTEGER: number;
  134389. readonly RGB_INTEGER: number;
  134390. readonly RGBA_INTEGER: number;
  134391. readonly R8_SNORM: number;
  134392. readonly RG8_SNORM: number;
  134393. readonly RGB8_SNORM: number;
  134394. readonly RGBA8_SNORM: number;
  134395. readonly R8I: number;
  134396. readonly RG8I: number;
  134397. readonly RGB8I: number;
  134398. readonly RGBA8I: number;
  134399. readonly R8UI: number;
  134400. readonly RG8UI: number;
  134401. readonly RGB8UI: number;
  134402. readonly RGBA8UI: number;
  134403. readonly R16I: number;
  134404. readonly RG16I: number;
  134405. readonly RGB16I: number;
  134406. readonly RGBA16I: number;
  134407. readonly R16UI: number;
  134408. readonly RG16UI: number;
  134409. readonly RGB16UI: number;
  134410. readonly RGBA16UI: number;
  134411. readonly R32I: number;
  134412. readonly RG32I: number;
  134413. readonly RGB32I: number;
  134414. readonly RGBA32I: number;
  134415. readonly R32UI: number;
  134416. readonly RG32UI: number;
  134417. readonly RGB32UI: number;
  134418. readonly RGBA32UI: number;
  134419. readonly RGB10_A2UI: number;
  134420. readonly R11F_G11F_B10F: number;
  134421. readonly RGB9_E5: number;
  134422. readonly RGB10_A2: number;
  134423. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  134424. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  134425. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  134426. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  134427. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  134428. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  134429. 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;
  134430. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  134431. readonly TRANSFORM_FEEDBACK: number;
  134432. readonly INTERLEAVED_ATTRIBS: number;
  134433. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  134434. createTransformFeedback(): WebGLTransformFeedback;
  134435. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  134436. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  134437. beginTransformFeedback(primitiveMode: number): void;
  134438. endTransformFeedback(): void;
  134439. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  134440. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134441. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134442. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134443. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  134444. }
  134445. interface ImageBitmap {
  134446. readonly width: number;
  134447. readonly height: number;
  134448. close(): void;
  134449. }
  134450. interface WebGLQuery extends WebGLObject {
  134451. }
  134452. declare var WebGLQuery: {
  134453. prototype: WebGLQuery;
  134454. new(): WebGLQuery;
  134455. };
  134456. interface WebGLSampler extends WebGLObject {
  134457. }
  134458. declare var WebGLSampler: {
  134459. prototype: WebGLSampler;
  134460. new(): WebGLSampler;
  134461. };
  134462. interface WebGLSync extends WebGLObject {
  134463. }
  134464. declare var WebGLSync: {
  134465. prototype: WebGLSync;
  134466. new(): WebGLSync;
  134467. };
  134468. interface WebGLTransformFeedback extends WebGLObject {
  134469. }
  134470. declare var WebGLTransformFeedback: {
  134471. prototype: WebGLTransformFeedback;
  134472. new(): WebGLTransformFeedback;
  134473. };
  134474. interface WebGLVertexArrayObject extends WebGLObject {
  134475. }
  134476. declare var WebGLVertexArrayObject: {
  134477. prototype: WebGLVertexArrayObject;
  134478. new(): WebGLVertexArrayObject;
  134479. };
  134480. // Type definitions for WebVR API
  134481. // Project: https://w3c.github.io/webvr/
  134482. // Definitions by: six a <https://github.com/lostfictions>
  134483. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  134484. interface VRDisplay extends EventTarget {
  134485. /**
  134486. * Dictionary of capabilities describing the VRDisplay.
  134487. */
  134488. readonly capabilities: VRDisplayCapabilities;
  134489. /**
  134490. * z-depth defining the far plane of the eye view frustum
  134491. * enables mapping of values in the render target depth
  134492. * attachment to scene coordinates. Initially set to 10000.0.
  134493. */
  134494. depthFar: number;
  134495. /**
  134496. * z-depth defining the near plane of the eye view frustum
  134497. * enables mapping of values in the render target depth
  134498. * attachment to scene coordinates. Initially set to 0.01.
  134499. */
  134500. depthNear: number;
  134501. /**
  134502. * An identifier for this distinct VRDisplay. Used as an
  134503. * association point in the Gamepad API.
  134504. */
  134505. readonly displayId: number;
  134506. /**
  134507. * A display name, a user-readable name identifying it.
  134508. */
  134509. readonly displayName: string;
  134510. readonly isConnected: boolean;
  134511. readonly isPresenting: boolean;
  134512. /**
  134513. * If this VRDisplay supports room-scale experiences, the optional
  134514. * stage attribute contains details on the room-scale parameters.
  134515. */
  134516. readonly stageParameters: VRStageParameters | null;
  134517. /**
  134518. * Passing the value returned by `requestAnimationFrame` to
  134519. * `cancelAnimationFrame` will unregister the callback.
  134520. * @param handle Define the hanle of the request to cancel
  134521. */
  134522. cancelAnimationFrame(handle: number): void;
  134523. /**
  134524. * Stops presenting to the VRDisplay.
  134525. * @returns a promise to know when it stopped
  134526. */
  134527. exitPresent(): Promise<void>;
  134528. /**
  134529. * Return the current VREyeParameters for the given eye.
  134530. * @param whichEye Define the eye we want the parameter for
  134531. * @returns the eye parameters
  134532. */
  134533. getEyeParameters(whichEye: string): VREyeParameters;
  134534. /**
  134535. * Populates the passed VRFrameData with the information required to render
  134536. * the current frame.
  134537. * @param frameData Define the data structure to populate
  134538. * @returns true if ok otherwise false
  134539. */
  134540. getFrameData(frameData: VRFrameData): boolean;
  134541. /**
  134542. * Get the layers currently being presented.
  134543. * @returns the list of VR layers
  134544. */
  134545. getLayers(): VRLayer[];
  134546. /**
  134547. * Return a VRPose containing the future predicted pose of the VRDisplay
  134548. * when the current frame will be presented. The value returned will not
  134549. * change until JavaScript has returned control to the browser.
  134550. *
  134551. * The VRPose will contain the position, orientation, velocity,
  134552. * and acceleration of each of these properties.
  134553. * @returns the pose object
  134554. */
  134555. getPose(): VRPose;
  134556. /**
  134557. * Return the current instantaneous pose of the VRDisplay, with no
  134558. * prediction applied.
  134559. * @returns the current instantaneous pose
  134560. */
  134561. getImmediatePose(): VRPose;
  134562. /**
  134563. * The callback passed to `requestAnimationFrame` will be called
  134564. * any time a new frame should be rendered. When the VRDisplay is
  134565. * presenting the callback will be called at the native refresh
  134566. * rate of the HMD. When not presenting this function acts
  134567. * identically to how window.requestAnimationFrame acts. Content should
  134568. * make no assumptions of frame rate or vsync behavior as the HMD runs
  134569. * asynchronously from other displays and at differing refresh rates.
  134570. * @param callback Define the eaction to run next frame
  134571. * @returns the request handle it
  134572. */
  134573. requestAnimationFrame(callback: FrameRequestCallback): number;
  134574. /**
  134575. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  134576. * Repeat calls while already presenting will update the VRLayers being displayed.
  134577. * @param layers Define the list of layer to present
  134578. * @returns a promise to know when the request has been fulfilled
  134579. */
  134580. requestPresent(layers: VRLayer[]): Promise<void>;
  134581. /**
  134582. * Reset the pose for this display, treating its current position and
  134583. * orientation as the "origin/zero" values. VRPose.position,
  134584. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  134585. * updated when calling resetPose(). This should be called in only
  134586. * sitting-space experiences.
  134587. */
  134588. resetPose(): void;
  134589. /**
  134590. * The VRLayer provided to the VRDisplay will be captured and presented
  134591. * in the HMD. Calling this function has the same effect on the source
  134592. * canvas as any other operation that uses its source image, and canvases
  134593. * created without preserveDrawingBuffer set to true will be cleared.
  134594. * @param pose Define the pose to submit
  134595. */
  134596. submitFrame(pose?: VRPose): void;
  134597. }
  134598. declare var VRDisplay: {
  134599. prototype: VRDisplay;
  134600. new(): VRDisplay;
  134601. };
  134602. interface VRLayer {
  134603. leftBounds?: number[] | Float32Array | null;
  134604. rightBounds?: number[] | Float32Array | null;
  134605. source?: HTMLCanvasElement | null;
  134606. }
  134607. interface VRDisplayCapabilities {
  134608. readonly canPresent: boolean;
  134609. readonly hasExternalDisplay: boolean;
  134610. readonly hasOrientation: boolean;
  134611. readonly hasPosition: boolean;
  134612. readonly maxLayers: number;
  134613. }
  134614. interface VREyeParameters {
  134615. /** @deprecated */
  134616. readonly fieldOfView: VRFieldOfView;
  134617. readonly offset: Float32Array;
  134618. readonly renderHeight: number;
  134619. readonly renderWidth: number;
  134620. }
  134621. interface VRFieldOfView {
  134622. readonly downDegrees: number;
  134623. readonly leftDegrees: number;
  134624. readonly rightDegrees: number;
  134625. readonly upDegrees: number;
  134626. }
  134627. interface VRFrameData {
  134628. readonly leftProjectionMatrix: Float32Array;
  134629. readonly leftViewMatrix: Float32Array;
  134630. readonly pose: VRPose;
  134631. readonly rightProjectionMatrix: Float32Array;
  134632. readonly rightViewMatrix: Float32Array;
  134633. readonly timestamp: number;
  134634. }
  134635. interface VRPose {
  134636. readonly angularAcceleration: Float32Array | null;
  134637. readonly angularVelocity: Float32Array | null;
  134638. readonly linearAcceleration: Float32Array | null;
  134639. readonly linearVelocity: Float32Array | null;
  134640. readonly orientation: Float32Array | null;
  134641. readonly position: Float32Array | null;
  134642. readonly timestamp: number;
  134643. }
  134644. interface VRStageParameters {
  134645. sittingToStandingTransform?: Float32Array;
  134646. sizeX?: number;
  134647. sizeY?: number;
  134648. }
  134649. interface Navigator {
  134650. getVRDisplays(): Promise<VRDisplay[]>;
  134651. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  134652. }
  134653. interface Window {
  134654. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  134655. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  134656. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  134657. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134658. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134659. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  134660. }
  134661. interface Gamepad {
  134662. readonly displayId: number;
  134663. }
  134664. type XRSessionMode =
  134665. | "inline"
  134666. | "immersive-vr"
  134667. | "immersive-ar";
  134668. type XRReferenceSpaceType =
  134669. | "viewer"
  134670. | "local"
  134671. | "local-floor"
  134672. | "bounded-floor"
  134673. | "unbounded";
  134674. type XREnvironmentBlendMode =
  134675. | "opaque"
  134676. | "additive"
  134677. | "alpha-blend";
  134678. type XRVisibilityState =
  134679. | "visible"
  134680. | "visible-blurred"
  134681. | "hidden";
  134682. type XRHandedness =
  134683. | "none"
  134684. | "left"
  134685. | "right";
  134686. type XRTargetRayMode =
  134687. | "gaze"
  134688. | "tracked-pointer"
  134689. | "screen";
  134690. type XREye =
  134691. | "none"
  134692. | "left"
  134693. | "right";
  134694. interface XRSpace extends EventTarget {
  134695. }
  134696. interface XRRenderState {
  134697. depthNear?: number;
  134698. depthFar?: number;
  134699. inlineVerticalFieldOfView?: number;
  134700. baseLayer?: XRWebGLLayer;
  134701. }
  134702. interface XRInputSource {
  134703. handedness: XRHandedness;
  134704. targetRayMode: XRTargetRayMode;
  134705. targetRaySpace: XRSpace;
  134706. gripSpace: XRSpace | undefined;
  134707. gamepad: Gamepad | undefined;
  134708. profiles: Array<string>;
  134709. }
  134710. interface XRSession {
  134711. addEventListener: Function;
  134712. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  134713. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  134714. requestAnimationFrame: Function;
  134715. end(): Promise<void>;
  134716. renderState: XRRenderState;
  134717. inputSources: Array<XRInputSource>;
  134718. }
  134719. interface XRReferenceSpace extends XRSpace {
  134720. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  134721. onreset: any;
  134722. }
  134723. interface XRFrame {
  134724. session: XRSession;
  134725. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  134726. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  134727. }
  134728. interface XRViewerPose extends XRPose {
  134729. views: Array<XRView>;
  134730. }
  134731. interface XRPose {
  134732. transform: XRRigidTransform;
  134733. emulatedPosition: boolean;
  134734. }
  134735. interface XRWebGLLayerOptions {
  134736. antialias ?: boolean;
  134737. depth ?: boolean;
  134738. stencil ?: boolean;
  134739. alpha ?: boolean;
  134740. multiview ?: boolean;
  134741. framebufferScaleFactor ?: number;
  134742. }
  134743. declare var XRWebGLLayer: {
  134744. prototype: XRWebGLLayer;
  134745. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  134746. };
  134747. interface XRWebGLLayer {
  134748. framebuffer: WebGLFramebuffer;
  134749. framebufferWidth: number;
  134750. framebufferHeight: number;
  134751. getViewport: Function;
  134752. }
  134753. interface XRRigidTransform {
  134754. position: DOMPointReadOnly;
  134755. orientation: DOMPointReadOnly;
  134756. matrix: Float32Array;
  134757. inverse: XRRigidTransform;
  134758. }
  134759. interface XRView {
  134760. eye: XREye;
  134761. projectionMatrix: Float32Array;
  134762. transform: XRRigidTransform;
  134763. }
  134764. interface XRInputSourceChangeEvent {
  134765. session: XRSession;
  134766. removed: Array<XRInputSource>;
  134767. added: Array<XRInputSource>;
  134768. }